Commit bcefbabc authored by yanjl1's avatar yanjl1
Browse files

update README

parent ca34d4d2
# hygon_samples
# samples
本项目提供了 hipDNN(HIP Deep Neural Network)前端 API 的使用示例,覆盖海光 DCU(Deep Computing Unit)硬件上常用的深度学习算子、融合算子以及 PyTorch 集成用法。
## 环境要求
- **DTK 版本**:≥ 25.04.2(推荐 26.04)
- **DTK 版本**:≥ 26.04.2
- **CMake 版本**:≥ 3.25.2
- **支持架构**`gfx906``gfx926``gfx928``gfx936``gfx938``gfx92a`
- **依赖**`hipdnn`(Python/C++)、`hip::host``hipdnn_frontend``PyTorch`(Python 示例)
所有开发和运行都需要先加载 DTK 环境:
```bash
source /data/dtk-26.04/env.sh
source /opt/dtk-26.04.2/env.sh
```
> 若未加载,C++ 编译时会报错 `Must be source dtk/env.sh`(`ROCM_PATH` 未设置)。
......@@ -51,32 +52,31 @@ source /data/dtk-26.04/env.sh
│ ├── block_scale/ # 块量化/反量化
│ └── ...
├── python/ # Python 示例(hipdnn Python API + PyTorch)
│ ├── convolution/
│ ├── conv_fusion/
│ ├── matmul/
│ ├── sdpa/
│ ├── batchnorm/
│ ├── layernorm/
│ ├── groupnorm/
│ ├── adamw/
│ ├── torch_wrapper/ # PyTorch 模块封装(如 TorchPReLU)
│ └── ...
└── CLAUDE.md # 本项目开发指引
├── convolution/
├── conv_fusion/
├── matmul/
├── sdpa/
├── batchnorm/
├── layernorm/
├── groupnorm/
├── adamw/
├── torch_wrapper/ # PyTorch 模块封装(如 TorchPReLU)
└── ...
```
## 编译 C++ 示例
```bash
cd cpp/build
cmake -G Ninja ..
ninja
cmake ..
make
```
编译完成后,可执行文件位于 `cpp/build/bin/`。如需单独编译某个示例:
```bash
ninja conv_forward
ninja sdpa_inference
make conv_forward
make sdpa_inference
```
> `CMakeLists.txt` 中部分示例被注释掉(如 `bn_finalize`、`block_scale_quantize`、`slice`、`rng`),如需启用请取消对应 `add_hipdnn_sample(...)` 行的注释。
......@@ -129,7 +129,7 @@ pip install ${ROCM_PATH}/share/hipdnn/wheels/hipdnn-*.whl
2. 编译 C++ 示例并运行:
```bash
cd cpp/build && cmake -G Ninja .. && ninja
cd cpp/build && cmake .. && make
./bin/conv_forward
```
......@@ -144,18 +144,6 @@ pip install ${ROCM_PATH}/share/hipdnn/wheels/hipdnn-*.whl
| 现象 | 原因 | 解决方式 |
|------|------|----------|
| `Must be source dtk/env.sh` | `ROCM_PATH` 未设置 | 先执行 `source /data/dtk-26.04/env.sh` |
| `hipdnn` 模块找不到 | Python 环境未加载 hipDNN | 确认 DTK 环境已加载,且 `hipdnn``PYTHONPATH` 中 |
| CMake 找不到 `hipdnn_frontend` | hipDNN 未安装或环境未加载 | 检查 `${ROCM_PATH}/lib/cmake/hipdnn/` 是否存在 |
| CUDA 相关报错 | PyTorch 张量未放至 GPU | 确保张量使用 `device="cuda"` |
| 编译警告被当作错误 | CMake 开启了 `-Werror` | 修复代码中的警告,或临时在 `CMakeLists.txt` 中移除 `-Werror` |
## 数据类型与布局说明
- **默认数据类型**`float`(C++)/ `torch.float32`(Python)。
- **FP16**:使用 `hipdnn_data_sdk::types::half` / `torch.float16`
- **INT8**:使用 `int8_t` / `torch.int8`,并采用 **NCHWc32** 分块布局(`vector_count=32`)。INT8 示例中的量化/反量化通过显式的 SUB/MUL/DIV/ADD 节点完成。
- **布局**:默认 NCHW;部分卷积示例使用 channels-last(`torch.channels_last`);INT8 使用 NCHWc32。
## 许可证
代码文件遵循 MIT 许可证(SPDX-License-Identifier: MIT)。
| 编译警告被当作错误 | CMake 开启了 `-Werror` | 修复代码中的警告,或临时在 `CMakeLists.txt` 中移除 `-Werror` |
\ No newline at end of file
{
"session_id": "eafc2bdd-f5a2-481a-9368-0fc8c1ceb3a0",
"ended_at": "2026-06-02T10:11:57.127Z",
"reason": "prompt_input_exit",
"agents_spawned": 0,
"agents_completed": 0,
"modes_used": []
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment