已合并
DOCTOOl工具修该 #3718
caiwenwen创建于 4月11日
DOCTOOl工具修该 #3718
已合并
从已删除 :9.0.0合入到cann/ops-nn9.0.0
共 226 个文件变更+817-498
| @@ -3,6 +3,7 @@ | |||
| 3 | > 本文档记录各版本的重要变更,版本按时间倒序排列。 | 3 | > 本文档记录各版本的重要变更,版本按时间倒序排列。 |
| 4 | 4 | ||
| 5 | ## v8.5.0-beta.1 | 5 | ## v8.5.0-beta.1 |
| 6 | + | ||
| 6 | 发布日期:2025-12-30 | 7 | 发布日期:2025-12-30 |
| 7 | 8 | ||
| 8 | ops-nn 算子首个 Beta 版本 v8.5.0-beta.1 现已发布。 | 9 | ops-nn 算子首个 Beta 版本 v8.5.0-beta.1 现已发布。 |
| @@ -11,6 +12,7 @@ ops-nn 算子首个 Beta 版本 v8.5.0-beta.1 现已发布。 | |||
| 11 | 使用方式请参阅[官方文档](https://gitcode.com/cann/ops-nn/blob/master/README.md)。 | 12 | 使用方式请参阅[官方文档](https://gitcode.com/cann/ops-nn/blob/master/README.md)。 |
| 12 | 13 | ||
| 13 | ### 🔗 版本地址 | 14 | ### 🔗 版本地址 |
| 15 | + | ||
| 14 | [CANN 8.5.0-beta 1](https://ascend.devcloud.huaweicloud.com/cann/run/software/8.5.0-beta.1/) | 16 | [CANN 8.5.0-beta 1](https://ascend.devcloud.huaweicloud.com/cann/run/software/8.5.0-beta.1/) |
| 15 | 17 | ||
| 16 | ``` | 18 | ``` |
| @@ -22,6 +24,7 @@ ops-nn 算子首个 Beta 版本 v8.5.0-beta.1 现已发布。 | |||
| 22 | │ ├── ops # ops算子包目录,用于归档算子子包 | 24 | │ ├── ops # ops算子包目录,用于归档算子子包 |
| 23 | │ ├── ... | 25 | │ ├── ... |
| 24 | ``` | 26 | ``` |
| 27 | + | ||
| 25 | ### 📌 版本配套 | 28 | ### 📌 版本配套 |
| 26 | 29 | ||
| 27 | **CANN独立升级子包版本配套关系** | 30 | **CANN独立升级子包版本配套关系** |
| @@ -37,6 +40,7 @@ ops-nn 算子首个 Beta 版本 v8.5.0-beta.1 现已发布。 | |||
| 37 | 40 | ||
| 38 | **CANN开源子包版本配套关系** | 41 | **CANN开源子包版本配套关系** |
| 39 | | CANN子包版本 | 版本源码标签 | 配套CANN版本 | | 42 | | CANN子包版本 | 版本源码标签 | 配套CANN版本 | |
| 43 | + | ||
| 40 | | ------------------------------------ | ------------------------------------------------------------ | ------------------- | | 44 | | ------------------------------------ | ------------------------------------------------------------ | ------------------- | |
| 41 | | cann-opbase 8.5.0-beta.1 | [v8.5.0-beta.1](https://gitcode.com/cann/opbase/tags/v8.5.0-beta.1) | CANN 8.5.0-beta.1 | | 45 | | cann-opbase 8.5.0-beta.1 | [v8.5.0-beta.1](https://gitcode.com/cann/opbase/tags/v8.5.0-beta.1) | CANN 8.5.0-beta.1 | |
| 42 | | cann-oam-tools 8.5.0-beta.1 | [v8.5.0-beta.1](https://gitcode.com/cann/oam-tools/tags/v8.5.0-beta.1) | CANN 8.5.0-beta.1 | | 46 | | cann-oam-tools 8.5.0-beta.1 | [v8.5.0-beta.1](https://gitcode.com/cann/oam-tools/tags/v8.5.0-beta.1) | CANN 8.5.0-beta.1 | |
| @@ -63,6 +67,7 @@ ops-nn 算子首个 Beta 版本 v8.5.0-beta.1 现已发布。 | |||
| 63 | - 【性能优化】增加asc_opc算子并行编译能力,优化编译效率;增加ccache,优化编译时长。([#692](https://gitcode.com/cann/ops-nn/pull/692)) | 67 | - 【性能优化】增加asc_opc算子并行编译能力,优化编译效率;增加ccache,优化编译时长。([#692](https://gitcode.com/cann/ops-nn/pull/692)) |
| 64 | 68 | ||
| 65 | ### 🐛 问题修复 | 69 | ### 🐛 问题修复 |
| 70 | + | ||
| 66 | - 修复conv类算子编译告警问题。([Issue33](https://gitcode.com/cann/ops-nn/issues/33)) | 71 | - 修复conv类算子编译告警问题。([Issue33](https://gitcode.com/cann/ops-nn/issues/33)) |
| 67 | - 使用constexpr修饰if使能编译优化。([Issue98](https://gitcode.com/cann/ops-nn/issues/98)) | 72 | - 使用constexpr修饰if使能编译优化。([Issue98](https://gitcode.com/cann/ops-nn/issues/98)) |
| 68 | -- add_example样例算子执行调用问题修复。([Issue245](https://gitcode.com/cann/ops-nn/issues/245)) | 73 | +- add_example样例算子执行调用问题修复。([Issue245](https://gitcode.com/cann/ops-nn/issues/245)) |
| @@ -11,18 +11,17 @@ | |||
| 11 | > 3. [算子开发指南](./docs/zh/develop/aicore_develop_guide.md):自定义开发标准算子的指南,学习从零创建算子工程、实现Tiling和Kernel。 | 11 | > 3. [算子开发指南](./docs/zh/develop/aicore_develop_guide.md):自定义开发标准算子的指南,学习从零创建算子工程、实现Tiling和Kernel。 |
| 12 | > 4. [调试调优指南](./docs/zh/debug/op_debug_prof.md):不同场景下的系统性调试技巧与性能优化方法。 | 12 | > 4. [调试调优指南](./docs/zh/debug/op_debug_prof.md):不同场景下的系统性调试技巧与性能优化方法。 |
| 13 | 13 | ||
| 14 | - | ||
| 15 | 算子开发和贡献的基本流程如下图,欢迎并鼓励您在社区贡献算子,共同丰富项目生态。 | 14 | 算子开发和贡献的基本流程如下图,欢迎并鼓励您在社区贡献算子,共同丰富项目生态。 |
| 16 | 15 | ||
| 17 |  | 16 |  |
| 18 | 17 | ||
| 19 | 为方便您能快速了解算子开发的全流程,我们将以**AddExample**算子作为实践对象,其源文件位于`ops-nn/examples/add_example`,具体操作步骤如下: | 18 | 为方便您能快速了解算子开发的全流程,我们将以**AddExample**算子作为实践对象,其源文件位于`ops-nn/examples/add_example`,具体操作步骤如下: |
| 20 | 19 | ||
| 21 | -1. **[环境安装](#一环境安装二选一)**:搭建算子开发和运行环境。 | 20 | +1. **[环境安装](#一环境安装二选一)**:搭建算子开发和运行环境。 |
| 22 | -2. **[编译部署](#二编译部署)**:编译自定义算子包并部署安装,实现快速调用算子。 | 21 | +2. **[编译部署](#二编译部署)**:编译自定义算子包并部署安装,实现快速调用算子。 |
| 23 | -3. **[算子开发](#三算子开发)**:通过修改现有算子Kernel,体验开发、编译、验证的完整闭环。 | 22 | +3. **[算子开发](#三算子开发)**:通过修改现有算子Kernel,体验开发、编译、验证的完整闭环。 |
| 24 | -4. **[算子调试](#四算子调试)**:掌握算子打印和性能采集方法。 | 23 | +4. **[算子调试](#四算子调试)**:掌握算子打印和性能采集方法。 |
| 25 | -5. **[算子验证](#五算子验证)**:学习如何修改算子example样例,以验证算子在不同输入下的功能正确性。 | 24 | +5. **[算子验证](#五算子验证)**:学习如何修改算子example样例,以验证算子在不同输入下的功能正确性。 |
| 26 | 25 | ||
| 27 | ## 一、环境安装(二选一) | 26 | ## 一、环境安装(二选一) |
| 28 | 27 | ||
| @@ -42,7 +41,7 @@ | |||
| 42 | 41 | ||
| 43 | 在云平台终端窗口,执行如下命令验证环境和驱动是否正常。 | 42 | 在云平台终端窗口,执行如下命令验证环境和驱动是否正常。 |
| 44 | 43 | ||
| 45 | - - **检查NPU设备** | 44 | + - **检查NPU设备** |
| 46 | 45 | ||
| 47 | 执行如下命令,若返回驱动相关信息说明已成功挂载。 | 46 | 执行如下命令,若返回驱动相关信息说明已成功挂载。 |
| 48 | 47 | ||
| @@ -50,7 +49,7 @@ | |||
| 50 | npu-smi info | 49 | npu-smi info |
| 51 | ``` | 50 | ``` |
| 52 | 51 | ||
| 53 | - - **检查CANN版本** | 52 | + - **检查CANN版本** |
| 54 | 53 | ||
| 55 | 执行如下命令查看CANN Toolkit版本信息。 | 54 | 执行如下命令查看CANN Toolkit版本信息。 |
| 56 | 55 | ||
| @@ -69,21 +68,24 @@ | |||
| 69 | > **注意**:使用`npu-smi info`查看对应的驱动与固件版本。 | 68 | > **注意**:使用`npu-smi info`查看对应的驱动与固件版本。 |
| 70 | 69 | ||
| 71 | #### 下载镜像 | 70 | #### 下载镜像 |
| 71 | + | ||
| 72 | 拉取已预集成CANN软件包及`ops-nn`所需依赖的镜像。 | 72 | 拉取已预集成CANN软件包及`ops-nn`所需依赖的镜像。 |
| 73 | 73 | ||
| 74 | -1. 以root用户登录宿主机。 | 74 | +1. 以root用户登录宿主机。 |
| 75 | -2. 执行拉取命令(请根据你的宿主机架构选择): | 75 | +2. 执行拉取命令(请根据你的宿主机架构选择): |
| 76 | 76 | ||
| 77 | * ARM架构: | 77 | * ARM架构: |
| 78 | 78 | ||
| 79 | ```bash | 79 | ```bash |
| 80 | docker pull --platform=arm64 swr.cn-south-1.myhuaweicloud.com/ascendhub/cann:8.5.0-910b-ubuntu22.04-py3.10-ops | 80 | docker pull --platform=arm64 swr.cn-south-1.myhuaweicloud.com/ascendhub/cann:8.5.0-910b-ubuntu22.04-py3.10-ops |
| 81 | ``` | 81 | ``` |
| 82 | + | ||
| 82 | * X86架构: | 83 | * X86架构: |
| 83 | 84 | ||
| 84 | ```bash | 85 | ```bash |
| 85 | docker pull --platform=amd64 swr.cn-south-1.myhuaweicloud.com/ascendhub/cann:8.5.0-910b-ubuntu22.04-py3.10-ops | 86 | docker pull --platform=amd64 swr.cn-south-1.myhuaweicloud.com/ascendhub/cann:8.5.0-910b-ubuntu22.04-py3.10-ops |
| 86 | ``` | 87 | ``` |
| 88 | + | ||
| 87 | > **注意**:正常网速下,镜像下载时间约为5-10分钟。 | 89 | > **注意**:正常网速下,镜像下载时间约为5-10分钟。 |
| 88 | 90 | ||
| 89 | #### Docker运行 | 91 | #### Docker运行 |
| @@ -93,7 +95,9 @@ | |||
| 93 | ```bash | 95 | ```bash |
| 94 | docker run --name cann_container --device /dev/davinci0 --device /dev/davinci_manager --device /dev/devmm_svm --device /dev/hisi_hdc -v /usr/local/dcmi:/usr/local/dcmi -v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi -v /usr/local/Ascend/driver/lib64/:/usr/local/Ascend/driver/lib64/ -v /usr/local/Ascend/driver/version.info:/usr/local/Ascend/driver/version.info -v /etc/ascend_install.info:/etc/ascend_install.info -it swr.cn-south-1.myhuaweicloud.com/ascendhub/cann:8.5.0-910b-ubuntu22.04-py3.10-ops bash | 96 | docker run --name cann_container --device /dev/davinci0 --device /dev/davinci_manager --device /dev/devmm_svm --device /dev/hisi_hdc -v /usr/local/dcmi:/usr/local/dcmi -v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi -v /usr/local/Ascend/driver/lib64/:/usr/local/Ascend/driver/lib64/ -v /usr/local/Ascend/driver/version.info:/usr/local/Ascend/driver/version.info -v /etc/ascend_install.info:/etc/ascend_install.info -it swr.cn-south-1.myhuaweicloud.com/ascendhub/cann:8.5.0-910b-ubuntu22.04-py3.10-ops bash |
| 95 | ``` | 97 | ``` |
| 98 | + | ||
| 96 | 以下为用户需关注的参数说明: | 99 | 以下为用户需关注的参数说明: |
| 100 | + | ||
| 97 | | 参数 | 说明 | 注意事项 | | 101 | | 参数 | 说明 | 注意事项 | |
| 98 | | :--- | :--- | :--- | | 102 | | :--- | :--- | :--- | |
| 99 | | `--name cann_container` | 为容器指定名称,便于管理。 | 可自定义。 | | 103 | | `--name cann_container` | 为容器指定名称,便于管理。 | 可自定义。 | |
| @@ -104,13 +108,15 @@ docker run --name cann_container --device /dev/davinci0 --device /dev/davinci_ma | |||
| 104 | 108 | ||
| 105 | 进入容器后,验证环境和驱动是否正常。 | 109 | 进入容器后,验证环境和驱动是否正常。 |
| 106 | 110 | ||
| 107 | -- **检查NPU设备** | 111 | +- **检查NPU设备** |
| 112 | + | ||
| 113 | + 执行如下命令,若返回驱动相关信息说明已成功挂载。 | ||
| 108 | 114 | ||
| 109 | - 执行如下命令,若返回驱动相关信息说明已成功挂载。 | ||
| 110 | ```bash | 115 | ```bash |
| 111 | npu-smi info | 116 | npu-smi info |
| 112 | ``` | 117 | ``` |
| 113 | -- **检查CANN版本** | 118 | + |
| 119 | +- **检查CANN版本** | ||
| 114 | 120 | ||
| 115 | 执行如下命令查看CANN Toolkit版本信息。 | 121 | 执行如下命令查看CANN Toolkit版本信息。 |
| 116 | 122 | ||
| @@ -133,14 +139,18 @@ docker run --name cann_container --device /dev/davinci0 --device /dev/davinci_ma | |||
| 133 | ```bash | 139 | ```bash |
| 134 | git clone -b ${tag_version} https://gitcode.com/cann/ops-nn.git | 140 | git clone -b ${tag_version} https://gitcode.com/cann/ops-nn.git |
| 135 | ``` | 141 | ``` |
| 142 | + | ||
| 136 | 若出现“`fatal: destination path 'ops-nn' already exists and is not an empty directory.`”说明项目源码已存在,如需刷新项目代码可使用`git pull`命令。 | 143 | 若出现“`fatal: destination path 'ops-nn' already exists and is not an empty directory.`”说明项目源码已存在,如需刷新项目代码可使用`git pull`命令。 |
| 137 | 144 | ||
| 138 | 2. 进入项目根目录,命令如下,请区分Docker和WebIDE场景。 | 145 | 2. 进入项目根目录,命令如下,请区分Docker和WebIDE场景。 |
| 139 | - Docker场景: | 146 | - Docker场景: |
| 147 | + | ||
| 140 | ```bash | 148 | ```bash |
| 141 | cd ops-nn | 149 | cd ops-nn |
| 142 | ``` | 150 | ``` |
| 151 | + | ||
| 143 | - WebIDE场景: | 152 | - WebIDE场景: |
| 153 | + | ||
| 144 | ```bash | 154 | ```bash |
| 145 | cd /mnt/workspace/ops-nn | 155 | cd /mnt/workspace/ops-nn |
| 146 | ``` | 156 | ``` |
| @@ -156,20 +166,25 @@ bash build.sh --pkg --soc=ascend910b --ops=add_example -j16 | |||
| 156 | ``` | 166 | ``` |
| 157 | 167 | ||
| 158 | 若提示如下信息,说明编译成功。 | 168 | 若提示如下信息,说明编译成功。 |
| 169 | + | ||
| 159 | ```bash | 170 | ```bash |
| 160 | Self-extractable archive "cann-ops-nn-custom-linux.${arch}.run" successfully created. | 171 | Self-extractable archive "cann-ops-nn-custom-linux.${arch}.run" successfully created. |
| 161 | ``` | 172 | ``` |
| 173 | + | ||
| 162 | 编译成功后,run包存放于项目根目录的build_out目录下。 | 174 | 编译成功后,run包存放于项目根目录的build_out目录下。 |
| 163 | 175 | ||
| 164 | ### 3. 安装AddExample算子包 | 176 | ### 3. 安装AddExample算子包 |
| 177 | + | ||
| 165 | ```bash | 178 | ```bash |
| 166 | ./build_out/cann-ops-nn-*linux*.run | 179 | ./build_out/cann-ops-nn-*linux*.run |
| 167 | ``` | 180 | ``` |
| 181 | + | ||
| 168 | `AddExample`安装在```${ASCEND_HOME_PATH}/opp/vendors```路径中,```${ASCEND_HOME_PATH}```表示CANN软件安装目录。 | 182 | `AddExample`安装在```${ASCEND_HOME_PATH}/opp/vendors```路径中,```${ASCEND_HOME_PATH}```表示CANN软件安装目录。 |
| 169 | 183 | ||
| 170 | ### 4. 配置环境变量 | 184 | ### 4. 配置环境变量 |
| 171 | 185 | ||
| 172 | 将自定义算子包的路径加入环境变量,确保运行时能够找到。 | 186 | 将自定义算子包的路径加入环境变量,确保运行时能够找到。 |
| 187 | + | ||
| 173 | ```bash | 188 | ```bash |
| 174 | export LD_LIBRARY_PATH=${ASCEND_HOME_PATH}/opp/vendors/custom_nn/op_api/lib:${LD_LIBRARY_PATH} | 189 | export LD_LIBRARY_PATH=${ASCEND_HOME_PATH}/opp/vendors/custom_nn/op_api/lib:${LD_LIBRARY_PATH} |
| 175 | ``` | 190 | ``` |
| @@ -183,6 +198,7 @@ export LD_LIBRARY_PATH=${ASCEND_HOME_PATH}/opp/vendors/custom_nn/op_api/lib:${LD | |||
| 183 | ```bash | 198 | ```bash |
| 184 | bash build.sh --run_example add_example eager cust --vendor_name=custom | 199 | bash build.sh --run_example add_example eager cust --vendor_name=custom |
| 185 | ``` | 200 | ``` |
| 201 | + | ||
| 186 | 预期输出:打印算子`AddExample`的加法计算结果,表明算子已成功部署并正确执行。 | 202 | 预期输出:打印算子`AddExample`的加法计算结果,表明算子已成功部署并正确执行。 |
| 187 | 203 | ||
| 188 | ``` | 204 | ``` |
| @@ -202,6 +218,7 @@ add_example first input[7] is: 1.000000, second input[7] is: 1.000000, result[7] | |||
| 202 | 本阶段目的是对已成功运行的AddExample算子尝试**修改核函数代码**。 | 218 | 本阶段目的是对已成功运行的AddExample算子尝试**修改核函数代码**。 |
| 203 | 219 | ||
| 204 | ### 1. 修改Kernel实现 | 220 | ### 1. 修改Kernel实现 |
| 221 | + | ||
| 205 | 找到AddExample算子的核心kernel实现文件`ops-nn/examples/add_example/op_kernel/add_example.h`,尝试将算子中的Add操作改为Mul操作: | 222 | 找到AddExample算子的核心kernel实现文件`ops-nn/examples/add_example/op_kernel/add_example.h`,尝试将算子中的Add操作改为Mul操作: |
| 206 | 223 | ||
| 207 | ```cpp | 224 | ```cpp |
| @@ -218,26 +235,32 @@ __aicore__ inline void AddExample<T>::Compute(int32_t progress) | |||
| 218 | inputQueueY.FreeTensor(yLocal); | 235 | inputQueueY.FreeTensor(yLocal); |
| 219 | } | 236 | } |
| 220 | ``` | 237 | ``` |
| 238 | + | ||
| 221 | ### 2. 编译与验证 | 239 | ### 2. 编译与验证 |
| 222 | 240 | ||
| 223 | 重复[编译部署](#二编译部署)章节中的第2至第5步: | 241 | 重复[编译部署](#二编译部署)章节中的第2至第5步: |
| 242 | + | ||
| 224 | 1. **重新编译**: | 243 | 1. **重新编译**: |
| 225 | 先回到项目根目录,编译命令如下: | 244 | 先回到项目根目录,编译命令如下: |
| 245 | + | ||
| 226 | ```bash | 246 | ```bash |
| 227 | bash build.sh --pkg --soc=ascend910b --ops=add_example -j16 | 247 | bash build.sh --pkg --soc=ascend910b --ops=add_example -j16 |
| 228 | ``` | 248 | ``` |
| 229 | 249 | ||
| 230 | 2. **重新安装**: | 250 | 2. **重新安装**: |
| 251 | + | ||
| 231 | ```bash | 252 | ```bash |
| 232 | ./build_out/cann-ops-nn-*linux*.run | 253 | ./build_out/cann-ops-nn-*linux*.run |
| 233 | ``` | 254 | ``` |
| 234 | 255 | ||
| 235 | 3. **重新验证**: | 256 | 3. **重新验证**: |
| 257 | + | ||
| 236 | ```bash | 258 | ```bash |
| 237 | bash build.sh --run_example add_example eager cust --vendor_name=custom | 259 | bash build.sh --run_example add_example eager cust --vendor_name=custom |
| 238 | ``` | 260 | ``` |
| 239 | 261 | ||
| 240 | 4. **成功标志**:输出结果变成乘法结果。 | 262 | 4. **成功标志**:输出结果变成乘法结果。 |
| 263 | + | ||
| 241 | ``` | 264 | ``` |
| 242 | add_example first input[0] is: 1.000000, second input[0] is: 1.000000, result[0] is: 1.000000 | 265 | add_example first input[0] is: 1.000000, second input[0] is: 1.000000, result[0] is: 1.000000 |
| 243 | add_example first input[1] is: 1.000000, second input[1] is: 1.000000, result[1] is: 1.000000 | 266 | add_example first input[1] is: 1.000000, second input[1] is: 1.000000, result[1] is: 1.000000 |
| @@ -251,9 +274,11 @@ __aicore__ inline void AddExample<T>::Compute(int32_t progress) | |||
| 251 | ``` | 274 | ``` |
| 252 | 275 | ||
| 253 | ## 四、算子调试 | 276 | ## 四、算子调试 |
| 277 | + | ||
| 254 | 本阶段以AddExample为例,在算子中添加打印并采集算子性能数据,以便后续问题分析定位。 | 278 | 本阶段以AddExample为例,在算子中添加打印并采集算子性能数据,以便后续问题分析定位。 |
| 255 | 279 | ||
| 256 | ### 1. 打印 | 280 | ### 1. 打印 |
| 281 | + | ||
| 257 | 算子如果出现执行失败、精度异常等问题,添加打印进行问题分析和定位。 | 282 | 算子如果出现执行失败、精度异常等问题,添加打印进行问题分析和定位。 |
| 258 | 283 | ||
| 259 | 请在`examples/add_example/op_kernel/add_example.h`中进行代码修改。 | 284 | 请在`examples/add_example/op_kernel/add_example.h`中进行代码修改。 |
| @@ -270,6 +295,7 @@ __aicore__ inline void AddExample<T>::Compute(int32_t progress) | |||
| 270 | // 打印当前核计算Block长度 | 295 | // 打印当前核计算Block长度 |
| 271 | AscendC::PRINTF("Tiling blockLength is %llu\n", blockLength_); | 296 | AscendC::PRINTF("Tiling blockLength is %llu\n", blockLength_); |
| 272 | ``` | 297 | ``` |
| 298 | + | ||
| 273 | * **DumpTensor** | 299 | * **DumpTensor** |
| 274 | 300 | ||
| 275 | 该接口支持Dump指定Tensor的内容,同时支持打印自定义附加信息,比如当前行号等,详细介绍请参见[《Ascend C API》](https://hiascend.com/document/redirect/CannCommunityAscendCApi)中“算子调测API > DumpTensor”。 | 301 | 该接口支持Dump指定Tensor的内容,同时支持打印自定义附加信息,比如当前行号等,详细介绍请参见[《Ascend C API》](https://hiascend.com/document/redirect/CannCommunityAscendCApi)中“算子调测API > DumpTensor”。 |
| @@ -279,24 +305,27 @@ __aicore__ inline void AddExample<T>::Compute(int32_t progress) | |||
| 279 | // 打印zLocal Tensor信息 | 305 | // 打印zLocal Tensor信息 |
| 280 | DumpTensor(zLocal, 0, 128); | 306 | DumpTensor(zLocal, 0, 128); |
| 281 | ``` | 307 | ``` |
| 308 | + | ||
| 282 | ### 2. 性能采集 | 309 | ### 2. 性能采集 |
| 283 | 310 | ||
| 284 | 当算子功能验证正确后,可通过`msprof`工具采集算子性能数据。 | 311 | 当算子功能验证正确后,可通过`msprof`工具采集算子性能数据。 |
| 285 | 312 | ||
| 286 | -- **生成可执行文件** | 313 | +- **生成可执行文件** |
| 287 | 314 | ||
| 288 | 调用AddExample算子的example样例,生成可执行文件(test_aclnn_add_example),该文件位于项目`ops-nn/build`目录。 | 315 | 调用AddExample算子的example样例,生成可执行文件(test_aclnn_add_example),该文件位于项目`ops-nn/build`目录。 |
| 316 | + | ||
| 289 | ```bash | 317 | ```bash |
| 290 | bash build.sh --run_example add_example eager cust --vendor_name=custom | 318 | bash build.sh --run_example add_example eager cust --vendor_name=custom |
| 291 | ``` | 319 | ``` |
| 292 | 320 | ||
| 293 | -- **采集性能数据** | 321 | +- **采集性能数据** |
| 294 | 322 | ||
| 295 | 进入AddExample算子可执行文件目录`ops-nn/build/`,执行如下命令: | 323 | 进入AddExample算子可执行文件目录`ops-nn/build/`,执行如下命令: |
| 296 | 324 | ||
| 297 | ```bash | 325 | ```bash |
| 298 | msprof --application="./test_aclnn_add_example" | 326 | msprof --application="./test_aclnn_add_example" |
| 299 | ``` | 327 | ``` |
| 328 | + | ||
| 300 | 采集结果在项目`ops-nn/build/`目录,msprof命令执行完后会自动解析并导出性能数据结果文件,详细内容请参见[msprof](https://www.hiascend.com/document/detail/zh/mindstudio/82RC1/T&ITools/Profiling/atlasprofiling_16_0110.html#ZH-CN_TOPIC_0000002504160251)。 | 329 | 采集结果在项目`ops-nn/build/`目录,msprof命令执行完后会自动解析并导出性能数据结果文件,详细内容请参见[msprof](https://www.hiascend.com/document/detail/zh/mindstudio/82RC1/T&ITools/Profiling/atlasprofiling_16_0110.html#ZH-CN_TOPIC_0000002504160251)。 |
| 301 | 330 | ||
| 302 | ## 五、算子验证 | 331 | ## 五、算子验证 |
| @@ -304,6 +333,7 @@ __aicore__ inline void AddExample<T>::Compute(int32_t progress) | |||
| 304 | 本阶段通过修改AddExample算子example样例中的输入数据,验证该算子在多种场景下的功能正确性。 | 333 | 本阶段通过修改AddExample算子example样例中的输入数据,验证该算子在多种场景下的功能正确性。 |
| 305 | 334 | ||
| 306 | ### 1. 修改测试输入 | 335 | ### 1. 修改测试输入 |
| 336 | + | ||
| 307 | 找到并编辑`AddExample`的`ops-nn/examples/add_example/examples/test_aclnn_add_example.cpp`,修改输入张量的形状和数值。 | 337 | 找到并编辑`AddExample`的`ops-nn/examples/add_example/examples/test_aclnn_add_example.cpp`,修改输入张量的形状和数值。 |
| 308 | 338 | ||
| 309 | **修改输入/输出数据**:修改输入、输出的shape信息,以及初始化数据,构造相应的输入、输出tensor。 | 339 | **修改输入/输出数据**:修改输入、输出的shape信息,以及初始化数据,构造相应的输入、输出tensor。 |
| @@ -326,6 +356,7 @@ int main() { | |||
| 326 | // ... 后续执行代码 ... | 356 | // ... 后续执行代码 ... |
| 327 | } | 357 | } |
| 328 | ``` | 358 | ``` |
| 359 | + | ||
| 329 | ### 2. 重新编译并验证 | 360 | ### 2. 重新编译并验证 |
| 330 | 361 | ||
| 331 | 1. 由于只修改了example测试代码,无需重新编译算子包。 | 362 | 1. 由于只修改了example测试代码,无需重新编译算子包。 |
| @@ -1,6 +1,7 @@ | |||
| 1 | # ops-nn | 1 | # ops-nn |
| 2 | 2 | ||
| 3 | ## 🔥Latest News | 3 | ## 🔥Latest News |
| 4 | + | ||
| 4 | - [2026/01] 新增[QuickStart](QUICKSTART.md),指导新手零基础入门算子项目部署(支持Docker环境)、算子开发和贡献流程。 | 5 | - [2026/01] 新增[QuickStart](QUICKSTART.md),指导新手零基础入门算子项目部署(支持Docker环境)、算子开发和贡献流程。 |
| 5 | - [2025/12] 开源算子支持Ascend 950PR/Ascend 950DT/KirinX90,可以通过[CANN Simulator](docs/zh/debug/cann_simulator.md)仿真工具开发调试;优化指南类文档,聚焦[算子开发指南](docs/zh/develop/aicore_develop_guide.md),明确最小交付件和关键示例代码,针对Ascend/samples仓算子提供迁移本项目的指导;新支持[稀疏4:2量化matmul算子](matmul/sparse4to2quant_matmul),针对稀疏矩阵使能硬件加速能力。 | 6 | - [2025/12] 开源算子支持Ascend 950PR/Ascend 950DT/KirinX90,可以通过[CANN Simulator](docs/zh/debug/cann_simulator.md)仿真工具开发调试;优化指南类文档,聚焦[算子开发指南](docs/zh/develop/aicore_develop_guide.md),明确最小交付件和关键示例代码,针对Ascend/samples仓算子提供迁移本项目的指导;新支持[稀疏4:2量化matmul算子](matmul/sparse4to2quant_matmul),针对稀疏矩阵使能硬件加速能力。 |
| 6 | - [2025/11] 新支持算子[index_fill](index/index_fill/)、[masked_scatter](index/masked_scatter/)、[scatter](index/scatter/)、[tf_scatter_add](index/tf_scatter_add/)、[fused_cross_entropy_loss_with_max_sum](loss/fused_cross_entropy_loss_with_max_sum/)。 | 7 | - [2025/11] 新支持算子[index_fill](index/index_fill/)、[masked_scatter](index/masked_scatter/)、[scatter](index/scatter/)、[tf_scatter_add](index/tf_scatter_add/)、[fused_cross_entropy_loss_with_max_sum](loss/fused_cross_entropy_loss_with_max_sum/)。 |
| @@ -41,7 +42,9 @@ ops-nn是[CANN](https://hiascend.com/software/cann) (Compute Architecture for | |||
| 41 | 除了上述指南,还提供了其他文档例如[算子调用方式](docs/zh/invocation/op_invocation.md)、术语概念、build参数介绍等,全量文档请访问[docs](docs/README.md)。 | 42 | 除了上述指南,还提供了其他文档例如[算子调用方式](docs/zh/invocation/op_invocation.md)、术语概念、build参数介绍等,全量文档请访问[docs](docs/README.md)。 |
| 42 | 43 | ||
| 43 | ## 🔍目录结构 | 44 | ## 🔍目录结构 |
| 45 | + | ||
| 44 | 关键目录如下,详细目录介绍参见[项目目录](./docs/zh/context/dir_structure.md)。 | 46 | 关键目录如下,详细目录介绍参见[项目目录](./docs/zh/context/dir_structure.md)。 |
| 47 | + | ||
| 45 | ``` | 48 | ``` |
| 46 | ├── activation # activation类算子 | 49 | ├── activation # activation类算子 |
| 47 | ├── cmake # 项目工程编译目录 | 50 | ├── cmake # 项目工程编译目录 |
| @@ -96,4 +99,4 @@ ops-nn是[CANN](https://hiascend.com/software/cann) (Compute Architecture for | |||
| 96 | |技术专题|样例| | 99 | |技术专题|样例| |
| 97 | |----|----| | 100 | |----|----| |
| 98 | |算子性能优化|[MatMul算子性能优化实践与效果分析](https://gitcode.com/cann/ops-nn/wiki/MatMul%E7%AE%97%E5%AD%90%E6%80%A7%E8%83%BD%E4%BC%98%E5%8C%96%E5%AE%9E%E8%B7%B5%E4%B8%8E%E6%95%88%E6%9E%9C%E5%88%86%E6%9E%90.md)| | 101 | |算子性能优化|[MatMul算子性能优化实践与效果分析](https://gitcode.com/cann/ops-nn/wiki/MatMul%E7%AE%97%E5%AD%90%E6%80%A7%E8%83%BD%E4%BC%98%E5%8C%96%E5%AE%9E%E8%B7%B5%E4%B8%8E%E6%95%88%E6%9E%9C%E5%88%86%E6%9E%90.md)| |
| 99 | - |算子性能优化|[MatMul算子VCV性能优化实践与效果分析](https://gitcode.com/cann/ops-nn/wiki/MatMul%E7%AE%97%E5%AD%90VCV%E6%80%A7%E8%83%BD%E4%BC%98%E5%8C%96%E5%AE%9E%E8%B7%B5%E4%B8%8E%E6%95%88%E6%9E%9C%E5%88%86%E6%9E%90.md)| | 102 | + |算子性能优化|[MatMul算子VCV性能优化实践与效果分析](https://gitcode.com/cann/ops-nn/wiki/MatMul%E7%AE%97%E5%AD%90VCV%E6%80%A7%E8%83%BD%E4%BC%98%E5%8C%96%E5%AE%9E%E8%B7%B5%E4%B8%8E%E6%95%88%E6%9E%9C%E5%88%86%E6%9E%90.md)| |
| @@ -22,20 +22,22 @@ | |||
| 22 | - 算子通过[PyTorch](https://gitee.com/ascend/pytorch)方式调用时,可能会因为版本不匹配导致运行错误,具体请参考[PyTorch安全声明](https://gitee.com/ascend/pytorch#%E5%AE%89%E5%85%A8%E5%A3%B0%E6%98%8E)。 | 22 | - 算子通过[PyTorch](https://gitee.com/ascend/pytorch)方式调用时,可能会因为版本不匹配导致运行错误,具体请参考[PyTorch安全声明](https://gitee.com/ascend/pytorch#%E5%AE%89%E5%85%A8%E5%A3%B0%E6%98%8E)。 |
| 23 | 23 | ||
| 24 | ## 公网地址声明 | 24 | ## 公网地址声明 |
| 25 | + | ||
| 25 | 本项目代码中包含的公网地址声明如下所示: | 26 | 本项目代码中包含的公网地址声明如下所示: |
| 26 | 27 | ||
| 27 | | 类型 | 开源代码地址 | 文件名 | 公网IP地址/公网URL地址/域名/邮箱地址/压缩文件地址 | 用途说明 | | 28 | | 类型 | 开源代码地址 | 文件名 | 公网IP地址/公网URL地址/域名/邮箱地址/压缩文件地址 | 用途说明 | |
| 28 | | :------------: |:------------------------------------------------------------------------------------------:|:----------------------------------------------------------| :---------------------------------------------------------- |:-----------------------------------------| | 29 | | :------------: |:------------------------------------------------------------------------------------------:|:----------------------------------------------------------| :---------------------------------------------------------- |:-----------------------------------------| |
| 29 | -| 依赖 | 不涉及 | cmake/third_party/makeself-fetch.cmake | https://gitcode.com/cann-src-third-party/makeself/releases/download/release-2.5.0-patch1.0/makeself-release-2.5.0-patch1.tar.gz | 从gitcode下载makeself源码,作用编译依赖 | | 30 | +| 依赖 | 不涉及 | cmake/third_party/makeself-fetch.cmake | [https://gitcode.com/cann-src-third-party/makeself/releases/download/release-2.5.0-patch1.0/makeself-release-2.5.0-patch1.tar.gz](https://gitcode.com/cann-src-third-party/makeself/releases/download/release-2.5.0-patch1.0/makeself-release-2.5.0-patch1.tar.gz) | 从gitcode下载makeself源码,作用编译依赖 | |
| 30 | -| 依赖 | 不涉及 | cmake/third_party/nlohmann_json.cmake | https://gitcode.com/cann-src-third-party/json/releases/download/v3.11.3/include.zip | 从gitcode下载json源码,作用编译依赖 | | 31 | +| 依赖 | 不涉及 | cmake/third_party/nlohmann_json.cmake | [https://gitcode.com/cann-src-third-party/json/releases/download/v3.11.3/include.zip](https://gitcode.com/cann-src-third-party/json/releases/download/v3.11.3/include.zip) | 从gitcode下载json源码,作用编译依赖 | |
| 31 | -| 依赖 | 不涉及 | cmake/third_party/gtest.cmake | https://gitcode.com/cann-src-third-party/googletest/releases/download/v1.14.0/googletest-1.14.0.tar.gz | 从gitcode下载googletest源码,作用编译依赖 | | 32 | +| 依赖 | 不涉及 | cmake/third_party/gtest.cmake | [https://gitcode.com/cann-src-third-party/googletest/releases/download/v1.14.0/googletest-1.14.0.tar.gz](https://gitcode.com/cann-src-third-party/googletest/releases/download/v1.14.0/googletest-1.14.0.tar.gz) | 从gitcode下载googletest源码,作用编译依赖 | |
| 32 | -| 依赖 | 不涉及 | cmake/third_party/eigen.cmake | https://gitcode.com/cann-src-third-party/eigen/releases/download/5.0.0-h0.trunk/eigen-5.0.0.tar.gz | 从gitcode下载eigen源码,作用编译依赖 | | 33 | +| 依赖 | 不涉及 | cmake/third_party/eigen.cmake | [https://gitcode.com/cann-src-third-party/eigen/releases/download/5.0.0-h0.trunk/eigen-5.0.0.tar.gz](https://gitcode.com/cann-src-third-party/eigen/releases/download/5.0.0-h0.trunk/eigen-5.0.0.tar.gz) | 从gitcode下载eigen源码,作用编译依赖 | |
| 33 | -| 依赖 | 不涉及 | ops-nn/install_deps.sh | https://apt.kitware.com/keys/kitware-archive-latest.asc | 从gitcode下载install_deps源码,作用编译依赖 | | 34 | +| 依赖 | 不涉及 | ops-nn/install_deps.sh | [https://apt.kitware.com/keys/kitware-archive-latest.asc](https://apt.kitware.com/keys/kitware-archive-latest.asc) | 从gitcode下载install_deps源码,作用编译依赖 | |
| 34 | -| 依赖 | 不涉及 | ops-nn/install_deps.sh | https://apt.kitware.com/ubuntu/ | 从gitcode下载install_deps源码,作用编译依赖 | | 35 | +| 依赖 | 不涉及 | ops-nn/install_deps.sh | [https://apt.kitware.com/ubuntu/](https://apt.kitware.com/ubuntu/) | 从gitcode下载install_deps源码,作用编译依赖 | |
| 35 | -| 依赖 | 不涉及 | cmake | https://apt.kitware.com/keys/kitware-archive-latest.asc | 从kitware下载cmake软件,作用编译依赖 | | 36 | +| 依赖 | 不涉及 | cmake | [https://apt.kitware.com/keys/kitware-archive-latest.asc](https://apt.kitware.com/keys/kitware-archive-latest.asc) | 从kitware下载cmake软件,作用编译依赖 | |
| 36 | -| 依赖 | 不涉及 | cmake | https://apt.kitware.com/ubuntu/ | 从kitware下载cmake软件,作用编译依赖 | | 37 | +| 依赖 | 不涉及 | cmake | [https://apt.kitware.com/ubuntu/](https://apt.kitware.com/ubuntu/) | 从kitware下载cmake软件,作用编译依赖 | |
| 37 | 38 | ||
| 38 | ## 漏洞机制说明 | 39 | ## 漏洞机制说明 |
| 40 | + | ||
| 39 | [漏洞管理](https://gitcode.com/cann/community/blob/master/security/security.md) | 41 | [漏洞管理](https://gitcode.com/cann/community/blob/master/security/security.md) |
| 40 | 42 | ||
| 41 | ## 附录 | 43 | ## 附录 |
| @@ -60,4 +62,4 @@ | |||
| 60 | | 业务数据文件目录 | 750(rwxr-x---) | | 62 | | 业务数据文件目录 | 750(rwxr-x---) | |
| 61 | | 密钥组件、私钥、证书、密文文件目录 | 700(rwx-----) | | 63 | | 密钥组件、私钥、证书、密文文件目录 | 700(rwx-----) | |
| 62 | | 密钥组件、私钥、证书、加密密文 | 600(rw-------) | | 64 | | 密钥组件、私钥、证书、加密密文 | 600(rw-------) | |
| 63 | -| 加解密接口、加解密脚本 | 500(r-x------) | | 65 | +| 加解密接口、加解密脚本 | 500(r-x------) | |
| @@ -68,11 +68,13 @@ | |||
| 68 | 68 | ||
| 69 | ## 约束说明 | 69 | ## 约束说明 |
| 70 | 70 | ||
| 71 | -- 确定性计算: | 71 | +- 确定性计算: |
| 72 | - aclnnBinaryCrossEntropyWithLogitsTargetBackward默认确定性实现。 | 72 | - aclnnBinaryCrossEntropyWithLogitsTargetBackward默认确定性实现。 |
| 73 | 73 | ||
| 74 | ## 调用示例 | 74 | ## 调用示例 |
| 75 | + | ||
| 75 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 76 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| 77 | + | ||
| 76 | ```Cpp | 78 | ```Cpp |
| 77 | #include <iostream> | 79 | #include <iostream> |
| 78 | #include <vector> | 80 | #include <vector> |
| @@ -152,7 +152,6 @@ | |||
| 152 | - 对于 `filter` 输入,`H`、`W` 的大小应该在 [1, 511] 的范围内。`N` 维度大小应该大于等于 0(等于 0 的场景仅在 `bias`、`output` 的 `N` 维度也等于 0 时支持),`C` 维度大小的支持情况与输入 `x` 的 `C` 维度一致。 | 152 | - 对于 `filter` 输入,`H`、`W` 的大小应该在 [1, 511] 的范围内。`N` 维度大小应该大于等于 0(等于 0 的场景仅在 `bias`、`output` 的 `N` 维度也等于 0 时支持),`C` 维度大小的支持情况与输入 `x` 的 `C` 维度一致。 |
| 153 | - 当 `x` 和 `filter` 数据类型是 `HIFLOAT8` 时,`bias` 数据类型会转成 `FLOAT` 参与计算。 | 153 | - 当 `x` 和 `filter` 数据类型是 `HIFLOAT8` 时,`bias` 数据类型会转成 `FLOAT` 参与计算。 |
| 154 | 154 | ||
| 155 | - | ||
| 156 | <table> | 155 | <table> |
| 157 | <tr> | 156 | <tr> |
| 158 | <th style="text-align:center; width:80px">张量</th> | 157 | <th style="text-align:center; width:80px">张量</th> |
| @@ -11,7 +11,6 @@ | |||
| 11 | | <term>Atlas 推理系列产品</term> | √ | | 11 | | <term>Atlas 推理系列产品</term> | √ | |
| 12 | | <term>Atlas 训练系列产品</term> | √ | | 12 | | <term>Atlas 训练系列产品</term> | √ | |
| 13 | 13 | ||
| 14 | - | ||
| 15 | ## 功能说明 | 14 | ## 功能说明 |
| 16 | 15 | ||
| 17 | - 算子功能:卷积的反向传播。根据输出掩码设置计算输入、权重和偏差的梯度。此函数支持1D、2D和3D卷积。 | 16 | - 算子功能:卷积的反向传播。根据输出掩码设置计算输入、权重和偏差的梯度。此函数支持1D、2D和3D卷积。 |
| @@ -33,7 +32,8 @@ | |||
| 33 | $$ | 32 | $$ |
| 34 | 33 | ||
| 35 | 卷积反向传播需要计算对卷积正向的输入张量 $x$、卷积核权重张量 $w$ 和偏置 $b$ 的梯度。 | 34 | 卷积反向传播需要计算对卷积正向的输入张量 $x$、卷积核权重张量 $w$ 和偏置 $b$ 的梯度。 |
| 36 | - - 对于 $x$ 的梯度 $\frac{\partial L}{\partial x}$: | 35 | + |
| 36 | + - 对于$x$ 的梯度 $\frac{\partial L}{\partial x}$: | ||
| 37 | 37 | ||
| 38 | $$ | 38 | $$ |
| 39 | \frac{\partial L}{\partial x_{n, c_{in}, i, j}} = \sum_{c_{out}=1}^{C_{out}} \sum_{p=1}^{k_H} \sum_{q=1}^{k_W} \frac{\partial L}{\partial y_{n, c_{out}, i-p, j-q}}\cdot w_{c_{out}, c_{in}, p, q} | 39 | \frac{\partial L}{\partial x_{n, c_{in}, i, j}} = \sum_{c_{out}=1}^{C_{out}} \sum_{p=1}^{k_H} \sum_{q=1}^{k_W} \frac{\partial L}{\partial y_{n, c_{out}, i-p, j-q}}\cdot w_{c_{out}, c_{in}, p, q} |
| @@ -44,4 +44,4 @@ | |||
| 44 | | 文档 | 说明 | | 44 | | 文档 | 说明 | |
| 45 | | ----------------------------------- | ------------------------------------------------------------ | | 45 | | ----------------------------------- | ------------------------------------------------------------ | |
| 46 | | [算子基本概念](zh/context/基本概念.md) | 介绍算子领域相关的基础概念和术语,如量化/稀疏、数据类型、数据格式等。 | | 46 | | [算子基本概念](zh/context/基本概念.md) | 介绍算子领域相关的基础概念和术语,如量化/稀疏、数据类型、数据格式等。 | |
| 47 | -| [build参数说明](zh/context/build.md) | 介绍本项目build.sh脚本的功能和参数含义。 | | 47 | +| [build参数说明](zh/context/build.md) | 介绍本项目build.sh脚本的功能和参数含义。 | |
| @@ -8,11 +8,12 @@ | |||
| 8 | 8 | ||
| 9 | > 说明: | 9 | > 说明: |
| 10 | > | 10 | > |
| 11 | ->- 为方便描述,表格中使用的数据类型是简写形式,代表的含义:ACL\_FLOAT\(f32\)、ACL\_FLOAT16\(f16\)、ACL\_DOUBLE\(f64\)、ACL\_BF16\(bf16\)、ACL\_INT8\(s8\)、ACL\_UINT8\(u8\)、ACL\_INT16\(s16\)、ACL\_UINT16\(u16\)、ACL\_INT32\(s32\)、ACL\_UINT32\(u32\)、ACL\_INT64\(s64\)、ACL\_UINT64\(u64\)、ACL\_BOOL\(bool\)、ACL\_COMPLEX32\(c32\)、ACL\_COMPLEX64\(c64\)、ACL\_COMPLEX128\(c128\)。 | 11 | +> - 为方便描述,表格中使用的数据类型是简写形式,代表的含义:ACL\_FLOAT\(f32\)、ACL\_FLOAT16\(f16\)、ACL\_DOUBLE\(f64\)、ACL\_BF16\(bf16\)、ACL\_INT8\(s8\)、ACL\_UINT8\(u8\)、ACL\_INT16\(s16\)、ACL\_UINT16\(u16\)、ACL\_INT32\(s32\)、ACL\_UINT32\(u32\)、ACL\_INT64\(s64\)、ACL\_UINT64\(u64\)、ACL\_BOOL\(bool\)、ACL\_COMPLEX32\(c32\)、ACL\_COMPLEX64\(c64\)、ACL\_COMPLEX128\(c128\)。 |
| 12 | ->- 表格里表头表示待推导的输入Tensor数据类型,最左侧一列分别表示待推导的输入Scalar数据类型,表格中对应位置表示推导出的数据类型。 | 12 | +> - 表格里表头表示待推导的输入Tensor数据类型,最左侧一列分别表示待推导的输入Scalar数据类型,表格中对应位置表示推导出的数据类型。 |
| 13 | ->- 表中叉号(×)表示这两种类型不能进行推导计算。 | 13 | +> - 表中叉号(×)表示这两种类型不能进行推导计算。 |
| 14 | 14 | ||
| 15 | **表 1** 数据类型推导关系表 | 15 | **表 1** 数据类型推导关系表 |
| 16 | + | ||
| 16 | | 数据类型 | f32 | f16 | f64 | bf16 | s8 | u8 | s16 | u16 | s32 | u32 | s64 | u64 | bool | c32 | c64 | c128 | | 17 | | 数据类型 | f32 | f16 | f64 | bf16 | s8 | u8 | s16 | u16 | s32 | u32 | s64 | u64 | bool | c32 | c64 | c128 | |
| 17 | | :------: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | | 18 | | :------: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | |
| 18 | | **f32** | f32 | f16 | f64 | bf16 | f32 | f32 | f32 | × | f32 | × | f32 | × | f32 | c32 | c64 | c128 | | 19 | | **f32** | f32 | f16 | f64 | bf16 | f32 | f32 | f32 | × | f32 | × | f32 | × | f32 | c32 | c64 | c128 | |
| @@ -34,6 +35,5 @@ | |||
| 34 | 35 | ||
| 35 | ## 推导示例 | 36 | ## 推导示例 |
| 36 | 37 | ||
| 37 | -- 如果输入Tensor的数据类型为float16,输入Scalar的数据类型为float32,那么API内部就会将输入Scalar的float32数据类型转换成float16数据类型然后进行计算。 | 38 | + - 如果输入Tensor的数据类型为float16,输入Scalar的数据类型为float32,那么API内部就会将输入Scalar的float32数据类型转换成float16数据类型然后进行计算。 |
| 38 | -- 如果输入Tensor的数据类型为bool,输入Scalar的数据类型为float32,那么API内部就会将输入Tensor的bool数据类型转换成float32数据类型然后进行计算。 | 39 | + - 如果输入Tensor的数据类型为bool,输入Scalar的数据类型为float32,那么API内部就会将输入Tensor的bool数据类型转换成float32数据类型然后进行计算。 |
| 39 | - | ||
| @@ -24,6 +24,7 @@ broadcast(广播)描述了算子在运算期间如何处理不同形状的 | |||
| 24 | - 规则3:如果数组间维度数不一致,且均没有等于1的维度,则会报错。 | 24 | - 规则3:如果数组间维度数不一致,且均没有等于1的维度,则会报错。 |
| 25 | 25 | ||
| 26 | 基于上述规则,广播过程一般先按**规则1**进行扩维,再按**规则2**进行形状拉伸,具体例子如下: | 26 | 基于上述规则,广播过程一般先按**规则1**进行扩维,再按**规则2**进行形状拉伸,具体例子如下: |
| 27 | + | ||
| 27 | ``` | 28 | ``` |
| 28 | 假设a.shape=(2,2,3),取值形如: | 29 | 假设a.shape=(2,2,3),取值形如: |
| 29 | [[[1 2 3],[4 5 6]], | 30 | [[[1 2 3],[4 5 6]], |
| @@ -48,5 +49,5 @@ broadcast(广播)描述了算子在运算期间如何处理不同形状的 | |||
| 48 | 条件:连续的需要广播的轴和连续的不需要广播的轴合并之后的维度要求小于6。 | 49 | 条件:连续的需要广播的轴和连续的不需要广播的轴合并之后的维度要求小于6。 |
| 49 | 举例: | 50 | 举例: |
| 50 | 51 | ||
| 51 | -- 当a.shape=\(5, 1, 5, 1, 5, 1\),b.shape=\(5, 5, 5, 5, 5, 5\),没有需要合并的轴,最后维度为6,广播报错。 | 52 | +- 当a.shape=\(5, 1, 5, 1, 5, 1\),b.shape=\(5, 5, 5, 5, 5, 5\),没有需要合并的轴,最后维度为6,广播报错。 |
| 52 | -- 当a.shape=\(5, 1, 5, 5, 1, 1\),b.shape=\(5, 5, 5, 5, 5, 5\),在第2和3维都不需要广播,4和5维都需要广播,分别连续合并,合并后的维度为4,广播成功。 | 53 | +- 当a.shape=\(5, 1, 5, 5, 1, 1\),b.shape=\(5, 5, 5, 5, 5, 5\),在第2和3维都不需要广播,4和5维都需要广播,分别连续合并,合并后的维度为4,广播成功。 |
| @@ -1,32 +1,38 @@ | |||
| 1 | # build参数说明 | 1 | # build参数说明 |
| 2 | 2 | ||
| 3 | ## 简介 | 3 | ## 简介 |
| 4 | + | ||
| 4 | build.sh是本项目的构建脚本,默认在项目根目录下,作用是将源代码自动编译、链接和配置,最终生成可执行文件、库文件或其它可供安装或直接运行的目标文件。具体来说,脚本中通过配置不同参数实现多种功能,包含构建多种目标库(如:libophost_nn.so)、编译算子包、执行单元测试等。 | 5 | build.sh是本项目的构建脚本,默认在项目根目录下,作用是将源代码自动编译、链接和配置,最终生成可执行文件、库文件或其它可供安装或直接运行的目标文件。具体来说,脚本中通过配置不同参数实现多种功能,包含构建多种目标库(如:libophost_nn.so)、编译算子包、执行单元测试等。 |
| 5 | 6 | ||
| 6 | - | ||
| 7 | ## 使用方法 | 7 | ## 使用方法 |
| 8 | + | ||
| 8 | 1. **配置环境变量** | 9 | 1. **配置环境变量** |
| 9 | 10 | ||
| 10 | 参考[环境部署](../context/quick_install.md)完成基础环境搭建。 | 11 | 参考[环境部署](../context/quick_install.md)完成基础环境搭建。 |
| 12 | + | ||
| 11 | ```bash | 13 | ```bash |
| 12 | # 默认路径安装,以root用户为例 | 14 | # 默认路径安装,以root用户为例 |
| 13 | source /usr/local/Ascend/cann/set_env.sh | 15 | source /usr/local/Ascend/cann/set_env.sh |
| 14 | ``` | 16 | ``` |
| 17 | + | ||
| 15 | 2. **构建命令格式** | 18 | 2. **构建命令格式** |
| 16 | 19 | ||
| 17 | 以编译算子包命令为例,样式如下,其中`--vendor_name`与`--ops`在该场景为可选项。 | 20 | 以编译算子包命令为例,样式如下,其中`--vendor_name`与`--ops`在该场景为可选项。 |
| 21 | + | ||
| 18 | ```bash | 22 | ```bash |
| 19 | bash build.sh --pkg --soc=${soc_version} [--vendor_name=${vendor_name}] [--ops=${op_list}] | 23 | bash build.sh --pkg --soc=${soc_version} [--vendor_name=${vendor_name}] [--ops=${op_list}] |
| 20 | ``` | 24 | ``` |
| 25 | + | ||
| 21 | 全量参数含义参见下方参数说明章节,请按实际情况选择合适的参数。 | 26 | 全量参数含义参见下方参数说明章节,请按实际情况选择合适的参数。 |
| 22 | 27 | ||
| 23 | ## 参数说明 | 28 | ## 参数说明 |
| 29 | + | ||
| 24 | build.sh支持多种功能,可通过如下命令查看所有功能参数。 | 30 | build.sh支持多种功能,可通过如下命令查看所有功能参数。 |
| 31 | + | ||
| 25 | ```bash | 32 | ```bash |
| 26 | bash build.sh --help | 33 | bash build.sh --help |
| 27 | ``` | 34 | ``` |
| 28 | 35 | ||
| 29 | - | ||
| 30 | | 参数名 | 可选/必选 | 参数说明 | | 36 | | 参数名 | 可选/必选 | 参数说明 | |
| 31 | |------------------|--------|-----------------------------------------------------------------------------| | 37 | |------------------|--------|-----------------------------------------------------------------------------| |
| 32 | | -j${n} | 可选 | 指定编译线程数,${n}为具体线程数,默认值为8(如:-j8);若线程数超过CPU核心数,会自动调整为CPU核心数。 | | 38 | | -j${n} | 可选 | 指定编译线程数,${n}为具体线程数,默认值为8(如:-j8);若线程数超过CPU核心数,会自动调整为CPU核心数。 | |
| @@ -61,4 +67,4 @@ bash build.sh --help | |||
| 61 | | --cann_3rd_lib_path| 可选 | 离线编译场景下第三方库存放的目录。 | | 67 | | --cann_3rd_lib_path| 可选 | 离线编译场景下第三方库存放的目录。 | |
| 62 | | --simulator | 可选 | 与--run_example组合使用,启用仿真器模式执行--run_example任务。仿真模式下,会根据soc_version链接对应的仿真库。 | | 68 | | --simulator | 可选 | 与--run_example组合使用,启用仿真器模式执行--run_example任务。仿真模式下,会根据soc_version链接对应的仿真库。 | |
| 63 | | --bisheng_flags | 可选 | 指定毕昇编译器编译参数,多个编译参数用英文逗号“,”分隔,不可与--mssanitizer、--oom、--dump_cce同时使用。 | | 69 | | --bisheng_flags | 可选 | 指定毕昇编译器编译参数,多个编译参数用英文逗号“,”分隔,不可与--mssanitizer、--oom、--dump_cce同时使用。 | |
| 64 | -| --kernel_template_input | 可选 | 指定编译kernel时的tilingKey模板,仅支持指定一个模板,与--ops同时使用且只能指定一个算子,不会编译该算子所依赖的其他算子二进制文件。 | | 70 | +| --kernel_template_input | 可选 | 指定编译kernel时的tilingKey模板,仅支持指定一个模板,与--ops同时使用且只能指定一个算子,不会编译该算子所依赖的其他算子二进制文件。 | |
| @@ -8,6 +8,7 @@ | |||
| 8 | > - 若缺少op_graph目录,说明该算子暂不支持图模式调用。 | 8 | > - 若缺少op_graph目录,说明该算子暂不支持图模式调用。 |
| 9 | 9 | ||
| 10 | 项目全量目录层级介绍如下: | 10 | 项目全量目录层级介绍如下: |
| 11 | + | ||
| 11 | ``` | 12 | ``` |
| 12 | ├── cmake # 项目工程编译目录 | 13 | ├── cmake # 项目工程编译目录 |
| 13 | │ ├── aclnn_ops_nn.h.in # aclnn汇总头文件模板 | 14 | │ ├── aclnn_ops_nn.h.in # aclnn汇总头文件模板 |
| @@ -24,6 +24,7 @@ | |||
| 24 | - make | 24 | - make |
| 25 | 25 | ||
| 26 | 上述依赖包可通过项目根目录install\_deps.sh安装,命令如下,若遇到不支持系统,请参考该文件自行适配。 | 26 | 上述依赖包可通过项目根目录install\_deps.sh安装,命令如下,若遇到不支持系统,请参考该文件自行适配。 |
| 27 | + | ||
| 27 | ```bash | 28 | ```bash |
| 28 | bash install_deps.sh | 29 | bash install_deps.sh |
| 29 | ``` | 30 | ``` |
| @@ -55,17 +56,17 @@ | |||
| 55 | 56 | ||
| 56 | <img src="../figures/webIDE.png" alt="云平台" width="1000px" height="150px"> | 57 | <img src="../figures/webIDE.png" alt="云平台" width="1000px" height="150px"> |
| 57 | 58 | ||
| 58 | - | ||
| 59 | ### 使用Docker部署 | 59 | ### 使用Docker部署 |
| 60 | 60 | ||
| 61 | > **说明:** | 61 | > **说明:** |
| 62 | +> | ||
| 62 | > - Docker镜像是一种高效部署方式,目前仅适用于Atlas A2系列产品,且目前仅适配Ubuntu操作系统。 | 63 | > - Docker镜像是一种高效部署方式,目前仅适用于Atlas A2系列产品,且目前仅适配Ubuntu操作系统。 |
| 63 | > - 镜像文件比较大,下载需要一定时间,请您耐心等待。 | 64 | > - 镜像文件比较大,下载需要一定时间,请您耐心等待。 |
| 64 | 65 | ||
| 65 | #### 1. 下载镜像 | 66 | #### 1. 下载镜像 |
| 66 | 67 | ||
| 67 | -1. 以root用户登录宿主机。确保宿主机已安装Docker引擎(版本1.11.2及以上)。 | 68 | +1. 以root用户登录宿主机。确保宿主机已安装Docker引擎(版本1.11.2及以上)。 |
| 68 | -2. 从[昇腾镜像仓库](https://www.hiascend.com/developer/ascendhub/detail/17da20d1c2b6493cb38765adeba85884)拉取已预集成CANN软件包及`ops-nn`所需依赖的镜像。命令如下,根据实际架构选择: | 69 | +2. 从[昇腾镜像仓库](https://www.hiascend.com/developer/ascendhub/detail/17da20d1c2b6493cb38765adeba85884)拉取已预集成CANN软件包及`ops-nn`所需依赖的镜像。命令如下,根据实际架构选择: |
| 69 | 70 | ||
| 70 | ```bash | 71 | ```bash |
| 71 | # 示例:拉取ARM架构的CANN开发镜像 | 72 | # 示例:拉取ARM架构的CANN开发镜像 |
| @@ -75,11 +76,13 @@ | |||
| 75 | ``` | 76 | ``` |
| 76 | 77 | ||
| 77 | #### 2. 运行Docker | 78 | #### 2. 运行Docker |
| 79 | + | ||
| 78 | 拉取镜像后,需要以特定参数启动容器,以便容器内能访问宿主的昇腾设备。 | 80 | 拉取镜像后,需要以特定参数启动容器,以便容器内能访问宿主的昇腾设备。 |
| 79 | 81 | ||
| 80 | ```bash | 82 | ```bash |
| 81 | docker run --name cann_container --device /dev/davinci0 --device /dev/davinci_manager --device /dev/devmm_svm --device /dev/hisi_hdc -v /usr/local/dcmi:/usr/local/dcmi -v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi -v /usr/local/Ascend/driver/lib64/:/usr/local/Ascend/driver/lib64/ -v /usr/local/Ascend/driver/version.info:/usr/local/Ascend/driver/version.info -v /etc/ascend_install.info:/etc/ascend_install.info -it swr.cn-south-1.myhuaweicloud.com/ascendhub/cann:8.5.0-910b-ubuntu22.04-py3.10-ops bash | 83 | docker run --name cann_container --device /dev/davinci0 --device /dev/davinci_manager --device /dev/devmm_svm --device /dev/hisi_hdc -v /usr/local/dcmi:/usr/local/dcmi -v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi -v /usr/local/Ascend/driver/lib64/:/usr/local/Ascend/driver/lib64/ -v /usr/local/Ascend/driver/version.info:/usr/local/Ascend/driver/version.info -v /etc/ascend_install.info:/etc/ascend_install.info -it swr.cn-south-1.myhuaweicloud.com/ascendhub/cann:8.5.0-910b-ubuntu22.04-py3.10-ops bash |
| 82 | ``` | 84 | ``` |
| 85 | + | ||
| 83 | | 参数 | 说明 | 注意事项 | | 86 | | 参数 | 说明 | 注意事项 | |
| 84 | | :--- | :--- | :--- | | 87 | | :--- | :--- | :--- | |
| 85 | | `--name cann_container` | 为容器指定名称,便于管理。 | 可自定义。 | | 88 | | `--name cann_container` | 为容器指定名称,便于管理。 | 可自定义。 | |
| @@ -109,6 +112,7 @@ docker run --name cann_container --device /dev/davinci0 --device /dev/davinci_ma | |||
| 109 | 注意产品型号和环境架构需与真实环境对应,此外ops包是运行态依赖,若仅编译算子,可以不安装此包。 | 112 | 注意产品型号和环境架构需与真实环境对应,此外ops包是运行态依赖,若仅编译算子,可以不安装此包。 |
| 110 | 113 | ||
| 111 | #### 2. 安装软件包 | 114 | #### 2. 安装软件包 |
| 115 | + | ||
| 112 | 1. **安装社区CANN toolkit包** | 116 | 1. **安装社区CANN toolkit包** |
| 113 | 117 | ||
| 114 | ```bash | 118 | ```bash |
| @@ -117,6 +121,7 @@ docker run --name cann_container --device /dev/davinci0 --device /dev/davinci_ma | |||
| 117 | # 安装命令 | 121 | # 安装命令 |
| 118 | ./Ascend-cann-toolkit_${cann_version}_linux-${arch}.run --install --force --install-path=${install_path} | 122 | ./Ascend-cann-toolkit_${cann_version}_linux-${arch}.run --install --force --install-path=${install_path} |
| 119 | ``` | 123 | ``` |
| 124 | + | ||
| 120 | - \$\{cann\_version\}:表示CANN包版本号。 | 125 | - \$\{cann\_version\}:表示CANN包版本号。 |
| 121 | - \$\{arch\}:表示CPU架构,如aarch64、x86_64。 | 126 | - \$\{arch\}:表示CPU架构,如aarch64、x86_64。 |
| 122 | - \$\{install\_path\}:表示指定安装路径,默认安装在`/usr/local/Ascend`目录。 | 127 | - \$\{install\_path\}:表示指定安装路径,默认安装在`/usr/local/Ascend`目录。 |
| @@ -139,12 +144,15 @@ docker run --name cann_container --device /dev/davinci0 --device /dev/davinci_ma | |||
| 139 | 144 | ||
| 140 | 安装完CANN包后,需验证环境和驱动是否正常。 | 145 | 安装完CANN包后,需验证环境和驱动是否正常。 |
| 141 | 146 | ||
| 142 | -- **检查NPU设备**: | 147 | +- **检查NPU设备**: |
| 148 | + | ||
| 143 | ```bash | 149 | ```bash |
| 144 | # 运行npu-smi,若能正常显示设备信息,则驱动正常 | 150 | # 运行npu-smi,若能正常显示设备信息,则驱动正常 |
| 145 | npu-smi info | 151 | npu-smi info |
| 146 | ``` | 152 | ``` |
| 147 | -- **检查CANN安装**: | 153 | + |
| 154 | +- **检查CANN安装**: | ||
| 155 | + | ||
| 148 | ```bash | 156 | ```bash |
| 149 | # 查看CANN Toolkit版本信息(默认路径安装) | 157 | # 查看CANN Toolkit版本信息(默认路径安装) |
| 150 | cat /usr/local/Ascend/ascend-toolkit/latest/opp/version.info | 158 | cat /usr/local/Ascend/ascend-toolkit/latest/opp/version.info |
| @@ -153,6 +161,7 @@ docker run --name cann_container --device /dev/davinci0 --device /dev/davinci_ma | |||
| 153 | ## 环境变量配置 | 161 | ## 环境变量配置 |
| 154 | 162 | ||
| 155 | 按需选择合适的命令使环境变量生效。 | 163 | 按需选择合适的命令使环境变量生效。 |
| 164 | + | ||
| 156 | ```bash | 165 | ```bash |
| 157 | # 默认路径安装,以root用户为例(非root用户,将/usr/local替换为${HOME}) | 166 | # 默认路径安装,以root用户为例(非root用户,将/usr/local替换为${HOME}) |
| 158 | source /usr/local/Ascend/cann/set_env.sh | 167 | source /usr/local/Ascend/cann/set_env.sh |
| @@ -171,9 +180,11 @@ git clone -b ${tag_version} https://gitcode.com/cann/ops-nn.git | |||
| 171 | cd ops-nn | 180 | cd ops-nn |
| 172 | pip3 install -r requirements.txt | 181 | pip3 install -r requirements.txt |
| 173 | ``` | 182 | ``` |
| 183 | + | ||
| 174 | > [!NOTE] 注意 | 184 | > [!NOTE] 注意 |
| 175 | > gitcode平台在使用HTTPS协议的时候要配置并使用个人访问令牌代替登录密码进行克隆,推送等操作。 | 185 | > gitcode平台在使用HTTPS协议的时候要配置并使用个人访问令牌代替登录密码进行克隆,推送等操作。 |
| 176 | 186 | ||
| 177 | 若您的编译环境无法访问网络,无法通过`git`指令下载代码,需要在联网环境中下载源码后,手动上传至目标环境。 | 187 | 若您的编译环境无法访问网络,无法通过`git`指令下载代码,需要在联网环境中下载源码后,手动上传至目标环境。 |
| 188 | + | ||
| 178 | - 在联网环境中, 进入[本项目主页](https://gitcode.com/cann/ops-nn),通过`下载ZIP`或`clone`按钮,根据指导,完成源码下载。 | 189 | - 在联网环境中, 进入[本项目主页](https://gitcode.com/cann/ops-nn),通过`下载ZIP`或`clone`按钮,根据指导,完成源码下载。 |
| 179 | -- 连接至离线环境中,上传源码至您指定的目录下。若下载的为源码压缩包,还需进行解压。 | 190 | +- 连接至离线环境中,上传源码至您指定的目录下。若下载的为源码压缩包,还需进行解压。 |
| @@ -27,6 +27,7 @@ $QK^T$矩阵在attenMask为True的位置会被遮蔽,效果如下: | |||
| 27 | ## sparseMode=0 | 27 | ## sparseMode=0 |
| 28 | 28 | ||
| 29 | sparseMode为0时,代表defaultMask模式。 | 29 | sparseMode为0时,代表defaultMask模式。 |
| 30 | + | ||
| 30 | - 不传mask:如果attenMask未传入则不做mask操作,attenMask取值为None,忽略preTokens和nextTokens取值。Masked $QK^T$矩阵示意如下: | 31 | - 不传mask:如果attenMask未传入则不做mask操作,attenMask取值为None,忽略preTokens和nextTokens取值。Masked $QK^T$矩阵示意如下: |
| 31 | 32 | ||
| 32 |  | 33 |  |
| @@ -123,6 +124,7 @@ Masked $QK^T$矩阵示意如下,在第二个batch对query进行切分,key和 | |||
| 123 |  | 124 |  |
| 124 | 125 | ||
| 125 | **说明**: | 126 | **说明**: |
| 127 | + | ||
| 126 | - sparseMode=7,band表示的是最后一个非空tensor的Batch的sparse类型;如果只有一个batch,用户需按照band模式的要求来配置参数;sparseMode=7时,用户需要输入2048x2048的下三角mask作为该融合算子的输入。 | 128 | - sparseMode=7,band表示的是最后一个非空tensor的Batch的sparse类型;如果只有一个batch,用户需按照band模式的要求来配置参数;sparseMode=7时,用户需要输入2048x2048的下三角mask作为该融合算子的输入。 |
| 127 | - 基于sparseMode=3进行外切产生的band模式的sparse参数应符合以下条件: | 129 | - 基于sparseMode=3进行外切产生的band模式的sparse参数应符合以下条件: |
| 128 | - preTokens >= last_Skv。 | 130 | - preTokens >= last_Skv。 |
| @@ -142,8 +144,9 @@ Masked $QK^T$矩阵示意如下,在第二个batch对query进行切分,key和 | |||
| 142 |  | 144 |  |
| 143 | 145 | ||
| 144 | **说明**: | 146 | **说明**: |
| 147 | + | ||
| 145 | - sparseMode=8,band表示的是第一个非空tensor的Batch的sparse类型;如果只有一个batch,用户需按照band模式的要求来配置参数;sparseMode=8时,用户需要输入2048x2048的下三角mask作为该融合算子的输入。 | 148 | - sparseMode=8,band表示的是第一个非空tensor的Batch的sparse类型;如果只有一个batch,用户需按照band模式的要求来配置参数;sparseMode=8时,用户需要输入2048x2048的下三角mask作为该融合算子的输入。 |
| 146 | - 基于sparseMode=2进行外切产生的band模式的sparse的参数应符合以下条件: | 149 | - 基于sparseMode=2进行外切产生的band模式的sparse的参数应符合以下条件: |
| 147 | - preTokens >= first_Skv。 | 150 | - preTokens >= first_Skv。 |
| 148 | - nextTokens >= first_Sq - first_Skv,根据实际情况进行配置。 | 151 | - nextTokens >= first_Sq - first_Skv,根据实际情况进行配置。 |
| 149 | - - 当前模式下不支持可选输入pse。 | 152 | + - 当前模式下不支持可选输入pse。 |
| @@ -12,8 +12,10 @@ aclnnStatus aclxxXxx(void *workspace, uint64_t workspaceSize, aclOpExecutor *exe | |||
| 12 | 其中“aclxx”表示算子接口前缀,如aclnn;而“Xxx”表示对应的算子类型,如Add算子。 | 12 | 其中“aclxx”表示算子接口前缀,如aclnn;而“Xxx”表示对应的算子类型,如Add算子。 |
| 13 | 13 | ||
| 14 | > 说明: | 14 | > 说明: |
| 15 | ->- workspace是指除输入/输出外,API在AI处理器上完成计算所需要的临时内存。 | 15 | +> |
| 16 | ->- 第二段接口aclxxXxx(...)不能重复调用,如下调用方式会出现异常: | 16 | +> - workspace是指除输入/输出外,API在AI处理器上完成计算所需要的临时内存。 |
| 17 | +> - 第二段接口aclxxXxx(...)不能重复调用,如下调用方式会出现异常: | ||
| 18 | +> | ||
| 17 | > ```Cpp | 19 | > ```Cpp |
| 18 | > aclxxXxxGetWorkspaceSize(...) | 20 | > aclxxXxxGetWorkspaceSize(...) |
| 19 | > aclxxXxx(...) | 21 | > aclxxXxx(...) |
| @@ -8,11 +8,12 @@ aclTensor支持的数据类型参见[数据类型](./数据类型.md),其中 | |||
| 8 | 8 | ||
| 9 | > 说明: | 9 | > 说明: |
| 10 | > | 10 | > |
| 11 | ->- 为方便描述,表格中使用的数据类型是**简写形式**,代表的含义:ACL\_FLOAT\(f32\)、ACL\_FLOAT16\(f16\)、ACL\_DOUBLE\(f64\)、ACL\_BF16\(bf16\)、ACL\_INT8\(s8\)、ACL\_UINT8\(u8\)、ACL\_INT16\(s16\)、ACL\_UINT16\(u16\)、ACL\_INT32\(s32\)、ACL\_UINT32\(u32\)、ACL\_INT64\(s64\)、ACL\_UINT64\(u64\)、ACL\_BOOL\(bool\)、ACL\_COMPLEX32\(c32\)、ACL\_COMPLEX64\(c64\)、ACL\_COMPLEX128\(c128\)。 | 11 | +> - 为方便描述,表格中使用的数据类型是**简写形式**,代表的含义:ACL\_FLOAT\(f32\)、ACL\_FLOAT16\(f16\)、ACL\_DOUBLE\(f64\)、ACL\_BF16\(bf16\)、ACL\_INT8\(s8\)、ACL\_UINT8\(u8\)、ACL\_INT16\(s16\)、ACL\_UINT16\(u16\)、ACL\_INT32\(s32\)、ACL\_UINT32\(u32\)、ACL\_INT64\(s64\)、ACL\_UINT64\(u64\)、ACL\_BOOL\(bool\)、ACL\_COMPLEX32\(c32\)、ACL\_COMPLEX64\(c64\)、ACL\_COMPLEX128\(c128\)。 |
| 12 | ->- 表格里表头和最左侧一列分别表示待推导的两个输入数据类型,表格中对应位置表示推导出的数据类型。 | 12 | +> - 表格里表头和最左侧一列分别表示待推导的两个输入数据类型,表格中对应位置表示推导出的数据类型。 |
| 13 | ->- 表中叉号(×)表示这两种类型不能进行推导计算。 | 13 | +> - 表中叉号(×)表示这两种类型不能进行推导计算。 |
| 14 | 14 | ||
| 15 | **表 1** 数据类型推导关系 | 15 | **表 1** 数据类型推导关系 |
| 16 | + | ||
| 16 | | 数据类型 | f32 | f16 | f64 | bf16 | s8 | u8 | s16 | u16 | s32 | u32 | s64 | u64 | bool | c32 | c64 | c128 | | 17 | | 数据类型 | f32 | f16 | f64 | bf16 | s8 | u8 | s16 | u16 | s32 | u32 | s64 | u64 | bool | c32 | c64 | c128 | |
| 17 | | :------: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | | 18 | | :------: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | |
| 18 | | **f32** | f32 | f32 | f64 | f32 | f32 | f32 | f32 | × | f32 | × | f32 | × | f32 | c64 | c64 | c128 | | 19 | | **f32** | f32 | f32 | f64 | f32 | f32 | f32 | f32 | × | f32 | × | f32 | × | f32 | c64 | c64 | c128 | |
| @@ -34,6 +35,5 @@ aclTensor支持的数据类型参见[数据类型](./数据类型.md),其中 | |||
| 34 | 35 | ||
| 35 | ## 推导示例 | 36 | ## 推导示例 |
| 36 | 37 | ||
| 37 | -- 调用aclnnAdd接口时,如果输入参数的数据类型不一致,一个为float16,一个为float32,那么API内部就会将float16的数据类型转换成float32的数据类型然后进行计算。 | 38 | +- 调用aclnnAdd接口时,如果输入参数的数据类型不一致,一个为float16,一个为float32,那么API内部就会将float16的数据类型转换成float32的数据类型然后进行计算。 |
| 38 | -- 调用aclnnAdd接口时,如果输入参数的数据类型不一致,一个为float32,一个为bool,那么API内部就会将bool的数据类型转换成float32的数据类型然后进行计算。 | 39 | +- 调用aclnnAdd接口时,如果输入参数的数据类型不一致,一个为float32,一个为bool,那么API内部就会将bool的数据类型转换成float32的数据类型然后进行计算。 |
| 39 | - | ||
| @@ -4,12 +4,12 @@ | |||
| 4 | 4 | ||
| 5 | 数据类型转换需要满足以下规则,不满足规则的将不能进行转换,调用API时会出现参数校验失败。 | 5 | 数据类型转换需要满足以下规则,不满足规则的将不能进行转换,调用API时会出现参数校验失败。 |
| 6 | 6 | ||
| 7 | -- 浮点类型:ACL\_FLOAT16、ACL\_FLOAT、ACL\_DOUBLE、ACL\_BF16。 | 7 | + - 浮点类型:ACL\_FLOAT16、ACL\_FLOAT、ACL\_DOUBLE、ACL\_BF16。 |
| 8 | -- 整数类型:ACL\_INT8、ACL\_UINT8、ACL\_INT16、ACL\_UINT16、ACL\_INT32、ACL\_UINT32、ACL\_INT64、ACL\_UINT64。 | 8 | + - 整数类型:ACL\_INT8、ACL\_UINT8、ACL\_INT16、ACL\_UINT16、ACL\_INT32、ACL\_UINT32、ACL\_INT64、ACL\_UINT64。 |
| 9 | -- 复数类型:ACL\_COMPLEX64、ACL\_COMPLEX128。 | 9 | + - 复数类型:ACL\_COMPLEX64、ACL\_COMPLEX128。 |
| 10 | -- 整数类型间可以转换,也支持往浮点、复数类型转换。 | 10 | + - 整数类型间可以转换,也支持往浮点、复数类型转换。 |
| 11 | -- 浮点类型间可以转换,也支持往复数类型转换。 | 11 | + - 浮点类型间可以转换,也支持往复数类型转换。 |
| 12 | -- 复数类型间可以转换。 | 12 | + - 复数类型间可以转换。 |
| 13 | -- BOOL支持往整数、浮点、复数类型转换。 | 13 | + - BOOL支持往整数、浮点、复数类型转换。 |
| 14 | 14 | ||
| 15 | -除了以上场景,其他场景的转换均不支持。 | 15 | +除了以上场景,其他场景的转换均不支持。 |
| @@ -1,11 +1,12 @@ | |||
| 1 | # 基本概念 | 1 | # 基本概念 |
| 2 | -- [两段式接口](./两段式接口.md) | 2 | + |
| 3 | -- [数据结构](./数据结构.md) | 3 | + - [两段式接口](./两段式接口.md) |
| 4 | -- [数据类型](./数据类型.md) | 4 | + - [数据结构](./数据结构.md) |
| 5 | -- [数据格式](./数据格式.md) | 5 | + - [数据类型](./数据类型.md) |
| 6 | -- [非连续的Tensor](./非连续的Tensor.md) | 6 | + - [数据格式](./数据格式.md) |
| 7 | -- [broadcast关系](./broadcast关系.md) | 7 | + - [非连续的Tensor](./非连续的Tensor.md) |
| 8 | -- [互推导关系](./互推导关系.md) | 8 | + - [broadcast关系](./broadcast关系.md) |
| 9 | -- [互转换关系](./互转换关系.md) | 9 | + - [互推导关系](./互推导关系.md) |
| 10 | -- [量化介绍](./量化介绍.md) | 10 | + - [互转换关系](./互转换关系.md) |
| 11 | -- [sparse模式介绍](./sparse_mode参数说明.md) | 11 | + - [量化介绍](./量化介绍.md) |
| 12 | + - [sparse模式介绍](./sparse_mode参数说明.md) | ||
| @@ -7,12 +7,13 @@ | |||
| 7 | 关于**数据格式排布原理**介绍参见[《Ascend C算子开发指南》](https://hiascend.com/document/redirect/CannCommunityOpdevAscendC)中“概念原理和术语>神经网络和算子>数据排布格式”。 | 7 | 关于**数据格式排布原理**介绍参见[《Ascend C算子开发指南》](https://hiascend.com/document/redirect/CannCommunityOpdevAscendC)中“概念原理和术语>神经网络和算子>数据排布格式”。 |
| 8 | 8 | ||
| 9 | ## 使用说明 | 9 | ## 使用说明 |
| 10 | + | ||
| 10 | 目前大部分算子API都是支持ND数据格式的。例如aclnnAdd接口,均标明支持的数据格式是ND(即多维Tensor的,低维度优先连续排布的规则)。对于aclnnConvolution,其属于CNN类API,要求输入的aclTensor设置具有业务语义的格式,而不是ND格式。此类算子,在计算过程中需要知道Tensor中的业务语义才可以进行对应的计算。例如2D卷积中,需要知道Batch维度、Channel维度、Height维度、Width维度与Tensor维度的对应关系是什么。 | 11 | 目前大部分算子API都是支持ND数据格式的。例如aclnnAdd接口,均标明支持的数据格式是ND(即多维Tensor的,低维度优先连续排布的规则)。对于aclnnConvolution,其属于CNN类API,要求输入的aclTensor设置具有业务语义的格式,而不是ND格式。此类算子,在计算过程中需要知道Tensor中的业务语义才可以进行对应的计算。例如2D卷积中,需要知道Batch维度、Channel维度、Height维度、Width维度与Tensor维度的对应关系是什么。 |
| 11 | 12 | ||
| 12 | >**说明:** | 13 | >**说明:** |
| 13 | > | 14 | > |
| 14 | ->- 两段式接口参数说明时,为简化描述,**将原始数据格式“ACL\_FORMAT\_XXXX_”简写为“_XXXX_”**。 | 15 | +>- 两段式接口参数说明时,为简化描述,**将原始数据格式“ACL\_FORMAT\_XXXX_”简写为“_XXXX_”**。 |
| 15 | ->- 数据格式中各维度含义:N(Batch)表示批量大小、H(Height)表示特征图高度、W(Width)表示特征图宽度、C(Channels)表示特征图通道、D(Depth)表示特征图深度、L(Length)表示特征图长度。 | 16 | +>- 数据格式中各维度含义:N(Batch)表示批量大小、H(Height)表示特征图高度、W(Width)表示特征图宽度、C(Channels)表示特征图通道、D(Depth)表示特征图深度、L(Length)表示特征图长度。 |
| 16 | 17 | ||
| 17 | ## 常见数据格式 | 18 | ## 常见数据格式 |
| 18 | 19 | ||
| @@ -22,14 +23,14 @@ ACL\_FORMAT\_ND、ACL\_FORMAT\_NCHW、ACL\_FORMAT\_NHWC、ACL\_FORMAT\_HWCN、AC | |||
| 22 | 23 | ||
| 23 | 对于非ND的Tensor,Tensor的维度要求与format表述是一致的。例如: | 24 | 对于非ND的Tensor,Tensor的维度要求与format表述是一致的。例如: |
| 24 | 25 | ||
| 25 | -- 5D的Tensor:要求为ACL\_FORMAT\_NCDHW、ACL\_FORMAT\_NDHWC或者ACL\_FORMAT\_ND(如果API参数说明中未标明支持ND,设置ND格式后API将会校验报错)。 | 26 | +- 5D的Tensor:要求为ACL\_FORMAT\_NCDHW、ACL\_FORMAT\_NDHWC或者ACL\_FORMAT\_ND(如果API参数说明中未标明支持ND,设置ND格式后API将会校验报错)。 |
| 26 | -- 4D的Tensor:要求为ACL\_FORMAT\_NCHW、ACL\_FORMAT\_NHWC、ACL\_FORMAT\_HWCN或者ACL\_FORMAT\_ND。 | 27 | +- 4D的Tensor:要求为ACL\_FORMAT\_NCHW、ACL\_FORMAT\_NHWC、ACL\_FORMAT\_HWCN或者ACL\_FORMAT\_ND。 |
| 27 | -- 3D的Tensor:要求为ACL\_FORMAT\_NCL或者ACL\_FORMAT\_ND。 | 28 | +- 3D的Tensor:要求为ACL\_FORMAT\_NCL或者ACL\_FORMAT\_ND。 |
| 28 | -- 2D的Tensor:要求为ACL\_FORMAT\_NC或者ACL\_FORMAT\_ND。 | 29 | +- 2D的Tensor:要求为ACL\_FORMAT\_NC或者ACL\_FORMAT\_ND。 |
| 29 | -- 其他维度的Tensor:要求为ACL\_FORMAT\_ND。 | 30 | +- 其他维度的Tensor:要求为ACL\_FORMAT\_ND。 |
| 30 | 31 | ||
| 31 | ## 私有数据格式 | 32 | ## 私有数据格式 |
| 32 | 33 | ||
| 33 | 除了上述常见数据格式,还存在其他的数据格式,比如ACL\_FORMAT\_NC1HWC0、ACL\_FORMAT\_FRACTAL\_Z、ACL\_FORMAT\_NC1HWC0\_C04、ACL\_FORMAT\_FRACTAL\_NZ、ACL\_FORMAT\_NDC1HWC0、ACL\_FORMAT\_FRACTAL\_Z\_3D等。 | 34 | 除了上述常见数据格式,还存在其他的数据格式,比如ACL\_FORMAT\_NC1HWC0、ACL\_FORMAT\_FRACTAL\_Z、ACL\_FORMAT\_NC1HWC0\_C04、ACL\_FORMAT\_FRACTAL\_NZ、ACL\_FORMAT\_NDC1HWC0、ACL\_FORMAT\_FRACTAL\_Z\_3D等。 |
| 34 | 35 | ||
| 35 | -这些格式,属于NPU的一些私有格式,当前绝大多数的aclnn API还不支持这些格式。如果有个别API声明了支持的数据格式,请以该API实际描述为准。 | 36 | +这些格式,属于NPU的一些私有格式,当前绝大多数的aclnn API还不支持这些格式。如果有个别API声明了支持的数据格式,请以该API实际描述为准。 |
| @@ -33,4 +33,4 @@ | |||
| 33 | | ACL_FLOAT6_E3M2 | FLOAT6_E3M2 | | 33 | | ACL_FLOAT6_E3M2 | FLOAT6_E3M2 | |
| 34 | | ACL_FLOAT6_E2M3 | FLOAT6_E2M3 | | 34 | | ACL_FLOAT6_E2M3 | FLOAT6_E2M3 | |
| 35 | | ACL_FLOAT4_E2M1 | FLOAT4_E2M1 | | 35 | | ACL_FLOAT4_E2M1 | FLOAT4_E2M1 | |
| 36 | -| ACL_FLOAT4_E1M2 | FLOAT4_E1M2 | | 36 | +| ACL_FLOAT4_E1M2 | FLOAT4_E1M2 | |
| @@ -76,4 +76,5 @@ | |||
| 76 | 76 | ||
| 77 | ``` | 77 | ``` |
| 78 | typedef void *aclrtStream | 78 | typedef void *aclrtStream |
| 79 | - ``` | 79 | + ``` |
| 80 | + | ||
| @@ -1,10 +1,12 @@ | |||
| 1 | # 编译与运行样例 | 1 | # 编译与运行样例 |
| 2 | 2 | ||
| 3 | ## 前提说明 | 3 | ## 前提说明 |
| 4 | + | ||
| 4 | - 如需编译执行算子API,请确保基础环境已搭建完成,包括驱动、固件、CANN软件包、ops包等。 | 5 | - 如需编译执行算子API,请确保基础环境已搭建完成,包括驱动、固件、CANN软件包、ops包等。 |
| 5 | - 算子API的调用流程和编译运行操作详情请参见[《应用开发(C&C++)》](https://hiascend.com/document/redirect/CannCommunityCppInferWizard)中“单算子调用>单算子API执行>调用aclnn接口示例代码”。 | 6 | - 算子API的调用流程和编译运行操作详情请参见[《应用开发(C&C++)》](https://hiascend.com/document/redirect/CannCommunityCppInferWizard)中“单算子调用>单算子API执行>调用aclnn接口示例代码”。 |
| 6 | 7 | ||
| 7 | ## 编译前准备 | 8 | ## 编译前准备 |
| 9 | + | ||
| 8 | 本章以开发和运行环境合设场景为例,即带AI处理器的机器既作为开发环境又作为运行环境。该场景下,代码开发和代码运行在同一台机器上。这里以**AddMatMul算子**为例,其他算子的调用逻辑、流程、编译脚本与AddMatMul算子大致一样,请根据实际情况自行修改API调用脚本(\*.cpp)和编译脚本(CMakeLists)。 | 10 | 本章以开发和运行环境合设场景为例,即带AI处理器的机器既作为开发环境又作为运行环境。该场景下,代码开发和代码运行在同一台机器上。这里以**AddMatMul算子**为例,其他算子的调用逻辑、流程、编译脚本与AddMatMul算子大致一样,请根据实际情况自行修改API调用脚本(\*.cpp)和编译脚本(CMakeLists)。 |
| 9 | 11 | ||
| 10 | - **示例代码** | 12 | - **示例代码** |
| @@ -14,6 +16,7 @@ | |||
| 14 | - **CMakeLists文件** | 16 | - **CMakeLists文件** |
| 15 | 17 | ||
| 16 | CMake文件示例如下,请根据实际情况修改: | 18 | CMake文件示例如下,请根据实际情况修改: |
| 19 | + | ||
| 17 | ``` | 20 | ``` |
| 18 | # Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved. | 21 | # Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved. |
| 19 | 22 | ||
| @@ -57,6 +60,7 @@ | |||
| 57 | # 可执行文件在CMakeLists文件所在目录的bin目录下 | 60 | # 可执行文件在CMakeLists文件所在目录的bin目录下 |
| 58 | install(TARGETS opapi_test DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) | 61 | install(TARGETS opapi_test DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) |
| 59 | ``` | 62 | ``` |
| 63 | + | ||
| 60 | 对于集合通信和MatMul计算融合、并行的算子,统称为通算融合算子(简称MC2算子),包括AllGatherMatmul、AlltoAllAllGatherBatchMatMul、BatchMatMulReduceScatterAlltoAll、MatmulAllReduce、MatmulAllReduceAddRmsNorm、MatmulReduceScatter等。调用该类算子API时,一般会涉及多线程和HCCL(Huawei Collective Communication Library,集合通信库),因此CMake文件需要额外导入如下内容,否则无法成功编译。 | 64 | 对于集合通信和MatMul计算融合、并行的算子,统称为通算融合算子(简称MC2算子),包括AllGatherMatmul、AlltoAllAllGatherBatchMatMul、BatchMatMulReduceScatterAlltoAll、MatmulAllReduce、MatmulAllReduceAddRmsNorm、MatmulReduceScatter等。调用该类算子API时,一般会涉及多线程和HCCL(Huawei Collective Communication Library,集合通信库),因此CMake文件需要额外导入如下内容,否则无法成功编译。 |
| 61 | 65 | ||
| 62 | ``` | 66 | ``` |
| @@ -70,19 +74,21 @@ | |||
| 70 | ${ASCEND_PATH}/lib64/libhccl.so # 集合通信库文件 | 74 | ${ASCEND_PATH}/lib64/libhccl.so # 集合通信库文件 |
| 71 | ${CMAKE_THREAD_LIBS_INIT}) # 多线程依赖的库文件 | 75 | ${CMAKE_THREAD_LIBS_INIT}) # 多线程依赖的库文件 |
| 72 | ``` | 76 | ``` |
| 77 | + | ||
| 73 | 其中“find_package(Threads REQUIRED)”是CMake用于查找线程库的命令,可自动链接线程库依赖的头文件或间接依赖的库文件。 | 78 | 其中“find_package(Threads REQUIRED)”是CMake用于查找线程库的命令,可自动链接线程库依赖的头文件或间接依赖的库文件。 |
| 74 | 79 | ||
| 75 | ## 编译与运行 | 80 | ## 编译与运行 |
| 76 | 81 | ||
| 77 | 1. 提前准备好算子的调用代码(\*.cpp)和编译脚本(CMakeLists.txt)。 | 82 | 1. 提前准备好算子的调用代码(\*.cpp)和编译脚本(CMakeLists.txt)。 |
| 78 | - 2. 配置环境变量。 | 83 | + 2. 配置环境变量。 |
| 79 | 84 | ||
| 80 | 安装CANN软件后,使用CANN运行用户登录环境,执行如下命令生效环境变量。 | 85 | 安装CANN软件后,使用CANN运行用户登录环境,执行如下命令生效环境变量。 |
| 81 | ``` | 86 | ``` |
| 82 | source ${INSTALL_DIR}/set_env.sh | 87 | source ${INSTALL_DIR}/set_env.sh |
| 83 | ``` | 88 | ``` |
| 89 | + | ||
| 84 | 其中${INSTALL_DIR}为CANN软件安装后文件存储路径,请根据实际情况替换。 | 90 | 其中${INSTALL_DIR}为CANN软件安装后文件存储路径,请根据实际情况替换。 |
| 85 | - 3. 编译并运行。 | 91 | + 3. 编译并运行。 |
| 86 | - 进入CMakeLists.txt所在目录,执行如下命令,新建build目录存放生成的编译文件。 | 92 | - 进入CMakeLists.txt所在目录,执行如下命令,新建build目录存放生成的编译文件。 |
| 87 | 93 | ||
| 88 | ``` | 94 | ``` |
| @@ -99,34 +105,38 @@ | |||
| 99 | 105 | ||
| 100 | 编译成功后,会在build目录的bin文件夹下生成opapi\_test可执行文件。 | 106 | 编译成功后,会在build目录的bin文件夹下生成opapi\_test可执行文件。 |
| 101 | 107 | ||
| 102 | - - 进入bin目录,运行可执行文件opapi_test。 | 108 | + - 进入bin目录,运行可执行文件opapi_test。 |
| 103 | 109 | ||
| 104 | - ``` | 110 | + ``` |
| 105 | - cd bin | 111 | + cd bin |
| 106 | - ./opapi_test | 112 | + ./opapi_test |
| 107 | - ``` | 113 | + ``` |
| 108 | 114 | ||
| 109 | - 以AddMatMul算子的运行结果为例,运行后的结果示例如下: | 115 | + 以AddMatMul算子的运行结果为例,运行后的结果示例如下: |
| 110 | - | 116 | + |
| 111 | - ``` | 117 | + ``` |
| 112 | - result[0] is: 1.200000 | 118 | + result[0] is: 1.200000 |
| 113 | - result[1] is: 2.200000 | 119 | + result[1] is: 2.200000 |
| 114 | - result[2] is: 3.200000 | 120 | + result[2] is: 3.200000 |
| 115 | - result[3] is: 5.400000 | 121 | + result[3] is: 5.400000 |
| 116 | - result[4] is: 6.400000 | 122 | + result[4] is: 6.400000 |
| 117 | - result[5] is: 7.400000 | 123 | + result[5] is: 7.400000 |
| 118 | - result[6] is: 9.600000 | 124 | + result[6] is: 9.600000 |
| 119 | - result[7] is: 10.600000 | 125 | + result[7] is: 10.600000 |
| 120 | - ``` | 126 | + ``` |
| 121 | - 若执行结果报错,未出现预期结果,可以使用aclGetRecentErrMsg接口获取报错具体信息。 | 127 | + |
| 122 | - 调用aclnnAddmmGetWorkspaceSize报错获取异常信息示例如下: | 128 | + 若执行结果报错,未出现预期结果,可以使用aclGetRecentErrMsg接口获取报错具体信息。 |
| 123 | - ``` | 129 | + 调用aclnnAddmmGetWorkspaceSize报错获取异常信息示例如下: |
| 124 | - // self is nullptr | 130 | + |
| 125 | - ret = aclnnAddmmGetWorkspaceSize(self, mat1, mat2, beta, alpha, out, cubeMathType, &workspaceSize, &executor); | 131 | + ``` |
| 126 | - CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclnnAddmmGetWorkspaceSize failed. ERROR: %d\n[ERROR msg]%s", ret, aclGetRecentErrMsg()); return ret); | 132 | + // self is nullptr |
| 127 | - ``` | 133 | + ret = aclnnAddmmGetWorkspaceSize(self, mat1, mat2, beta, alpha, out, cubeMathType, &workspaceSize, &executor); |
| 128 | - 上述构造空指针问题获取报错信息示例如下: | 134 | + CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclnnAddmmGetWorkspaceSize failed. ERROR: %d\n[ERROR msg]%s", ret, aclGetRecentErrMsg()); return ret); |
| 129 | - ``` | 135 | + ``` |
| 130 | - aclnnAddmmGetWorkspaceSize failed. ERROR: 161001 | 136 | + |
| 131 | - [ERROR msg][PID:xxxx] xxx(timesamp) AclNN_Parameter_Error(EZ1001): Expected a proper Tensor but got null for argument addmmTennsor.self. | 137 | + 上述构造空指针问题获取报错信息示例如下: |
| 132 | - ``` | 138 | + |
| 139 | + ``` | ||
| 140 | + aclnnAddmmGetWorkspaceSize failed. ERROR: 161001 | ||
| 141 | + [ERROR msg][PID:xxxx] xxx(timesamp) AclNN_Parameter_Error(EZ1001): Expected a proper Tensor but got null for argument addmmTennsor.self. | ||
| 142 | + ``` | ||
| @@ -47,7 +47,6 @@ CANN算子量化是指对神经网络中Matmul等矩阵(cube)类算子的输 | |||
| 47 | 47 | ||
| 48 |  | 48 |  |
| 49 | 49 | ||
| 50 | - | ||
| 51 | ## 常见组合量化 | 50 | ## 常见组合量化 |
| 52 | 51 | ||
| 53 | - 全量化:一般是指对左、右矩阵均进行量化的模式,包括 | 52 | - 全量化:一般是指对左、右矩阵均进行量化的模式,包括 |
| @@ -1,4 +1,5 @@ | |||
| 1 | # 非连续的Tensor | 1 | # 非连续的Tensor |
| 2 | + | ||
| 2 | 目前大部分算子API的输入aclTensor支持“**非连续的Tensor**”,即一个Tensor可以通过\(shape, strides, offset\)表示。 | 3 | 目前大部分算子API的输入aclTensor支持“**非连续的Tensor**”,即一个Tensor可以通过\(shape, strides, offset\)表示。 |
| 3 | 4 | ||
| 4 | 说明:创建aclTensor可通过[《算子库接口》](https://hiascend.com/document/redirect/CannCommunityOplist)中“公共接口>aclCreateTensor”实现。 | 5 | 说明:创建aclTensor可通过[《算子库接口》](https://hiascend.com/document/redirect/CannCommunityOplist)中“公共接口>aclCreateTensor”实现。 |
| @@ -17,7 +18,6 @@ | |||
| 17 | > a<sub>8,0</sub> , a<sub>8,1</sub> , a<sub>8,2</sub> , a<sub>8,3</sub> , a<sub>8,4</sub> , a<sub>8,5</sub> , a<sub>8,6</sub> , a<sub>8,7</sub> , a<sub>8,8</sub> , a<sub>8,9</sub> | 18 | > a<sub>8,0</sub> , a<sub>8,1</sub> , a<sub>8,2</sub> , a<sub>8,3</sub> , a<sub>8,4</sub> , a<sub>8,5</sub> , a<sub>8,6</sub> , a<sub>8,7</sub> , a<sub>8,8</sub> , a<sub>8,9</sub> |
| 18 | > a<sub>9,0</sub> , a<sub>9,1</sub> , a<sub>9,2</sub> , a<sub>9,3</sub> , a<sub>9,4</sub> , a<sub>9,5</sub> , a<sub>9,6</sub> , a<sub>9,7</sub> , a<sub>9,8</sub> , a<sub>9,9</sub> | 19 | > a<sub>9,0</sub> , a<sub>9,1</sub> , a<sub>9,2</sub> , a<sub>9,3</sub> , a<sub>9,4</sub> , a<sub>9,5</sub> , a<sub>9,6</sub> , a<sub>9,7</sub> , a<sub>9,8</sub> , a<sub>9,9</sub> |
| 19 | 20 | ||
| 20 | - | ||
| 21 | 即该Tensor排布如上图的深色位置。这个完整的Tensor在内存排布上是不连续的,strides描述Tensor维度上相邻两个元素的间隔,如果在维度1上的stride为1, 该维度是连续的;如果在维度0上的stride为10,那么相邻的元素间隔10个元素,即非连续。offset表示这个Tensor的首元素相对addr的偏移。 | 21 | 即该Tensor排布如上图的深色位置。这个完整的Tensor在内存排布上是不连续的,strides描述Tensor维度上相邻两个元素的间隔,如果在维度1上的stride为1, 该维度是连续的;如果在维度0上的stride为10,那么相邻的元素间隔10个元素,即非连续。offset表示这个Tensor的首元素相对addr的偏移。 |
| 22 | 22 | ||
| 23 | ## 示例2 | 23 | ## 示例2 |
| @@ -35,4 +35,4 @@ | |||
| 35 | > a<sub>8,0</sub> , a<sub>8,1</sub> , **a<sub>8,2</sub>** , a<sub>8,3</sub> , **a<sub>8,4</sub>** , a<sub>8,5</sub> , **a<sub>8,6</sub>** , a<sub>8,7</sub> , a<sub>8,8</sub> , a<sub>8,9</sub> | 35 | > a<sub>8,0</sub> , a<sub>8,1</sub> , **a<sub>8,2</sub>** , a<sub>8,3</sub> , **a<sub>8,4</sub>** , a<sub>8,5</sub> , **a<sub>8,6</sub>** , a<sub>8,7</sub> , a<sub>8,8</sub> , a<sub>8,9</sub> |
| 36 | > a<sub>9,0</sub> , a<sub>9,1</sub> , a<sub>9,2</sub> , a<sub>9,3</sub> , a<sub>9,4</sub> , a<sub>9,5</sub> , a<sub>9,6</sub> , a<sub>9,7</sub> , a<sub>9,8</sub> , a<sub>9,9</sub> | 36 | > a<sub>9,0</sub> , a<sub>9,1</sub> , a<sub>9,2</sub> , a<sub>9,3</sub> , a<sub>9,4</sub> , a<sub>9,5</sub> , a<sub>9,6</sub> , a<sub>9,7</sub> , a<sub>9,8</sub> , a<sub>9,9</sub> |
| 37 | 37 | ||
| 38 | -即该Tensor排布如上图的深色位置。这个完整的Tensor在内存排布上是不连续的,strides描述Tensor维度上相邻两个元素的间隔,如果在维度1上的stride为2, 该维度上间隔1个元素;如果在维度0上的stride为20,那么相邻的元素间隔20个元素,即非连续。offset表示这个Tensor的首元素相对addr的偏移。 | 38 | +即该Tensor排布如上图的深色位置。这个完整的Tensor在内存排布上是不连续的,strides描述Tensor维度上相邻两个元素的间隔,如果在维度1上的stride为2, 该维度上间隔1个元素;如果在维度0上的stride为20,那么相邻的元素间隔20个元素,即非连续。offset表示这个Tensor的首元素相对addr的偏移。 |
| @@ -26,6 +26,7 @@ | |||
| 26 | 7. [算子验证](#算子验证):通过常见算子调用方式,验证自定义算子功能。 | 26 | 7. [算子验证](#算子验证):通过常见算子调用方式,验证自定义算子功能。 |
| 27 | 27 | ||
| 28 | ## 工程创建 | 28 | ## 工程创建 |
| 29 | + | ||
| 29 | **1. 环境部署** | 30 | **1. 环境部署** |
| 30 | 31 | ||
| 31 | 开发算子前,请先参考[环境部署](../context/quick_install.md)完成基础环境搭建。 | 32 | 开发算子前,请先参考[环境部署](../context/quick_install.md)完成基础环境搭建。 |
| @@ -48,6 +49,7 @@ bash build.sh --genop=${op_class}/${op_name} | |||
| 48 | ```bash | 49 | ```bash |
| 49 | Create the initial directory for ${op_name} under ${op_class} success | 50 | Create the initial directory for ${op_name} under ${op_class} success |
| 50 | ``` | 51 | ``` |
| 52 | + | ||
| 51 | 创建完成后,目录结构如下所示: | 53 | 创建完成后,目录结构如下所示: |
| 52 | 54 | ||
| 53 | ``` | 55 | ``` |
| @@ -71,6 +73,7 @@ ${op_name} # 替换为实际算子名的小写下 | |||
| 71 | 若```${op_class}```为全新算子分类,需额外在`cmake/variables.cmake`的`OP_CATEGORY_LIST`中添加```${op_class}```,否则无法正常编译。 | 73 | 若```${op_class}```为全新算子分类,需额外在`cmake/variables.cmake`的`OP_CATEGORY_LIST`中添加```${op_class}```,否则无法正常编译。 |
| 72 | 74 | ||
| 73 | ## 算子定义 | 75 | ## 算子定义 |
| 76 | + | ||
| 74 | 算子定义需要完成两个交付件:`README.md` ```${op_name}_def.cpp``` | 77 | 算子定义需要完成两个交付件:`README.md` ```${op_name}_def.cpp``` |
| 75 | 78 | ||
| 76 | **交付件1:README.md** | 79 | **交付件1:README.md** |
| @@ -84,6 +87,7 @@ ${op_name} # 替换为实际算子名的小写下 | |||
| 84 | 算子信息库。 | 87 | 算子信息库。 |
| 85 | 88 | ||
| 86 | 以自定义`AddExample`算子说明为例,请参考[AddExample算子信息库](../../../examples/add_example/op_host/add_example_def.cpp)。 | 89 | 以自定义`AddExample`算子说明为例,请参考[AddExample算子信息库](../../../examples/add_example/op_host/add_example_def.cpp)。 |
| 90 | + | ||
| 87 | ## Tiling实现 | 91 | ## Tiling实现 |
| 88 | 92 | ||
| 89 | ### Tiling简介 | 93 | ### Tiling简介 |
| @@ -178,6 +182,7 @@ static ge::graphStatus TilingFunc(gert::TilingContext* context){ | |||
| 178 | // 3.Tiling注册入口 | 182 | // 3.Tiling注册入口 |
| 179 | IMPL_OP_OPTILING(${op_name}).Tiling(TilingFunc).TilingParse<CompileInfo>(TilingParse); | 183 | IMPL_OP_OPTILING(${op_name}).Tiling(TilingFunc).TilingParse<CompileInfo>(TilingParse); |
| 180 | ``` | 184 | ``` |
| 185 | + | ||
| 181 | **交付件2:${op_name}_tiling_key.h** | 186 | **交付件2:${op_name}_tiling_key.h** |
| 182 | 187 | ||
| 183 | TilingKey是一个算子内为了区分不同的实现而将kernel代码进行区分的方法,kernel侧可以通过TilingKey来选择不同的算法逻辑。 | 188 | TilingKey是一个算子内为了区分不同的实现而将kernel代码进行区分的方法,kernel侧可以通过TilingKey来选择不同的算法逻辑。 |
| @@ -196,6 +201,7 @@ ASCENDC_TPL_ARGS_DECL( | |||
| 196 | ASCENDC_TPL_SEL(ASCENDC_TPL_ARGS_SEL( | 201 | ASCENDC_TPL_SEL(ASCENDC_TPL_ARGS_SEL( |
| 197 | ASCENDC_TPL_UINT_SEL(schMode, ASCENDC_TPL_UI_LIST, ELEMENTWISE_TPL_SCH_MODE_0, ELEMENTWISE_TPL_SCH_MODE_1))); | 202 | ASCENDC_TPL_UINT_SEL(schMode, ASCENDC_TPL_UI_LIST, ELEMENTWISE_TPL_SCH_MODE_0, ELEMENTWISE_TPL_SCH_MODE_1))); |
| 198 | ``` | 203 | ``` |
| 204 | + | ||
| 199 | **交付件3:${op_name}_tiling_data.h** | 205 | **交付件3:${op_name}_tiling_data.h** |
| 200 | 206 | ||
| 201 | 切分算法相关的参数,比如总数据量大小、每个核数据切块数量,通过结构体存储。 | 207 | 切分算法相关的参数,比如总数据量大小、每个核数据切块数量,通过结构体存储。 |
| @@ -213,6 +219,7 @@ struct ${op_name}TilingData { | |||
| 213 | ## Kernel实现 | 219 | ## Kernel实现 |
| 214 | 220 | ||
| 215 | ### Kernel简介 | 221 | ### Kernel简介 |
| 222 | + | ||
| 216 | Kernel是算子在NPU执行的核心部分,负责张量数据的加载、计算和存储,是算子功能实现的最终载体。Kernel的实现需要与Tiling策略紧密配合,根据Tiling提供的`TilingData`、`TilingKey`信息进行内存分配和计算调度。 | 223 | Kernel是算子在NPU执行的核心部分,负责张量数据的加载、计算和存储,是算子功能实现的最终载体。Kernel的实现需要与Tiling策略紧密配合,根据Tiling提供的`TilingData`、`TilingKey`信息进行内存分配和计算调度。 |
| 217 | 224 | ||
| 218 | Kernel实现包括如下步骤,整个流程通过`Process`函数串联,实现完整的算子流程。 | 225 | Kernel实现包括如下步骤,整个流程通过`Process`函数串联,实现完整的算子流程。 |
| @@ -264,6 +271,7 @@ __global__ __aicore__ void add_example(GM_ADDR x, GM_ADDR y, GM_ADDR z, GM_ADDR | |||
| 264 | .... | 271 | .... |
| 265 | } | 272 | } |
| 266 | ``` | 273 | ``` |
| 274 | + | ||
| 267 | **交付件2:${op_name}.h** | 275 | **交付件2:${op_name}.h** |
| 268 | 276 | ||
| 269 | 定义Kernel头文件,包含函数声明、结构定义、逻辑实现等。 | 277 | 定义Kernel头文件,包含函数声明、结构定义、逻辑实现等。 |
| @@ -346,6 +354,7 @@ __aicore__ inline void AddExample<T>::Process() | |||
| 346 | } | 354 | } |
| 347 | ... | 355 | ... |
| 348 | ``` | 356 | ``` |
| 357 | + | ||
| 349 | ## aclnn适配 | 358 | ## aclnn适配 |
| 350 | 359 | ||
| 351 | 通常算子开发和编译完成后,会自动生成aclnn接口(一套基于C 的API),可直接在应用程序中调用aclnn接口实现调用算子。 | 360 | 通常算子开发和编译完成后,会自动生成aclnn接口(一套基于C 的API),可直接在应用程序中调用aclnn接口实现调用算子。 |
| @@ -375,6 +384,7 @@ __aicore__ inline void AddExample<T>::Process() | |||
| 375 | ```bash | 384 | ```bash |
| 376 | # 编译指定算子,如bash build.sh --pkg --ops=add_example | 385 | # 编译指定算子,如bash build.sh --pkg --ops=add_example |
| 377 | bash build.sh --pkg --soc=${soc_version} --vendor_name=${vendor_name} --ops=${op_list} [--experimental] | 386 | bash build.sh --pkg --soc=${soc_version} --vendor_name=${vendor_name} --ops=${op_list} [--experimental] |
| 387 | + | ||
| 378 | ``` | 388 | ``` |
| 379 | - --soc:\$\{soc\_version\}表示NPU型号。Atlas A2系列产品使用"ascend910b"(默认),Atlas A3系列产品使用"ascend910_93",Ascend 950PR/Ascend 950DT产品使用"ascend950"。 | 389 | - --soc:\$\{soc\_version\}表示NPU型号。Atlas A2系列产品使用"ascend910b"(默认),Atlas A3系列产品使用"ascend910_93",Ascend 950PR/Ascend 950DT产品使用"ascend950"。 |
| 380 | - --vendor_name(可选):\$\{vendor\_name\}表示构建的自定义算子包名,默认名为custom。 | 390 | - --vendor_name(可选):\$\{vendor\_name\}表示构建的自定义算子包名,默认名为custom。 |
| @@ -393,11 +403,13 @@ __aicore__ inline void AddExample<T>::Process() | |||
| 393 | # 安装run包 | 403 | # 安装run包 |
| 394 | ./build_out/cann-ops-nn-${vendor_name}-linux.${arch}.run | 404 | ./build_out/cann-ops-nn-${vendor_name}-linux.${arch}.run |
| 395 | ``` | 405 | ``` |
| 406 | + | ||
| 396 | 自定义算子包安装在```${ASCEND_HOME_PATH}/opp/vendors```路径中,```${ASCEND_HOME_PATH}```表示CANN软件安装目录,可提前在环境变量中配置。 | 407 | 自定义算子包安装在```${ASCEND_HOME_PATH}/opp/vendors```路径中,```${ASCEND_HOME_PATH}```表示CANN软件安装目录,可提前在环境变量中配置。 |
| 397 | 408 | ||
| 398 | 4. **(可选)卸载自定义算子包。** | 409 | 4. **(可选)卸载自定义算子包。** |
| 399 | 410 | ||
| 400 | 自定义算子包安装后在```${ASCEND_HOME_PATH}/opp/vendors/${vendor_name}_nn/scripts```目录会生成`uninstall.sh`,通过该脚本可卸载自定义算子包,命令如下: | 411 | 自定义算子包安装后在```${ASCEND_HOME_PATH}/opp/vendors/${vendor_name}_nn/scripts```目录会生成`uninstall.sh`,通过该脚本可卸载自定义算子包,命令如下: |
| 412 | + | ||
| 401 | ```bash | 413 | ```bash |
| 402 | bash ${ASCEND_HOME_PATH}/opp/vendors/${vendor_name}_nn/scripts/uninstall.sh | 414 | bash ${ASCEND_HOME_PATH}/opp/vendors/${vendor_name}_nn/scripts/uninstall.sh |
| 403 | ``` | 415 | ``` |
| @@ -405,6 +417,7 @@ __aicore__ inline void AddExample<T>::Process() | |||
| 405 | ## 算子验证 | 417 | ## 算子验证 |
| 406 | 418 | ||
| 407 | 验证算子前需确保已配置了环境变量,命令如下: | 419 | 验证算子前需确保已配置了环境变量,命令如下: |
| 420 | + | ||
| 408 | ```bash | 421 | ```bash |
| 409 | export LD_LIBRARY_PATH=${ASCEND_HOME_PATH}/opp/vendors/${vendor_name}_nn/op_api/lib:${LD_LIBRARY_PATH} | 422 | export LD_LIBRARY_PATH=${ASCEND_HOME_PATH}/opp/vendors/${vendor_name}_nn/op_api/lib:${LD_LIBRARY_PATH} |
| 410 | ``` | 423 | ``` |
| @@ -568,6 +581,7 @@ static graphStatus InferShape(gert::InferShapeContext *context) | |||
| 568 | IMPL_OP_INFERSHAPE(AddCustom).InferShape(InferShape); // 在该文件中完成InferShape注册 | 581 | IMPL_OP_INFERSHAPE(AddCustom).InferShape(InferShape); // 在该文件中完成InferShape注册 |
| 569 | } // namespace ge | 582 | } // namespace ge |
| 570 | ``` | 583 | ``` |
| 584 | + | ||
| 571 | <div id="op_host/{op_name}_tiling.cpp"> | 585 | <div id="op_host/{op_name}_tiling.cpp"> |
| 572 | <p style="font-size:18px;"><b>op_host/{op_name}_tiling.cpp</b></p> | 586 | <p style="font-size:18px;"><b>op_host/{op_name}_tiling.cpp</b></p> |
| 573 | </div> | 587 | </div> |
| @@ -738,4 +752,4 @@ template<int D_T_X, int D_T_Y, int D_T_Z, int TILE_NUM, int IS_SPLIT> | |||
| 738 | <p style="font-size:18px;"><b>op_kernel/{op_name}_tiling_key.h</b></p> | 752 | <p style="font-size:18px;"><b>op_kernel/{op_name}_tiling_key.h</b></p> |
| 739 | </div> | 753 | </div> |
| 740 | 754 | ||
| 741 | -保留原有op_kernel/tiling_key_{op_name}.h中算子的模板参数定义,若不存在op_kernel/tiling_key_{op_name}.h,请参考[add_example_tiling_key.h](../../../examples/add_example/op_kernel/add_example_tiling_key.h)新增定义模板参数和模板参数组合。 | 755 | +保留原有op_kernel/tiling_key_{op_name}.h中算子的模板参数定义,若不存在op_kernel/tiling_key_{op_name}.h,请参考[add_example_tiling_key.h](../../../examples/add_example/op_kernel/add_example_tiling_key.h)新增定义模板参数和模板参数组合。 |
| @@ -14,7 +14,7 @@ | |||
| 14 | 14 | ||
| 15 | 2. [算子定义](#算子定义):确定算子功能与原型定义。 | 15 | 2. [算子定义](#算子定义):确定算子功能与原型定义。 |
| 16 | 16 | ||
| 17 | -3. [Kernel实现](#Kernel实现):实现Device侧算子核函数。 | 17 | +3. [Kernel实现](#kernel实现):实现Device侧算子核函数。 |
| 18 | 18 | ||
| 19 | 4. [aclnn适配](#aclnn适配):自定义算子推荐aclnn接口调用,需提前完成二进制发布。**如采用图模式调用算子**,请参考[图模式适配指南](./graph_develop_guide.md)。 | 19 | 4. [aclnn适配](#aclnn适配):自定义算子推荐aclnn接口调用,需提前完成二进制发布。**如采用图模式调用算子**,请参考[图模式适配指南](./graph_develop_guide.md)。 |
| 20 | 20 | ||
| @@ -22,7 +22,8 @@ | |||
| 22 | 22 | ||
| 23 | 6. [算子验证](#算子验证):通过常见算子调用方式,验证自定义算子功能。 | 23 | 6. [算子验证](#算子验证):通过常见算子调用方式,验证自定义算子功能。 |
| 24 | 24 | ||
| 25 | -## 工程创建 | 25 | +## 工程创建 |
| 26 | + | ||
| 26 | **1. 环境部署** | 27 | **1. 环境部署** |
| 27 | 28 | ||
| 28 | 开发算子前,请先参考[环境部署](../context/quick_install.md)完成基础环境搭建。 | 29 | 开发算子前,请先参考[环境部署](../context/quick_install.md)完成基础环境搭建。 |
| @@ -45,6 +46,7 @@ bash build.sh --genop_aicpu=${op_class}/${op_name} | |||
| 45 | ```bash | 46 | ```bash |
| 46 | Create the AI CPU initial directory for ${op_name} under ${op_class} success | 47 | Create the AI CPU initial directory for ${op_name} under ${op_class} success |
| 47 | ``` | 48 | ``` |
| 49 | + | ||
| 48 | 创建完成后,目录结构如下所示: | 50 | 创建完成后,目录结构如下所示: |
| 49 | 51 | ||
| 50 | ``` | 52 | ``` |
| @@ -65,6 +67,7 @@ ${op_name} # 替换为实际算子名的小写下 | |||
| 65 | 若```${op_class}```为全新算子分类,需额外在`cmake/variables.cmake`的`OP_CATEGORY_LIST`中添加```${op_class}```,否则无法正常编译。 | 67 | 若```${op_class}```为全新算子分类,需额外在`cmake/variables.cmake`的`OP_CATEGORY_LIST`中添加```${op_class}```,否则无法正常编译。 |
| 66 | 68 | ||
| 67 | ## 算子定义 | 69 | ## 算子定义 |
| 70 | + | ||
| 68 | 算子定义需要完成两个交付件:`README.md` ```${op_name}.json``` | 71 | 算子定义需要完成两个交付件:`README.md` ```${op_name}.json``` |
| 69 | 72 | ||
| 70 | **交付件1:README.md** | 73 | **交付件1:README.md** |
| @@ -79,17 +82,18 @@ ${op_name} # 替换为实际算子名的小写下 | |||
| 79 | 82 | ||
| 80 | 以自定义`AddExample`算子说明为例,请参考[AddExample算子信息库](../../../examples/add_example_aicpu/op_kernel_aicpu/add_example.json)。 | 83 | 以自定义`AddExample`算子说明为例,请参考[AddExample算子信息库](../../../examples/add_example_aicpu/op_kernel_aicpu/add_example.json)。 |
| 81 | 84 | ||
| 82 | - | ||
| 83 | ## Kernel实现 | 85 | ## Kernel实现 |
| 84 | 86 | ||
| 85 | ### Kernel简介 | 87 | ### Kernel简介 |
| 88 | + | ||
| 86 | Kernel是算子在NPU执行的核心部分,Kernel实现包括如下步骤: | 89 | Kernel是算子在NPU执行的核心部分,Kernel实现包括如下步骤: |
| 87 | 90 | ||
| 88 | ```mermaid | 91 | ```mermaid |
| 89 | graph LR | 92 | graph LR |
| 90 | - H([算子类声明]) -->A([Compute函数实现]) | 93 | +H([算子类声明]) -->A([Compute函数实现]) |
| 91 | - A -->B([注册算子]) | 94 | +A -->B([注册算子]) |
| 92 | ``` | 95 | ``` |
| 96 | + | ||
| 93 | ### 代码实现 | 97 | ### 代码实现 |
| 94 | 98 | ||
| 95 | Kernel一共需要两个交付件:```${op_name}_aicpu.cpp``` ```${op_name}_aicpu.h``` | 99 | Kernel一共需要两个交付件:```${op_name}_aicpu.cpp``` ```${op_name}_aicpu.h``` |
| @@ -101,7 +105,6 @@ Kernel一共需要两个交付件:```${op_name}_aicpu.cpp``` ```${op_name}_aic | |||
| 101 | Kernel实现的第一步,需在头文件```op_kernel_aicpu/${op_name}_aicpu.h```进行算子类的声明,算子类需继承CpuKernel基类。 | 105 | Kernel实现的第一步,需在头文件```op_kernel_aicpu/${op_name}_aicpu.h```进行算子类的声明,算子类需继承CpuKernel基类。 |
| 102 | 如需查看详细实现,请参考[add_example_aicpu.h](../../../examples/add_example_aicpu/op_kernel_aicpu/add_example_aicpu.h)。 | 106 | 如需查看详细实现,请参考[add_example_aicpu.h](../../../examples/add_example_aicpu/op_kernel_aicpu/add_example_aicpu.h)。 |
| 103 | 107 | ||
| 104 | - | ||
| 105 | ```CPP | 108 | ```CPP |
| 106 | // 1、算子类声明 | 109 | // 1、算子类声明 |
| 107 | // 包含AI CPU基础库头文件 | 110 | // 包含AI CPU基础库头文件 |
| @@ -177,6 +180,7 @@ uint32_t AddExampleCpuKernel::Compute(CpuKernelContext& ctx) { | |||
| 177 | REGISTER_CPU_KERNEL(kAddExample, AddExampleCpuKernel); | 180 | REGISTER_CPU_KERNEL(kAddExample, AddExampleCpuKernel); |
| 178 | } // namespace aicpu | 181 | } // namespace aicpu |
| 179 | ``` | 182 | ``` |
| 183 | + | ||
| 180 | ## aclnn适配 | 184 | ## aclnn适配 |
| 181 | 185 | ||
| 182 | 通常算子开发和编译完成后,会自动生成aclnn接口(一套基于C 的API),无需做其他配置,可直接在应用程序中调用aclnn接口实现调用算子。 | 186 | 通常算子开发和编译完成后,会自动生成aclnn接口(一套基于C 的API),无需做其他配置,可直接在应用程序中调用aclnn接口实现调用算子。 |
| @@ -197,6 +201,7 @@ REGISTER_CPU_KERNEL(kAddExample, AddExampleCpuKernel); | |||
| 197 | # 编译指定算子,如bash build.sh --pkg --ops=add_example | 201 | # 编译指定算子,如bash build.sh --pkg --ops=add_example |
| 198 | bash build.sh --pkg --soc=${soc_version} --vendor_name=${vendor_name} --ops=${op_list} [--experimental] | 202 | bash build.sh --pkg --soc=${soc_version} --vendor_name=${vendor_name} --ops=${op_list} [--experimental] |
| 199 | ``` | 203 | ``` |
| 204 | + | ||
| 200 | - --soc:\$\{soc\_version\}表示NPU型号。Atlas A2系列产品使用"ascend910b"(默认),Atlas A3系列产品使用"ascend910_93",Ascend 950PR/Ascend 950DT产品使用"ascend950"。 | 205 | - --soc:\$\{soc\_version\}表示NPU型号。Atlas A2系列产品使用"ascend910b"(默认),Atlas A3系列产品使用"ascend910_93",Ascend 950PR/Ascend 950DT产品使用"ascend950"。 |
| 201 | - --vendor_name(可选):\$\{vendor\_name\}表示构建的自定义算子包名,默认名为custom。 | 206 | - --vendor_name(可选):\$\{vendor\_name\}表示构建的自定义算子包名,默认名为custom。 |
| 202 | - --ops(可选):\$\{op\_list\}表示待编译算子,不指定时默认编译所有算子。格式形如"--ops=add_example"。 | 207 | - --ops(可选):\$\{op\_list\}表示待编译算子,不指定时默认编译所有算子。格式形如"--ops=add_example"。 |
| @@ -214,6 +219,7 @@ REGISTER_CPU_KERNEL(kAddExample, AddExampleCpuKernel); | |||
| 214 | # 安装run包 | 219 | # 安装run包 |
| 215 | ./build_out/cann-ops-nn-${vendor_name}-linux.${arch}.run | 220 | ./build_out/cann-ops-nn-${vendor_name}-linux.${arch}.run |
| 216 | ``` | 221 | ``` |
| 222 | + | ||
| 217 | 自定义算子包安装在```${ASCEND_HOME_PATH}/opp/vendors```路径中,```${ASCEND_HOME_PATH}```表示CANN软件安装目录,可提前在环境变量中配置。 | 223 | 自定义算子包安装在```${ASCEND_HOME_PATH}/opp/vendors```路径中,```${ASCEND_HOME_PATH}```表示CANN软件安装目录,可提前在环境变量中配置。 |
| 218 | 224 | ||
| 219 | 4. **(可选)卸载自定义算子包。** | 225 | 4. **(可选)卸载自定义算子包。** |
| @@ -227,13 +233,15 @@ REGISTER_CPU_KERNEL(kAddExample, AddExampleCpuKernel); | |||
| 227 | ## 算子验证 | 233 | ## 算子验证 |
| 228 | 234 | ||
| 229 | 验证算子前需确保已配置了环境变量,命令如下: | 235 | 验证算子前需确保已配置了环境变量,命令如下: |
| 236 | + | ||
| 230 | ```bash | 237 | ```bash |
| 231 | export LD_LIBRARY_PATH=${ASCEND_HOME_PATH}/opp/vendors/${vendor_name}_nn/op_api/lib:${LD_LIBRARY_PATH} | 238 | export LD_LIBRARY_PATH=${ASCEND_HOME_PATH}/opp/vendors/${vendor_name}_nn/op_api/lib:${LD_LIBRARY_PATH} |
| 232 | ``` | 239 | ``` |
| 240 | + | ||
| 233 | - **UT验证** | 241 | - **UT验证** |
| 234 | 242 | ||
| 235 | 算子开发过程中,可通过UT验证(如Kernel)方式进行快速验证。 | 243 | 算子开发过程中,可通过UT验证(如Kernel)方式进行快速验证。 |
| 236 | 244 | ||
| 237 | - **aclnn调用验证** | 245 | - **aclnn调用验证** |
| 238 | 246 | ||
| 239 | - 开发好的算子完成编译部署后,可通过aclnn方式验证功能,方法请参考[算子调用方式](../invocation/op_invocation.md)。 | 247 | + 开发好的算子完成编译部署后,可通过aclnn方式验证功能,方法请参考[算子调用方式](../invocation/op_invocation.md)。 |
| @@ -71,9 +71,11 @@ IMPL_OP(AddExample).InferDataType(InferDataTypeAddExample); | |||
| 71 | ``` | 71 | ``` |
| 72 | 72 | ||
| 73 | ## 算子原型配置 | 73 | ## 算子原型配置 |
| 74 | + | ||
| 74 | 图模式调用需要将算子原型注册到[Graph Engine](https://www.hiascend.com/cann/graph-engine)(简称GE)中,以便GE能够识别该类算子的输入、输出及属性信息。注册通过`REG_OP`接口完成,开发者需定义算子输入、输出张量类型及数量等基本信息。 | 75 | 图模式调用需要将算子原型注册到[Graph Engine](https://www.hiascend.com/cann/graph-engine)(简称GE)中,以便GE能够识别该类算子的输入、输出及属性信息。注册通过`REG_OP`接口完成,开发者需定义算子输入、输出张量类型及数量等基本信息。 |
| 75 | 76 | ||
| 76 | 常用张量/属性数据类型示例如下: | 77 | 常用张量/属性数据类型示例如下: |
| 78 | + | ||
| 77 | |张量类型|属性类型|示例| | 79 | |张量类型|属性类型|示例| |
| 78 | |-----|------|-----| | 80 | |-----|------|-----| |
| 79 | |int64|/|DT_INT64| | 81 | |int64|/|DT_INT64| |
| @@ -94,6 +96,7 @@ IMPL_OP(AddExample).InferDataType(InferDataTypeAddExample); | |||
| 94 | |/|list|ListInt| | 96 | |/|list|ListInt| |
| 95 | 97 | ||
| 96 | 基本信息如下: | 98 | 基本信息如下: |
| 99 | + | ||
| 97 | |输入/输出|关键字|示例| | 100 | |输入/输出|关键字|示例| |
| 98 | |-----|------|-----| | 101 | |-----|------|-----| |
| 99 | |必选输入|INPUT|.INPUT(${name}, TensorType({input_dtype}))| | 102 | |必选输入|INPUT|.INPUT(${name}, TensorType({input_dtype}))| |
| @@ -112,4 +115,4 @@ REG_OP(AddExample) | |||
| 112 | .OP_END_FACTORY_REG(AddExample) | 115 | .OP_END_FACTORY_REG(AddExample) |
| 113 | ``` | 116 | ``` |
| 114 | 117 | ||
| 115 | -完整代码请参考`examples/add_example/op_graph`目录下[add_example_proto.h](../../../examples/add_example/op_graph/add_example_proto.h)。 | 118 | +完整代码请参考`examples/add_example/op_graph`目录下[add_example_proto.h](../../../examples/add_example/op_graph/add_example_proto.h)。 |
| @@ -214,6 +214,7 @@ int main() | |||
| 214 | ```bash | 214 | ```bash |
| 215 | bash run.sh | 215 | bash run.sh |
| 216 | ``` | 216 | ``` |
| 217 | + | ||
| 217 | 默认在当前执行路径 `/build/bin`下生成可执行文件test\_aclnn\_add\_example,运行结果如下: | 218 | 默认在当前执行路径 `/build/bin`下生成可执行文件test\_aclnn\_add\_example,运行结果如下: |
| 218 | 219 | ||
| 219 | ``` | 220 | ``` |
| @@ -379,4 +380,4 @@ int main() { | |||
| 379 | 380 | ||
| 380 | ``` | 381 | ``` |
| 381 | INFO - [XIR]: Finalize ir graph session success | 382 | INFO - [XIR]: Finalize ir graph session success |
| 382 | - ``` | 383 | + ``` |
| @@ -39,8 +39,8 @@ | |||
| 39 | 39 | ||
| 40 | 表示整个项目编译为一个静态库文件,包含libcann_nn_static.a和aclnn接口头文件。该包仅支持aclnn调用AI Core算子。 | 40 | 表示整个项目编译为一个静态库文件,包含libcann_nn_static.a和aclnn接口头文件。该包仅支持aclnn调用AI Core算子。 |
| 41 | 41 | ||
| 42 | - | ||
| 43 | ### 联网编译 | 42 | ### 联网编译 |
| 43 | + | ||
| 44 | #### 自定义算子包 | 44 | #### 自定义算子包 |
| 45 | 45 | ||
| 46 | 1. **编译自定义算子包** | 46 | 1. **编译自定义算子包** |
| @@ -53,6 +53,7 @@ | |||
| 53 | # bash build.sh --pkg --soc=ascend910b --vendor_name=transpose_batch_mat_mul --ops=transpose_batch_mat_mul | 53 | # bash build.sh --pkg --soc=ascend910b --vendor_name=transpose_batch_mat_mul --ops=transpose_batch_mat_mul |
| 54 | # 编译experimental贡献目录下的用户算子 | 54 | # 编译experimental贡献目录下的用户算子 |
| 55 | # bash build.sh --pkg --experimental --soc=ascend910b --ops=${experimental_op} | 55 | # bash build.sh --pkg --experimental --soc=ascend910b --ops=${experimental_op} |
| 56 | + | ||
| 56 | ``` | 57 | ``` |
| 57 | - --soc:\$\{soc\_version\}表示NPU型号。Atlas A2系列产品使用"ascend910b"(默认),Atlas A3系列产品使用"ascend910_93",Ascend 950PR/Ascend 950DT产品使用"ascend950"。 | 58 | - --soc:\$\{soc\_version\}表示NPU型号。Atlas A2系列产品使用"ascend910b"(默认),Atlas A3系列产品使用"ascend910_93",Ascend 950PR/Ascend 950DT产品使用"ascend950"。 |
| 58 | - --vendor_name(可选):\$\{vendor\_name\}表示构建的自定义算子包名,默认名为custom。 | 59 | - --vendor_name(可选):\$\{vendor\_name\}表示构建的自定义算子包名,默认名为custom。 |
| @@ -60,9 +61,11 @@ | |||
| 60 | - --experimental(可选):表示编译experimental贡献目录下的算子,${experimental_op}为新贡献算子目录名,贡献说明参见[贡献指南](../../../CONTRIBUTING.md)。 | 61 | - --experimental(可选):表示编译experimental贡献目录下的算子,${experimental_op}为新贡献算子目录名,贡献说明参见[贡献指南](../../../CONTRIBUTING.md)。 |
| 61 | 62 | ||
| 62 | 若\$\{vendor\_name\}和\$\{op\_list\}都不传入编译的是ops-nn包;若编译所有算子的自定义算子包,需传入\$\{vendor\_name\}。当提示如下信息,说明编译成功。 | 63 | 若\$\{vendor\_name\}和\$\{op\_list\}都不传入编译的是ops-nn包;若编译所有算子的自定义算子包,需传入\$\{vendor\_name\}。当提示如下信息,说明编译成功。 |
| 64 | + | ||
| 63 | ```bash | 65 | ```bash |
| 64 | Self-extractable archive "cann-ops-nn-${vendor_name}-linux.${arch}.run" successfully created. | 66 | Self-extractable archive "cann-ops-nn-${vendor_name}-linux.${arch}.run" successfully created. |
| 65 | ``` | 67 | ``` |
| 68 | + | ||
| 66 | 编译成功后,run包存放于项目根目录的build_out目录下。 | 69 | 编译成功后,run包存放于项目根目录的build_out目录下。 |
| 67 | 70 | ||
| 68 | 2. **安装自定义算子包** | 71 | 2. **安装自定义算子包** |
| @@ -76,6 +79,7 @@ | |||
| 76 | 3. **(可选)卸载自定义算子包** | 79 | 3. **(可选)卸载自定义算子包** |
| 77 | 80 | ||
| 78 | 自定义算子包安装后在```${ASCEND_HOME_PATH}/opp/vendors/${vendor_name}_nn/scripts```目录会生成`uninstall.sh`脚本,通过执行该脚本可卸载自定义算子包,具体命令如下: | 81 | 自定义算子包安装后在```${ASCEND_HOME_PATH}/opp/vendors/${vendor_name}_nn/scripts```目录会生成`uninstall.sh`脚本,通过执行该脚本可卸载自定义算子包,具体命令如下: |
| 82 | + | ||
| 79 | ```bash | 83 | ```bash |
| 80 | bash ${ASCEND_HOME_PATH}/opp/vendors/${vendor_name}_nn/scripts/uninstall.sh | 84 | bash ${ASCEND_HOME_PATH}/opp/vendors/${vendor_name}_nn/scripts/uninstall.sh |
| 81 | ``` | 85 | ``` |
| @@ -92,6 +96,7 @@ | |||
| 92 | # 编译experimental贡献目录下的所有算子 | 96 | # 编译experimental贡献目录下的所有算子 |
| 93 | # bash build.sh --pkg --experimental --soc=${soc_version} | 97 | # bash build.sh --pkg --experimental --soc=${soc_version} |
| 94 | ``` | 98 | ``` |
| 99 | + | ||
| 95 | - --soc:\$\{soc\_version\}表示NPU型号。Atlas A2系列产品使用"ascend910b"(默认),Atlas A3系列产品使用"ascend910_93",Ascend 950PR/Ascend 950DT产品使用"ascend950"。 | 100 | - --soc:\$\{soc\_version\}表示NPU型号。Atlas A2系列产品使用"ascend910b"(默认),Atlas A3系列产品使用"ascend910_93",Ascend 950PR/Ascend 950DT产品使用"ascend950"。 |
| 96 | - --experimental(可选):表示编译experimental贡献目录下的算子。 | 101 | - --experimental(可选):表示编译experimental贡献目录下的算子。 |
| 97 | 102 | ||
| @@ -130,6 +135,7 @@ | |||
| 130 | ```bash | 135 | ```bash |
| 131 | bash build.sh --pkg --static --soc=${soc_version} | 136 | bash build.sh --pkg --static --soc=${soc_version} |
| 132 | ``` | 137 | ``` |
| 138 | + | ||
| 133 | \$\{soc\_version\}表示NPU型号。Atlas A2系列产品使用"ascend910b"(默认),Atlas A3系列产品使用"ascend910_93"。 | 139 | \$\{soc\_version\}表示NPU型号。Atlas A2系列产品使用"ascend910b"(默认),Atlas A3系列产品使用"ascend910_93"。 |
| 134 | 140 | ||
| 135 | 若提示如下信息,说明编译并压缩成功。 | 141 | 若提示如下信息,说明编译并压缩成功。 |
| @@ -141,7 +147,6 @@ | |||
| 141 | 147 | ||
| 142 | \$\{repo\_path\}表示项目根目录,\$\{soc\_name\}表示NPU型号名称,即\$\{soc\_version\}删除“ascend”后剩余的内容。编译成功后,压缩包存放于build_out目录下。 | 148 | \$\{repo\_path\}表示项目根目录,\$\{soc\_name\}表示NPU型号名称,即\$\{soc\_version\}删除“ascend”后剩余的内容。编译成功后,压缩包存放于build_out目录下。 |
| 143 | 149 | ||
| 144 | - | ||
| 145 | 2. **解压ops-nn静态库** | 150 | 2. **解压ops-nn静态库** |
| 146 | 151 | ||
| 147 | 进入build_out目录执行解压命令: | 152 | 进入build_out目录执行解压命令: |
| @@ -151,6 +156,7 @@ | |||
| 151 | ``` | 156 | ``` |
| 152 | 157 | ||
| 153 | \$\{static\_lib\_path\}表示静态库解压路径。解压后目录结构如下: | 158 | \$\{static\_lib\_path\}表示静态库解压路径。解压后目录结构如下: |
| 159 | + | ||
| 154 | ``` | 160 | ``` |
| 155 | ├── cann-${soc_name}-ops-nn-static_${cann_version}_linux-${arch} | 161 | ├── cann-${soc_name}-ops-nn-static_${cann_version}_linux-${arch} |
| 156 | │ ├── lib64 | 162 | │ ├── lib64 |
| @@ -181,9 +187,10 @@ | |||
| 181 | ```bash | 187 | ```bash |
| 182 | python ${scripts_dir}/third_lib_download.py | 188 | python ${scripts_dir}/third_lib_download.py |
| 183 | ``` | 189 | ``` |
| 190 | + | ||
| 184 | \$\{scripts\_dir\}表示脚本存放路径,下载的第三方软件包默认存放在当前脚本所在目录。 | 191 | \$\{scripts\_dir\}表示脚本存放路径,下载的第三方软件包默认存放在当前脚本所在目录。 |
| 185 | 192 | ||
| 186 | - 3. **编译算子包** | 193 | +3. **编译算子包** |
| 187 | 194 | ||
| 188 | 将下载好的第三方软件上传至离线环境,可存放在`third_party`目录或自定义目录下。**推荐前者,其编译命令与联网编译场景下的命令一致。** | 195 | 将下载好的第三方软件上传至离线环境,可存放在`third_party`目录或自定义目录下。**推荐前者,其编译命令与联网编译场景下的命令一致。** |
| 189 | 196 | ||
| @@ -236,6 +243,7 @@ | |||
| 236 | > **说明**:Ascend 950PR产品使用仿真执行算子样例,请见[仿真指导](../debug/op_debug_prof.md#方式二针对ascend-950pr)。 | 243 | > **说明**:Ascend 950PR产品使用仿真执行算子样例,请见[仿真指导](../debug/op_debug_prof.md#方式二针对ascend-950pr)。 |
| 237 | 244 | ||
| 238 | - 基于**自定义算子包**执行算子样例,包安装后,执行如下命令: | 245 | - 基于**自定义算子包**执行算子样例,包安装后,执行如下命令: |
| 246 | + | ||
| 239 | ```bash | 247 | ```bash |
| 240 | bash build.sh --run_example ${op} ${mode} ${pkg_mode} [--example_name=${example_name}] [--vendor_name=${vendor_name}] [--soc=${soc_version}] [--simulator] | 248 | bash build.sh --run_example ${op} ${mode} ${pkg_mode} [--example_name=${example_name}] [--vendor_name=${vendor_name}] [--soc=${soc_version}] [--simulator] |
| 241 | # 以TransposeBatchMatMul算子执行test_aclnn_transpose_batch_mat_mul.cpp为例 | 249 | # 以TransposeBatchMatMul算子执行test_aclnn_transpose_batch_mat_mul.cpp为例 |
| @@ -253,6 +261,7 @@ | |||
| 253 | 说明:\$\{mode\}为graph时,不指定\$\{pkg_mode\}和\$\{vendor\_name\} | 261 | 说明:\$\{mode\}为graph时,不指定\$\{pkg_mode\}和\$\{vendor\_name\} |
| 254 | 262 | ||
| 255 | - 基于**ops-nn包**执行算子样例,安装后,执行命令如下: | 263 | - 基于**ops-nn包**执行算子样例,安装后,执行命令如下: |
| 264 | + | ||
| 256 | ```bash | 265 | ```bash |
| 257 | bash build.sh --run_example ${op} ${mode} [--soc=${soc_version}] [--simulator] | 266 | bash build.sh --run_example ${op} ${mode} [--soc=${soc_version}] [--simulator] |
| 258 | # 以TransposeBatchMatMul算子example执行为例 | 267 | # 以TransposeBatchMatMul算子example执行为例 |
| @@ -309,7 +318,6 @@ | |||
| 309 | bash run.sh | 318 | bash run.sh |
| 310 | ``` | 319 | ``` |
| 311 | 320 | ||
| 312 | - | ||
| 313 | 无论上述哪种方式,算子样例执行后会打印结果,以TransposeBatchMatMul算子执行为例: | 321 | 无论上述哪种方式,算子样例执行后会打印结果,以TransposeBatchMatMul算子执行为例: |
| 314 | 322 | ||
| 315 | ``` | 323 | ``` |
| @@ -319,6 +327,7 @@ result[2] is: 0.000000 | |||
| 319 | result[3] is: 0.000000 | 327 | result[3] is: 0.000000 |
| 320 | ... | 328 | ... |
| 321 | ``` | 329 | ``` |
| 330 | + | ||
| 322 | ### 执行算子UT | 331 | ### 执行算子UT |
| 323 | 332 | ||
| 324 | > 说明:执行UT用例依赖googletest单元测试框架,详细介绍参见[googletest官网](https://google.github.io/googletest/advanced.html#running-a-subset-of-the-tests)。 | 333 | > 说明:执行UT用例依赖googletest单元测试框架,详细介绍参见[googletest官网](https://google.github.io/googletest/advanced.html#running-a-subset-of-the-tests)。 |
| @@ -354,4 +363,5 @@ Global Environment TearDown | |||
| 354 | [ PASSED ] ${n} tests. | 363 | [ PASSED ] ${n} tests. |
| 355 | [100%] Built target nn_op_host_ut | 364 | [100%] Built target nn_op_host_ut |
| 356 | ``` | 365 | ``` |
| 357 | -\$\{n\}表示执行了n个用例,\$\{m\}表示m项测试,\$\{x\}表示执行用例消耗的时间,单位为毫秒。 | 366 | + |
| 367 | +\$\{n\}表示执行了n个用例,\$\{m\}表示m项测试,\$\{x\}表示执行用例消耗的时间,单位为毫秒。 | ||
| @@ -361,10 +361,11 @@ | |||
| 361 | | [aclnnWeightQuantBatchMatmulV3](../../matmul/weight_quant_batch_matmul_v2/docs/aclnnWeightQuantBatchMatmulV3.md) | 完成一个输入为伪量化场景的矩阵乘计算,并可以实现对于输出的量化计算。 | 默认非确定性实现,支持配置开启。 | 默认确定性实现 | | 361 | | [aclnnWeightQuantBatchMatmulV3](../../matmul/weight_quant_batch_matmul_v2/docs/aclnnWeightQuantBatchMatmulV3.md) | 完成一个输入为伪量化场景的矩阵乘计算,并可以实现对于输出的量化计算。 | 默认非确定性实现,支持配置开启。 | 默认确定性实现 | |
| 362 | 362 | ||
| 363 | ## 废弃接口 | 363 | ## 废弃接口 |
| 364 | + | ||
| 364 | |废弃接口|说明| | 365 | |废弃接口|说明| |
| 365 | |-------|----| | 366 | |-------|----| |
| 366 | | [aclnnWeightQuantBatchMatmul](../../matmul/weight_quant_batch_matmul/docs/aclnnWeightQuantBatchMatmul.md)|此接口后续版本会废弃,请使用最新接口[aclnnWeightQuantBatchMatmulV2](../../matmul/weight_quant_batch_matmul_v2/docs/aclnnWeightQuantBatchMatmulV2.md)、[aclnnWeightQuantBatchMatmulV3](../../matmul/weight_quant_batch_matmul_v2/docs/aclnnWeightQuantBatchMatmulV3.md)。 | | 367 | | [aclnnWeightQuantBatchMatmul](../../matmul/weight_quant_batch_matmul/docs/aclnnWeightQuantBatchMatmul.md)|此接口后续版本会废弃,请使用最新接口[aclnnWeightQuantBatchMatmulV2](../../matmul/weight_quant_batch_matmul_v2/docs/aclnnWeightQuantBatchMatmulV2.md)、[aclnnWeightQuantBatchMatmulV3](../../matmul/weight_quant_batch_matmul_v2/docs/aclnnWeightQuantBatchMatmulV3.md)。 | |
| 367 | | [aclnnQuantMatmul](../../matmul/quant_matmul/docs/aclnnQuantMatmul.md)|此接口后续版本会废弃,请使用最新接口[aclnnQuantMatmulV5](../../matmul/quant_batch_matmul_v4/docs/aclnnQuantMatmulV5.md)。 | | 368 | | [aclnnQuantMatmul](../../matmul/quant_matmul/docs/aclnnQuantMatmul.md)|此接口后续版本会废弃,请使用最新接口[aclnnQuantMatmulV5](../../matmul/quant_batch_matmul_v4/docs/aclnnQuantMatmulV5.md)。 | |
| 368 | | [aclnnQuantMatmulV2](../../matmul/quant_matmul/docs/aclnnQuantMatmulV2.md)|此接口后续版本会废弃,请使用最新接口[aclnnQuantMatmulV5](../../matmul/quant_batch_matmul_v4/docs/aclnnQuantMatmulV5.md)。 | | 369 | | [aclnnQuantMatmulV2](../../matmul/quant_matmul/docs/aclnnQuantMatmulV2.md)|此接口后续版本会废弃,请使用最新接口[aclnnQuantMatmulV5](../../matmul/quant_batch_matmul_v4/docs/aclnnQuantMatmulV5.md)。 | |
| 369 | | [aclnnQuantMatmulV3](../../matmul/quant_batch_matmul_v3/docs/aclnnQuantMatmulV3.md)|此接口后续版本会废弃,请使用最新接口[aclnnQuantMatmulV5](../../matmul/quant_batch_matmul_v4/docs/aclnnQuantMatmulV5.md)。 | | 370 | | [aclnnQuantMatmulV3](../../matmul/quant_batch_matmul_v3/docs/aclnnQuantMatmulV3.md)|此接口后续版本会废弃,请使用最新接口[aclnnQuantMatmulV5](../../matmul/quant_batch_matmul_v4/docs/aclnnQuantMatmulV5.md)。 | |
| 370 | -| [aclnnQuantMatmulV4](../../matmul/quant_batch_matmul_v3/docs/aclnnQuantMatmulV4.md)|此接口后续版本会废弃,请使用最新接口[aclnnQuantMatmulV5](../../matmul/quant_batch_matmul_v4/docs/aclnnQuantMatmulV5.md)。 | | 371 | +| [aclnnQuantMatmulV4](../../matmul/quant_batch_matmul_v3/docs/aclnnQuantMatmulV4.md)|此接口后续版本会废弃,请使用最新接口[aclnnQuantMatmulV5](../../matmul/quant_batch_matmul_v4/docs/aclnnQuantMatmulV5.md)。 | |
| @@ -1,6 +1,7 @@ | |||
| 1 | # 算子列表 | 1 | # 算子列表 |
| 2 | 2 | ||
| 3 | > 说明: | 3 | > 说明: |
| 4 | +> | ||
| 4 | > - **算子目录**:目录名为算子名小写下划线形式,每个目录承载该算子所有交付件,包括代码实现、examples、文档等,目录介绍参见[项目目录](./context/dir_structure.md)。 | 5 | > - **算子目录**:目录名为算子名小写下划线形式,每个目录承载该算子所有交付件,包括代码实现、examples、文档等,目录介绍参见[项目目录](./context/dir_structure.md)。 |
| 5 | > - **算子执行硬件单元**:大部分算子运行在AI Core,少部分算子运行在AI CPU。默认情况下,项目中提到的算子一般指AI Core算子。关于AI Core和AI CPU详细介绍参见[《Ascend C算子开发》](https://hiascend.com/document/redirect/CannCommunityOpdevAscendC)中“概念原理和术语 > 硬件架构与数据处理原理”。 | 6 | > - **算子执行硬件单元**:大部分算子运行在AI Core,少部分算子运行在AI CPU。默认情况下,项目中提到的算子一般指AI Core算子。关于AI Core和AI CPU详细介绍参见[《Ascend C算子开发》](https://hiascend.com/document/redirect/CannCommunityOpdevAscendC)中“概念原理和术语 > 硬件架构与数据处理原理”。 |
| 6 | > - **算子接口列表**:为方便调用算子,CANN提供一套C API执行算子,一般以aclnn为前缀,全量接口参见[aclnn列表](op_api_list.md)。 | 7 | > - **算子接口列表**:为方便调用算子,CANN提供一套C API执行算子,一般以aclnn为前缀,全量接口参见[aclnn列表](op_api_list.md)。 |
| @@ -3265,4 +3266,4 @@ | |||
| 3265 | <td>初始化hash表。</td> | 3266 | <td>初始化hash表。</td> |
| 3266 | </tr> | 3267 | </tr> |
| 3267 | </tbody> | 3268 | </tbody> |
| 3268 | -</table> | 3269 | +</table> |
| @@ -1,12 +1,14 @@ | |||
| 1 | -## 简介 | 1 | +# 简介 |
| 2 | 2 | ||
| 3 | > 说明: | 3 | > 说明: |
| 4 | +> | ||
| 4 | > - 目前算子库中大部分算子运行在AI Core上,少部分算子运行在AI CPU上。默认情况下,项目中提到的算子指AI Core算子。 | 5 | > - 目前算子库中大部分算子运行在AI Core上,少部分算子运行在AI CPU上。默认情况下,项目中提到的算子指AI Core算子。 |
| 5 | > - 关于AI Core和AI CPU的介绍请参见[《Ascend C算子开发》](https://hiascend.com/document/redirect/CannCommunityOpdevAscendC)中“概念原理和术语 > 硬件架构与数据处理原理”。 | 6 | > - 关于AI Core和AI CPU的介绍请参见[《Ascend C算子开发》](https://hiascend.com/document/redirect/CannCommunityOpdevAscendC)中“概念原理和术语 > 硬件架构与数据处理原理”。 |
| 6 | 7 | ||
| 7 | 本项目提供了AI Core算子和AI CPU算子的开发和调用样例,请开发者根据实际情况参考对应实现。 | 8 | 本项目提供了AI Core算子和AI CPU算子的开发和调用样例,请开发者根据实际情况参考对应实现。 |
| 8 | 9 | ||
| 9 | ## 目录说明 | 10 | ## 目录说明 |
| 11 | + | ||
| 10 | ``` | 12 | ``` |
| 11 | ├── examples | 13 | ├── examples |
| 12 | │ ├── add_example # AI Core算子名 | 14 | │ ├── add_example # AI Core算子名 |
| @@ -27,8 +29,9 @@ | |||
| 27 | ``` | 29 | ``` |
| 28 | 30 | ||
| 29 | ## 算子开发样例 | 31 | ## 算子开发样例 |
| 32 | + | ||
| 30 | |样例目录| 样例介绍 |算子开发|算子调用 | | 33 | |样例目录| 样例介绍 |算子开发|算子调用 | |
| 31 | |---|------------------|---|---| | 34 | |---|------------------|---|---| |
| 32 | | add_example | 实现两个张量相加功能的算子。 | 算子端到端开发过程参见[AI Core算子开发指南](../docs/zh/develop/aicore_develop_guide.md) |调用参见[README](add_example/README.md)| | 35 | | add_example | 实现两个张量相加功能的算子。 | 算子端到端开发过程参见[AI Core算子开发指南](../docs/zh/develop/aicore_develop_guide.md) |调用参见[README](add_example/README.md)| |
| 33 | |add_example_aicpu| 实现两个张量相加功能的算子。 |算子端到端开发过程参见[AI CPU算子开发指南](../docs/zh/develop/aicpu_develop_guide.md)| 调用参见[README](add_example_aicpu/README.md) | | 36 | |add_example_aicpu| 实现两个张量相加功能的算子。 |算子端到端开发过程参见[AI CPU算子开发指南](../docs/zh/develop/aicpu_develop_guide.md)| 调用参见[README](add_example_aicpu/README.md) | |
| 34 | -|fast_kernel_launch_example| 实现一种PyTorch场景下快速端到端开发算子的样例。 |算子端到端开发过程参见[PyTorch算子快速开发指南](./fast_kernel_launch_example/README.md)| 调用参见[README](fast_kernel_launch_example/README.md) | | 37 | +|fast_kernel_launch_example| 实现一种PyTorch场景下快速端到端开发算子的样例。 |算子端到端开发过程参见[PyTorch算子快速开发指南](./fast_kernel_launch_example/README.md)| 调用参见[README](fast_kernel_launch_example/README.md) | |
| @@ -1,6 +1,6 @@ | |||
| 1 | # AddExample | 1 | # AddExample |
| 2 | 2 | ||
| 3 | -## 产品支持情况 | 3 | +## 产品支持情况 |
| 4 | 4 | ||
| 5 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| 6 | | ---- | :----:| | 6 | | ---- | :----:| |
| @@ -85,4 +85,4 @@ $$ | |||
| 85 | <td><a href="./examples/test_geir_add_example.cpp">test_geir_add_example</a></td> | 85 | <td><a href="./examples/test_geir_add_example.cpp">test_geir_add_example</a></td> |
| 86 | </tr> | 86 | </tr> |
| 87 | </tbody> | 87 | </tbody> |
| 88 | -</table> | 88 | +</table> |
| @@ -1,6 +1,6 @@ | |||
| 1 | # AddExample | 1 | # AddExample |
| 2 | 2 | ||
| 3 | -## 产品支持情况 | 3 | +## 产品支持情况 |
| 4 | 4 | ||
| 5 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| 6 | | ---- | :----:| | 6 | | ---- | :----:| |
| @@ -85,4 +85,4 @@ $$ | |||
| 85 | <td><a href="./examples/test_geir_add_example_aicpu.cpp">test_geir_add_example_aicpu</a></td> | 85 | <td><a href="./examples/test_geir_add_example_aicpu.cpp">test_geir_add_example_aicpu</a></td> |
| 86 | </tr> | 86 | </tr> |
| 87 | </tbody> | 87 | </tbody> |
| 88 | -</table> | 88 | +</table> |
| @@ -5,6 +5,7 @@ | |||
| 5 | 本文档演示如何使用Ascend C和[PyTorch Extension](https://docs.pytorch.org/tutorials/extension.html)能力开发自定义NPU算子。 | 5 | 本文档演示如何使用Ascend C和[PyTorch Extension](https://docs.pytorch.org/tutorials/extension.html)能力开发自定义NPU算子。 |
| 6 | 6 | ||
| 7 | **核心优势:** | 7 | **核心优势:** |
| 8 | + | ||
| 8 | - **单交付件:** 一个文件完成算子开发和PyTorch框架适配。 | 9 | - **单交付件:** 一个文件完成算子开发和PyTorch框架适配。 |
| 9 | - **高效调用:** 使用`<<<>>>`语法启动核函数,流程简单高效。 | 10 | - **高效调用:** 使用`<<<>>>`语法启动核函数,流程简单高效。 |
| 10 | 11 | ||
| @@ -21,24 +22,29 @@ | |||
| 21 | 1. 进入`examples/fast_kernel_launch_example`目录。 | 22 | 1. 进入`examples/fast_kernel_launch_example`目录。 |
| 22 | 23 | ||
| 23 | 2. 安装依赖 | Install Dependencies: | 24 | 2. 安装依赖 | Install Dependencies: |
| 25 | + | ||
| 24 | ```sh | 26 | ```sh |
| 25 | python3 -m pip install -r requirements.txt | 27 | python3 -m pip install -r requirements.txt |
| 26 | ``` | 28 | ``` |
| 27 | 29 | ||
| 28 | 3. 构建Wheel包 | Build the Wheel: | 30 | 3. 构建Wheel包 | Build the Wheel: |
| 31 | + | ||
| 29 | ```sh | 32 | ```sh |
| 30 | # -n: non-isolated build (uses existing environment) | 33 | # -n: non-isolated build (uses existing environment) |
| 31 | python3 -m build --wheel -n | 34 | python3 -m build --wheel -n |
| 32 | ``` | 35 | ``` |
| 36 | + | ||
| 33 | 构建完成后,产物在当前目录的`dist`文件夹下,产物名`ascend_ops-1.0.0-${python_version}-abi3-${arch}.whl`, | 37 | 构建完成后,产物在当前目录的`dist`文件夹下,产物名`ascend_ops-1.0.0-${python_version}-abi3-${arch}.whl`, |
| 34 | `${python_version}`表示当前环境中的python版本(python3.8.3为cp38),`${arch}`表示CPU架构。 | 38 | `${python_version}`表示当前环境中的python版本(python3.8.3为cp38),`${arch}`表示CPU架构。 |
| 35 | 39 | ||
| 36 | 4. 安装Wheel包 | Install Package: | 40 | 4. 安装Wheel包 | Install Package: |
| 41 | + | ||
| 37 | ```sh | 42 | ```sh |
| 38 | python3 -m pip install dist/*.whl --force-reinstall --no-deps | 43 | python3 -m pip install dist/*.whl --force-reinstall --no-deps |
| 39 | ``` | 44 | ``` |
| 40 | 45 | ||
| 41 | 5. (可选)再次构建前建议先执行以下命令清理编译缓存 | 46 | 5. (可选)再次构建前建议先执行以下命令清理编译缓存 |
| 47 | + | ||
| 42 | ```sh | 48 | ```sh |
| 43 | python setup.py clean | 49 | python setup.py clean |
| 44 | ``` | 50 | ``` |
| @@ -75,9 +81,11 @@ print("Verification successful!") | |||
| 75 | 1. 首先您需要在csrc目录下使用算子名`add`建立一个文件夹,在此文件夹内使用你当前想要开发的soc名建立一个子文件夹`ascend910b`。 | 81 | 1. 首先您需要在csrc目录下使用算子名`add`建立一个文件夹,在此文件夹内使用你当前想要开发的soc名建立一个子文件夹`ascend910b`。 |
| 76 | 82 | ||
| 77 | 2. 在soc目录下新建一个`CMakeLists.txt` | 83 | 2. 在soc目录下新建一个`CMakeLists.txt` |
| 84 | + | ||
| 78 | ``` | 85 | ``` |
| 79 | add_sources("--npu-arch=dav-2201") | 86 | add_sources("--npu-arch=dav-2201") |
| 80 | ``` | 87 | ``` |
| 88 | + | ||
| 81 | 这里`dav-2201`为ascend910b芯片对应的编译参数,获取方法参考[NpuArch说明和使用指导](https://gitcode.com/cann/ops-math/wiki/NpuArch%E8%AF%B4%E6%98%8E%E5%92%8C%E4%BD%BF%E7%94%A8%E6%8C%87%E5%AF%BC.md)。 | 89 | 这里`dav-2201`为ascend910b芯片对应的编译参数,获取方法参考[NpuArch说明和使用指导](https://gitcode.com/cann/ops-math/wiki/NpuArch%E8%AF%B4%E6%98%8E%E5%92%8C%E4%BD%BF%E7%94%A8%E6%8C%87%E5%AF%BC.md)。 |
| 82 | 90 | ||
| 83 | 3. 在soc目录下新建一个`add.cpp`(建议使用算子名为文件名)。这个文件包含了开发一个AI Core算子所需要的全部模块。 | 91 | 3. 在soc目录下新建一个`add.cpp`(建议使用算子名为文件名)。这个文件包含了开发一个AI Core算子所需要的全部模块。 |
| @@ -200,5 +208,6 @@ print("Verification successful!") | |||
| 200 | } // namespace ascend_ops | 208 | } // namespace ascend_ops |
| 201 | 209 | ||
| 202 | ``` | 210 | ``` |
| 211 | + | ||
| 203 | 4. 参考[安装步骤](#安装步骤--installation-steps)章节重新构建Wheel包并安装。 | 212 | 4. 参考[安装步骤](#安装步骤--installation-steps)章节重新构建Wheel包并安装。 |
| 204 | -5. 基于pytest测试算子API,请参考[test_add.py](tests/add/test_add.py)的实现。 | 213 | +5. 基于pytest测试算子API,请参考[test_add.py](tests/add/test_add.py)的实现。 |
| @@ -1,9 +1,11 @@ | |||
| 1 | # Celu | 1 | # Celu |
| 2 | + | ||
| 2 | ## 产品支持情况 | 3 | ## 产品支持情况 |
| 3 | 4 | ||
| 4 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| 5 | | :----------------------------------------------------------- | :------- | | 6 | | :----------------------------------------------------------- | :------- | |
| 6 | | <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term> | √ | | 7 | | <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term> | √ | |
| 8 | + | ||
| 7 | ## 功能说明 | 9 | ## 功能说明 |
| 8 | 10 | ||
| 9 | - 算子功能:激活函数Celu(Continuously Differentiable Exponential Linear Units)。 | 11 | - 算子功能:激活函数Celu(Continuously Differentiable Exponential Linear Units)。 |
| @@ -29,4 +31,4 @@ | |||
| 29 | 31 | ||
| 30 | | 调用方式 | 样例代码 | 说明 | | 32 | | 调用方式 | 样例代码 | 说明 | |
| 31 | | :-------- | :----------------------------------------------------------- | :----------------------------------------------------------- | | 33 | | :-------- | :----------------------------------------------------------- | :----------------------------------------------------------- | |
| 32 | -| aclnn接口 | [test_celu](./examples/test_aclnn_celu_v2.cpp) | 通过[aclnnCelu]接口方式调用Celu算子。 | | 34 | +| aclnn接口 | [test_celu](./examples/test_aclnn_celu_v2.cpp) | 通过[aclnnCelu]接口方式调用Celu算子。 | |
| @@ -1,9 +1,11 @@ | |||
| 1 | # HardSwish | 1 | # HardSwish |
| 2 | + | ||
| 2 | ## 产品支持情况 | 3 | ## 产品支持情况 |
| 3 | 4 | ||
| 4 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| 5 | | :----------------------------------------------------------- | :------- | | 6 | | :----------------------------------------------------------- | :------- | |
| 6 | | <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term> | √ | | 7 | | <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term> | √ | |
| 8 | + | ||
| 7 | ## 功能说明 | 9 | ## 功能说明 |
| 8 | 10 | ||
| 9 | - 算子功能:对输入张量x逐元素计算HardSwish激活函数值,计算公式为: | 11 | - 算子功能:对输入张量x逐元素计算HardSwish激活函数值,计算公式为: |
| @@ -16,13 +18,16 @@ $y = \frac{x * min(max(x + 3, 0), 6)}{6}$。 | |||
| 16 | | self | 输入 | x | float、half、bfloat16 | ND | | 18 | | self | 输入 | x | float、half、bfloat16 | ND | |
| 17 | | out | 输出 | y | float、half、bfloat16 | ND | | 19 | | out | 输出 | y | float、half、bfloat16 | ND | |
| 18 | 20 | ||
| 19 | - | ||
| 20 | ## 约束说明 | 21 | ## 约束说明 |
| 22 | + | ||
| 21 | 无 | 23 | 无 |
| 24 | + | ||
| 22 | ## 待更新 | 25 | ## 待更新 |
| 26 | + | ||
| 23 | 目前支持float32、float16、bfloat16数据类型,不支持broadcast,后续会持续改进 | 27 | 目前支持float32、float16、bfloat16数据类型,不支持broadcast,后续会持续改进 |
| 28 | + | ||
| 24 | ## 调用说明 | 29 | ## 调用说明 |
| 25 | 30 | ||
| 26 | | 调用方式 | 样例代码 | 说明 | | 31 | | 调用方式 | 样例代码 | 说明 | |
| 27 | | :-------- | :----------------------------------------------------------- | :----------------------------------------------------------- | | 32 | | :-------- | :----------------------------------------------------------- | :----------------------------------------------------------- | |
| 28 | -| aclnn接口 | [test_hard_swish_v2](examples/test_aclnn_hard_swish_v2.cpp) | 通过[aclnnHardSwishV2]接口方式调用HardSwish算子。 | | 33 | +| aclnn接口 | [test_hard_swish_v2](examples/test_aclnn_hard_swish_v2.cpp) | 通过[aclnnHardSwishV2]接口方式调用HardSwish算子。 | |
| @@ -1,9 +1,11 @@ | |||
| 1 | # LeakyRelu | 1 | # LeakyRelu |
| 2 | + | ||
| 2 | ## 产品支持情况 | 3 | ## 产品支持情况 |
| 3 | 4 | ||
| 4 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| 5 | | :----------------------------------------------------------- | :------- | | 6 | | :----------------------------------------------------------- | :------- | |
| 6 | | <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term> | √ | | 7 | | <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term> | √ | |
| 8 | + | ||
| 7 | ## 功能说明 | 9 | ## 功能说明 |
| 8 | 10 | ||
| 9 | - 算子功能:LeakyRelu激活函数。 | 11 | - 算子功能:LeakyRelu激活函数。 |
| @@ -28,4 +30,4 @@ $$ y = \begin{cases} x, & x \ge 0 \\ negative\_slope \times x, & x < 0 \end{case | |||
| 28 | 30 | ||
| 29 | | 调用方式 | 样例代码 | 说明 | | 31 | | 调用方式 | 样例代码 | 说明 | |
| 30 | | :-------- | :----------------------------------------------------------- | :----------------------------------------------------------- | | 32 | | :-------- | :----------------------------------------------------------- | :----------------------------------------------------------- | |
| 31 | -| aclnn接口 | [test_leaky_relu](./examples/test_aclnn_leakyrelu_v2.cpp) | 通过[aclnnLeakyRelu]接口方式调用LeakyRelu算子。 | | 33 | +| aclnn接口 | [test_leaky_relu](./examples/test_aclnn_leakyrelu_v2.cpp) | 通过[aclnnLeakyRelu]接口方式调用LeakyRelu算子。 | |
| @@ -2,7 +2,6 @@ | |||
| 2 | 2 | ||
| 3 | ## 产品支持情况 | 3 | ## 产品支持情况 |
| 4 | 4 | ||
| 5 | - | ||
| 6 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| 7 | | ------------------------------------------------------------------ | :------: | | 6 | | ------------------------------------------------------------------ | :------: | |
| 8 | | Atlas A2 训练系列产品/Atlas 800I A2 推理产品/A200I A2 Box 异构组件 | √ | | 7 | | Atlas A2 训练系列产品/Atlas 800I A2 推理产品/A200I A2 Box 异构组件 | √ | |
| @@ -82,7 +81,6 @@ $$ | |||
| 82 | 81 | ||
| 83 | ## 调用说明 | 82 | ## 调用说明 |
| 84 | 83 | ||
| 85 | - | ||
| 86 | | 调用方式 | 调用样例 | 说明 | | 84 | | 调用方式 | 调用样例 | 说明 | |
| 87 | | --------- | ----------------------------------------------------------- | ---------------------------------------------------------------------- | | 85 | | --------- | ----------------------------------------------------------- | ---------------------------------------------------------------------- | |
| 88 | | aclnn调用 | [test_aclnn_mish_grad](./examples/test_aclnn_mish_grad.cpp) | 通过[aclnnMishBackward](./docs/aclnnMishBackward.md)接口方式调用MishGrad算子。 | | 86 | | aclnn调用 | [test_aclnn_mish_grad](./examples/test_aclnn_mish_grad.cpp) | 通过[aclnnMishBackward](./docs/aclnnMishBackward.md)接口方式调用MishGrad算子。 | |
| @@ -91,4 +89,4 @@ $$ | |||
| 91 | 89 | ||
| 92 | | 贡献者 | 贡献方 | 贡献算子 | 贡献时间 | 贡献内容 | | 90 | | 贡献者 | 贡献方 | 贡献算子 | 贡献时间 | 贡献内容 | |
| 93 | | ---- | ---- | ---- | ---- | ---- | | 91 | | ---- | ---- | ---- | ---- | ---- | |
| 94 | -| ilovescrapy | 个人开发者 | MishGrad | 2025/12/23 | MishGrad算子适配开源仓 | | 92 | +| ilovescrapy | 个人开发者 | MishGrad | 2025/12/23 | MishGrad算子适配开源仓 | |
| @@ -63,7 +63,7 @@ aclnnStatus aclnnMishBackward( | |||
| 63 | <td>gradOutput</td> | 63 | <td>gradOutput</td> |
| 64 | <td>输入</td> | 64 | <td>输入</td> |
| 65 | <td>反向传播过程中上一步输出的梯度,作为本反向算子的输入。公式中的gradOutput。</td> | 65 | <td>反向传播过程中上一步输出的梯度,作为本反向算子的输入。公式中的gradOutput。</td> |
| 66 | - <td><ul><li>不支持空Tensor。</li><li>数据类型与self的数据类型需满足数据类型推导规则(参见<a href="../../../docs/context/互推导关系.md" target="_blank">互推导关系</a>)。</li><li>shape需要与self满足<a href="../../../docs/context/broadcast关系.md" target="_blank">broadcast关系</a>。</li></ul></td> | 66 | + <td><ul><li>不支持空Tensor。</li><li>数据类型与self的数据类型需满足数据类型推导规则(参见<a href="../../../docs/zh/context/互推导关系.md" target="_blank">互推导关系</a>)。</li><li>shape需要与self满足<a href="../../../docs/zh/context/broadcast关系.md" target="_blank">broadcast关系</a>。</li></ul></td> |
| 67 | <td>BFLOAT16、FLOAT16、FLOAT32</td> | 67 | <td>BFLOAT16、FLOAT16、FLOAT32</td> |
| 68 | <td>ND</td> | 68 | <td>ND</td> |
| 69 | <td>0-8</td> | 69 | <td>0-8</td> |
| @@ -73,7 +73,7 @@ aclnnStatus aclnnMishBackward( | |||
| 73 | <td>self</td> | 73 | <td>self</td> |
| 74 | <td>输入</td> | 74 | <td>输入</td> |
| 75 | <td>正向的输入数据。公式中的self。</td> | 75 | <td>正向的输入数据。公式中的self。</td> |
| 76 | - <td><ul><li>不支持空Tensor。</li><li>数据类型与gradOutput的数据类型需满足数据类型推导规则(参见<a href="../../../docs/context/互推导关系.md" target="_blank">互推导关系</a>)。</li><li>shape需要与gradOutput满足<a href="../../../docs/context/broadcast关系.md" target="_blank">broadcast关系</a>。</li></ul></td> | 76 | + <td><ul><li>不支持空Tensor。</li><li>数据类型与gradOutput的数据类型需满足数据类型推导规则(参见<a href="../../../docs/zh/context/互推导关系.md" target="_blank">互推导关系</a>)。</li><li>shape需要与gradOutput满足<a href="../../../docs/context/broadcast关系.md" target="_blank">broadcast关系</a>。</li></ul></td> |
| 77 | <td>BFLOAT16、FLOAT16、FLOAT32</td> | 77 | <td>BFLOAT16、FLOAT16、FLOAT32</td> |
| 78 | <td>ND</td> | 78 | <td>ND</td> |
| 79 | <td>0-8</td> | 79 | <td>0-8</td> |
| @@ -83,7 +83,7 @@ aclnnStatus aclnnMishBackward( | |||
| 83 | <td>gradInput</td> | 83 | <td>gradInput</td> |
| 84 | <td>输出</td> | 84 | <td>输出</td> |
| 85 | <td>计算得到梯度,作为反向传播下一步反向算子的计算输入。</td> | 85 | <td>计算得到梯度,作为反向传播下一步反向算子的计算输入。</td> |
| 86 | - <td><ul><li>不支持空Tensor。</li><li>数据类型与gradOutput的数据类型需满足推导规则(参见<a href="../../../docs/context/互推导关系.md" target="_blank">互推导关系</a>)。</li><li>shape需要与gradOutput满足<a href="../../../docs/context/broadcast关系.md" target="_blank">broadcast关系</a>。</li></ul></td> | 86 | + <td><ul><li>不支持空Tensor。</li><li>数据类型与gradOutput的数据类型需满足推导规则(参见<a href="../../../docs/zh/context/互推导关系.md" target="_blank">互推导关系</a>)。</li><li>shape需要与gradOutput满足<a href="../../../docs/zh/context/broadcast关系.md" target="_blank">broadcast关系</a>。</li></ul></td> |
| 87 | <td>BFLOAT16、FLOAT16、FLOAT32</td> | 87 | <td>BFLOAT16、FLOAT16、FLOAT32</td> |
| 88 | <td>ND</td> | 88 | <td>ND</td> |
| 89 | <td>0-8</td> | 89 | <td>0-8</td> |
| @@ -112,8 +112,6 @@ aclnnStatus aclnnMishBackward( | |||
| 112 | </tbody> | 112 | </tbody> |
| 113 | </table> | 113 | </table> |
| 114 | 114 | ||
| 115 | - | ||
| 116 | - | ||
| 117 | - **返回值**: | 115 | - **返回值**: |
| 118 | 116 | ||
| 119 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../../docs/zh/context/aclnn返回码.md)。 | 117 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../../docs/zh/context/aclnn返回码.md)。 |
| @@ -149,7 +147,6 @@ aclnnStatus aclnnMishBackward( | |||
| 149 | </tr> | 147 | </tr> |
| 150 | </tbody></table> | 148 | </tbody></table> |
| 151 | 149 | ||
| 152 | - | ||
| 153 | ## aclnnMishBackward | 150 | ## aclnnMishBackward |
| 154 | 151 | ||
| 155 | - **参数说明:** | 152 | - **参数说明:** |
| @@ -194,6 +191,7 @@ aclnnStatus aclnnMishBackward( | |||
| 194 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../../docs/zh/context/aclnn返回码.md)。 | 191 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../../docs/zh/context/aclnn返回码.md)。 |
| 195 | 192 | ||
| 196 | ## 约束说明 | 193 | ## 约束说明 |
| 194 | + | ||
| 197 | 无。 | 195 | 无。 |
| 198 | 196 | ||
| 199 | ## 调用示例 | 197 | ## 调用示例 |
| @@ -77,4 +77,4 @@ | |||
| 77 | | 调用方式 | 调用样例 | 说明 | | 77 | | 调用方式 | 调用样例 | 说明 | |
| 78 | |--------------|------------------------------------------------------------------------|----------------------------------------------------------------| | 78 | |--------------|------------------------------------------------------------------------|----------------------------------------------------------------| |
| 79 | | aclnn调用 | [test_aclnn_silu_mul](./examples/test_aclnn_silu_mul.cpp) | 通过[aclnnSiluMul](./docs/aclnnSiluMul.md)接口方式调用SiluMul算子。 | | 79 | | aclnn调用 | [test_aclnn_silu_mul](./examples/test_aclnn_silu_mul.cpp) | 通过[aclnnSiluMul](./docs/aclnnSiluMul.md)接口方式调用SiluMul算子。 | |
| 80 | -| 图模式调用 | - | 通过[算子IR](./op_graph/silu_mul_proto.h)构图方式调用SiluMul算子。 | | 80 | +| 图模式调用 | - | 通过[算子IR](./op_graph/silu_mul_proto.h)构图方式调用SiluMul算子。 | |
| @@ -127,7 +127,6 @@ aclnnStatus aclnnSiluMul( | |||
| 127 | </tbody> | 127 | </tbody> |
| 128 | </table> | 128 | </table> |
| 129 | 129 | ||
| 130 | - | ||
| 131 | - **返回值:** | 130 | - **返回值:** |
| 132 | 131 | ||
| 133 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../../docs/zh/context/aclnn返回码.md)。 | 132 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../../docs/zh/context/aclnn返回码.md)。 |
| @@ -357,4 +356,4 @@ int main() { | |||
| 357 | 356 | ||
| 358 | return 0; | 357 | return 0; |
| 359 | } | 358 | } |
| 360 | -``` | 359 | +``` |
| @@ -57,7 +57,6 @@ aclnnStatus aclnnSwishBackward( | |||
| 57 | aclrtStream stream) | 57 | aclrtStream stream) |
| 58 | ``` | 58 | ``` |
| 59 | 59 | ||
| 60 | - | ||
| 61 | ## aclnnSwishBackwardGetWorkspaceSize | 60 | ## aclnnSwishBackwardGetWorkspaceSize |
| 62 | 61 | ||
| 63 | - **参数说明:** | 62 | - **参数说明:** |
| @@ -147,8 +146,6 @@ aclnnStatus aclnnSwishBackward( | |||
| 147 | </tbody> | 146 | </tbody> |
| 148 | </table> | 147 | </table> |
| 149 | 148 | ||
| 150 | - | ||
| 151 | - | ||
| 152 | - **返回值:** | 149 | - **返回值:** |
| 153 | 150 | ||
| 154 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../../docs/zh/context/aclnn返回码.md)。 | 151 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../../docs/zh/context/aclnn返回码.md)。 |
| @@ -184,7 +181,6 @@ aclnnStatus aclnnSwishBackward( | |||
| 184 | </tr> | 181 | </tr> |
| 185 | </tbody></table> | 182 | </tbody></table> |
| 186 | 183 | ||
| 187 | - | ||
| 188 | ## aclnnSwishBackward | 184 | ## aclnnSwishBackward |
| 189 | 185 | ||
| 190 | - **参数说明:** | 186 | - **参数说明:** |
| @@ -223,8 +219,6 @@ aclnnStatus aclnnSwishBackward( | |||
| 223 | </tbody> | 219 | </tbody> |
| 224 | </table> | 220 | </table> |
| 225 | 221 | ||
| 226 | - | ||
| 227 | - | ||
| 228 | - **返回值:** | 222 | - **返回值:** |
| 229 | 223 | ||
| 230 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../../docs/zh/context/aclnn返回码.md)。 | 224 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../../docs/zh/context/aclnn返回码.md)。 |
| @@ -236,6 +230,7 @@ aclnnStatus aclnnSwishBackward( | |||
| 236 | ## 调用示例 | 230 | ## 调用示例 |
| 237 | 231 | ||
| 238 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../../docs/zh/context/编译与运行样例.md)。 | 232 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../../docs/zh/context/编译与运行样例.md)。 |
| 233 | + | ||
| 239 | ```Cpp | 234 | ```Cpp |
| 240 | #include <iostream> | 235 | #include <iostream> |
| 241 | #include <vector> | 236 | #include <vector> |
| @@ -1,6 +1,6 @@ | |||
| 1 | # BinaryCrossEntropyGrad | 1 | # BinaryCrossEntropyGrad |
| 2 | 2 | ||
| 3 | -## 产品支持情况 | 3 | +## 产品支持情况 |
| 4 | 4 | ||
| 5 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| 6 | | ---- | :----:| | 6 | | ---- | :----:| |
| @@ -88,5 +88,3 @@ $$ | |||
| 88 | | 调用方式 | 调用样例 | 说明 | | 88 | | 调用方式 | 调用样例 | 说明 | |
| 89 | |--------------|------------------------------------------------------------------------|--------------------------------------------------------------| | 89 | |--------------|------------------------------------------------------------------------|--------------------------------------------------------------| |
| 90 | | aclnn调用 | [test_aclnn_binary_cross_entropy_grad_v2.cpp](./examples/test_aclnn_binary_cross_entropy_grad_v2.cpp) | 通过[test_aclnn_binary_cross_entropy_grad_v2]接口方式调用BinaryCrossEntropyGrad算子。 | | 90 | | aclnn调用 | [test_aclnn_binary_cross_entropy_grad_v2.cpp](./examples/test_aclnn_binary_cross_entropy_grad_v2.cpp) | 通过[test_aclnn_binary_cross_entropy_grad_v2]接口方式调用BinaryCrossEntropyGrad算子。 | |
| 91 | - | ||
| 92 | - | ||
| @@ -1,4 +1,5 @@ | |||
| 1 | -## 目录结构介绍 | 1 | +# 目录结构介绍 |
| 2 | + | ||
| 2 | ``` | 3 | ``` |
| 3 | ├── examples // 通过aclnn调用的方式调用MatmulFp32算子 | 4 | ├── examples // 通过aclnn调用的方式调用MatmulFp32算子 |
| 4 | │ ├── inc // 头文件目录 | 5 | │ ├── inc // 头文件目录 |
| @@ -20,6 +21,7 @@ | |||
| 20 | ``` | 21 | ``` |
| 21 | 22 | ||
| 22 | ## 代码实现介绍 | 23 | ## 代码实现介绍 |
| 24 | + | ||
| 23 | 完成自定义算子的开发部署后,可以通过单算子调用的方式来验证单算子的功能。src/main.cpp代码为单算子API执行方式。单算子API执行是基于C语言的API执行算子,无需提供单算子描述文件进行离线模型的转换,直接调用单算子API接口。 | 25 | 完成自定义算子的开发部署后,可以通过单算子调用的方式来验证单算子的功能。src/main.cpp代码为单算子API执行方式。单算子API执行是基于C语言的API执行算子,无需提供单算子描述文件进行离线模型的转换,直接调用单算子API接口。 |
| 24 | 26 | ||
| 25 | 自定义算子编译部署后,会自动生成单算子API,可以直接在应用程序中调用。算子API的形式一般定义为“两段式接口”,形如: | 27 | 自定义算子编译部署后,会自动生成单算子API,可以直接在应用程序中调用。算子API的形式一般定义为“两段式接口”,形如: |
| @@ -30,14 +32,20 @@ aclnnStatus aclnnMatmulFp32GetWorkspaceSize(const aclTensor *a, const aclTensor | |||
| 30 | // 执行算子 | 32 | // 执行算子 |
| 31 | aclnnStatus aclnnMatmulFp32(void *workspace, uint64_t workspaceSize, aclOpExecutor *executor, aclrtStream stream); | 33 | aclnnStatus aclnnMatmulFp32(void *workspace, uint64_t workspaceSize, aclOpExecutor *executor, aclrtStream stream); |
| 32 | ``` | 34 | ``` |
| 35 | + | ||
| 33 | 其中aclnnMatmulFp32GetWorkspaceSize为第一段接口,主要用于计算本次API调用计算过程中需要多少的workspace内存。获取到本次API计算需要的workspace大小后,按照workspaceSize大小申请Device侧内存,然后调用第二段接口aclnnMatmulFp32执行计算。具体请参考[单算子API调用](https://hiascend.com/document/redirect/CannCommunityAscendCInVorkSingleOp)章节。 | 36 | 其中aclnnMatmulFp32GetWorkspaceSize为第一段接口,主要用于计算本次API调用计算过程中需要多少的workspace内存。获取到本次API计算需要的workspace大小后,按照workspaceSize大小申请Device侧内存,然后调用第二段接口aclnnMatmulFp32执行计算。具体请参考[单算子API调用](https://hiascend.com/document/redirect/CannCommunityAscendCInVorkSingleOp)章节。 |
| 34 | 37 | ||
| 35 | ## 运行样例算子 | 38 | ## 运行样例算子 |
| 39 | + | ||
| 36 | ### 1. 编译算子工程 | 40 | ### 1. 编译算子工程 |
| 41 | + | ||
| 37 | 运行此样例前,请参考[编译算子工程](../README.md#operatorcompile)完成前期准备。 | 42 | 运行此样例前,请参考[编译算子工程](../README.md#operatorcompile)完成前期准备。 |
| 43 | + | ||
| 38 | ### 2. aclnn调用样例运行 | 44 | ### 2. aclnn调用样例运行 |
| 39 | - - 进入到样例目录 | 45 | + |
| 46 | + - 进入到样例目录 | ||
| 40 | 以命令行方式下载样例代码,master分支为例。 | 47 | 以命令行方式下载样例代码,master分支为例。 |
| 48 | + | ||
| 41 | ```bash | 49 | ```bash |
| 42 | cd ${git_clone_path}/experimental/matmul/matmul_fp32/examples | 50 | cd ${git_clone_path}/experimental/matmul/matmul_fp32/examples |
| 43 | ``` | 51 | ``` |
| @@ -45,7 +53,8 @@ aclnnStatus aclnnMatmulFp32(void *workspace, uint64_t workspaceSize, aclOpExecut | |||
| 45 | - 样例执行 | 53 | - 样例执行 |
| 46 | 54 | ||
| 47 | 样例执行过程中会自动生成测试数据,然后编译与运行aclnn样例,检验运行结果并采集性能数据,。具体过程可参见run.sh脚本。 | 55 | 样例执行过程中会自动生成测试数据,然后编译与运行aclnn样例,检验运行结果并采集性能数据,。具体过程可参见run.sh脚本。 |
| 56 | + | ||
| 48 | ```bash | 57 | ```bash |
| 49 | bash run.sh | 58 | bash run.sh |
| 50 | ``` | 59 | ``` |
| 51 | - | 60 | + |
| @@ -1,15 +1,18 @@ | |||
| 1 | # WeightQuantBatchMatmulExperiment算子 | 1 | # WeightQuantBatchMatmulExperiment算子 |
| 2 | 2 | ||
| 3 | -## 概述 | 3 | +## 概述 |
| 4 | + | ||
| 4 | 本样例的WeightQuantBatchMatmulExperiment算子实现使用自定义算子工程,其kernel包含两个模板:基础模板以及计算解耦流水模板。example的用例分别使用两个模板的精度均正常,示例通过msprof工具采集了模板的性能数据。 | 5 | 本样例的WeightQuantBatchMatmulExperiment算子实现使用自定义算子工程,其kernel包含两个模板:基础模板以及计算解耦流水模板。example的用例分别使用两个模板的精度均正常,示例通过msprof工具采集了模板的性能数据。 |
| 5 | 6 | ||
| 6 | -## 支持的AI处理器 | 7 | +## 支持的AI处理器 |
| 8 | + | ||
| 7 | | 产品 | 是否支持 | | 9 | | 产品 | 是否支持 | |
| 8 | | ---- | :----:| | 10 | | ---- | :----:| |
| 9 | |Atlas A3 训练系列产品/Atlas A3 推理系列产品|√| | 11 | |Atlas A3 训练系列产品/Atlas A3 推理系列产品|√| |
| 10 | |Atlas A2 训练系列产品/Atlas A2 推理系列产品|√| | 12 | |Atlas A2 训练系列产品/Atlas A2 推理系列产品|√| |
| 11 | 13 | ||
| 12 | ## 目录结构介绍 | 14 | ## 目录结构介绍 |
| 15 | + | ||
| 13 | ``` | 16 | ``` |
| 14 | ├── weight_quant_batch_matmul_experiment | 17 | ├── weight_quant_batch_matmul_experiment |
| 15 | │ ├── examples // 样例工程 | 18 | │ ├── examples // 样例工程 |
| @@ -20,13 +23,19 @@ | |||
| 20 | ## 功能说明 | 23 | ## 功能说明 |
| 21 | 24 | ||
| 22 | - 算子功能: | 25 | - 算子功能: |
| 26 | + | ||
| 23 | 本样例算子实现的是MatMul伪量化A16W4 PerGroup场景,并使用MSD算法完成伪量化的计算过程。其数学表达式为: | 27 | 本样例算子实现的是MatMul伪量化A16W4 PerGroup场景,并使用MSD算法完成伪量化的计算过程。其数学表达式为: |
| 28 | + | ||
| 24 | 1. 计算$A_{max}$: | 29 | 1. 计算$A_{max}$: |
| 25 | 30 | ||
| 26 | $$A_{max} = rowMax(|A_{group}|)$$ | 31 | $$A_{max} = rowMax(|A_{group}|)$$ |
| 27 | 32 | ||
| 28 | 2. 计算$tmp_{1}$: | 33 | 2. 计算$tmp_{1}$: |
| 29 | 34 | ||
| 35 | +$$A_{max} = rowMax(|A_{group}|)$$ | ||
| 36 | + | ||
| 37 | +2. 计算$tmp_{1}$: | ||
| 38 | + | ||
| 30 | $$tmp_{1} = \frac{7.49 * A_{group}}{A_{max}}$$ | 39 | $$tmp_{1} = \frac{7.49 * A_{group}}{A_{max}}$$ |
| 31 | 40 | ||
| 32 | 3. 计算$A_1$: | 41 | 3. 计算$A_1$: |
| @@ -92,22 +101,29 @@ $$Y^{i} = Y_{group} + Y^{i-1}$$ | |||
| 92 | </table> | 101 | </table> |
| 93 | 102 | ||
| 94 | ## 编译运行 | 103 | ## 编译运行 |
| 104 | + | ||
| 95 | - 配置环境变量 | 105 | - 配置环境变量 |
| 96 | 根据当前环境上CANN开发套件包(toolkit包+ops包)的安装方式,选择对应配置环境变量的命令。 | 106 | 根据当前环境上CANN开发套件包(toolkit包+ops包)的安装方式,选择对应配置环境变量的命令。 |
| 97 | - 默认路径,root用户安装CANN软件包 | 107 | - 默认路径,root用户安装CANN软件包 |
| 108 | + | ||
| 98 | ```bash | 109 | ```bash |
| 99 | export ASCEND_INSTALL_PATH=/usr/local/Ascend/cann | 110 | export ASCEND_INSTALL_PATH=/usr/local/Ascend/cann |
| 100 | ``` | 111 | ``` |
| 112 | + | ||
| 101 | - 默认路径,非root用户安装CANN软件包 | 113 | - 默认路径,非root用户安装CANN软件包 |
| 114 | + | ||
| 102 | ```bash | 115 | ```bash |
| 103 | export ASCEND_INSTALL_PATH=$HOME/Ascend/cann | 116 | export ASCEND_INSTALL_PATH=$HOME/Ascend/cann |
| 104 | ``` | 117 | ``` |
| 118 | + | ||
| 105 | - 指定路径install_path,安装CANN软件包 | 119 | - 指定路径install_path,安装CANN软件包 |
| 120 | + | ||
| 106 | ```bash | 121 | ```bash |
| 107 | export ASCEND_INSTALL_PATH=${install_path}/cann | 122 | export ASCEND_INSTALL_PATH=${install_path}/cann |
| 108 | ``` | 123 | ``` |
| 109 | 124 | ||
| 110 | - 编译与安装自定义算子包 | 125 | - 编译与安装自定义算子包 |
| 126 | + | ||
| 111 | ```bash | 127 | ```bash |
| 112 | # 切换到工程根目录 | 128 | # 切换到工程根目录 |
| 113 | cd ${git_clone_path} | 129 | cd ${git_clone_path} |
| @@ -117,8 +133,8 @@ bash build.sh --pkg --soc=ascend910b --vendor_name=custom --ops=weight_quant_ba | |||
| 117 | ./build_out/cann-ops-nn-${vendor_name}-${arch}_linux.run | 133 | ./build_out/cann-ops-nn-${vendor_name}-${arch}_linux.run |
| 118 | ``` | 134 | ``` |
| 119 | 135 | ||
| 120 | - | ||
| 121 | - 编译+执行aclnn接口样例,采集样例性能: | 136 | - 编译+执行aclnn接口样例,采集样例性能: |
| 137 | + | ||
| 122 | ```bash | 138 | ```bash |
| 123 | # 切换weight_quant_batch_matmul_experiment aclnn执行用例目录 | 139 | # 切换weight_quant_batch_matmul_experiment aclnn执行用例目录 |
| 124 | cd ${git_clone_path}/experimental/matmul/weight_quant_batch_matmul_experiment/examples | 140 | cd ${git_clone_path}/experimental/matmul/weight_quant_batch_matmul_experiment/examples |
| @@ -129,19 +145,23 @@ cd ${git_clone_path}/experimental/matmul/weight_quant_batch_matmul_experiment/ex | |||
| 129 | ``` | 145 | ``` |
| 130 | 146 | ||
| 131 | ## 流水设计 | 147 | ## 流水设计 |
| 148 | + | ||
| 132 | ### 基础流水模板 | 149 | ### 基础流水模板 |
| 150 | + | ||
| 133 | 该模板实现如下流水: | 151 | 该模板实现如下流水: |
| 134 |  | 152 |  |
| 135 | 在前处理模块中,多个核产生后处理模块依赖的$A_{max}$和矩阵计算模块依赖的$A_{int}$。在矩阵计算模块中产生后处理模块依赖的$C_{int}$。因此这些模块执行结束后都需要执行一次全核同步,保证下个模块处理的时候上一个模块已完全使用完数据,避免数据踩踏。 | 153 | 在前处理模块中,多个核产生后处理模块依赖的$A_{max}$和矩阵计算模块依赖的$A_{int}$。在矩阵计算模块中产生后处理模块依赖的$C_{int}$。因此这些模块执行结束后都需要执行一次全核同步,保证下个模块处理的时候上一个模块已完全使用完数据,避免数据踩踏。 |
| 136 | 154 | ||
| 137 | ### Preload流水模板 | 155 | ### Preload流水模板 |
| 156 | + | ||
| 138 | 该模板实现如下流水: | 157 | 该模板实现如下流水: |
| 139 |  | 158 |  |
| 140 | 前处理计算单元可以连续执行两轮,实现当前轮的矩阵计算模板处理和上一轮的后处理模块、下一轮的前处理模块实现并行计算的效果。 | 159 | 前处理计算单元可以连续执行两轮,实现当前轮的矩阵计算模板处理和上一轮的后处理模块、下一轮的前处理模块实现并行计算的效果。 |
| 141 | 160 | ||
| 142 | ## 性能分析 | 161 | ## 性能分析 |
| 162 | + | ||
| 143 | preload流水模板通过流水优化,可以在相同的计算逻辑下实现显著的性能提升,基于Atlas A2进行测试,可以得到如下数据: | 163 | preload流水模板通过流水优化,可以在相同的计算逻辑下实现显著的性能提升,基于Atlas A2进行测试,可以得到如下数据: |
| 144 | <table> | 164 | <table> |
| 145 | <tr><td rowspan="1" align="center">模板类型</td><td colspan="4" align="center">基础流水模板(us)</td><td colspan="4" align="center">preload流水模板(us)</td></tr> | 165 | <tr><td rowspan="1" align="center">模板类型</td><td colspan="4" align="center">基础流水模板(us)</td><td colspan="4" align="center">preload流水模板(us)</td></tr> |
| 146 | <tr><td rowspan="1" align="center">算子耗时</td><td colspan="4" align="center">396</td><td colspan="4" align="center">303</td></tr> | 166 | <tr><td rowspan="1" align="center">算子耗时</td><td colspan="4" align="center">396</td><td colspan="4" align="center">303</td></tr> |
| 147 | - </table> | 167 | + </table> |
| @@ -1,4 +1,5 @@ | |||
| 1 | -## 目录结构介绍 | 1 | +# 目录结构介绍 |
| 2 | + | ||
| 2 | ``` | 3 | ``` |
| 3 | ├── examples // 通过aclnn调用的方式调用WeightQuantBatchMatmulExperiment算子 | 4 | ├── examples // 通过aclnn调用的方式调用WeightQuantBatchMatmulExperiment算子 |
| 4 | │ ├── inc // 头文件目录 | 5 | │ ├── inc // 头文件目录 |
| @@ -10,6 +11,7 @@ | |||
| 10 | ``` | 11 | ``` |
| 11 | 12 | ||
| 12 | ## 代码实现介绍 | 13 | ## 代码实现介绍 |
| 14 | + | ||
| 13 | 完成自定义算子的开发部署后,可以通过单算子调用的方式来验证单算子的功能。src/main.cpp代码为单算子API执行方式。单算子API执行是基于C语言的API执行算子,无需提供单算子描述文件进行离线模型的转换,直接调用单算子API接口。 | 15 | 完成自定义算子的开发部署后,可以通过单算子调用的方式来验证单算子的功能。src/main.cpp代码为单算子API执行方式。单算子API执行是基于C语言的API执行算子,无需提供单算子描述文件进行离线模型的转换,直接调用单算子API接口。 |
| 14 | 16 | ||
| 15 | 自定义算子编译部署后,会自动生成单算子API,可以直接在应用程序中调用。算子API的形式一般定义为“两段式接口”,形如: | 17 | 自定义算子编译部署后,会自动生成单算子API,可以直接在应用程序中调用。算子API的形式一般定义为“两段式接口”,形如: |
| @@ -19,15 +21,22 @@ | |||
| 19 | aclnnStatus aclnnWeightQuantBatchMatmulExperimentGetWorkspaceSize(const aclTensor *a, const aclTensor *b, const aclTensor *bias, bool transposeX1, bool transposeX2, const aclTensor *out, uint64_t *workspaceSize, aclOpExecutor **executor); | 21 | aclnnStatus aclnnWeightQuantBatchMatmulExperimentGetWorkspaceSize(const aclTensor *a, const aclTensor *b, const aclTensor *bias, bool transposeX1, bool transposeX2, const aclTensor *out, uint64_t *workspaceSize, aclOpExecutor **executor); |
| 20 | // 执行算子 | 22 | // 执行算子 |
| 21 | aclnnStatus aclnnWeightQuantBatchMatmulExperiment(void *workspace, uint64_t workspaceSize, aclOpExecutor *executor, aclrtStream stream); | 23 | aclnnStatus aclnnWeightQuantBatchMatmulExperiment(void *workspace, uint64_t workspaceSize, aclOpExecutor *executor, aclrtStream stream); |
| 24 | + | ||
| 22 | ``` | 25 | ``` |
| 26 | + | ||
| 23 | 其中aclnnWeightQuantBatchMatmulExperimentGetWorkspaceSize为第一段接口,主要用于计算本次API调用计算过程中需要多少的workspace内存。获取到本次API计算需要的workspace大小后,按照workspaceSize大小申请Device侧内存,然后调用第二段接口aclnnWeightQuantBatchMatmulExperiment执行计算。具体请参考[单算子API调用](https://hiascend.com/document/redirect/CannCommunityAscendCInVorkSingleOp)章节。 | 27 | 其中aclnnWeightQuantBatchMatmulExperimentGetWorkspaceSize为第一段接口,主要用于计算本次API调用计算过程中需要多少的workspace内存。获取到本次API计算需要的workspace大小后,按照workspaceSize大小申请Device侧内存,然后调用第二段接口aclnnWeightQuantBatchMatmulExperiment执行计算。具体请参考[单算子API调用](https://hiascend.com/document/redirect/CannCommunityAscendCInVorkSingleOp)章节。 |
| 24 | 28 | ||
| 25 | ## 运行样例算子 | 29 | ## 运行样例算子 |
| 30 | + | ||
| 26 | ### 1. 编译算子工程 | 31 | ### 1. 编译算子工程 |
| 32 | + | ||
| 27 | 运行此样例前,请参考[编译算子工程](../README.md#operatorcompile)完成前期准备。 | 33 | 运行此样例前,请参考[编译算子工程](../README.md#operatorcompile)完成前期准备。 |
| 34 | + | ||
| 28 | ### 2. aclnn调用样例运行 | 35 | ### 2. aclnn调用样例运行 |
| 29 | - - 进入到样例目录 | 36 | + |
| 37 | + - 进入到样例目录 | ||
| 30 | 以命令行方式下载样例代码,master分支为例。 | 38 | 以命令行方式下载样例代码,master分支为例。 |
| 39 | + | ||
| 31 | ```bash | 40 | ```bash |
| 32 | cd ${git_clone_path}/experimental/matmul/weight_quant_batch_matmul_experiment/examples | 41 | cd ${git_clone_path}/experimental/matmul/weight_quant_batch_matmul_experiment/examples |
| 33 | ``` | 42 | ``` |
| @@ -35,11 +44,13 @@ aclnnStatus aclnnWeightQuantBatchMatmulExperiment(void *workspace, uint64_t work | |||
| 35 | - 样例执行 | 44 | - 样例执行 |
| 36 | 45 | ||
| 37 | 样例执行过程中会自动生成测试数据,然后编译与运行aclnn样例,检验运行结果并采集性能数据,。具体过程可参见run.sh脚本。 | 46 | 样例执行过程中会自动生成测试数据,然后编译与运行aclnn样例,检验运行结果并采集性能数据,。具体过程可参见run.sh脚本。 |
| 47 | + | ||
| 38 | ```bash | 48 | ```bash |
| 39 | bash run.sh | 49 | bash run.sh |
| 40 | ``` | 50 | ``` |
| 41 | 51 | ||
| 42 | ## 更新说明 | 52 | ## 更新说明 |
| 53 | + | ||
| 43 | | 时间 | 更新事项 | | 54 | | 时间 | 更新事项 | |
| 44 | | ---------- | ------------ | | 55 | | ---------- | ------------ | |
| 45 | | 2026/01/06 | 新增本readme | | 56 | | 2026/01/06 | 新增本readme | |
| @@ -1,6 +1,6 @@ | |||
| 1 | # ApplyTopKTopPWithSorted | 1 | # ApplyTopKTopPWithSorted |
| 2 | 2 | ||
| 3 | -## 产品支持情况 | 3 | +## 产品支持情况 |
| 4 | 4 | ||
| 5 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| 6 | | :----------------------------------------------------------- | :------: | | 6 | | :----------------------------------------------------------- | :------: | |
| @@ -108,13 +108,13 @@ | |||
| 108 | </tbody></table> | 108 | </tbody></table> |
| 109 | 109 | ||
| 110 | - Kirin X90/Kirin 9030处理器系列产品:不支持BFLOAT16。 | 110 | - Kirin X90/Kirin 9030处理器系列产品:不支持BFLOAT16。 |
| 111 | -## 约束说明 | ||
| 112 | -无。 | ||
| 113 | 111 | ||
| 112 | +## 约束说明 | ||
| 113 | + | ||
| 114 | +无。 | ||
| 114 | 115 | ||
| 115 | ## 调用说明 | 116 | ## 调用说明 |
| 116 | 117 | ||
| 117 | | 调用方式 | 样例代码 | 说明 | | 118 | | 调用方式 | 样例代码 | 说明 | |
| 118 | | ---------------- | --------------------------- | --------------------------------------------------- | | 119 | | ---------------- | --------------------------- | --------------------------------------------------- | |
| 119 | | aclnn接口 | [test_aclnn_apply_top_k_top_p.cpp](examples/test_aclnn_apply_top_k_top_p.cpp) | 通过[aclnnApplyTopKTopP](docs/aclnnApplyTopKTopP.md)接口方式调用ApplyTopKTopPWithSorted算子。 | | 120 | | aclnn接口 | [test_aclnn_apply_top_k_top_p.cpp](examples/test_aclnn_apply_top_k_top_p.cpp) | 通过[aclnnApplyTopKTopP](docs/aclnnApplyTopKTopP.md)接口方式调用ApplyTopKTopPWithSorted算子。 | |
| 120 | - | ||
| @@ -56,6 +56,7 @@ | |||
| 56 | ## 函数原型 | 56 | ## 函数原型 |
| 57 | 57 | ||
| 58 | 每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnApplyTopKTopPGetWorkspaceSize”接口获取计算所需workspace大小以及包含了算子计算流程的执行器,再调用“aclnnApplyTopKTopP”接口执行计算。 | 58 | 每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnApplyTopKTopPGetWorkspaceSize”接口获取计算所需workspace大小以及包含了算子计算流程的执行器,再调用“aclnnApplyTopKTopP”接口执行计算。 |
| 59 | + | ||
| 59 | ```Cpp | 60 | ```Cpp |
| 60 | aclnnStatus aclnnApplyTopKTopPGetWorkspaceSize( | 61 | aclnnStatus aclnnApplyTopKTopPGetWorkspaceSize( |
| 61 | const aclTensor* logits, | 62 | const aclTensor* logits, |
| @@ -19,19 +19,23 @@ | |||
| 19 | - <term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>、<term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas 推理系列产品</term>、<term>Atlas 训练系列产品</term>: | 19 | - <term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>、<term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas 推理系列产品</term>、<term>Atlas 训练系列产品</term>: |
| 20 | 20 | ||
| 21 | - 当mode为sum模式: | 21 | - 当mode为sum模式: |
| 22 | + | ||
| 22 | ``` | 23 | ``` |
| 23 | output的shape为includeLastOffset ? (bagOffsets - 1, embeddingDim) : (bagOffsets, embeddingDim) | 24 | output的shape为includeLastOffset ? (bagOffsets - 1, embeddingDim) : (bagOffsets, embeddingDim) |
| 24 | offset2bag的shape 为 (bagIndices,) | 25 | offset2bag的shape 为 (bagIndices,) |
| 25 | bagSize的shape为includeLastOffset ? (bagOffsets - 1) : (bagOffsets,) | 26 | bagSize的shape为includeLastOffset ? (bagOffsets - 1) : (bagOffsets,) |
| 26 | maxIndices的shape为includeLastOffset ? (bagOffsets - 1) : (bagOffsets,) | 27 | maxIndices的shape为includeLastOffset ? (bagOffsets - 1) : (bagOffsets,) |
| 27 | ``` | 28 | ``` |
| 29 | + | ||
| 28 | - 当mode为mean模式: | 30 | - 当mode为mean模式: |
| 31 | + | ||
| 29 | ``` | 32 | ``` |
| 30 | output的shape为includeLastOffset? (bagOffsets - 1, embeddingDim) : (bagOffsets, embeddingDim) | 33 | output的shape为includeLastOffset? (bagOffsets - 1, embeddingDim) : (bagOffsets, embeddingDim) |
| 31 | offset2bag的shape为(bagIndices,) | 34 | offset2bag的shape为(bagIndices,) |
| 32 | bagSize的shape为includeLastOffset ? (bagOffsets - 1) : (bagOffsets,) | 35 | bagSize的shape为includeLastOffset ? (bagOffsets - 1) : (bagOffsets,) |
| 33 | maxIndices的shape为includeLastOffset ? (bagOffsets - 1) : (bagOffsets,) | 36 | maxIndices的shape为includeLastOffset ? (bagOffsets - 1) : (bagOffsets,) |
| 34 | ``` | 37 | ``` |
| 38 | + | ||
| 35 | - 当mode为max模式: | 39 | - 当mode为max模式: |
| 36 | ``` | 40 | ``` |
| 37 | output的shape为includeLastOffset ? (bagOffsets - 1, embeddingDim) : (bagOffsets, embeddingDim) | 41 | output的shape为includeLastOffset ? (bagOffsets - 1, embeddingDim) : (bagOffsets, embeddingDim) |
| @@ -39,6 +43,7 @@ | |||
| 39 | bagSize的shape为includeLastOffset ? (bagOffsets - 1) : (bagOffsets,) | 43 | bagSize的shape为includeLastOffset ? (bagOffsets - 1) : (bagOffsets,) |
| 40 | maxIndices的shape为includeLastOffset ? (bagOffsets - 1, embeddingDim) : (bagOffsets, embeddingDim) | 44 | maxIndices的shape为includeLastOffset ? (bagOffsets - 1, embeddingDim) : (bagOffsets, embeddingDim) |
| 41 | ``` | 45 | ``` |
| 46 | + | ||
| 42 | - <term>Ascend 950PR/Ascend 950DT</term>: | 47 | - <term>Ascend 950PR/Ascend 950DT</term>: |
| 43 | - 当mode为sum模式: | 48 | - 当mode为sum模式: |
| 44 | ``` | 49 | ``` |
| @@ -47,6 +52,7 @@ | |||
| 47 | bagSize的shape为(bagOffsets,) | 52 | bagSize的shape为(bagOffsets,) |
| 48 | maxIndices的shape为(0,) | 53 | maxIndices的shape为(0,) |
| 49 | ``` | 54 | ``` |
| 55 | + | ||
| 50 | - 当mode为mean模式: | 56 | - 当mode为mean模式: |
| 51 | ``` | 57 | ``` |
| 52 | output的shape为includeLastOffset? (bagOffsets - 1, embeddingDim) : (bagOffsets, embeddingDim) | 58 | output的shape为includeLastOffset? (bagOffsets - 1, embeddingDim) : (bagOffsets, embeddingDim) |
| @@ -54,6 +60,7 @@ | |||
| 54 | bagSize的shape为bagOffsets | 60 | bagSize的shape为bagOffsets |
| 55 | maxIndices的shape为(0,) | 61 | maxIndices的shape为(0,) |
| 56 | ``` | 62 | ``` |
| 63 | + | ||
| 57 | - 当mode为max模式: | 64 | - 当mode为max模式: |
| 58 | ``` | 65 | ``` |
| 59 | output的shape为includeLastOffset ? (bagOffsets - 1, embeddingDim) : (bagOffsets, embeddingDim) | 66 | output的shape为includeLastOffset ? (bagOffsets - 1, embeddingDim) : (bagOffsets, embeddingDim) |
| @@ -271,7 +278,7 @@ aclnnStatus aclnnEmbeddingBag( | |||
| 271 | </tr> | 278 | </tr> |
| 272 | </tbody></table> | 279 | </tbody></table> |
| 273 | 280 | ||
| 274 | - - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term> indices仅支持0-1维, perSampleWeights仅支持1维 。 | 281 | + - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term> indices仅支持0-1维, perSampleWeights仅支持1维。 |
| 275 | 282 | ||
| 276 | - **返回值** | 283 | - **返回值** |
| 277 | 284 | ||
| @@ -105,4 +105,4 @@ | |||
| 105 | 105 | ||
| 106 | | 调用方式 | 调用样例 | 说明 | | 106 | | 调用方式 | 调用样例 | 说明 | |
| 107 | |--------------|------------------------------------------------------------------------|--------------------------------------------------------------| | 107 | |--------------|------------------------------------------------------------------------|--------------------------------------------------------------| |
| 108 | - | aclnn调用 | [test_aclnn_embedding_dense_grad](./examples/test_aclnn_embedding_dense_grad.cpp) | 通过[aclnnEmbeddingDenseBackward](./docs/aclnnEmbeddingDenseBackward.md)接口方式调用EmbeddingDenseGrad算子。 | | 108 | + | aclnn调用 | [test_aclnn_embedding_dense_grad](./examples/test_aclnn_embedding_dense_grad.cpp) | 通过[aclnnEmbeddingDenseBackward](./docs/aclnnEmbeddingDenseBackward.md)接口方式调用EmbeddingDenseGrad算子。 | |
| @@ -54,7 +54,6 @@ | |||
| 54 | 54 | ||
| 55 | ## aclnnEmbeddingDenseBackward | 55 | ## aclnnEmbeddingDenseBackward |
| 56 | 56 | ||
| 57 | - | ||
| 58 | - **参数说明:** | 57 | - **参数说明:** |
| 59 | 58 | ||
| 60 | * workspace(void *, 入参): 在Device侧申请的workspace内存地址。 | 59 | * workspace(void *, 入参): 在Device侧申请的workspace内存地址。 |
| @@ -67,6 +66,7 @@ | |||
| 67 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 66 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| 68 | 67 | ||
| 69 | ## 约束说明 | 68 | ## 约束说明 |
| 69 | + | ||
| 70 | - <term>Atlas 训练系列产品</term>: | 70 | - <term>Atlas 训练系列产品</term>: |
| 71 | - 对于scale为true的场景,设定grad最后一维为embeddingDim,其大小超出指定范围时会被拦截报错。其合理范围如下: | 71 | - 对于scale为true的场景,设定grad最后一维为embeddingDim,其大小超出指定范围时会被拦截报错。其合理范围如下: |
| 72 | - indices为int32时,需满足 | 72 | - indices为int32时,需满足 |
| @@ -88,6 +88,7 @@ | |||
| 88 | - indices合轴后维度超过INT32_INF(2139095040)时,无法保证高性能 | 88 | - indices合轴后维度超过INT32_INF(2139095040)时,无法保证高性能 |
| 89 | 89 | ||
| 90 | ## 调用示例 | 90 | ## 调用示例 |
| 91 | + | ||
| 91 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 92 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| 92 | 93 | ||
| 93 | ```Cpp | 94 | ```Cpp |
| @@ -236,4 +237,4 @@ int main() { | |||
| 236 | aclFinalize(); | 237 | aclFinalize(); |
| 237 | return 0; | 238 | return 0; |
| 238 | } | 239 | } |
| 239 | -``` | 240 | +``` |
| @@ -1,6 +1,6 @@ | |||
| 1 | # EmbeddingDenseGradV2 | 1 | # EmbeddingDenseGradV2 |
| 2 | 2 | ||
| 3 | -## 产品支持情况 | 3 | +## 产品支持情况 |
| 4 | 4 | ||
| 5 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| 6 | | :----------------------------------------------------------- | :------: | | 6 | | :----------------------------------------------------------- | :------: | |
| @@ -10,6 +10,7 @@ | |||
| 10 | | <term>Atlas 200I/500 A2 推理产品</term> | × | | 10 | | <term>Atlas 200I/500 A2 推理产品</term> | × | |
| 11 | | <term>Atlas 推理系列产品</term> | × | | 11 | | <term>Atlas 推理系列产品</term> | × | |
| 12 | | <term>Atlas 训练系列产品</term> | √ | | 12 | | <term>Atlas 训练系列产品</term> | √ | |
| 13 | + | ||
| 13 | ## 功能说明 | 14 | ## 功能说明 |
| 14 | 15 | ||
| 15 | 实现[aclnnEmbedding](../../gather_v2/docs/aclnnEmbedding.md)的反向计算, 将相同索引`indices`对应`grad`的一行累加到`out`上。 | 16 | 实现[aclnnEmbedding](../../gather_v2/docs/aclnnEmbedding.md)的反向计算, 将相同索引`indices`对应`grad`的一行累加到`out`上。 |
| @@ -38,6 +38,7 @@ aclnnStatus aclnnExpandIntoJaggedPermuteGetWorkspaceSize( | |||
| 38 | uint64_t *workspaceSize, | 38 | uint64_t *workspaceSize, |
| 39 | aclOpExecutor **executor) | 39 | aclOpExecutor **executor) |
| 40 | ``` | 40 | ``` |
| 41 | + | ||
| 41 | ```c++ | 42 | ```c++ |
| 42 | aclnnStatus aclnnExpandIntoJaggedPermute( | 43 | aclnnStatus aclnnExpandIntoJaggedPermute( |
| 43 | void *workspace, | 44 | void *workspace, |
| @@ -470,4 +471,4 @@ int main() { | |||
| 470 | 471 | ||
| 471 | return 0; | 472 | return 0; |
| 472 | } | 473 | } |
| 473 | -``` | 474 | +``` |
| @@ -158,7 +158,6 @@ aclnnStatus aclnnMaxUnpool2dBackward( | |||
| 158 | </tr> | 158 | </tr> |
| 159 | </tbody></table> | 159 | </tbody></table> |
| 160 | 160 | ||
| 161 | - | ||
| 162 | - **返回值:** | 161 | - **返回值:** |
| 163 | 162 | ||
| 164 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 163 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| @@ -259,7 +258,6 @@ aclnnStatus aclnnMaxUnpool2dBackward( | |||
| 259 | </tbody> | 258 | </tbody> |
| 260 | </table> | 259 | </table> |
| 261 | 260 | ||
| 262 | - | ||
| 263 | - **返回值:** | 261 | - **返回值:** |
| 264 | 262 | ||
| 265 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 263 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| @@ -269,10 +267,10 @@ aclnnStatus aclnnMaxUnpool2dBackward( | |||
| 269 | - 确定性计算: | 267 | - 确定性计算: |
| 270 | - aclnnMaxUnpool2dBackward默认确定性实现。 | 268 | - aclnnMaxUnpool2dBackward默认确定性实现。 |
| 271 | 269 | ||
| 272 | - | ||
| 273 | ## 调用示例 | 270 | ## 调用示例 |
| 274 | 271 | ||
| 275 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 272 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| 273 | + | ||
| 276 | ```Cpp | 274 | ```Cpp |
| 277 | #include <iostream> | 275 | #include <iostream> |
| 278 | #include <vector> | 276 | #include <vector> |
| @@ -432,4 +430,3 @@ int main() { | |||
| 432 | return 0; | 430 | return 0; |
| 433 | } | 431 | } |
| 434 | ``` | 432 | ``` |
| 435 | - | ||
| @@ -11,7 +11,6 @@ | |||
| 11 | | <term>Atlas 推理系列产品</term> | × | | 11 | | <term>Atlas 推理系列产品</term> | × | |
| 12 | | <term>Atlas 训练系列产品</term> | × | | 12 | | <term>Atlas 训练系列产品</term> | × | |
| 13 | 13 | ||
| 14 | - | ||
| 15 | ## 功能说明 | 14 | ## 功能说明 |
| 16 | 15 | ||
| 17 | - 接口功能:对于维度为**r≥1**的输入张量`self`,和维度**q≥1**的输入张量`indices`,将数据切片收集到维度为 **(q-1) + (r - indices_shape[-1])** 的输出张量out中。indices是一个**q**维的整型张量,可视作一个**q-1**维的由**索引对**构成的特殊张量(每个**索引对**是一个长度为**indices_shape[-1]**的一维张量,每个**索引对**指向**self**中一个切片)。 | 16 | - 接口功能:对于维度为**r≥1**的输入张量`self`,和维度**q≥1**的输入张量`indices`,将数据切片收集到维度为 **(q-1) + (r - indices_shape[-1])** 的输出张量out中。indices是一个**q**维的整型张量,可视作一个**q-1**维的由**索引对**构成的特殊张量(每个**索引对**是一个长度为**indices_shape[-1]**的一维张量,每个**索引对**指向**self**中一个切片)。 |
| @@ -36,6 +36,7 @@ | |||
| 36 | ## 函数原型 | 36 | ## 函数原型 |
| 37 | 37 | ||
| 38 | 每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnEmbeddingRenormGetWorkspaceSize”接口获取计算所需workspace大小以及包含了算子计算流程的执行器,再调用“aclnnEmbeddingRenorm”接口执行计算。 | 38 | 每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnEmbeddingRenormGetWorkspaceSize”接口获取计算所需workspace大小以及包含了算子计算流程的执行器,再调用“aclnnEmbeddingRenorm”接口执行计算。 |
| 39 | + | ||
| 39 | ```Cpp | 40 | ```Cpp |
| 40 | aclnnStatus aclnnEmbeddingRenormGetWorkspaceSize( | 41 | aclnnStatus aclnnEmbeddingRenormGetWorkspaceSize( |
| 41 | aclTensor *selfRef, | 42 | aclTensor *selfRef, |
| @@ -45,6 +46,7 @@ aclnnStatus aclnnEmbeddingRenormGetWorkspaceSize( | |||
| 45 | uint64_t *workspaceSize, | 46 | uint64_t *workspaceSize, |
| 46 | aclOpExecutor **executor) | 47 | aclOpExecutor **executor) |
| 47 | ``` | 48 | ``` |
| 49 | + | ||
| 48 | ```Cpp | 50 | ```Cpp |
| 49 | aclnnStatus aclnnEmbeddingRenorm( | 51 | aclnnStatus aclnnEmbeddingRenorm( |
| 50 | void *workspace, | 52 | void *workspace, |
| @@ -18,6 +18,7 @@ | |||
| 18 | 接口功能:返回所有元素的中位数(若总元素个数为size,则中位数对应排序后的下标为`(size - 1) // 2`)。 | 18 | 接口功能:返回所有元素的中位数(若总元素个数为size,则中位数对应排序后的下标为`(size - 1) // 2`)。 |
| 19 | 19 | ||
| 20 | ## 函数原型 | 20 | ## 函数原型 |
| 21 | + | ||
| 21 | 每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnMedianGetWorkspaceSize”接口获取计算所需workspace大小以及包含了算子计算流程的执行器,再调用“aclnnMedian”接口执行计算。 | 22 | 每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnMedianGetWorkspaceSize”接口获取计算所需workspace大小以及包含了算子计算流程的执行器,再调用“aclnnMedian”接口执行计算。 |
| 22 | 23 | ||
| 23 | ```cpp | 24 | ```cpp |
| @@ -189,7 +190,8 @@ aclnnStatus aclnnMedian( | |||
| 189 | - 确定性计算: | 190 | - 确定性计算: |
| 190 | - aclnnMedian默认确定性实现。 | 191 | - aclnnMedian默认确定性实现。 |
| 191 | 192 | ||
| 192 | -- self的数据类型不为FLOAT、FLOAT16、BFLOAT16时,tensor size过大可能会导致算子执行超时(aicpu error类型报错,报错 reason=[aicpu timeout])具体类型最大size(与机器具体剩余内存强相关) 限制如下: | 193 | +- self的数据类型不为FLOAT、FLOAT16、BFLOAT16时,tensor size过大可能会导致算子执行超时(aicpu error类型报错,报错 reason=[aicpu timeout])具体类型最大size(与机器具体剩余内存强相关) 限制如下: |
| 194 | + | ||
| 193 | - INT64 类型:150000000 | 195 | - INT64 类型:150000000 |
| 194 | - UINT8、INT8、INT16、INT32 类型:725000000 | 196 | - UINT8、INT8、INT16、INT32 类型:725000000 |
| 195 | - 当self为BFLOAT16数据类型时,不支持尾轴为1。 | 197 | - 当self为BFLOAT16数据类型时,不支持尾轴为1。 |
| @@ -385,4 +385,4 @@ int main() { | |||
| 385 | aclFinalize(); | 385 | aclFinalize(); |
| 386 | return 0; | 386 | return 0; |
| 387 | } | 387 | } |
| 388 | -``` | 388 | +``` |
| @@ -337,4 +337,4 @@ int main() { | |||
| 337 | aclFinalize(); | 337 | aclFinalize(); |
| 338 | return 0; | 338 | return 0; |
| 339 | } | 339 | } |
| 340 | -``` | 340 | +``` |
| @@ -24,6 +24,7 @@ | |||
| 24 | 假设self的shape为[2, 3, 4],dim = 1,keepDim为true,则输出shape为[2, 1, 4]。 | 24 | 假设self的shape为[2, 3, 4],dim = 1,keepDim为true,则输出shape为[2, 1, 4]。 |
| 25 | 假设self的shape为[2, 3, 4],dim = 1,keepDim为false,则输出shape为[2, 4]。 | 25 | 假设self的shape为[2, 3, 4],dim = 1,keepDim为false,则输出shape为[2, 4]。 |
| 26 | ``` | 26 | ``` |
| 27 | + | ||
| 27 | - 示例2: | 28 | - 示例2: |
| 28 | ``` | 29 | ``` |
| 29 | 关于输出shape的示例 | 30 | 关于输出shape的示例 |
| @@ -35,6 +36,7 @@ | |||
| 35 | valuesOut = tensor([[-1., float('nan'), 3., 2.]]) shape为[1, 4] | 36 | valuesOut = tensor([[-1., float('nan'), 3., 2.]]) shape为[1, 4] |
| 36 | indicesOut = tensor([[1, 0, 0, 0]]) shape为[1, 4] | 37 | indicesOut = tensor([[1, 0, 0, 0]]) shape为[1, 4] |
| 37 | ``` | 38 | ``` |
| 39 | + | ||
| 38 | - 示例3: | 40 | - 示例3: |
| 39 | ``` | 41 | ``` |
| 40 | 若输入 | 42 | 若输入 |
| @@ -45,6 +47,7 @@ | |||
| 45 | valuesOut = tensor([-1., float('nan'), 3., 2.]) shape为[4] | 47 | valuesOut = tensor([-1., float('nan'), 3., 2.]) shape为[4] |
| 46 | indicesOut = tensor([1, 0, 0, 0]) shape为[4] | 48 | indicesOut = tensor([1, 0, 0, 0]) shape为[4] |
| 47 | ``` | 49 | ``` |
| 50 | + | ||
| 48 | - 示例4: | 51 | - 示例4: |
| 49 | ``` | 52 | ``` |
| 50 | 若输入 | 53 | 若输入 |
| @@ -1,6 +1,6 @@ | |||
| 1 | # IndexFillD | 1 | # IndexFillD |
| 2 | 2 | ||
| 3 | -## 产品支持情况 | 3 | +## 产品支持情况 |
| 4 | 4 | ||
| 5 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| 6 | | :----------------------------------------------------------- | :------: | | 6 | | :----------------------------------------------------------- | :------: | |
| @@ -41,7 +41,6 @@ | |||
| 41 | 41 | ||
| 42 | ## 参数说明 | 42 | ## 参数说明 |
| 43 | 43 | ||
| 44 | - | ||
| 45 | <table style="undefined;table-layout: fixed; width: 980px"><colgroup> | 44 | <table style="undefined;table-layout: fixed; width: 980px"><colgroup> |
| 46 | <col style="width: 100px"> | 45 | <col style="width: 100px"> |
| 47 | <col style="width: 150px"> | 46 | <col style="width: 150px"> |
| @@ -98,6 +97,7 @@ | |||
| 98 | ## 约束说明 | 97 | ## 约束说明 |
| 99 | 98 | ||
| 100 | 无 | 99 | 无 |
| 100 | + | ||
| 101 | ## 调用说明 | 101 | ## 调用说明 |
| 102 | 102 | ||
| 103 | | 调用方式 | 调用样例 | 说明 | | 103 | | 调用方式 | 调用样例 | 说明 | |
| @@ -1,6 +1,6 @@ | |||
| 1 | # aclnnIndexFillTensor&aclnnInplaceIndexFillTensor | 1 | # aclnnIndexFillTensor&aclnnInplaceIndexFillTensor |
| 2 | 2 | ||
| 3 | -## 产品支持情况 | 3 | +## 产品支持情况 |
| 4 | 4 | ||
| 5 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| 6 | | :----------------------------------------------------------- | :------: | | 6 | | :----------------------------------------------------------- | :------: | |
| @@ -442,7 +442,6 @@ aclnnStatus aclnnInplaceIndexFillTensor( | |||
| 442 | - 确定性计算: | 442 | - 确定性计算: |
| 443 | - aclnnIndexFillTensor&aclnnInplaceIndexFillTensor默认确定性实现。 | 443 | - aclnnIndexFillTensor&aclnnInplaceIndexFillTensor默认确定性实现。 |
| 444 | 444 | ||
| 445 | - | ||
| 446 | ## 调用示例 | 445 | ## 调用示例 |
| 447 | 446 | ||
| 448 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 447 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| @@ -13,7 +13,6 @@ | |||
| 13 | | <term>Atlas 推理系列产品</term> | × | | 13 | | <term>Atlas 推理系列产品</term> | × | |
| 14 | | <term>Atlas 训练系列产品</term> | √ | | 14 | | <term>Atlas 训练系列产品</term> | √ | |
| 15 | 15 | ||
| 16 | - | ||
| 17 | ## 功能说明 | 16 | ## 功能说明 |
| 18 | 17 | ||
| 19 | - 接口功能:根据索引 indices 将输入 self 对应坐标的数据与输入 values 进行替换或累加。 | 18 | - 接口功能:根据索引 indices 将输入 self 对应坐标的数据与输入 values 进行替换或累加。 |
| @@ -1,6 +1,6 @@ | |||
| 1 | # IndexPutWithSort | 1 | # IndexPutWithSort |
| 2 | 2 | ||
| 3 | -## 产品支持情况 | 3 | +## 产品支持情况 |
| 4 | 4 | ||
| 5 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| 6 | | :----------------------------------------------------------- | :------: | | 6 | | :----------------------------------------------------------- | :------: | |
| @@ -84,6 +84,7 @@ | |||
| 84 | </tbody></table> | 84 | </tbody></table> |
| 85 | 85 | ||
| 86 | - Kirin X90/Kirin 9030处理器系列产品:var和value的数据类型不支持BFLOAT16。 | 86 | - Kirin X90/Kirin 9030处理器系列产品:var和value的数据类型不支持BFLOAT16。 |
| 87 | + | ||
| 87 | ## 约束说明 | 88 | ## 约束说明 |
| 88 | 89 | ||
| 89 | 无 | 90 | 无 |
| @@ -92,4 +93,4 @@ | |||
| 92 | 93 | ||
| 93 | | 调用方式 | 调用样例 | 说明 | | 94 | | 调用方式 | 调用样例 | 说明 | |
| 94 | |--------------|------------------------------------------------------------------------|--------------------------------------------------------------| | 95 | |--------------|------------------------------------------------------------------------|--------------------------------------------------------------| |
| 95 | -| aclnn调用 | [test_aclnn_index_add](../inplace_scatter_add/examples/test_aclnn_index_add.cpp) | 通过[aclnnIndexAdd](../inplace_scatter_add/docs/aclnnIndexAdd.md)接口方式调用InplaceIndexAddWithSorted算子。 | | 96 | +| aclnn调用 | [test_aclnn_index_add](../inplace_scatter_add/examples/test_aclnn_index_add.cpp) | 通过[aclnnIndexAdd](../inplace_scatter_add/docs/aclnnIndexAdd.md)接口方式调用InplaceIndexAddWithSorted算子。 | |
| @@ -11,7 +11,6 @@ | |||
| 11 | | <term>Atlas 推理系列产品</term> | × | | 11 | | <term>Atlas 推理系列产品</term> | × | |
| 12 | | <term>Atlas 训练系列产品</term> | × | | 12 | | <term>Atlas 训练系列产品</term> | × | |
| 13 | 13 | ||
| 14 | - | ||
| 15 | ## 功能说明 | 14 | ## 功能说明 |
| 16 | 15 | ||
| 17 | - 算子功能:根据给定的indices,将updates中的值加到输入张量var的第一维度上。 | 16 | - 算子功能:根据给定的indices,将updates中的值加到输入张量var的第一维度上。 |
| @@ -13,7 +13,6 @@ | |||
| 13 | | <term>Atlas 推理系列产品</term> | × | | 13 | | <term>Atlas 推理系列产品</term> | × | |
| 14 | | <term>Atlas 训练系列产品</term> | × | | 14 | | <term>Atlas 训练系列产品</term> | × | |
| 15 | 15 | ||
| 16 | - | ||
| 17 | ## 功能说明 | 16 | ## 功能说明 |
| 18 | 17 | ||
| 19 | 在指定维度上,根据给定的索引,将源张量中的值加到输入张量中对应位置的值上。 | 18 | 在指定维度上,根据给定的索引,将源张量中的值加到输入张量中对应位置的值上。 |
| @@ -66,6 +66,7 @@ | |||
| 66 | </tbody></table> | 66 | </tbody></table> |
| 67 | 67 | ||
| 68 | - Kirin X90/Kirin 9030处理器系列产品:value_size和index的数据类型不支持INT64。 | 68 | - Kirin X90/Kirin 9030处理器系列产品:value_size和index的数据类型不支持INT64。 |
| 69 | + | ||
| 69 | ## 约束说明 | 70 | ## 约束说明 |
| 70 | 71 | ||
| 71 | 无 | 72 | 无 |
| @@ -11,7 +11,6 @@ | |||
| 11 | | <term>Atlas 推理系列产品</term> | × | | 11 | | <term>Atlas 推理系列产品</term> | × | |
| 12 | | <term>Atlas 训练系列产品</term> | × | | 12 | | <term>Atlas 训练系列产品</term> | × | |
| 13 | 13 | ||
| 14 | - | ||
| 15 | ## 功能说明 | 14 | ## 功能说明 |
| 16 | 15 | ||
| 17 | - 算子功能:将多维数组 / 矩阵的元素位置映射为单一整数的索引方式。 | 16 | - 算子功能:将多维数组 / 矩阵的元素位置映射为单一整数的索引方式。 |
| @@ -1,3 +1,3 @@ | |||
| 1 | # MapIndex | 1 | # MapIndex |
| 2 | 2 | ||
| 3 | -本目录仅包含MapIndex算子对应的aclnn接口;如您想要贡献该算子的AscendC实现,请参考[贡献流程](../../CONTRIBUTING.md)。 | 3 | +本目录仅包含MapIndex算子对应的aclnn接口;如您想要贡献该算子的AscendC实现,请参考[贡献流程](../../CONTRIBUTING.md)。 |
| @@ -1,6 +1,5 @@ | |||
| 1 | # MaskedScatter | 1 | # MaskedScatter |
| 2 | 2 | ||
| 3 | - | ||
| 4 | ## 产品支持情况 | 3 | ## 产品支持情况 |
| 5 | 4 | ||
| 6 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| @@ -12,7 +11,6 @@ | |||
| 12 | | <term>Atlas 推理系列产品</term> | × | | 11 | | <term>Atlas 推理系列产品</term> | × | |
| 13 | | <term>Atlas 训练系列产品</term> | × | | 12 | | <term>Atlas 训练系列产品</term> | × | |
| 14 | 13 | ||
| 15 | - | ||
| 16 | ## 功能说明 | 14 | ## 功能说明 |
| 17 | 15 | ||
| 18 | 根据掩码(mask)张量中元素为True的位置,复制(source)中的元素到(selfRef)对应的位置上。 | 16 | 根据掩码(mask)张量中元素为True的位置,复制(source)中的元素到(selfRef)对应的位置上。 |
| @@ -115,7 +113,6 @@ aclnnStatus aclnnInplaceMaskedScatter( | |||
| 115 | </tr> | 113 | </tr> |
| 116 | </tbody></table> | 114 | </tbody></table> |
| 117 | 115 | ||
| 118 | - | ||
| 119 | - **返回值** | 116 | - **返回值** |
| 120 | 117 | ||
| 121 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../docs/zh/context/aclnn返回码.md)。 | 118 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../docs/zh/context/aclnn返回码.md)。 |
| @@ -205,4 +202,4 @@ aclnnStatus aclnnInplaceMaskedScatter( | |||
| 205 | 202 | ||
| 206 | | 调用方式 | 样例代码 | 说明 | | 203 | | 调用方式 | 样例代码 | 说明 | |
| 207 | | ---------------- | --------------------------- | --------------------------------------------------- | | 204 | | ---------------- | --------------------------- | --------------------------------------------------- | |
| 208 | -| aclnn接口 | [test_aclnn_masked_scatter](./examples/test_aclnn_masked_scatter.cpp) | 通过[aclnnInplaceMaskedScatter](docs/aclnnInplaceMaskedScatter.md)接口方式调用MaskedScatter算子。 | | 205 | +| aclnn接口 | [test_aclnn_masked_scatter](./examples/test_aclnn_masked_scatter.cpp) | 通过[aclnnInplaceMaskedScatter](docs/aclnnInplaceMaskedScatter.md)接口方式调用MaskedScatter算子。 | |
| @@ -1,7 +1,5 @@ | |||
| 1 | # aclnnInplaceMaskedScatter | 1 | # aclnnInplaceMaskedScatter |
| 2 | 2 | ||
| 3 | - | ||
| 4 | - | ||
| 5 | ## 产品支持情况 | 3 | ## 产品支持情况 |
| 6 | 4 | ||
| 7 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| @@ -13,7 +11,6 @@ | |||
| 13 | | <term>Atlas 推理系列产品</term> | × | | 11 | | <term>Atlas 推理系列产品</term> | × | |
| 14 | | <term>Atlas 训练系列产品</term> | × | | 12 | | <term>Atlas 训练系列产品</term> | × | |
| 15 | 13 | ||
| 16 | - | ||
| 17 | ## 功能说明 | 14 | ## 功能说明 |
| 18 | 15 | ||
| 19 | 根据掩码(mask)张量中元素为True的位置,复制(source)中的元素到(selfRef)对应的位置上。 | 16 | 根据掩码(mask)张量中元素为True的位置,复制(source)中的元素到(selfRef)对应的位置上。 |
| @@ -203,7 +200,6 @@ aclnnStatus aclnnInplaceMaskedScatter( | |||
| 203 | - 确定性计算: | 200 | - 确定性计算: |
| 204 | - aclnnInplaceMaskedScatter默认确定性实现。 | 201 | - aclnnInplaceMaskedScatter默认确定性实现。 |
| 205 | 202 | ||
| 206 | - | ||
| 207 | ## 调用示例 | 203 | ## 调用示例 |
| 208 | 204 | ||
| 209 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 205 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| @@ -1,6 +1,6 @@ | |||
| 1 | # Maskedscatterwithposition | 1 | # Maskedscatterwithposition |
| 2 | 2 | ||
| 3 | -## 产品支持情况 | 3 | +## 产品支持情况 |
| 4 | 4 | ||
| 5 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| 6 | | :----------------------------------------------------------- | :------: | | 6 | | :----------------------------------------------------------- | :------: | |
| @@ -78,7 +78,6 @@ | |||
| 78 | </tr> | 78 | </tr> |
| 79 | </tbody></table> | 79 | </tbody></table> |
| 80 | 80 | ||
| 81 | - | ||
| 82 | ## 约束说明 | 81 | ## 约束说明 |
| 83 | 82 | ||
| 84 | 无 | 83 | 无 |
| @@ -1,3 +1,3 @@ | |||
| 1 | # MatrixInverse | 1 | # MatrixInverse |
| 2 | 2 | ||
| 3 | -本目录仅包含MatrixInverse算子对应的aclnn接口;如您想要贡献该算子的AscendC实现,请参考[贡献流程](../../CONTRIBUTING.md)。 | 3 | +本目录仅包含MatrixInverse算子对应的aclnn接口;如您想要贡献该算子的AscendC实现,请参考[贡献流程](../../CONTRIBUTING.md)。 |
| @@ -12,6 +12,7 @@ | |||
| 12 | | <term>Atlas 200I/500 A2 推理产品</term> | × | | 12 | | <term>Atlas 200I/500 A2 推理产品</term> | × | |
| 13 | | <term>Atlas 推理系列产品</term> | × | | 13 | | <term>Atlas 推理系列产品</term> | × | |
| 14 | | <term>Atlas 训练系列产品</term> | × | | 14 | | <term>Atlas 训练系列产品</term> | × | |
| 15 | + | ||
| 15 | ## 功能说明 | 16 | ## 功能说明 |
| 16 | 17 | ||
| 17 | - 接口功能:计算输入方阵的逆矩阵。 | 18 | - 接口功能:计算输入方阵的逆矩阵。 |
| @@ -14,6 +14,7 @@ | |||
| 14 | ## 功能说明 | 14 | ## 功能说明 |
| 15 | 15 | ||
| 16 | 算子功能:找出`self`中非零元素的位置,设self的维度为D,self中非零元素的个数为N,则返回`out`的shape为N * D,每一列表示一个非零元素的位置坐标。 | 16 | 算子功能:找出`self`中非零元素的位置,设self的维度为D,self中非零元素的个数为N,则返回`out`的shape为N * D,每一列表示一个非零元素的位置坐标。 |
| 17 | + | ||
| 17 | ## 参数说明 | 18 | ## 参数说明 |
| 18 | 19 | ||
| 19 | <table style="undefined;table-layout: fixed; width: 980px"><colgroup> | 20 | <table style="undefined;table-layout: fixed; width: 980px"><colgroup> |
| @@ -68,4 +69,4 @@ | |||
| 68 | | 调用方式 | 调用样例 | 说明 | | 69 | | 调用方式 | 调用样例 | 说明 | |
| 69 | |--------------|------------------------------------------------------------------------|--------------------------------------------------------------| | 70 | |--------------|------------------------------------------------------------------------|--------------------------------------------------------------| |
| 70 | | aclnn调用 | [test_aclnn_non_zero](./examples/test_aclnn_non_zero.cpp) | 通过[aclnnNonzero](./docs/aclnnNonzero.md)接口方式调用Nonzero算子。 | | 71 | | aclnn调用 | [test_aclnn_non_zero](./examples/test_aclnn_non_zero.cpp) | 通过[aclnnNonzero](./docs/aclnnNonzero.md)接口方式调用Nonzero算子。 | |
| 71 | -| aclnn调用 | [test_aclnn_non_zero_v2](./examples/test_aclnn_non_zero_v2.cpp) | 通过[aclnnNonzeroV2](./docs/aclnnNonzeroV2.md)接口方式调用NonzeroV2算子。 | | 72 | +| aclnn调用 | [test_aclnn_non_zero_v2](./examples/test_aclnn_non_zero_v2.cpp) | 通过[aclnnNonzeroV2](./docs/aclnnNonzeroV2.md)接口方式调用NonzeroV2算子。 | |
| @@ -46,6 +46,7 @@ | |||
| 46 | |---|---|---|---|---| | 46 | |---|---|---|---|---| |
| 47 | |INT8|INT32|FLOAT16|FLOAT32|INT32| | 47 | |INT8|INT32|FLOAT16|FLOAT32|INT32| |
| 48 | |INT8|INT64|FLOAT16|FLOAT32|INT32| | 48 | |INT8|INT64|FLOAT16|FLOAT32|INT32| |
| 49 | + | ||
| 49 | - <term>Atlas A2 训练系列产品/Atlas 800I A2 推理产品/A200I A2 Box 异构组件</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>、<term>Ascend 950PR/Ascend 950DT</term>: | 50 | - <term>Atlas A2 训练系列产品/Atlas 800I A2 推理产品/A200I A2 Box 异构组件</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>、<term>Ascend 950PR/Ascend 950DT</term>: |
| 50 | 51 | ||
| 51 | |selfRef|indices|updates|quantScales|quantZeroPoints| | 52 | |selfRef|indices|updates|quantScales|quantZeroPoints| |
| @@ -59,4 +60,4 @@ | |||
| 59 | 60 | ||
| 60 | | 调用方式 | 样例代码 | 说明 | | 61 | | 调用方式 | 样例代码 | 说明 | |
| 61 | | ---------------- | --------------------------- | --------------------------------------------------- | | 62 | | ---------------- | --------------------------- | --------------------------------------------------- | |
| 62 | -| aclnn接口 | [test_aclnn_inplace_quant_scatter](examples/test_aclnn_inplace_quant_scatter.cpp) | 通过[aclnnInplaceQuantScatter](docs/aclnnInplaceQuantScatter.md)接口方式调用QuantUpdateScatter算子。 | | 63 | +| aclnn接口 | [test_aclnn_inplace_quant_scatter](examples/test_aclnn_inplace_quant_scatter.cpp) | 通过[aclnnInplaceQuantScatter](docs/aclnnInplaceQuantScatter.md)接口方式调用QuantUpdateScatter算子。 | |
| @@ -32,6 +32,7 @@ aclnnStatus aclnnInplaceQuantScatterGetWorkspaceSize( | |||
| 32 | uint64_t *workspaceSize, | 32 | uint64_t *workspaceSize, |
| 33 | aclOpExecutor **executor) | 33 | aclOpExecutor **executor) |
| 34 | ``` | 34 | ``` |
| 35 | + | ||
| 35 | ```c++ | 36 | ```c++ |
| 36 | aclnnStatus aclnnInplaceQuantScatter( | 37 | aclnnStatus aclnnInplaceQuantScatter( |
| 37 | void *workspace, | 38 | void *workspace, |
| @@ -209,7 +210,7 @@ aclnnStatus aclnnInplaceQuantScatter( | |||
| 209 | 210 | ||
| 210 | ## aclnnInplaceQuantScatter | 211 | ## aclnnInplaceQuantScatter |
| 211 | 212 | ||
| 212 | -- **参数说明** | 213 | +- **参数说明** |
| 213 | 214 | ||
| 214 | <table> | 215 | <table> |
| 215 | <thead> | 216 | <thead> |
| @@ -240,6 +241,7 @@ aclnnStatus aclnnInplaceQuantScatter( | |||
| 240 | |---|---|---|---|---| | 241 | |---|---|---|---|---| |
| 241 | |INT8|INT32|FLOAT16|FLOAT32|INT32| | 242 | |INT8|INT32|FLOAT16|FLOAT32|INT32| |
| 242 | |INT8|INT64|FLOAT16|FLOAT32|INT32| | 243 | |INT8|INT64|FLOAT16|FLOAT32|INT32| |
| 244 | + | ||
| 243 | - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>、<term>Ascend 950PR/Ascend 950DT</term>: | 245 | - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>、<term>Ascend 950PR/Ascend 950DT</term>: |
| 244 | 246 | ||
| 245 | |selfRef|indices|updates|quantScales|quantZeroPoints| | 247 | |selfRef|indices|updates|quantScales|quantZeroPoints| |
| @@ -1,3 +1,3 @@ | |||
| 1 | # RepeatInterleave | 1 | # RepeatInterleave |
| 2 | 2 | ||
| 3 | -本目录仅包含RepeatInterleave算子对应的aclnn接口;如您想要贡献该算子的AscendC实现,请参考[贡献流程](../../CONTRIBUTING.md)。 | 3 | +本目录仅包含RepeatInterleave算子对应的aclnn接口;如您想要贡献该算子的AscendC实现,请参考[贡献流程](../../CONTRIBUTING.md)。 |
| @@ -237,6 +237,7 @@ aclnnStatus aclnnRepeatInterleave( | |||
| 237 | ## 调用示例 | 237 | ## 调用示例 |
| 238 | 238 | ||
| 239 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 239 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| 240 | + | ||
| 240 | ```Cpp | 241 | ```Cpp |
| 241 | #include <iostream> | 242 | #include <iostream> |
| 242 | #include <vector> | 243 | #include <vector> |
| @@ -222,6 +222,7 @@ aclnnStatus aclnnRepeatInterleaveInt( | |||
| 222 | ## 调用示例 | 222 | ## 调用示例 |
| 223 | 223 | ||
| 224 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 224 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| 225 | + | ||
| 225 | ```Cpp | 226 | ```Cpp |
| 226 | #include <iostream> | 227 | #include <iostream> |
| 227 | #include <vector> | 228 | #include <vector> |
| @@ -355,4 +356,3 @@ int main() { | |||
| 355 | return 0; | 356 | return 0; |
| 356 | } | 357 | } |
| 357 | ``` | 358 | ``` |
| 358 | - | ||
| @@ -240,6 +240,7 @@ aclnnStatus aclnnRepeatInterleaveIntWithDim( | |||
| 240 | ## 调用示例 | 240 | ## 调用示例 |
| 241 | 241 | ||
| 242 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 242 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| 243 | + | ||
| 243 | ```Cpp | 244 | ```Cpp |
| 244 | #include <iostream> | 245 | #include <iostream> |
| 245 | #include <vector> | 246 | #include <vector> |
| @@ -13,7 +13,6 @@ | |||
| 13 | | <term>Atlas 推理系列产品</term> | × | | 13 | | <term>Atlas 推理系列产品</term> | × | |
| 14 | | <term>Atlas 训练系列产品</term> | × | | 14 | | <term>Atlas 训练系列产品</term> | × | |
| 15 | 15 | ||
| 16 | - | ||
| 17 | ## 功能说明 | 16 | ## 功能说明 |
| 18 | 17 | ||
| 19 | - 接口功能:算子repeatInterleave的反向, 将yGrad tensor的axis维度按repeats进行ReduceSum。 | 18 | - 接口功能:算子repeatInterleave的反向, 将yGrad tensor的axis维度按repeats进行ReduceSum。 |
| @@ -377,4 +376,3 @@ int main() { | |||
| 377 | return 0; | 376 | return 0; |
| 378 | } | 377 | } |
| 379 | ``` | 378 | ``` |
| 380 | - | ||
| @@ -1,3 +1,3 @@ | |||
| 1 | # ReverseV2 | 1 | # ReverseV2 |
| 2 | 2 | ||
| 3 | -本目录仅包含ReverseV2算子对应的aclnn接口;如您想要贡献该算子的AscendC实现,请参考[贡献流程](../../CONTRIBUTING.md)。 | 3 | +本目录仅包含ReverseV2算子对应的aclnn接口;如您想要贡献该算子的AscendC实现,请参考[贡献流程](../../CONTRIBUTING.md)。 |
| @@ -46,7 +46,6 @@ | |||
| 46 | data[i][j][indices[i]+k][l] = updates[i][j][k][l] # if dim=-2 | 46 | data[i][j][indices[i]+k][l] = updates[i][j][k][l] # if dim=-2 |
| 47 | data[i][j][k][indices[i]+l] = updates[i][j][k][l] # if dim=-1 | 47 | data[i][j][k][indices[i]+l] = updates[i][j][k][l] # if dim=-1 |
| 48 | 48 | ||
| 49 | - | ||
| 50 | ## 约束说明 | 49 | ## 约束说明 |
| 51 | 50 | ||
| 52 | 无 | 51 | 无 |
| @@ -93,6 +93,7 @@ | |||
| 93 | 2.self、out的shape不一致。 | 93 | 2.self、out的shape不一致。 |
| 94 | 3.src、index shape不合法。 | 94 | 3.src、index shape不合法。 |
| 95 | ``` | 95 | ``` |
| 96 | + | ||
| 96 | ## aclnnScatterAdd | 97 | ## aclnnScatterAdd |
| 97 | 98 | ||
| 98 | - **参数说明:** | 99 | - **参数说明:** |
| @@ -105,7 +106,6 @@ | |||
| 105 | 106 | ||
| 106 | - stream(aclrtStream,入参):指定执行任务的Stream。 | 107 | - stream(aclrtStream,入参):指定执行任务的Stream。 |
| 107 | 108 | ||
| 108 | - | ||
| 109 | - **返回值:** | 109 | - **返回值:** |
| 110 | 110 | ||
| 111 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 111 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| @@ -117,6 +117,7 @@ | |||
| 117 | ## 调用示例 | 117 | ## 调用示例 |
| 118 | 118 | ||
| 119 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 119 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| 120 | + | ||
| 120 | ```Cpp | 121 | ```Cpp |
| 121 | #include <iostream> | 122 | #include <iostream> |
| 122 | #include <vector> | 123 | #include <vector> |
| @@ -265,4 +266,3 @@ int main() { | |||
| 265 | return 0; | 266 | return 0; |
| 266 | } | 267 | } |
| 267 | ``` | 268 | ``` |
| 268 | - | ||
| @@ -16,6 +16,7 @@ | |||
| 16 | 算子功能:返回输入张量中的唯一元素。 | 16 | 算子功能:返回输入张量中的唯一元素。 |
| 17 | 17 | ||
| 18 | ## 参数说明 | 18 | ## 参数说明 |
| 19 | + | ||
| 19 | - self(aclTensor*,计算输入):Device侧的aclTensor,[数据格式](../../docs/zh/context/数据格式.md)支持ND,维度不大于8。 | 20 | - self(aclTensor*,计算输入):Device侧的aclTensor,[数据格式](../../docs/zh/context/数据格式.md)支持ND,维度不大于8。 |
| 20 | - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>、<term>Ascend 950PR/Ascend 950DT</term>:数据类型支持BOOL、FLOAT、FLOAT16、DOUBLE、UINT8、INT8、UINT16、INT16、INT32、UINT32、UINT64、INT64、BFLOAT16。 | 21 | - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>、<term>Ascend 950PR/Ascend 950DT</term>:数据类型支持BOOL、FLOAT、FLOAT16、DOUBLE、UINT8、INT8、UINT16、INT16、INT32、UINT32、UINT64、INT64、BFLOAT16。 |
| 21 | 22 | ||
| @@ -33,4 +34,4 @@ | |||
| 33 | 34 | ||
| 34 | | 调用方式 | 样例代码 | 说明 | | 35 | | 调用方式 | 样例代码 | 说明 | |
| 35 | | ---------------- | --------------------------- | --------------------------------------------------- | | 36 | | ---------------- | --------------------------- | --------------------------------------------------- | |
| 36 | -| aclnn接口 | [test_aclnn_unique](examples/test_aclnn_unique.cpp) | 通过[aclnnUnique](docs/aclnnUnique.md)接口方式调用ScatterElements算子。 | | 37 | +| aclnn接口 | [test_aclnn_unique](examples/test_aclnn_unique.cpp) | 通过[aclnnUnique](docs/aclnnUnique.md)接口方式调用ScatterElements算子。 | |
| @@ -29,7 +29,6 @@ | |||
| 29 | outRef[N][C][indices[N][C][i]] = self[N][C][i] | 29 | outRef[N][C][indices[N][C][i]] = self[N][C][i] |
| 30 | $$ | 30 | $$ |
| 31 | 31 | ||
| 32 | - | ||
| 33 | 其中outRef、indices和self是最后两轴合为一轴,经过reshape得到的,i ∈ [0, D * H * W)。 | 32 | 其中outRef、indices和self是最后两轴合为一轴,经过reshape得到的,i ∈ [0, D * H * W)。 |
| 34 | 33 | ||
| 35 | ## 函数原型 | 34 | ## 函数原型 |
| @@ -293,7 +292,9 @@ aclnnStatus aclnnMaxUnpool3d( | |||
| 293 | - aclnnMaxUnpool3d默认确定性实现。 | 292 | - aclnnMaxUnpool3d默认确定性实现。 |
| 294 | 293 | ||
| 295 | ## 调用示例 | 294 | ## 调用示例 |
| 295 | + | ||
| 296 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 296 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| 297 | + | ||
| 297 | ```Cpp | 298 | ```Cpp |
| 298 | #include <iostream> | 299 | #include <iostream> |
| 299 | #include <vector> | 300 | #include <vector> |
| @@ -73,6 +73,7 @@ | |||
| 73 | * <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>:在输入self包含0的情况下,算子的输出中会包含正0和负0,而非只输出一个0。 | 73 | * <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>:在输入self包含0的情况下,算子的输出中会包含正0和负0,而非只输出一个0。 |
| 74 | 74 | ||
| 75 | ## 调用示例 | 75 | ## 调用示例 |
| 76 | + | ||
| 76 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 77 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| 77 | 78 | ||
| 78 | ```Cpp | 79 | ```Cpp |
| @@ -234,4 +234,4 @@ int main() { | |||
| 234 | aclFinalize(); | 234 | aclFinalize(); |
| 235 | return 0; | 235 | return 0; |
| 236 | } | 236 | } |
| 237 | -``` | 237 | +``` |
| @@ -1,6 +1,6 @@ | |||
| 1 | # ScatterElementsV2 | 1 | # ScatterElementsV2 |
| 2 | 2 | ||
| 3 | -## 产品支持情况 | 3 | +## 产品支持情况 |
| 4 | 4 | ||
| 5 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| 6 | | :----------------------------------------------------------- | :------: | | 6 | | :----------------------------------------------------------- | :------: | |
| @@ -94,7 +94,6 @@ | |||
| 94 | </tr> | 94 | </tr> |
| 95 | </tbody></table> | 95 | </tbody></table> |
| 96 | 96 | ||
| 97 | - | ||
| 98 | ## 约束说明 | 97 | ## 约束说明 |
| 99 | 98 | ||
| 100 | 无 | 99 | 无 |
| @@ -416,4 +416,4 @@ int main() { | |||
| 416 | aclFinalize(); | 416 | aclFinalize(); |
| 417 | return 0; | 417 | return 0; |
| 418 | } | 418 | } |
| 419 | -``` | 419 | +``` |
| @@ -12,6 +12,7 @@ | |||
| 12 | | <term>Atlas 训练系列产品</term> | × | | 12 | | <term>Atlas 训练系列产品</term> | × | |
| 13 | 13 | ||
| 14 | ## 功能说明 | 14 | ## 功能说明 |
| 15 | + | ||
| 15 | - **算子功能**:将scalar value中的值按指定的轴和方向和对应的位置关系逐个填入tensor self中。value会被broadcast成和tensor index的shape一致的tensor src进行Scatter的计算。 | 16 | - **算子功能**:将scalar value中的值按指定的轴和方向和对应的位置关系逐个填入tensor self中。value会被broadcast成和tensor index的shape一致的tensor src进行Scatter的计算。 |
| 16 | 17 | ||
| 17 | - **示例:** | 18 | - **示例:** |
| @@ -45,6 +46,7 @@ | |||
| 45 | - `aclnnStatus aclnnInplaceScatterValue(void *workspace, uint64_t workspaceSize, aclOpExecutor *executor, aclrtStream stream)` | 46 | - `aclnnStatus aclnnInplaceScatterValue(void *workspace, uint64_t workspaceSize, aclOpExecutor *executor, aclrtStream stream)` |
| 46 | 47 | ||
| 47 | ## aclnnScatterValueGetWorkspaceSize | 48 | ## aclnnScatterValueGetWorkspaceSize |
| 49 | + | ||
| 48 | - **参数说明:** | 50 | - **参数说明:** |
| 49 | 51 | ||
| 50 | - self(aclTensor*, 计算输入):公式中的`self`,Device侧的aclTensor。scatter的目标张量。self的维度数量需要与index相同,shape支持0-8维。支持[非连续的Tensor](../../../docs/zh/context/非连续的Tensor.md)。[数据格式](../../../docs/zh/context/数据格式.md)支持ND。 | 52 | - self(aclTensor*, 计算输入):公式中的`self`,Device侧的aclTensor。scatter的目标张量。self的维度数量需要与index相同,shape支持0-8维。支持[非连续的Tensor](../../../docs/zh/context/非连续的Tensor.md)。[数据格式](../../../docs/zh/context/数据格式.md)支持ND。 |
| @@ -67,7 +69,6 @@ | |||
| 67 | 69 | ||
| 68 | - executor(aclOpExecutor ,出参):返回op执行器,包含了算子计算流程。 | 70 | - executor(aclOpExecutor ,出参):返回op执行器,包含了算子计算流程。 |
| 69 | 71 | ||
| 70 | - | ||
| 71 | - **返回值:** | 72 | - **返回值:** |
| 72 | 73 | ||
| 73 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 74 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| @@ -98,7 +99,6 @@ | |||
| 98 | 99 | ||
| 99 | - stream(aclrtStream,入参):指定执行任务的Stream。 | 100 | - stream(aclrtStream,入参):指定执行任务的Stream。 |
| 100 | 101 | ||
| 101 | - | ||
| 102 | - **返回值:** | 102 | - **返回值:** |
| 103 | 103 | ||
| 104 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 104 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| @@ -150,7 +150,6 @@ | |||
| 150 | - 确定性计算: | 150 | - 确定性计算: |
| 151 | - aclnnScatterValue&aclnnInplaceScatterValue默认确定性实现。 | 151 | - aclnnScatterValue&aclnnInplaceScatterValue默认确定性实现。 |
| 152 | 152 | ||
| 153 | - | ||
| 154 | ## 调用示例 | 153 | ## 调用示例 |
| 155 | 154 | ||
| 156 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 155 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| @@ -447,4 +446,3 @@ int main() { | |||
| 447 | return 0; | 446 | return 0; |
| 448 | } | 447 | } |
| 449 | ``` | 448 | ``` |
| 450 | - | ||
| @@ -1,6 +1,6 @@ | |||
| 1 | # ScatterList简介 | 1 | # ScatterList简介 |
| 2 | 2 | ||
| 3 | -## 产品支持情况 | 3 | +## 产品支持情况 |
| 4 | 4 | ||
| 5 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| 6 | | :----------------------------------------------------------- | :------: | | 6 | | :----------------------------------------------------------- | :------: | |
| @@ -17,7 +17,6 @@ | |||
| 17 | 17 | ||
| 18 | - 算子功能:将稀疏矩阵更新应用到变量引用中。 | 18 | - 算子功能:将稀疏矩阵更新应用到变量引用中。 |
| 19 | 19 | ||
| 20 | - | ||
| 21 | ## 参数说明 | 20 | ## 参数说明 |
| 22 | 21 | ||
| 23 | <table style="undefined;table-layout: fixed; width: 1576px"><colgroup> | 22 | <table style="undefined;table-layout: fixed; width: 1576px"><colgroup> |
| @@ -88,6 +87,7 @@ | |||
| 88 | </tbody></table> | 87 | </tbody></table> |
| 89 | 88 | ||
| 90 | - Kirin X90/Kirin 9030处理器系列产品:var和updates的数据类型不支持BFLOAT16,输出var的数据类型不支持DOUBLE、BFLOAT16、INT64和BOOL。 | 89 | - Kirin X90/Kirin 9030处理器系列产品:var和updates的数据类型不支持BFLOAT16,输出var的数据类型不支持DOUBLE、BFLOAT16、INT64和BOOL。 |
| 90 | + | ||
| 91 | ## 约束说明 | 91 | ## 约束说明 |
| 92 | 92 | ||
| 93 | 无 | 93 | 无 |
| @@ -156,7 +156,6 @@ aclnnStatus aclnnScatterList( | |||
| 156 | </tbody> | 156 | </tbody> |
| 157 | </table> | 157 | </table> |
| 158 | 158 | ||
| 159 | - | ||
| 160 | - **返回值:** | 159 | - **返回值:** |
| 161 | 160 | ||
| 162 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 161 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| @@ -235,7 +234,6 @@ aclnnStatus aclnnScatterList( | |||
| 235 | </tbody> | 234 | </tbody> |
| 236 | </table> | 235 | </table> |
| 237 | 236 | ||
| 238 | - | ||
| 239 | - **返回值:** | 237 | - **返回值:** |
| 240 | 238 | ||
| 241 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 239 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| @@ -12,9 +12,11 @@ | |||
| 12 | | <term>Atlas 训练系列产品</term> | × | | 12 | | <term>Atlas 训练系列产品</term> | × | |
| 13 | 13 | ||
| 14 | ## 功能说明 | 14 | ## 功能说明 |
| 15 | + | ||
| 15 | 算子功能:拷贝data的数据至out,同时在指定indices处根据updates更新out中的数据。 | 16 | 算子功能:拷贝data的数据至out,同时在指定indices处根据updates更新out中的数据。 |
| 16 | 17 | ||
| 17 | ## 参数说明 | 18 | ## 参数说明 |
| 19 | + | ||
| 18 | - data(aclTensor*,计算输入):Device侧的aclTensor, 数据类型与updates、out一致,shape满足1<=rank(data)<=8。支持[非连续的Tensor](../../docs/zh/context/非连续的Tensor.md),[数据格式](../../docs/zh/context/数据格式.md)支持ND。 | 20 | - data(aclTensor*,计算输入):Device侧的aclTensor, 数据类型与updates、out一致,shape满足1<=rank(data)<=8。支持[非连续的Tensor](../../docs/zh/context/非连续的Tensor.md),[数据格式](../../docs/zh/context/数据格式.md)支持ND。 |
| 19 | - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>:数据类型支持FLOAT16、FLOAT、BOOL、BFLOAT16 | 21 | - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>:数据类型支持FLOAT16、FLOAT、BOOL、BFLOAT16 |
| 20 | 22 | ||
| @@ -27,10 +29,11 @@ | |||
| 27 | - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>:数据类型支持FLOAT16、FLOAT、BOOL、BFLOAT16 | 29 | - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>:数据类型支持FLOAT16、FLOAT、BOOL、BFLOAT16 |
| 28 | 30 | ||
| 29 | ## 约束说明 | 31 | ## 约束说明 |
| 32 | + | ||
| 30 | 无 | 33 | 无 |
| 31 | 34 | ||
| 32 | ## 调用说明 | 35 | ## 调用说明 |
| 33 | 36 | ||
| 34 | | 调用方式 | 样例代码 | 说明 | | 37 | | 调用方式 | 样例代码 | 说明 | |
| 35 | | ---------------- | --------------------------- | --------------------------------------------------- | | 38 | | ---------------- | --------------------------- | --------------------------------------------------- | |
| 36 | -| aclnn接口 | [test_aclnn_scatter_nd](examples/test_aclnn_scatter_nd.cpp) | 通过[aclnnScatterNd](docs/aclnnScatterNd.md)接口方式调用ScatterNdUpdate算子。 | | 39 | +| aclnn接口 | [test_aclnn_scatter_nd](examples/test_aclnn_scatter_nd.cpp) | 通过[aclnnScatterNd](docs/aclnnScatterNd.md)接口方式调用ScatterNdUpdate算子。 | |
| @@ -376,4 +376,4 @@ int main() { | |||
| 376 | 376 | ||
| 377 | return 0; | 377 | return 0; |
| 378 | } | 378 | } |
| 379 | -``` | 379 | +``` |
| @@ -1,3 +1,3 @@ | |||
| 1 | # ScatterNdUpdate | 1 | # ScatterNdUpdate |
| 2 | 2 | ||
| 3 | -本目录仅包含ScatterNdUpdate算子对应的aclnn接口;如您想要贡献该算子的AscendC实现,请参考[贡献流程](../../CONTRIBUTING.md)。 | 3 | +本目录仅包含ScatterNdUpdate算子对应的aclnn接口;如您想要贡献该算子的AscendC实现,请参考[贡献流程](../../CONTRIBUTING.md)。 |
| @@ -1,4 +1,5 @@ | |||
| 1 | # aclnnScatterNd | 1 | # aclnnScatterNd |
| 2 | + | ||
| 2 | ## 产品支持情况 | 3 | ## 产品支持情况 |
| 3 | 4 | ||
| 4 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| @@ -9,16 +10,20 @@ | |||
| 9 | | <term>Atlas 200I/500 A2 推理产品</term> | × | | 10 | | <term>Atlas 200I/500 A2 推理产品</term> | × | |
| 10 | | <term>Atlas 推理系列产品</term> | × | | 11 | | <term>Atlas 推理系列产品</term> | × | |
| 11 | | <term>Atlas 训练系列产品</term> | × | | 12 | | <term>Atlas 训练系列产品</term> | × | |
| 13 | + | ||
| 12 | ## 功能说明 | 14 | ## 功能说明 |
| 15 | + | ||
| 13 | 算子功能:拷贝data的数据至out,同时在指定indices处根据updates更新out中的数据。 | 16 | 算子功能:拷贝data的数据至out,同时在指定indices处根据updates更新out中的数据。 |
| 14 | 17 | ||
| 15 | ## 函数原型 | 18 | ## 函数原型 |
| 19 | + | ||
| 16 | 每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnScatterNdGetWorkspaceSize”接口获取计算所需workspace大小以及包含了算子计算流程的执行器,再调用“aclnnScatterNd”接口执行计算。 | 20 | 每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnScatterNdGetWorkspaceSize”接口获取计算所需workspace大小以及包含了算子计算流程的执行器,再调用“aclnnScatterNd”接口执行计算。 |
| 17 | 21 | ||
| 18 | * `aclnnStatus aclnnScatterNdGetWorkspaceSize(const aclTensor *data,const aclTensor *indices,const aclTensor *updates, aclTensor *out, uint64_t *workspaceSize, aclOpExecutor **executor)` | 22 | * `aclnnStatus aclnnScatterNdGetWorkspaceSize(const aclTensor *data,const aclTensor *indices,const aclTensor *updates, aclTensor *out, uint64_t *workspaceSize, aclOpExecutor **executor)` |
| 19 | * `aclnnStatus aclnnScatterNd(void *workspace, uint64_t workspaceSize, aclOpExecutor *executor, aclrtStream stream)` | 23 | * `aclnnStatus aclnnScatterNd(void *workspace, uint64_t workspaceSize, aclOpExecutor *executor, aclrtStream stream)` |
| 20 | 24 | ||
| 21 | ## aclnnScatterNdGetWorkspaceSize | 25 | ## aclnnScatterNdGetWorkspaceSize |
| 26 | + | ||
| 22 | - **参数说明:** | 27 | - **参数说明:** |
| 23 | * data(aclTensor*,计算输入):Device侧的aclTensor, 数据类型与updates、out一致,shape满足1<=rank(data)<=8。支持[非连续的Tensor](../../../docs/zh/context/非连续的Tensor.md),[数据格式](../../../docs/zh/context/数据格式.md)支持ND。 | 28 | * data(aclTensor*,计算输入):Device侧的aclTensor, 数据类型与updates、out一致,shape满足1<=rank(data)<=8。支持[非连续的Tensor](../../../docs/zh/context/非连续的Tensor.md),[数据格式](../../../docs/zh/context/数据格式.md)支持ND。 |
| 24 | - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>:数据类型支持FLOAT16、FLOAT、BOOL、BFLOAT16 | 29 | - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>:数据类型支持FLOAT16、FLOAT、BOOL、BFLOAT16 |
| @@ -35,6 +40,7 @@ | |||
| 35 | - **返回值:** | 40 | - **返回值:** |
| 36 | 41 | ||
| 37 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 42 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| 43 | + | ||
| 38 | ``` | 44 | ``` |
| 39 | 第一段接口完成入参校验,出现以下场景时报错: | 45 | 第一段接口完成入参校验,出现以下场景时报错: |
| 40 | 返回161001(ACLNN_ERR_PARAM_NULLPTR):1.传入的data、indices、updates、out中有空指针 | 46 | 返回161001(ACLNN_ERR_PARAM_NULLPTR):1.传入的data、indices、updates、out中有空指针 |
| @@ -44,7 +50,9 @@ | |||
| 44 | 4. shape不满足要求:1<=rank(updates)<=8, updates.shape == indices.shape[:-1] + data.shape[indices.shape[-1] :] | 50 | 4. shape不满足要求:1<=rank(updates)<=8, updates.shape == indices.shape[:-1] + data.shape[indices.shape[-1] :] |
| 45 | 5. shape不满足要求:data.shape == out.shape | 51 | 5. shape不满足要求:data.shape == out.shape |
| 46 | ``` | 52 | ``` |
| 53 | + | ||
| 47 | ## aclnnScatterNd | 54 | ## aclnnScatterNd |
| 55 | + | ||
| 48 | - **参数说明:** | 56 | - **参数说明:** |
| 49 | * workspace(void *, 入参):在Device侧申请的workspace内存地址。 | 57 | * workspace(void *, 入参):在Device侧申请的workspace内存地址。 |
| 50 | * workspaceSize(uint64_t, 入参):在Device侧申请的workspace大小,由第一段接口aclnnScatterNdGetWorkspaceSize获取。 | 58 | * workspaceSize(uint64_t, 入参):在Device侧申请的workspace大小,由第一段接口aclnnScatterNdGetWorkspaceSize获取。 |
| @@ -60,7 +68,9 @@ | |||
| 60 | - aclnnScatterNd默认确定性实现。 | 68 | - aclnnScatterNd默认确定性实现。 |
| 61 | 69 | ||
| 62 | ## 调用示例 | 70 | ## 调用示例 |
| 71 | + | ||
| 63 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 72 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| 73 | + | ||
| 64 | ```Cpp | 74 | ```Cpp |
| 65 | #include <iostream> | 75 | #include <iostream> |
| 66 | #include <vector> | 76 | #include <vector> |
| @@ -347,4 +347,4 @@ int main() { | |||
| 347 | aclFinalize(); | 347 | aclFinalize(); |
| 348 | return 0; | 348 | return 0; |
| 349 | } | 349 | } |
| 350 | -``` | 350 | +``` |
| @@ -1,3 +1,3 @@ | |||
| 1 | # ScatterUpdate | 1 | # ScatterUpdate |
| 2 | 2 | ||
| 3 | -本目录仅包含ScatterUpdate算子对应的aclnn接口;如您想要贡献该算子的AscendC实现,请参考[贡献流程](../../CONTRIBUTING.md)。 | 3 | +本目录仅包含ScatterUpdate算子对应的aclnn接口;如您想要贡献该算子的AscendC实现,请参考[贡献流程](../../CONTRIBUTING.md)。 |
| @@ -1,3 +1,3 @@ | |||
| 1 | # TfScatterAdd | 1 | # TfScatterAdd |
| 2 | 2 | ||
| 3 | -本目录仅包含TfScatterAdd算子对应的aclnn接口;如您想要贡献该算子的AscendC实现,请参考[贡献流程](../../CONTRIBUTING.md)。 | 3 | +本目录仅包含TfScatterAdd算子对应的aclnn接口;如您想要贡献该算子的AscendC实现,请参考[贡献流程](../../CONTRIBUTING.md)。 |
| @@ -79,6 +79,7 @@ $$ | |||
| 79 | ## 调用示例 | 79 | ## 调用示例 |
| 80 | 80 | ||
| 81 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 81 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| 82 | + | ||
| 82 | ```Cpp | 83 | ```Cpp |
| 83 | #include <iostream> | 84 | #include <iostream> |
| 84 | #include <vector> | 85 | #include <vector> |
| @@ -16,6 +16,7 @@ | |||
| 16 | - 算子功能:根据输入词频logits、topK/topP采样参数、随机采样权重分布q,进行topK-topP-sample采样计算,输出每个batch的最大词频logitsSelectIdx,以及topK-topP采样后的词频分布logitsTopKPSelect。 | 16 | - 算子功能:根据输入词频logits、topK/topP采样参数、随机采样权重分布q,进行topK-topP-sample采样计算,输出每个batch的最大词频logitsSelectIdx,以及topK-topP采样后的词频分布logitsTopKPSelect。 |
| 17 | 17 | ||
| 18 | 算子包含三个可单独使能,但上下游处理关系保持不变的采样算法(从原始输入到最终输出):TopK采样、TopP采样、指数采样(本文档中Sample所指)。它们可以构成八种计算场景。如下表所示: | 18 | 算子包含三个可单独使能,但上下游处理关系保持不变的采样算法(从原始输入到最终输出):TopK采样、TopP采样、指数采样(本文档中Sample所指)。它们可以构成八种计算场景。如下表所示: |
| 19 | + | ||
| 19 | | 计算场景 | TopK采样 | TopP采样 | 指数分布采样 |备注| | 20 | | 计算场景 | TopK采样 | TopP采样 | 指数分布采样 |备注| |
| 20 | | :-------:| :------:|:-------:|:-------:|:-------:| | 21 | | :-------:| :------:|:-------:|:-------:|:-------:| |
| 21 | |Softmax-Argmax采样|×|×|×|对输入logits按每个batch,取SoftMax后取最大结果| | 22 | |Softmax-Argmax采样|×|×|×|对输入logits按每个batch,取SoftMax后取最大结果| |
| @@ -26,6 +27,7 @@ | |||
| 26 | |topK-Sample采样|√|×|√|对输入logits按每个batch,先进行topK采样,再进行Sample采样后取最大结果| | 27 | |topK-Sample采样|√|×|√|对输入logits按每个batch,先进行topK采样,再进行Sample采样后取最大结果| |
| 27 | |topP-Sample采样|×|√|√|对输入logits按每个batch,先进行topP采样,再进行Sample采样后取最大结果| | 28 | |topP-Sample采样|×|√|√|对输入logits按每个batch,先进行topP采样,再进行Sample采样后取最大结果| |
| 28 | |topK-topP-Sample采样|√|√|√|对输入logits按每个batch,先进行topK采样,再进行topP采样,最后进行Sample采样后取最大结果| | 29 | |topK-topP-Sample采样|√|√|√|对输入logits按每个batch,先进行topK采样,再进行topP采样,最后进行Sample采样后取最大结果| |
| 30 | + | ||
| 29 | - 计算公式: | 31 | - 计算公式: |
| 30 | 32 | ||
| 31 | 输入logits为大小为[batch, voc_size]的词频表,其中每个batch对应一条输入序列,而voc_size则是约定每个batch的统一长度。<br> | 33 | 输入logits为大小为[batch, voc_size]的词频表,其中每个batch对应一条输入序列,而voc_size则是约定每个batch的统一长度。<br> |
| @@ -244,8 +246,8 @@ logits中的每一行logits[batch][:]根据相应的topK[batch]、topP[batch]、 | |||
| 244 | </tr> | 246 | </tr> |
| 245 | </tbody></table> | 247 | </tbody></table> |
| 246 | 248 | ||
| 247 | - | ||
| 248 | ## 约束说明 | 249 | ## 约束说明 |
| 250 | + | ||
| 249 | * 输入值域限制: | 251 | * 输入值域限制: |
| 250 | * 对于所有参数,它们的尺寸必须满足,batch>0,0<vocSize<=2^20。 | 252 | * 对于所有参数,它们的尺寸必须满足,batch>0,0<vocSize<=2^20。 |
| 251 | * 输入shape限制: | 253 | * 输入shape限制: |
| @@ -16,6 +16,7 @@ | |||
| 16 | - 算子功能:根据输入词频logits、topK/topP/minP采样参数、随机采样权重分布q,进行topK-topP-minP-sample采样计算。当输入isNeedSampleResult为false时,输出每个batch的最大词频logitsSelectIdx,以及topK-topP-minP采样后的词频分布logitsTopKPSelect;当输入isNeedSampleResult为true时,输出topK-topP-minP采样后的中间计算结果logitsIdx和logitsSortMasked,其中logitsSortMasked为词频logits经过topK-topP-minP采样计算后的中间结果,logitsIdx为logitsSortMasked在logits中对应的索引。 | 16 | - 算子功能:根据输入词频logits、topK/topP/minP采样参数、随机采样权重分布q,进行topK-topP-minP-sample采样计算。当输入isNeedSampleResult为false时,输出每个batch的最大词频logitsSelectIdx,以及topK-topP-minP采样后的词频分布logitsTopKPSelect;当输入isNeedSampleResult为true时,输出topK-topP-minP采样后的中间计算结果logitsIdx和logitsSortMasked,其中logitsSortMasked为词频logits经过topK-topP-minP采样计算后的中间结果,logitsIdx为logitsSortMasked在logits中对应的索引。 |
| 17 | 17 | ||
| 18 | 算子包含四个可单独使能,但上下游处理关系保持不变的采样算法(从原始输入到最终输出):TopK采样、TopP采样、MinP采样、指数采样(本文档中Sample所指)。目前支持以下计算场景。如下表所示: | 18 | 算子包含四个可单独使能,但上下游处理关系保持不变的采样算法(从原始输入到最终输出):TopK采样、TopP采样、MinP采样、指数采样(本文档中Sample所指)。目前支持以下计算场景。如下表所示: |
| 19 | + | ||
| 19 | | 计算场景 | TopK采样 | TopP采样 | minP采样 | 指数分布采样 | 输出中间计算结果 |备注| | 20 | | 计算场景 | TopK采样 | TopP采样 | minP采样 | 指数分布采样 | 输出中间计算结果 |备注| |
| 20 | | :-------:| :------:|:-------:|:-------:|:-------:|:-------:|:-------:| | 21 | | :-------:| :------:|:-------:|:-------:|:-------:|:-------:|:-------:| |
| 21 | |Softmax-Argmax采样|×|×|×|×|×|对输入logits按每个batch,取SoftMax后取最大结果| | 22 | |Softmax-Argmax采样|×|×|×|×|×|对输入logits按每个batch,取SoftMax后取最大结果| |
| @@ -30,6 +31,7 @@ | |||
| 30 | |topK-minP采样-中间结果|√|×|√|×|√|对输入logits按每个batch,先进行topK采样,再进行minP采样,输出中间计算结果| | 31 | |topK-minP采样-中间结果|√|×|√|×|√|对输入logits按每个batch,先进行topK采样,再进行minP采样,输出中间计算结果| |
| 31 | |topK-topP采样-中间结果|√|√|×|×|√|对输入logits按每个batch,先进行topK采样,再进行minP采样,输出中间计算结果| | 32 | |topK-topP采样-中间结果|√|√|×|×|√|对输入logits按每个batch,先进行topK采样,再进行minP采样,输出中间计算结果| |
| 32 | |topK采样-中间结果|√|×|×|×|√|对输入logits按每个batch,进行topK采样,输出中间计算结果| | 33 | |topK采样-中间结果|√|×|×|×|√|对输入logits按每个batch,进行topK采样,输出中间计算结果| |
| 34 | + | ||
| 33 | - 计算公式: | 35 | - 计算公式: |
| 34 | 36 | ||
| 35 | 输入logits为大小为[batch, voc_size]的词频表,其中每个batch对应一条输入序列,而voc_size则是约定每个batch的统一长度。<br> | 37 | 输入logits为大小为[batch, voc_size]的词频表,其中每个batch对应一条输入序列,而voc_size则是约定每个batch的统一长度。<br> |
| @@ -359,8 +361,8 @@ logits中的每一行logits[batch][:]根据相应的topK[batch]、topP[batch]、 | |||
| 359 | </tr> | 361 | </tr> |
| 360 | </tbody></table> | 362 | </tbody></table> |
| 361 | 363 | ||
| 362 | - | ||
| 363 | ## 约束说明 | 364 | ## 约束说明 |
| 365 | + | ||
| 364 | * 输入值域限制: | 366 | * 输入值域限制: |
| 365 | * 对于所有参数,它们的尺寸必须满足,batch>0,0<vocSize<=2^20。 | 367 | * 对于所有参数,它们的尺寸必须满足,batch>0,0<vocSize<=2^20。 |
| 366 | * ksMax的值域为[1, 1024]。 | 368 | * ksMax的值域为[1, 1024]。 |
| @@ -379,4 +381,4 @@ logits中的每一行logits[batch][:]根据相应的topK[batch]、topP[batch]、 | |||
| 379 | 381 | ||
| 380 | | 调用方式 | 样例代码 | 说明 | | 382 | | 调用方式 | 样例代码 | 说明 | |
| 381 | | ---------------- | --------------------------- | --------------------------------------------------- | | 383 | | ---------------- | --------------------------- | --------------------------------------------------- | |
| 382 | -| aclnn接口 | [test_aclnn_top_k_top_p_sample_v2](examples/test_aclnn_top_k_top_p_sample_v2.cpp) | 通过[aclnnTopKTopPSampleV2](docs/aclnnTopKTopPSampleV2.md)接口方式调用TopKTopPSampleV2算子。 | | 384 | +| aclnn接口 | [test_aclnn_top_k_top_p_sample_v2](examples/test_aclnn_top_k_top_p_sample_v2.cpp) | 通过[aclnnTopKTopPSampleV2](docs/aclnnTopKTopPSampleV2.md)接口方式调用TopKTopPSampleV2算子。 | |
| @@ -1,6 +1,6 @@ | |||
| 1 | # UniqueConsecutive | 1 | # UniqueConsecutive |
| 2 | 2 | ||
| 3 | -## 产品支持情况 | 3 | +## 产品支持情况 |
| 4 | 4 | ||
| 5 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| 6 | | :----------------------------------------------------------- | :------: | | 6 | | :----------------------------------------------------------- | :------: | |
| @@ -1,3 +1,3 @@ | |||
| 1 | # UniqueWithCountsExt2 | 1 | # UniqueWithCountsExt2 |
| 2 | 2 | ||
| 3 | -本目录仅包含UniqueWithCountsExt2算子对应的aclnn接口;如您想要贡献该算子的AscendC实现,请参考[贡献流程](../../CONTRIBUTING.md)。 | 3 | +本目录仅包含UniqueWithCountsExt2算子对应的aclnn接口;如您想要贡献该算子的AscendC实现,请参考[贡献流程](../../CONTRIBUTING.md)。 |
| @@ -112,7 +112,8 @@ | |||
| 112 | - 确定性计算: | 112 | - 确定性计算: |
| 113 | - aclnnUniqueDim默认确定性实现。 | 113 | - aclnnUniqueDim默认确定性实现。 |
| 114 | - 性能: | 114 | - 性能: |
| 115 | - - A2、A3及训练系列产品上,当self在dim上的维度值超过2亿时,性能很差甚至是运行超时。 | 115 | + - A2、A3及训练系列产品上,当self在dim上的维度值超过2亿时,性能很差甚至是运行超时。 |
| 116 | + | ||
| 116 | ## 调用示例 | 117 | ## 调用示例 |
| 117 | 118 | ||
| 118 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 119 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| @@ -11,7 +11,6 @@ | |||
| 11 | | <term>Atlas 推理系列产品</term> | √ | | 11 | | <term>Atlas 推理系列产品</term> | √ | |
| 12 | | <term>Atlas 训练系列产品</term> | √ | | 12 | | <term>Atlas 训练系列产品</term> | √ | |
| 13 | 13 | ||
| 14 | - | ||
| 15 | ## 功能说明 | 14 | ## 功能说明 |
| 16 | 15 | ||
| 17 | 算子功能:找出张量`x`中非零或True元素的位置,设张量`x`的维度为D,非零元素的个数为N,则返回`y`的shape为D * N,每一列表示一个非零元素的位置坐标。 | 16 | 算子功能:找出张量`x`中非零或True元素的位置,设张量`x`的维度为D,非零元素的个数为N,则返回`y`的shape为D * N,每一列表示一个非零元素的位置坐标。 |
| @@ -61,4 +60,4 @@ | |||
| 61 | 60 | ||
| 62 | | 调用方式 | 样例代码 | 说明 | | 61 | | 调用方式 | 样例代码 | 说明 | |
| 63 | | ---------------- | --------------------------- | --------------------------------------------------- | | 62 | | ---------------- | --------------------------- | --------------------------------------------------- | |
| 64 | -| 图模式调用 | [test_geir_where](./examples/test_geir_where.cpp) | 通过[算子IR](./op_graph/where_proto.h)构图方式调用where算子。 | | 63 | +| 图模式调用 | [test_geir_where](./examples/test_geir_where.cpp) | 通过[算子IR](./op_graph/where_proto.h)构图方式调用where算子。 | |
| @@ -32,7 +32,6 @@ | |||
| 32 | \end{cases} | 32 | \end{cases} |
| 33 | $$ | 33 | $$ |
| 34 | 34 | ||
| 35 | - | ||
| 36 | ## 参数说明 | 35 | ## 参数说明 |
| 37 | 36 | ||
| 38 | <table style="table-layout: auto; width: 100%"> | 37 | <table style="table-layout: auto; width: 100%"> |
| @@ -92,4 +91,4 @@ | |||
| 92 | 91 | ||
| 93 | | 调用方式 | 样例代码 | 说明 | | 92 | | 调用方式 | 样例代码 | 说明 | |
| 94 | | ---------------- | --------------------------- | --------------------------------------------------- | | 93 | | ---------------- | --------------------------- | --------------------------------------------------- | |
| 95 | -| aclnn接口 | [test_aclnn_binary_cross_entropy.cpp](examples/test_aclnn_binary_cross_entropy.cpp) | 通过[aclnnBinaryCrossEntropy](docs/aclnnBinaryCrossEntropy.md)接口方式调用BinaryCrossEntropy算子。 | | 94 | +| aclnn接口 | [test_aclnn_binary_cross_entropy.cpp](examples/test_aclnn_binary_cross_entropy.cpp) | 通过[aclnnBinaryCrossEntropy](docs/aclnnBinaryCrossEntropy.md)接口方式调用BinaryCrossEntropy算子。 | |
| @@ -40,7 +40,6 @@ | |||
| 40 | out = mean(grad\_input) \ if \ reduction = mean | 40 | out = mean(grad\_input) \ if \ reduction = mean |
| 41 | $$ | 41 | $$ |
| 42 | 42 | ||
| 43 | - | ||
| 44 | ## 参数说明 | 43 | ## 参数说明 |
| 45 | 44 | ||
| 46 | <table style="table-layout: auto; width: 100%"> | 45 | <table style="table-layout: auto; width: 100%"> |
| @@ -107,4 +106,4 @@ | |||
| 107 | 106 | ||
| 108 | | 调用方式 | 样例代码 | 说明 | | 107 | | 调用方式 | 样例代码 | 说明 | |
| 109 | | ---------------- | --------------------------- | --------------------------------------------------- | | 108 | | ---------------- | --------------------------- | --------------------------------------------------- | |
| 110 | -| aclnn接口 | [test_aclnn_binary_cross_entropy_backward.cpp](examples/test_aclnn_binary_cross_entropy_backward.cpp) | 通过[aclnnBinaryCrossEntropyBackward](docs/aclnnBinaryCrossEntropyBackward.md)接口方式调用BinaryCrossEntropyGrad算子。 | | 109 | +| aclnn接口 | [test_aclnn_binary_cross_entropy_backward.cpp](examples/test_aclnn_binary_cross_entropy_backward.cpp) | 通过[aclnnBinaryCrossEntropyBackward](docs/aclnnBinaryCrossEntropyBackward.md)接口方式调用BinaryCrossEntropyGrad算子。 | |
| @@ -265,11 +265,13 @@ aclnnStatus aclnnBinaryCrossEntropyBackward( | |||
| 265 | 265 | ||
| 266 | ## 约束说明 | 266 | ## 约束说明 |
| 267 | 267 | ||
| 268 | -- 确定性计算: | 268 | +- 确定性计算: |
| 269 | - - aclnnBinaryCrossEntropyBackward默认确定性实现。 | 269 | + - aclnnBinaryCrossEntropyBackward默认确定性实现。 |
| 270 | 270 | ||
| 271 | ## 调用示例 | 271 | ## 调用示例 |
| 272 | + | ||
| 272 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 273 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| 274 | + | ||
| 273 | ```cpp | 275 | ```cpp |
| 274 | #include <iostream> | 276 | #include <iostream> |
| 275 | #include <vector> | 277 | #include <vector> |
| @@ -431,4 +433,4 @@ int main() { | |||
| 431 | aclFinalize(); | 433 | aclFinalize(); |
| 432 | return 0; | 434 | return 0; |
| 433 | } | 435 | } |
| 434 | -``` | 436 | +``` |
| @@ -11,13 +11,12 @@ | |||
| 11 | | <term>Atlas 推理系列产品</term> | × | | 11 | | <term>Atlas 推理系列产品</term> | × | |
| 12 | | <term>Atlas 训练系列产品</term> | × | | 12 | | <term>Atlas 训练系列产品</term> | × | |
| 13 | 13 | ||
| 14 | - | ||
| 15 | ## 功能说明 | 14 | ## 功能说明 |
| 16 | 15 | ||
| 17 | - 算子功能:ChamferDistance(倒角距离)的反向算子,根据正向的输入对输出的贡献及初始梯度求出输入对应的梯度。 | 16 | - 算子功能:ChamferDistance(倒角距离)的反向算子,根据正向的输入对输出的贡献及初始梯度求出输入对应的梯度。 |
| 18 | - 计算公式: | 17 | - 计算公式: |
| 19 | 18 | ||
| 20 | - 假设有两个点集: xyz1=[B,N,2], xyz2=[B,M,2] | 19 | + 假设有两个点集:xyz1=[B,N,2], xyz2=[B,M,2] |
| 21 | 20 | ||
| 22 | - ChamferDistance(倒角距离)正向算子计算公式为: | 21 | - ChamferDistance(倒角距离)正向算子计算公式为: |
| 23 | 22 | ||
| @@ -138,5 +137,3 @@ xyz1、xyz2的shape为(B, N, 2),grad_dist1、grad_dist2、idx1、idx2的shape | |||
| 138 | | 调用方式 | 调用样例 | 说明 | | 137 | | 调用方式 | 调用样例 | 说明 | |
| 139 | |--------------|------------------------------------------------------------------------|----------------------------------------------------------------| | 138 | |--------------|------------------------------------------------------------------------|----------------------------------------------------------------| |
| 140 | | aclnn调用 | [test_aclnn_chamfer_distance_backward](./examples/test_aclnn_chamfer_distance_grad.cpp) | 通过[aclnnChamferDistanceBackward](./docs/aclnnChamferDistanceBackward.md)接口方式调用ChamferDistanceGrad算子。 | | 139 | | aclnn调用 | [test_aclnn_chamfer_distance_backward](./examples/test_aclnn_chamfer_distance_grad.cpp) | 通过[aclnnChamferDistanceBackward](./docs/aclnnChamferDistanceBackward.md)接口方式调用ChamferDistanceGrad算子。 | |
| 141 | - | ||
| 142 | - | ||
| @@ -81,4 +81,4 @@ a和b的维度要大于dim,且a和b的dim维大小必须是3。 | |||
| 81 | 81 | ||
| 82 | | 调用方式 | 样例代码 | 说明 | | 82 | | 调用方式 | 样例代码 | 说明 | |
| 83 | | ---------------- | --------------------------- | --------------------------------------------------- | | 83 | | ---------------- | --------------------------- | --------------------------------------------------- | |
| 84 | -| 图模式调用 | [test_geir_cross_v2](./examples/test_geir_cross_v2.cpp) | 通过[算子IR](./op_graph/cross_v2_proto.h)构图方式调用CrossV2算子。 | | 84 | +| 图模式调用 | [test_geir_cross_v2](./examples/test_geir_cross_v2.cpp) | 通过[算子IR](./op_graph/cross_v2_proto.h)构图方式调用CrossV2算子。 | |
| @@ -105,7 +105,6 @@ | |||
| 105 | </tr> | 105 | </tr> |
| 106 | </tbody></table> | 106 | </tbody></table> |
| 107 | 107 | ||
| 108 | - | ||
| 109 | ## 约束说明 | 108 | ## 约束说明 |
| 110 | 109 | ||
| 111 | 无 | 110 | 无 |
| @@ -114,4 +113,4 @@ | |||
| 114 | 113 | ||
| 115 | | 调用方式 | 调用样例 | 说明 | | 114 | | 调用方式 | 调用样例 | 说明 | |
| 116 | |--------------|------------------------------------------------------------------------|----------------------------------------------------------------| | 115 | |--------------|------------------------------------------------------------------------|----------------------------------------------------------------| |
| 117 | -| aclnn调用 | [test_aclnn_ctc_loss_v2](./examples/arch35/test_aclnn_ctc_loss_v2.cpp) | 通过[aclnnCtcLoss](./docs/aclnnCtcLoss.md)接口方式调用CtcLossV2算子。 | | 116 | +| aclnn调用 | [test_aclnn_ctc_loss_v2](./examples/arch35/test_aclnn_ctc_loss_v2.cpp) | 通过[aclnnCtcLoss](./docs/aclnnCtcLoss.md)接口方式调用CtcLossV2算子。 | |
| @@ -294,6 +294,7 @@ aclnnStatus aclnnCtcLoss( | |||
| 294 | ## 调用示例 | 294 | ## 调用示例 |
| 295 | 295 | ||
| 296 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 296 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| 297 | + | ||
| 297 | - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>: | 298 | - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>: |
| 298 | 299 | ||
| 299 | ```Cpp | 300 | ```Cpp |
| @@ -580,6 +581,7 @@ aclnnStatus aclnnCtcLoss( | |||
| 580 | return 0; | 581 | return 0; |
| 581 | } | 582 | } |
| 582 | ``` | 583 | ``` |
| 584 | + | ||
| 583 | - <term>Ascend 950PR/Ascend 950DT</term>: | 585 | - <term>Ascend 950PR/Ascend 950DT</term>: |
| 584 | 586 | ||
| 585 | ```Cpp | 587 | ```Cpp |
| @@ -865,4 +867,4 @@ aclnnStatus aclnnCtcLoss( | |||
| 865 | aclFinalize(); | 867 | aclFinalize(); |
| 866 | return 0; | 868 | return 0; |
| 867 | } | 869 | } |
| 868 | - ``` | 870 | + ``` |
| @@ -113,4 +113,4 @@ | |||
| 113 | 113 | ||
| 114 | | 调用方式 | 样例代码 | 说明 | | 114 | | 调用方式 | 样例代码 | 说明 | |
| 115 | | ---------------- | --------------------------- | --------------------------------------------------- | | 115 | | ---------------- | --------------------------- | --------------------------------------------------- | |
| 116 | -| aclnn接口 | [test_aclnn_ctc_loss_v3](examples/test_aclnn_ctc_loss_v3.cpp) | 通过[aclnnCtcLoss](../ctc_loss_v2/docs/aclnnCtcLoss.md)接口方式调用CtclossV3算子。 | | 116 | +| aclnn接口 | [test_aclnn_ctc_loss_v3](examples/test_aclnn_ctc_loss_v3.cpp) | 通过[aclnnCtcLoss](../ctc_loss_v2/docs/aclnnCtcLoss.md)接口方式调用CtclossV3算子。 | |
| @@ -24,7 +24,6 @@ | |||
| 24 | softMaxOutOptional = exp(vocab\_parallel\_logits -logits\_max.unsqueeze(dim = -1)) \ sum\_exp\_logits.unsqueeze(dim = -1) | 24 | softMaxOutOptional = exp(vocab\_parallel\_logits -logits\_max.unsqueeze(dim = -1)) \ sum\_exp\_logits.unsqueeze(dim = -1) |
| 25 | $$ | 25 | $$ |
| 26 | 26 | ||
| 27 | - | ||
| 28 | ## 参数说明 | 27 | ## 参数说明 |
| 29 | 28 | ||
| 30 | <table style="undefined;table-layout: fixed; width: 1005px"><colgroup> | 29 | <table style="undefined;table-layout: fixed; width: 1005px"><colgroup> |
| @@ -116,4 +115,4 @@ | |||
| 116 | 115 | ||
| 117 | | 调用方式 | 样例代码 | 说明 | | 116 | | 调用方式 | 样例代码 | 说明 | |
| 118 | | ---------------- | --------------------------- | --------------------------------------------------- | | 117 | | ---------------- | --------------------------- | --------------------------------------------------- | |
| 119 | -| aclnn接口 | [test_aclnn_fused_cross_entropy_loss_with_max_sum](examples/test_aclnn_fused_cross_entropy_loss_with_max_sum.cpp) | 通过[aclnnFusedCrossEntropyLossWithMaxSum](docs/aclnnFusedCrossEntropyLossWithMaxSum.md)接口方式调用FusedCrossEntropyLossWithMaxSum算子。 | | 118 | +| aclnn接口 | [test_aclnn_fused_cross_entropy_loss_with_max_sum](examples/test_aclnn_fused_cross_entropy_loss_with_max_sum.cpp) | 通过[aclnnFusedCrossEntropyLossWithMaxSum](docs/aclnnFusedCrossEntropyLossWithMaxSum.md)接口方式调用FusedCrossEntropyLossWithMaxSum算子。 | |
| @@ -11,14 +11,12 @@ | |||
| 11 | | <term>Atlas 推理系列产品</term> | × | | 11 | | <term>Atlas 推理系列产品</term> | × | |
| 12 | | <term>Atlas 训练系列产品</term> | × | | 12 | | <term>Atlas 训练系列产品</term> | × | |
| 13 | 13 | ||
| 14 | - | ||
| 15 | ## 功能说明 | 14 | ## 功能说明 |
| 16 | 15 | ||
| 17 | 算子功能:进行[aclnnKlDiv](https://gitcode.com/cann/ops-math/blob/master/math/kl_div_v2/docs/aclnnKlDiv.md) api的结果的反向计算。 | 16 | 算子功能:进行[aclnnKlDiv](https://gitcode.com/cann/ops-math/blob/master/math/kl_div_v2/docs/aclnnKlDiv.md) api的结果的反向计算。 |
| 18 | 17 | ||
| 19 | ## 参数说明 | 18 | ## 参数说明 |
| 20 | 19 | ||
| 21 | - | ||
| 22 | - gradOutput(aclTensor*, 计算输入):Device侧的aclTensor,[数据格式](../../docs/zh/context/数据格式.md)支持ND。shape需要与self满足[broadcast关系](../../docs/zh/context/broadcast关系.md)。支持[非连续的Tensor](../../docs/zh/context/非连续的Tensor.md)。 | 20 | - gradOutput(aclTensor*, 计算输入):Device侧的aclTensor,[数据格式](../../docs/zh/context/数据格式.md)支持ND。shape需要与self满足[broadcast关系](../../docs/zh/context/broadcast关系.md)。支持[非连续的Tensor](../../docs/zh/context/非连续的Tensor.md)。 |
| 23 | - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>、<term>Ascend 950PR/Ascend 950DT</term>:数据类型支持FLOAT、FLOAT16、BFLOAT16。 | 21 | - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>、<term>Ascend 950PR/Ascend 950DT</term>:数据类型支持FLOAT、FLOAT16、BFLOAT16。 |
| 24 | - self(aclTensor*, 计算输入):Device侧的aclTensor。[数据格式](../../docs/zh/context/数据格式.md)支持ND。支持[非连续的Tensor](../../docs/zh/context/非连续的Tensor.md)。 | 22 | - self(aclTensor*, 计算输入):Device侧的aclTensor。[数据格式](../../docs/zh/context/数据格式.md)支持ND。支持[非连续的Tensor](../../docs/zh/context/非连续的Tensor.md)。 |
| @@ -38,4 +36,4 @@ | |||
| 38 | 36 | ||
| 39 | | 调用方式 | 样例代码 | 说明 | | 37 | | 调用方式 | 样例代码 | 说明 | |
| 40 | | ---------------- | --------------------------- | --------------------------------------------------- | | 38 | | ---------------- | --------------------------- | --------------------------------------------------- | |
| 41 | -| aclnn接口 | [test_aclnn_kl_div_loss_grad.cpp](examples/test_aclnn_kl_div_loss_grad.cpp) | 通过[aclnnKlDivBackward](docs/aclnnKlDivBackward.md)接口方式调用KlDivLossGrad算子。 | | 39 | +| aclnn接口 | [test_aclnn_kl_div_loss_grad.cpp](examples/test_aclnn_kl_div_loss_grad.cpp) | 通过[aclnnKlDivBackward](docs/aclnnKlDivBackward.md)接口方式调用KlDivLossGrad算子。 | |
| @@ -11,7 +11,6 @@ | |||
| 11 | | <term>Atlas 推理系列产品</term> | √ | | 11 | | <term>Atlas 推理系列产品</term> | √ | |
| 12 | | <term>Atlas 训练系列产品</term> | √ | | 12 | | <term>Atlas 训练系列产品</term> | √ | |
| 13 | 13 | ||
| 14 | - | ||
| 15 | ## 功能说明 | 14 | ## 功能说明 |
| 16 | 15 | ||
| 17 | - 算子功能:计算[aclnnL1Loss](../lp_loss/docs/aclnnL1Loss.md)的反向传播。reduction指定损失函数的计算方式,支持 'none'、'mean'、'sum'。'none' 表示不应用减少,'mean' 表示输出的总和将除以输出中的元素数,'sum' 表示输出将被求和。 | 16 | - 算子功能:计算[aclnnL1Loss](../lp_loss/docs/aclnnL1Loss.md)的反向传播。reduction指定损失函数的计算方式,支持 'none'、'mean'、'sum'。'none' 表示不应用减少,'mean' 表示输出的总和将除以输出中的元素数,'sum' 表示输出将被求和。 |
| @@ -36,4 +35,4 @@ | |||
| 36 | 35 | ||
| 37 | | 调用方式 | 样例代码 | 说明 | | 36 | | 调用方式 | 样例代码 | 说明 | |
| 38 | | ---------------- | --------------------------- |-------------------------------------------------------------------------| | 37 | | ---------------- | --------------------------- |-------------------------------------------------------------------------| |
| 39 | -| aclnn接口 | [test_aclnn_l1_loss_grad.cpp](examples/test_aclnn_l1_loss_grad.cpp) | 通过[aclnnL1LossBackward](docs/aclnnL1LossBackward.md)接口方式调用L1LossGrad算子。 | | 38 | +| aclnn接口 | [test_aclnn_l1_loss_grad.cpp](examples/test_aclnn_l1_loss_grad.cpp) | 通过[aclnnL1LossBackward](docs/aclnnL1LossBackward.md)接口方式调用L1LossGrad算子。 | |
| @@ -92,4 +92,4 @@ $$ | |||
| 92 | | 调用方式 | 调用样例 | 说明 | | 92 | | 调用方式 | 调用样例 | 说明 | |
| 93 | |--------------|------------------------------------------------------------------------|----------------------------------------------------------------| | 93 | |--------------|------------------------------------------------------------------------|----------------------------------------------------------------| |
| 94 | | aclnn调用 | [test_aclnn_logit_grad](./examples/test_aclnn_logit_grad.cpp) | 通过[aclnnLogitGrad](./docs/aclnnLogitGrad.md)接口方式调用LogitGrad算子。 | | 94 | | aclnn调用 | [test_aclnn_logit_grad](./examples/test_aclnn_logit_grad.cpp) | 通过[aclnnLogitGrad](./docs/aclnnLogitGrad.md)接口方式调用LogitGrad算子。 | |
| 95 | -| 图模式调用 | - | 通过[算子IR](./op_graph/logit_grad_proto.h)构图方式调用LogitGrad算子。 | | 95 | +| 图模式调用 | - | 通过[算子IR](./op_graph/logit_grad_proto.h)构图方式调用LogitGrad算子。 | |
| @@ -1,6 +1,5 @@ | |||
| 1 | # LpLoss | 1 | # LpLoss |
| 2 | 2 | ||
| 3 | - | ||
| 4 | ## 产品支持情况 | 3 | ## 产品支持情况 |
| 5 | 4 | ||
| 6 | |产品 | 是否支持 | | 5 | |产品 | 是否支持 | |
| @@ -34,6 +33,7 @@ | |||
| 34 | \operatorname{sum}(L), & \text{if reduction} = \text{'sum'.} | 33 | \operatorname{sum}(L), & \text{if reduction} = \text{'sum'.} |
| 35 | \end{cases} | 34 | \end{cases} |
| 36 | $$ | 35 | $$ |
| 36 | + | ||
| 37 | ## 参数说明 | 37 | ## 参数说明 |
| 38 | 38 | ||
| 39 | - self (aclTensor*,计算输入):公式中的输入`self`,Device侧的aclTensor。数据类型与target的数据类型满足数据类型推导规则(参见[互推导关系](../../docs/zh/context/互推导关系.md))。shape支持0-8维,shape需要与target满足[broadcast规则](../../docs/zh/context/broadcast关系.md)。支持[非连续的Tensor](../../docs/zh/context/非连续的Tensor.md),[数据格式](../../docs/zh/context/数据格式.md)支持ND。 | 39 | - self (aclTensor*,计算输入):公式中的输入`self`,Device侧的aclTensor。数据类型与target的数据类型满足数据类型推导规则(参见[互推导关系](../../docs/zh/context/互推导关系.md))。shape支持0-8维,shape需要与target满足[broadcast规则](../../docs/zh/context/broadcast关系.md)。支持[非连续的Tensor](../../docs/zh/context/非连续的Tensor.md),[数据格式](../../docs/zh/context/数据格式.md)支持ND。 |
| @@ -54,4 +54,4 @@ | |||
| 54 | 54 | ||
| 55 | | 调用方式 | 样例代码 | 说明 | | 55 | | 调用方式 | 样例代码 | 说明 | |
| 56 | | ---------------- | --------------------------- | --------------------------------------------------- | | 56 | | ---------------- | --------------------------- | --------------------------------------------------- | |
| 57 | -| aclnn接口 | [test_aclnn_l1_loss.cpp](examples/test_aclnn_l1_loss.cpp) | 通过[aclnnL1Loss](docs/aclnnL1Loss.md)接口方式调用LpLoss算子。 | | 57 | +| aclnn接口 | [test_aclnn_l1_loss.cpp](examples/test_aclnn_l1_loss.cpp) | 通过[aclnnL1Loss](docs/aclnnL1Loss.md)接口方式调用LpLoss算子。 | |
| @@ -86,10 +86,10 @@ | |||
| 86 | 86 | ||
| 87 | ## 约束说明 | 87 | ## 约束说明 |
| 88 | 88 | ||
| 89 | -无 | 89 | +无 |
| 90 | 90 | ||
| 91 | ## 调用说明 | 91 | ## 调用说明 |
| 92 | 92 | ||
| 93 | | 调用方式 | 调用样例 | 说明 | | 93 | | 调用方式 | 调用样例 | 说明 | |
| 94 | |--------------|------------------------------------------------------------------------|----------------------------------------------------------------| | 94 | |--------------|------------------------------------------------------------------------|----------------------------------------------------------------| |
| 95 | -| aclnn调用 | [test_aclnn_mse_loss_grad](./examples/test_aclnn_mse_loss_backward.cpp) | 通过[aclnnMseLossGrad](../mse_loss_grad_v2/docs/aclnnMseLossBackward.md)接口方式调用mse_loss_grad算子。 | | 95 | +| aclnn调用 | [test_aclnn_mse_loss_grad](./examples/test_aclnn_mse_loss_backward.cpp) | 通过[aclnnMseLossGrad](../mse_loss_grad_v2/docs/aclnnMseLossBackward.md)接口方式调用mse_loss_grad算子。 | |
| @@ -1,3 +1,3 @@ | |||
| 1 | # MultilabelMarginLoss | 1 | # MultilabelMarginLoss |
| 2 | 2 | ||
| 3 | -本目录仅包含MultilabelMarginLoss算子对应的aclnn接口;如您想要贡献该算子的AscendC实现,请参考[贡献流程](../../CONTRIBUTING.md)。 | 3 | +本目录仅包含MultilabelMarginLoss算子对应的aclnn接口;如您想要贡献该算子的AscendC实现,请参考[贡献流程](../../CONTRIBUTING.md)。 |
| @@ -1,6 +1,6 @@ | |||
| 1 | # NllLoss | 1 | # NllLoss |
| 2 | 2 | ||
| 3 | - ## 产品支持情况 | 3 | +## 产品支持情况 |
| 4 | 4 | ||
| 5 | |产品 | 是否支持 | | 5 | |产品 | 是否支持 | |
| 6 | |:-------------------------|:----------:| | 6 | |:-------------------------|:----------:| |
| @@ -11,7 +11,7 @@ | |||
| 11 | | <term>Atlas 推理系列产品</term> | √ | | 11 | | <term>Atlas 推理系列产品</term> | √ | |
| 12 | | <term>Atlas 训练系列产品</term> | √ | | 12 | | <term>Atlas 训练系列产品</term> | √ | |
| 13 | 13 | ||
| 14 | - ## 功能说明 | 14 | +## 功能说明 |
| 15 | 15 | ||
| 16 | - 接口功能:计算负对数似然损失值。 | 16 | - 接口功能:计算负对数似然损失值。 |
| 17 | 17 | ||
| @@ -40,7 +40,7 @@ | |||
| 40 | totalWeight = \sum_{n=1}^N w_{y_n} | 40 | totalWeight = \sum_{n=1}^N w_{y_n} |
| 41 | $$ | 41 | $$ |
| 42 | 42 | ||
| 43 | - ## 参数说明 | 43 | +## 参数说明 |
| 44 | 44 | ||
| 45 | <table style="undefined;table-layout: fixed; width: 980px"><colgroup> | 45 | <table style="undefined;table-layout: fixed; width: 980px"><colgroup> |
| 46 | <col style="width: 100px"> | 46 | <col style="width: 100px"> |
| @@ -102,13 +102,13 @@ | |||
| 102 | </tr> | 102 | </tr> |
| 103 | </tbody></table> | 103 | </tbody></table> |
| 104 | 104 | ||
| 105 | - ## 约束说明 | 105 | +## 约束说明 |
| 106 | 106 | ||
| 107 | 无 | 107 | 无 |
| 108 | 108 | ||
| 109 | - ## 调用说明 | 109 | +## 调用说明 |
| 110 | 110 | ||
| 111 | | 调用方式 | 调用样例 | 说明 | | 111 | | 调用方式 | 调用样例 | 说明 | |
| 112 | |--------------|------------------------------------------------------------------------|--------------------------------------------------------------| | 112 | |--------------|------------------------------------------------------------------------|--------------------------------------------------------------| |
| 113 | | aclnn调用 | [test_aclnn_nll_loss](./examples/test_aclnn_nll_loss.cpp) | 通过[aclnnNLLLoss](./docs/aclnnNLLLoss.md)接口方式调用NLLLoss算子。 | | 113 | | aclnn调用 | [test_aclnn_nll_loss](./examples/test_aclnn_nll_loss.cpp) | 通过[aclnnNLLLoss](./docs/aclnnNLLLoss.md)接口方式调用NLLLoss算子。 | |
| 114 | - | aclnn调用 | [test_aclnn_nll_loss_2d](./examples/test_aclnn_nll_loss_2d.cpp) | 通过[aclnnNLLLoss2d](./docs/aclnnNLLLoss2d.md)接口方式调用NLLLoss算子。 | | 114 | + | aclnn调用 | [test_aclnn_nll_loss_2d](./examples/test_aclnn_nll_loss_2d.cpp) | 通过[aclnnNLLLoss2d](./docs/aclnnNLLLoss2d.md)接口方式调用NLLLoss算子。 | |
| @@ -277,6 +277,7 @@ aclnnStatus aclnnNLLLoss( | |||
| 277 | ## 调用示例 | 277 | ## 调用示例 |
| 278 | 278 | ||
| 279 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 279 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| 280 | + | ||
| 280 | ```Cpp | 281 | ```Cpp |
| 281 | #include <iostream> | 282 | #include <iostream> |
| 282 | #include <vector> | 283 | #include <vector> |
| @@ -438,4 +439,3 @@ int main() { | |||
| 438 | return 0; | 439 | return 0; |
| 439 | } | 440 | } |
| 440 | ``` | 441 | ``` |
| 441 | - | ||
| @@ -274,6 +274,7 @@ aclnnStatus aclnnNLLLoss2d( | |||
| 274 | ## 调用示例 | 274 | ## 调用示例 |
| 275 | 275 | ||
| 276 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 276 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| 277 | + | ||
| 277 | ```Cpp | 278 | ```Cpp |
| 278 | #include <iostream> | 279 | #include <iostream> |
| 279 | #include <vector> | 280 | #include <vector> |
| @@ -432,4 +433,4 @@ int main() { | |||
| 432 | aclFinalize(); | 433 | aclFinalize(); |
| 433 | return 0; | 434 | return 0; |
| 434 | } | 435 | } |
| 435 | -``` | 436 | +``` |
| @@ -27,6 +27,7 @@ x\_grad[n][i] = | |||
| 27 | $$ | 27 | $$ |
| 28 | 28 | ||
| 29 | ## 参数说明 | 29 | ## 参数说明 |
| 30 | + | ||
| 30 | <table style="undefined;table-layout: fixed; width: 1349px"><colgroup> | 31 | <table style="undefined;table-layout: fixed; width: 1349px"><colgroup> |
| 31 | <col style="width: 158px"> | 32 | <col style="width: 158px"> |
| 32 | <col style="width: 120px"> | 33 | <col style="width: 120px"> |
| @@ -115,4 +116,4 @@ $$ | |||
| 115 | | 调用方式 | 调用样例 | 说明 | | 116 | | 调用方式 | 调用样例 | 说明 | |
| 116 | |--------------|------------------------------------------------------------------------|--------------------------------------------------------------| | 117 | |--------------|------------------------------------------------------------------------|--------------------------------------------------------------| |
| 117 | | aclnn调用 | [test_aclnn_nll_loss_grad](./examples/test_aclnn_nll_loss_grad.cpp) | 通过[aclnnNLLLossBackward](./docs/aclnnNLLLossBackward.md)接口方式调用NLLLossGrad算子。 | | 118 | | aclnn调用 | [test_aclnn_nll_loss_grad](./examples/test_aclnn_nll_loss_grad.cpp) | 通过[aclnnNLLLossBackward](./docs/aclnnNLLLossBackward.md)接口方式调用NLLLossGrad算子。 | |
| 118 | -| aclnn调用 | [test_aclnn_nll_loss_grad_2d](./examples/test_aclnn_nll_loss_grad_2d.cpp) | 通过[aclnnNLLLoss2dBackward](./docs/aclnnNLLLoss2dBackward.md)接口方式调用NLLLossGrad算子。 | | 119 | +| aclnn调用 | [test_aclnn_nll_loss_grad_2d](./examples/test_aclnn_nll_loss_grad_2d.cpp) | 通过[aclnnNLLLoss2dBackward](./docs/aclnnNLLLoss2dBackward.md)接口方式调用NLLLossGrad算子。 | |
| @@ -228,7 +228,6 @@ aclnnStatus aclnnNLLLoss2dBackward( | |||
| 228 | </tbody> | 228 | </tbody> |
| 229 | </table> | 229 | </table> |
| 230 | 230 | ||
| 231 | - | ||
| 232 | ## aclnnNLLLoss2dBackward | 231 | ## aclnnNLLLoss2dBackward |
| 233 | 232 | ||
| 234 | - **参数说明** | 233 | - **参数说明** |
| @@ -268,7 +267,6 @@ aclnnStatus aclnnNLLLoss2dBackward( | |||
| 268 | </tbody> | 267 | </tbody> |
| 269 | </table> | 268 | </table> |
| 270 | 269 | ||
| 271 | - | ||
| 272 | - **返回值** | 270 | - **返回值** |
| 273 | 271 | ||
| 274 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 272 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| @@ -281,6 +279,7 @@ aclnnStatus aclnnNLLLoss2dBackward( | |||
| 281 | ## 调用示例 | 279 | ## 调用示例 |
| 282 | 280 | ||
| 283 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 281 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| 282 | + | ||
| 284 | ```Cpp | 283 | ```Cpp |
| 285 | #include <iostream> | 284 | #include <iostream> |
| 286 | #include <vector> | 285 | #include <vector> |
| @@ -456,4 +455,3 @@ int main() { | |||
| 456 | return 0; | 455 | return 0; |
| 457 | } | 456 | } |
| 458 | ``` | 457 | ``` |
| 459 | - | ||
| @@ -200,7 +200,6 @@ aclnnStatus aclnnNLLLossBackward( | |||
| 200 | </tbody> | 200 | </tbody> |
| 201 | </table> | 201 | </table> |
| 202 | 202 | ||
| 203 | - | ||
| 204 | - **返回值:** | 203 | - **返回值:** |
| 205 | 204 | ||
| 206 | aclnnStatus: 返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 205 | aclnnStatus: 返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| @@ -292,6 +291,7 @@ aclnnStatus aclnnNLLLossBackward( | |||
| 292 | ## 调用示例 | 291 | ## 调用示例 |
| 293 | 292 | ||
| 294 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 293 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| 294 | + | ||
| 295 | ```Cpp | 295 | ```Cpp |
| 296 | #include <iostream> | 296 | #include <iostream> |
| 297 | #include <vector> | 297 | #include <vector> |
| @@ -464,4 +464,3 @@ int main() { | |||
| 464 | return 0; | 464 | return 0; |
| 465 | } | 465 | } |
| 466 | ``` | 466 | ``` |
| 467 | - | ||
| @@ -1,3 +1,3 @@ | |||
| 1 | # SigmoidCrossEntropyWithLogitsGradV2 | 1 | # SigmoidCrossEntropyWithLogitsGradV2 |
| 2 | 2 | ||
| 3 | -本目录仅包含SigmoidCrossEntropyWithLogitsGradV2算子对应的aclnn接口;如您想要贡献该算子的AscendC实现,请参考[贡献流程](../../CONTRIBUTING.md)。 | 3 | +本目录仅包含SigmoidCrossEntropyWithLogitsGradV2算子对应的aclnn接口;如您想要贡献该算子的AscendC实现,请参考[贡献流程](../../CONTRIBUTING.md)。 |
Mloss/sigmoid_cross_entropy_with_logits_grad_v2/docs/aclnnBinaryCrossEntropyWithLogitsBackward.md+3-1
| @@ -206,7 +206,6 @@ aclnnStatus aclnnBinaryCrossEntropyWithLogitsBackward( | |||
| 206 | </tbody> | 206 | </tbody> |
| 207 | </table> | 207 | </table> |
| 208 | 208 | ||
| 209 | - | ||
| 210 | ## aclnnBinaryCrossEntropyWithLogitsBackward | 209 | ## aclnnBinaryCrossEntropyWithLogitsBackward |
| 211 | 210 | ||
| 212 | - **参数说明:** | 211 | - **参数说明:** |
| @@ -251,11 +250,14 @@ aclnnStatus aclnnBinaryCrossEntropyWithLogitsBackward( | |||
| 251 | aclnnStatus: 返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 250 | aclnnStatus: 返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| 252 | 251 | ||
| 253 | ## 约束说明 | 252 | ## 约束说明 |
| 253 | + | ||
| 254 | - 确定性计算: | 254 | - 确定性计算: |
| 255 | - aclnnBinaryCrossEntropyWithLogitsBackward默认确定性实现。 | 255 | - aclnnBinaryCrossEntropyWithLogitsBackward默认确定性实现。 |
| 256 | 256 | ||
| 257 | ## 调用示例 | 257 | ## 调用示例 |
| 258 | + | ||
| 258 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 259 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| 260 | + | ||
| 259 | ```Cpp | 261 | ```Cpp |
| 260 | #include <iostream> | 262 | #include <iostream> |
| 261 | #include <vector> | 263 | #include <vector> |
| @@ -142,4 +142,4 @@ | |||
| 142 | 142 | ||
| 143 | | 调用方式 | 调用样例 | 说明 | | 143 | | 调用方式 | 调用样例 | 说明 | |
| 144 | |--------------|------------------------------------------------------------------------|--------------------------------------------------------------| | 144 | |--------------|------------------------------------------------------------------------|--------------------------------------------------------------| |
| 145 | -| aclnn调用 | [aclnnBinaryCrossEntropyWithLogits](./docs/aclnnBinaryCrossEntropyWithLogits.md) | 通过[aclnnBinaryCrossEntropyWithLogits](./docs/aclnnBinaryCrossEntropyWithLogits.md)接口方式调用SigmoidCrossEntropyWithLogitsV2算子。 | | 145 | +| aclnn调用 | [aclnnBinaryCrossEntropyWithLogits](./docs/aclnnBinaryCrossEntropyWithLogits.md) | 通过[aclnnBinaryCrossEntropyWithLogits](./docs/aclnnBinaryCrossEntropyWithLogits.md)接口方式调用SigmoidCrossEntropyWithLogitsV2算子。 | |
| @@ -263,11 +263,14 @@ aclnnStatus aclnnBinaryCrossEntropyWithLogits( | |||
| 263 | aclnnStatus: 返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 263 | aclnnStatus: 返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| 264 | 264 | ||
| 265 | ## 约束说明 | 265 | ## 约束说明 |
| 266 | -- 确定性计算: | 266 | + |
| 267 | - - aclnnBinaryCrossEntropyWithLogits默认确定性实现。 | 267 | +- 确定性计算: |
| 268 | + - aclnnBinaryCrossEntropyWithLogits默认确定性实现。 | ||
| 268 | 269 | ||
| 269 | ## 调用示例 | 270 | ## 调用示例 |
| 271 | + | ||
| 270 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 272 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| 273 | + | ||
| 271 | ```Cpp | 274 | ```Cpp |
| 272 | #include <iostream> | 275 | #include <iostream> |
| 273 | #include <vector> | 276 | #include <vector> |
| @@ -11,7 +11,6 @@ | |||
| 11 | | <term>Atlas 推理系列产品</term> | √ | | 11 | | <term>Atlas 推理系列产品</term> | √ | |
| 12 | | <term>Atlas 训练系列产品</term> | √ | | 12 | | <term>Atlas 训练系列产品</term> | √ | |
| 13 | 13 | ||
| 14 | - | ||
| 15 | ## 功能说明 | 14 | ## 功能说明 |
| 16 | 15 | ||
| 17 | - 算子功能:计算[aclnnSmoothL1Loss](../smooth_l1_loss_v2/docs/aclnnSmoothL1Loss.md) api的反向传播。 | 16 | - 算子功能:计算[aclnnSmoothL1Loss](../smooth_l1_loss_v2/docs/aclnnSmoothL1Loss.md) api的反向传播。 |
| @@ -55,11 +54,12 @@ | |||
| 55 | - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>、<term>Ascend 950PR/Ascend 950DT</term>:数据类型支持BFLOAT16、FLOAT16、FLOAT32。 | 54 | - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>、<term>Ascend 950PR/Ascend 950DT</term>:数据类型支持BFLOAT16、FLOAT16、FLOAT32。 |
| 56 | 55 | ||
| 57 | ## 约束说明 | 56 | ## 约束说明 |
| 58 | -- 确定性计算: | 57 | + |
| 58 | +- 确定性计算: | ||
| 59 | - aclnnSmoothL1LossBackward默认确定性实现。 | 59 | - aclnnSmoothL1LossBackward默认确定性实现。 |
| 60 | 60 | ||
| 61 | ## 调用说明 | 61 | ## 调用说明 |
| 62 | 62 | ||
| 63 | | 调用方式 | 样例代码 | 说明 | | 63 | | 调用方式 | 样例代码 | 说明 | |
| 64 | | ---------------- | --------------------------- | --------------------------------------------------- | | 64 | | ---------------- | --------------------------- | --------------------------------------------------- | |
| 65 | -| aclnn接口 | [test_aclnn_smooth_l1_loss_backward.cpp](examples/test_aclnn_smooth_l1_loss_backward.cpp) | 通过[aclnnSmoothL1LossBackward](docs/aclnnSmoothL1LossBackward.md)接口方式调用SmoothL1LossBackward算子。 | | 65 | +| aclnn接口 | [test_aclnn_smooth_l1_loss_backward.cpp](examples/test_aclnn_smooth_l1_loss_backward.cpp) | 通过[aclnnSmoothL1LossBackward](docs/aclnnSmoothL1LossBackward.md)接口方式调用SmoothL1LossBackward算子。 | |
| @@ -43,7 +43,6 @@ | |||
| 43 | - Xn: predictions | 43 | - Xn: predictions |
| 44 | - Yn: labels/truth | 44 | - Yn: labels/truth |
| 45 | 45 | ||
| 46 | - | ||
| 47 | ## 参数说明 | 46 | ## 参数说明 |
| 48 | 47 | ||
| 49 | <table style="table-layout: auto; width: 100%"> | 48 | <table style="table-layout: auto; width: 100%"> |
| @@ -103,4 +102,4 @@ | |||
| 103 | 102 | ||
| 104 | | 调用方式 | 样例代码 | 说明 | | 103 | | 调用方式 | 样例代码 | 说明 | |
| 105 | | ---------------- | --------------------------- | --------------------------------------------------- | | 104 | | ---------------- | --------------------------- | --------------------------------------------------- | |
| 106 | -| aclnn接口 | [test_aclnn_smooth_l1_loss_v2.cpp](examples/test_aclnn_smooth_l1_loss_v2.cpp) | 通过[aclnnsmoothL1Loss](docs/aclnnSmoothL1Loss.md)接口方式调用SmoothL1Loss算子。 | | 105 | +| aclnn接口 | [test_aclnn_smooth_l1_loss_v2.cpp](examples/test_aclnn_smooth_l1_loss_v2.cpp) | 通过[aclnnsmoothL1Loss](docs/aclnnSmoothL1Loss.md)接口方式调用SmoothL1Loss算子。 | |
| @@ -1,3 +1,3 @@ | |||
| 1 | # SoftMarginLoss | 1 | # SoftMarginLoss |
| 2 | 2 | ||
| 3 | -本目录仅包含SoftMarginLoss算子对应的aclnn接口;如您想要贡献该算子的AscendC实现,请参考[贡献流程](../../CONTRIBUTING.md)。 | 3 | +本目录仅包含SoftMarginLoss算子对应的aclnn接口;如您想要贡献该算子的AscendC实现,请参考[贡献流程](../../CONTRIBUTING.md)。 |
| @@ -1,3 +1,3 @@ | |||
| 1 | # SoftMarginLossGrad | 1 | # SoftMarginLossGrad |
| 2 | 2 | ||
| 3 | -本目录仅包含SoftMarginLossGrad算子对应的aclnn接口;如您想要贡献该算子的AscendC实现,请参考[贡献流程](../../CONTRIBUTING.md)。 | 3 | +本目录仅包含SoftMarginLossGrad算子对应的aclnn接口;如您想要贡献该算子的AscendC实现,请参考[贡献流程](../../CONTRIBUTING.md)。 |
| @@ -1,3 +1,3 @@ | |||
| 1 | # Addmv | 1 | # Addmv |
| 2 | 2 | ||
| 3 | -本目录仅包含Addmv算子对应的aclnn接口;如您想要贡献该算子的AscendC实现,请参考[贡献流程](../../CONTRIBUTING.md)。 | 3 | +本目录仅包含Addmv算子对应的aclnn接口;如您想要贡献该算子的AscendC实现,请参考[贡献流程](../../CONTRIBUTING.md)。 |
| @@ -1,7 +1,6 @@ | |||
| 1 | # BatchMatMulV3 | 1 | # BatchMatMulV3 |
| 2 | 2 | ||
| 3 | - | 3 | +## 产品支持情况 |
| 4 | -## 产品支持情况 | ||
| 5 | 4 | ||
| 6 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| 7 | | ---- | :----:| | 6 | | ---- | :----:| |
| @@ -76,6 +75,7 @@ | |||
| 76 | - Atlas A2 训练系列产品/Atlas A2 推理系列产品、Atlas A3 训练系列产品/Atlas A3 推理系列产品:bias不支持BFLOAT16数据格式。 | 75 | - Atlas A2 训练系列产品/Atlas A2 推理系列产品、Atlas A3 训练系列产品/Atlas A3 推理系列产品:bias不支持BFLOAT16数据格式。 |
| 77 | - Atlas 推理系列产品:只支持FLOAT16数据格式,输入mat2只支持FRACTAL_NZ格式。 | 76 | - Atlas 推理系列产品:只支持FLOAT16数据格式,输入mat2只支持FRACTAL_NZ格式。 |
| 78 | - Kirin X90/Kirin 9030处理器系列产品:self、mat2和out的数据类型不支持BFLOAT16、FLOAT32,bias只支持INT8。 | 77 | - Kirin X90/Kirin 9030处理器系列产品:self、mat2和out的数据类型不支持BFLOAT16、FLOAT32,bias只支持INT8。 |
| 78 | + | ||
| 79 | ## 约束说明 | 79 | ## 约束说明 |
| 80 | 80 | ||
| 81 | - 支持空tensor,空tensor场景下不支持bias。 | 81 | - 支持空tensor,空tensor场景下不支持bias。 |
| @@ -85,4 +85,4 @@ | |||
| 85 | 85 | ||
| 86 | | 调用方式 | 样例代码 | 说明 | | 86 | | 调用方式 | 样例代码 | 说明 | |
| 87 | | ---------------- | --------------------------- | --------------------------------------------------- | | 87 | | ---------------- | --------------------------- | --------------------------------------------------- | |
| 88 | -| aclnn接口 | [test_aclnn_batchmatmul](examples/test_aclnn_batchmatmul.cpp) | 通过<br>[aclnnAddbmm&aclnnInplaceAddbmm](./docs/aclnnAddbmm&aclnnInplaceAddbmm.md)<br>[aclnnBaddbmm&aclnnInplaceBaddbmm](./docs/aclnnBaddbmm&aclnnInplaceBaddbmm.md)<br>[aclnnBatchMatMul](docs/aclnnBatchMatMul.md)<br>[aclnnBatchMatMulWeightNz](docs/aclnnBatchMatMulWeightNz.md)<br>等方式调用BatchMatMulV3算子。 | | 88 | +| aclnn接口 | [test_aclnn_batchmatmul](examples/test_aclnn_batchmatmul.cpp) | 通过<br>[aclnnAddbmm&aclnnInplaceAddbmm](./docs/aclnnAddbmm&aclnnInplaceAddbmm.md)<br>[aclnnBaddbmm&aclnnInplaceBaddbmm](./docs/aclnnBaddbmm&aclnnInplaceBaddbmm.md)<br>[aclnnBatchMatMul](docs/aclnnBatchMatMul.md)<br>[aclnnBatchMatMulWeightNz](docs/aclnnBatchMatMulWeightNz.md)<br>等方式调用BatchMatMulV3算子。 | |
| @@ -30,6 +30,7 @@ | |||
| 30 | ## 函数原型 | 30 | ## 函数原型 |
| 31 | 31 | ||
| 32 | 每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnBatchMatMulGetWorkspaceSize”接口获取入参并根据流程计算所需workspace大小,再调用“aclnnBatchMatMul”接口执行计算。 | 32 | 每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnBatchMatMulGetWorkspaceSize”接口获取入参并根据流程计算所需workspace大小,再调用“aclnnBatchMatMul”接口执行计算。 |
| 33 | + | ||
| 33 | ```cpp | 34 | ```cpp |
| 34 | aclnnStatus aclnnBatchMatMulGetWorkspaceSize( | 35 | aclnnStatus aclnnBatchMatMulGetWorkspaceSize( |
| 35 | const aclTensor *self, | 36 | const aclTensor *self, |
| @@ -39,6 +40,7 @@ aclnnStatus aclnnBatchMatMulGetWorkspaceSize( | |||
| 39 | uint64_t *workspaceSize, | 40 | uint64_t *workspaceSize, |
| 40 | aclOpExecutor **executor) | 41 | aclOpExecutor **executor) |
| 41 | ``` | 42 | ``` |
| 43 | + | ||
| 42 | ```cpp | 44 | ```cpp |
| 43 | aclnnStatus aclnnBatchMatMul( | 45 | aclnnStatus aclnnBatchMatMul( |
| 44 | void *workspace, | 46 | void *workspace, |
| @@ -150,7 +152,6 @@ aclnnStatus aclnnBatchMatMul( | |||
| 150 | - cubeMathType=1,当输入数据类型为FLOAT32时,会转换为FLOAT16计算,当输入为其他数据类型时不做处理; | 152 | - cubeMathType=1,当输入数据类型为FLOAT32时,会转换为FLOAT16计算,当输入为其他数据类型时不做处理; |
| 151 | - 不支持cubeMathType=3。 | 153 | - 不支持cubeMathType=3。 |
| 152 | 154 | ||
| 153 | - | ||
| 154 | - **返回值:** | 155 | - **返回值:** |
| 155 | 156 | ||
| 156 | aclnnStatus: 返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 157 | aclnnStatus: 返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| @@ -233,12 +234,15 @@ aclnnStatus aclnnBatchMatMul( | |||
| 233 | aclnnStatus: 返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 234 | aclnnStatus: 返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| 234 | 235 | ||
| 235 | ## 约束说明 | 236 | ## 约束说明 |
| 237 | + | ||
| 236 | - 确定性计算 | 238 | - 确定性计算 |
| 237 | - <term>Atlas 训练系列产品</term>、<term>Atlas 推理系列产品</term>:aclnnBatchMatMul默认确定性实现。 | 239 | - <term>Atlas 训练系列产品</term>、<term>Atlas 推理系列产品</term>:aclnnBatchMatMul默认确定性实现。 |
| 238 | - <term>Ascend 950PR/Ascend 950DT</term>: aclnnBatchMatMul默认确定性实现。 | 240 | - <term>Ascend 950PR/Ascend 950DT</term>: aclnnBatchMatMul默认确定性实现。 |
| 239 | 241 | ||
| 240 | ## 调用示例 | 242 | ## 调用示例 |
| 243 | + | ||
| 241 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 244 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| 245 | + | ||
| 242 | ```Cpp | 246 | ```Cpp |
| 243 | #include <iostream> | 247 | #include <iostream> |
| 244 | #include <vector> | 248 | #include <vector> |
| @@ -34,6 +34,7 @@ aclnnStatus aclnnBatchMatMulWeightNzGetWorkspaceSize( | |||
| 34 | uint64_t *workspaceSize, | 34 | uint64_t *workspaceSize, |
| 35 | aclOpExecutor **executor) | 35 | aclOpExecutor **executor) |
| 36 | ``` | 36 | ``` |
| 37 | + | ||
| 37 | ```cpp | 38 | ```cpp |
| 38 | aclnnStatus aclnnBatchMatMulWeightNz( | 39 | aclnnStatus aclnnBatchMatMulWeightNz( |
| 39 | void *workspace, | 40 | void *workspace, |
| @@ -43,6 +44,7 @@ aclnnStatus aclnnBatchMatMulWeightNz( | |||
| 43 | ``` | 44 | ``` |
| 44 | 45 | ||
| 45 | ## aclnnBatchMatMulWeightNzGetWorkspaceSize | 46 | ## aclnnBatchMatMulWeightNzGetWorkspaceSize |
| 47 | + | ||
| 46 | - **参数说明:** | 48 | - **参数说明:** |
| 47 | <table style="undefined;table-layout: fixed; width: 1508px"><colgroup> | 49 | <table style="undefined;table-layout: fixed; width: 1508px"><colgroup> |
| 48 | <col style="width: 151px"> | 50 | <col style="width: 151px"> |
| @@ -221,6 +223,7 @@ aclnnStatus aclnnBatchMatMulWeightNz( | |||
| 221 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 223 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| 222 | 224 | ||
| 223 | ## 约束说明 | 225 | ## 约束说明 |
| 226 | + | ||
| 224 | - 确定性说明: | 227 | - 确定性说明: |
| 225 | - aclnnBatchMatMulWeightNz默认确定性实现。 | 228 | - aclnnBatchMatMulWeightNz默认确定性实现。 |
| 226 | 229 | ||
| @@ -232,6 +235,7 @@ aclnnStatus aclnnBatchMatMulWeightNz( | |||
| 232 | 235 | ||
| 233 | - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>: | 236 | - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>: |
| 234 | self和mat2数据类型为float16,mat2为NZ格式场景下的示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 237 | self和mat2数据类型为float16,mat2为NZ格式场景下的示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| 238 | + | ||
| 235 | ```Cpp | 239 | ```Cpp |
| 236 | #include <iostream> | 240 | #include <iostream> |
| 237 | #include <vector> | 241 | #include <vector> |
| @@ -453,8 +457,10 @@ self和mat2数据类型为float16,mat2为NZ格式场景下的示例代码如 | |||
| 453 | return 0; | 457 | return 0; |
| 454 | } | 458 | } |
| 455 | ``` | 459 | ``` |
| 460 | + | ||
| 456 | - <term>Ascend 950PR/Ascend 950DT</term>: | 461 | - <term>Ascend 950PR/Ascend 950DT</term>: |
| 457 | self和mat2数据类型为float16,mat2为NZ格式场景下的示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 462 | self和mat2数据类型为float16,mat2为NZ格式场景下的示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| 463 | + | ||
| 458 | ```Cpp | 464 | ```Cpp |
| 459 | #include <iostream> | 465 | #include <iostream> |
| 460 | #include <memory> | 466 | #include <memory> |
| @@ -697,4 +703,4 @@ self和mat2数据类型为float16,mat2为NZ格式场景下的示例代码如 | |||
| 697 | aclFinalize(); | 703 | aclFinalize(); |
| 698 | return 0; | 704 | return 0; |
| 699 | } | 705 | } |
| 700 | - ``` | 706 | + ``` |
| @@ -1,4 +1,5 @@ | |||
| 1 | # aclnnEinsum | 1 | # aclnnEinsum |
| 2 | + | ||
| 2 | ## 产品支持情况 | 3 | ## 产品支持情况 |
| 3 | 4 | ||
| 4 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| @@ -11,6 +12,7 @@ | |||
| 11 | | <term>Atlas 训练系列产品</term> | × | | 12 | | <term>Atlas 训练系列产品</term> | × | |
| 12 | 13 | ||
| 13 | ## 功能说明 | 14 | ## 功能说明 |
| 15 | + | ||
| 14 | - 接口功能:使用爱因斯坦求和约定执行张量计算,形式为“term1, term2 -> output-term”,按照以下等式生成输出张量,其中reduce-sum对出现在输入项(term1, term2)中但未出现在输出项中的所有索引执行求和。 | 16 | - 接口功能:使用爱因斯坦求和约定执行张量计算,形式为“term1, term2 -> output-term”,按照以下等式生成输出张量,其中reduce-sum对出现在输入项(term1, term2)中但未出现在输出项中的所有索引执行求和。 |
| 15 | - 计算公式: | 17 | - 计算公式: |
| 16 | 18 | ||
| @@ -21,6 +23,7 @@ | |||
| 21 | ## 函数原型 | 23 | ## 函数原型 |
| 22 | 24 | ||
| 23 | 每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnEinsumGetWorkspaceSize”接口获取计算所需workspace大小以及包含了算子计算流程的执行器,再调用“aclnnEinsum”接口执行计算。 | 25 | 每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnEinsumGetWorkspaceSize”接口获取计算所需workspace大小以及包含了算子计算流程的执行器,再调用“aclnnEinsum”接口执行计算。 |
| 26 | + | ||
| 24 | ```cpp | 27 | ```cpp |
| 25 | aclnnStatus aclnnEinsumGetWorkspaceSize( | 28 | aclnnStatus aclnnEinsumGetWorkspaceSize( |
| 26 | const aclTensorList *tensors, | 29 | const aclTensorList *tensors, |
| @@ -29,6 +32,7 @@ aclnnStatus aclnnEinsumGetWorkspaceSize( | |||
| 29 | uint64_t *workspaceSize, | 32 | uint64_t *workspaceSize, |
| 30 | aclOpExecutor **executor) | 33 | aclOpExecutor **executor) |
| 31 | ``` | 34 | ``` |
| 35 | + | ||
| 32 | ```cpp | 36 | ```cpp |
| 33 | aclnnStatus aclnnEinsum( | 37 | aclnnStatus aclnnEinsum( |
| 34 | void *workspace, | 38 | void *workspace, |
| @@ -210,6 +214,7 @@ aclnnStatus aclnnEinsum( | |||
| 210 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 214 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| 211 | 215 | ||
| 212 | ## 约束说明 | 216 | ## 约束说明 |
| 217 | + | ||
| 213 | - 确定性说明:aclnnEinsum默认确定性实现。 | 218 | - 确定性说明:aclnnEinsum默认确定性实现。 |
| 214 | 219 | ||
| 215 | - 目前equation需完全匹配,才能找到对应函数。 | 220 | - 目前equation需完全匹配,才能找到对应函数。 |
| @@ -1,7 +1,6 @@ | |||
| 1 | # BatchMatmulQuant | 1 | # BatchMatmulQuant |
| 2 | 2 | ||
| 3 | - | 3 | +## 产品支持情况 |
| 4 | -## 产品支持情况 | ||
| 5 | 4 | ||
| 6 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| 7 | | ---- | :----: | | 6 | | ---- | :----: | |
| @@ -94,4 +93,4 @@ | |||
| 94 | 93 | ||
| 95 | | 调用方式 | 样例代码 | 说明 | | 94 | | 调用方式 | 样例代码 | 说明 | |
| 96 | | ---------------- | --------------------------- | --------------------------------------------------- | | 95 | | ---------------- | --------------------------- | --------------------------------------------------- | |
| 97 | -| aclnn接口 | [test_aclnn_batch_matmul_quant](examples/test_aclnn_batch_matmul_quant.cpp) | 通过<br>[aclnnBatchMatmulQuant](docs/aclnnBatchMatmulQuant.md)<br>调用BatchMatmulQuant算子。 | | 96 | +| aclnn接口 | [test_aclnn_batch_matmul_quant](examples/test_aclnn_batch_matmul_quant.cpp) | 通过<br>[aclnnBatchMatmulQuant](docs/aclnnBatchMatmulQuant.md)<br>调用BatchMatmulQuant算子。 | |
| @@ -1,3 +1,3 @@ | |||
| 1 | # ConvertWeightToInt4Pack | 1 | # ConvertWeightToInt4Pack |
| 2 | 2 | ||
| 3 | -本目录仅包含ConvertWeightToInt4Pack算子对应的aclnn接口;如您想要贡献该算子的AscendC实现,请参考[贡献流程](../../CONTRIBUTING.md)。 | 3 | +本目录仅包含ConvertWeightToInt4Pack算子对应的aclnn接口;如您想要贡献该算子的AscendC实现,请参考[贡献流程](../../CONTRIBUTING.md)。 |
| @@ -17,6 +17,7 @@ | |||
| 17 | 17 | ||
| 18 | 对输入weight数据做预处理,实现低比特数据由稀疏存储到紧密存储的排布转换。输出weightInt4Pack的[数据格式](../../../docs/zh/context/数据格式.md)声明为FRACTAL_NZ时,该算子将[数据格式](../../../docs/zh/context/数据格式.md)从ND转为FRACTAL_NZ。 | 18 | 对输入weight数据做预处理,实现低比特数据由稀疏存储到紧密存储的排布转换。输出weightInt4Pack的[数据格式](../../../docs/zh/context/数据格式.md)声明为FRACTAL_NZ时,该算子将[数据格式](../../../docs/zh/context/数据格式.md)从ND转为FRACTAL_NZ。 |
| 19 | - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>:将INT32类型的weight输入数据打包为紧密排布的INT4数据。 | 19 | - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>:将INT32类型的weight输入数据打包为紧密排布的INT4数据。 |
| 20 | + | ||
| 20 | - <term>Ascend 950PR/Ascend 950DT</term> :将INT32类型的weight打包为紧密排布的INT4类型,将FLOAT类型的weight打包为紧密排布的FLOAT4_E2M1类型。 | 21 | - <term>Ascend 950PR/Ascend 950DT</term> :将INT32类型的weight打包为紧密排布的INT4类型,将FLOAT类型的weight打包为紧密排布的FLOAT4_E2M1类型。 |
| 21 | 22 | ||
| 22 | ## 函数原型 | 23 | ## 函数原型 |
| @@ -30,6 +31,7 @@ aclnnStatus aclnnConvertWeightToINT4PackGetWorkspaceSize( | |||
| 30 | uint64_t *workspaceSize, | 31 | uint64_t *workspaceSize, |
| 31 | aclOpExecutor **executor) | 32 | aclOpExecutor **executor) |
| 32 | ``` | 33 | ``` |
| 34 | + | ||
| 33 | ```Cpp | 35 | ```Cpp |
| 34 | aclnnStatus aclnnConvertWeightToINT4Pack( | 36 | aclnnStatus aclnnConvertWeightToINT4Pack( |
| 35 | void *workspace, | 37 | void *workspace, |
| @@ -199,6 +201,7 @@ aclnnStatus aclnnConvertWeightToINT4Pack( | |||
| 199 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 201 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| 200 | 202 | ||
| 201 | ## 约束说明 | 203 | ## 约束说明 |
| 204 | + | ||
| 202 | - 确定性说明: | 205 | - 确定性说明: |
| 203 | 206 | ||
| 204 | - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>、<term>Ascend 950PR/Ascend 950DT</term>:aclnnConvertWeightToINT4Pack默认确定性实现。 | 207 | - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>、<term>Ascend 950PR/Ascend 950DT</term>:aclnnConvertWeightToINT4Pack默认确定性实现。 |
| @@ -670,8 +673,9 @@ aclnnStatus aclnnConvertWeightToINT4Pack( | |||
| 670 | } | 673 | } |
| 671 | 674 | ||
| 672 | - <term>Ascend 950PR/Ascend 950DT</term>: | 675 | - <term>Ascend 950PR/Ascend 950DT</term>: |
| 676 | + | ||
| 673 | 示例代码如下(INT32输入),仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 677 | 示例代码如下(INT32输入),仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| 674 | - 伪量化有aclnnWeightQuantBatchMatmulV2和aclnnWeightQuantBatchMatmulV3接口, 这里以aclnnWeightQuantBatchMatmulV2为例 | 678 | + 伪量化有aclnnWeightQuantBatchMatmulV2和aclnnWeightQuantBatchMatmulV3接口,这里以aclnnWeightQuantBatchMatmulV2为例 |
| 675 | 679 | ||
| 676 | ```Cpp | 680 | ```Cpp |
| 677 | #include <iostream> | 681 | #include <iostream> |
| @@ -1319,4 +1323,3 @@ aclnnStatus aclnnConvertWeightToINT4Pack( | |||
| 1319 | return 0; | 1323 | return 0; |
| 1320 | } | 1324 | } |
| 1321 | ``` | 1325 | ``` |
| 1322 | - | ||
| @@ -1,7 +1,6 @@ | |||
| 1 | # FusedLinearOnlineMaxSum | 1 | # FusedLinearOnlineMaxSum |
| 2 | 2 | ||
| 3 | - | 3 | +## 产品支持情况 |
| 4 | -## 产品支持情况 | ||
| 5 | 4 | ||
| 6 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| 7 | | ---- | :----:| | 6 | | ---- | :----:| |
| @@ -12,7 +11,6 @@ | |||
| 12 | | <term>Atlas 推理系列产品</term> | × | | 11 | | <term>Atlas 推理系列产品</term> | × | |
| 13 | | <term>Atlas 训练系列产品</term> | × | | 12 | | <term>Atlas 训练系列产品</term> | × | |
| 14 | 13 | ||
| 15 | - | ||
| 16 | ## 功能说明 | 14 | ## 功能说明 |
| 17 | 15 | ||
| 18 | - 算子功能:功能等价Megatron的matmul与fused\_vocab\_parallel\_cross\_entropy的实现,支持vocabulary\_size维度切卡融合matmul与celoss,中间根据通信拆分为[FusedLinearOnlineMaxSum](./)和[FusedCrossEntropyLossWithMaxSum](../../loss/fused_cross_entropy_loss_with_max_sum)。 | 16 | - 算子功能:功能等价Megatron的matmul与fused\_vocab\_parallel\_cross\_entropy的实现,支持vocabulary\_size维度切卡融合matmul与celoss,中间根据通信拆分为[FusedLinearOnlineMaxSum](./)和[FusedCrossEntropyLossWithMaxSum](../../loss/fused_cross_entropy_loss_with_max_sum)。 |
| @@ -192,4 +190,4 @@ | |||
| 192 | 190 | ||
| 193 | | 调用方式 | 样例代码 | 说明 | | 191 | | 调用方式 | 样例代码 | 说明 | |
| 194 | | ---------------- | --------------------------- | --------------------------------------------------- | | 192 | | ---------------- | --------------------------- | --------------------------------------------------- | |
| 195 | -| aclnn接口 | [test_aclnn_fused_linear_online_max_sum.cpp](examples/test_aclnn_fused_linear_online_max_sum.cpp) | 通过[aclnnFusedLinearOnlineMaxSum](docs/aclnnFusedLinearOnlineMaxSum.md)接口方式调用FusedLinearOnlineMaxSum算子。 | | 193 | +| aclnn接口 | [test_aclnn_fused_linear_online_max_sum.cpp](examples/test_aclnn_fused_linear_online_max_sum.cpp) | 通过[aclnnFusedLinearOnlineMaxSum](docs/aclnnFusedLinearOnlineMaxSum.md)接口方式调用FusedLinearOnlineMaxSum算子。 | |
| @@ -1,7 +1,6 @@ | |||
| 1 | # FusedQuantMatmul | 1 | # FusedQuantMatmul |
| 2 | 2 | ||
| 3 | - | 3 | +## 产品支持情况 |
| 4 | -## 产品支持情况 | ||
| 5 | 4 | ||
| 6 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| 7 | | ---- | :----:| | 6 | | ---- | :----:| |
| @@ -17,13 +16,13 @@ | |||
| 17 | - 算子功能:完成量化矩阵乘和Gelu的融合计算。 | 16 | - 算子功能:完成量化矩阵乘和Gelu的融合计算。 |
| 18 | - 计算公式: | 17 | - 计算公式: |
| 19 | 18 | ||
| 20 | - - x1Scale, bias INT32(此场景无offset): | 19 | + - x1Scale,bias INT32(此场景无offset): |
| 21 | 20 | ||
| 22 | $$ | 21 | $$ |
| 23 | qbmmout = (x1@x2 + bias) * x2Scale * x1Scale | 22 | qbmmout = (x1@x2 + bias) * x2Scale * x1Scale |
| 24 | $$ | 23 | $$ |
| 25 | 24 | ||
| 26 | - - x1Scale, bias BFLOAT16/FLOAT16/FLOAT32(此场景无offset): | 25 | + - x1Scale,bias BFLOAT16/FLOAT16/FLOAT32(此场景无offset): |
| 27 | 26 | ||
| 28 | $$ | 27 | $$ |
| 29 | qbmmout = x1@x2 * x2scale * x1Scale + bias | 28 | qbmmout = x1@x2 * x2scale * x1Scale + bias |
| @@ -120,4 +119,4 @@ | |||
| 120 | 119 | ||
| 121 | | 调用方式 | 样例代码 | 说明 | | 120 | | 调用方式 | 样例代码 | 说明 | |
| 122 | | ---------------- | --------------------------- | --------------------------------------------------- | | 121 | | ---------------- | --------------------------- | --------------------------------------------------- | |
| 123 | -| aclnn接口 | [test_aclnn_fused_quant_mat_mul](examples/test_aclnn_fused_quant_mat_mul.cpp) | 通过<br>[aclnnFusedQuantMatmul](docs/aclnnFusedQuantMatmul.md)<br>[aclnnFusedQuantMatmulWeightNz](docs/aclnnFusedQuantMatmulWeightNz.md)<br>等方式调用FusedQuantMatmul算子。 | | 122 | +| aclnn接口 | [test_aclnn_fused_quant_mat_mul](examples/test_aclnn_fused_quant_mat_mul.cpp) | 通过<br>[aclnnFusedQuantMatmul](docs/aclnnFusedQuantMatmul.md)<br>[aclnnFusedQuantMatmulWeightNz](docs/aclnnFusedQuantMatmulWeightNz.md)<br>等方式调用FusedQuantMatmul算子。 | |
| @@ -306,7 +306,6 @@ aclnnStatus aclnnFusedQuantMatmul( | |||
| 306 | </tbody> | 306 | </tbody> |
| 307 | </table> | 307 | </table> |
| 308 | 308 | ||
| 309 | - | ||
| 310 | ## aclnnFusedQuantMatmul | 309 | ## aclnnFusedQuantMatmul |
| 311 | 310 | ||
| 312 | - **参数说明:** | 311 | - **参数说明:** |
| @@ -350,10 +349,12 @@ aclnnStatus aclnnFusedQuantMatmul( | |||
| 350 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 349 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| 351 | 350 | ||
| 352 | ## 约束说明 | 351 | ## 约束说明 |
| 352 | + | ||
| 353 | - 确定性说明: | 353 | - 确定性说明: |
| 354 | - <term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>、<term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>:aclnnFusedQuantMatmul默认确定性实现。 | 354 | - <term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>、<term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>:aclnnFusedQuantMatmul默认确定性实现。 |
| 355 | 355 | ||
| 356 | - 输入和输出支持以下数据类型组合: | 356 | - 输入和输出支持以下数据类型组合: |
| 357 | + | ||
| 357 | | x1 | x2 | x1Scale | x2Scale | x2OffsetOptional | yScaleOptional | biasOptional | yOffsetOptional | out | | 358 | | x1 | x2 | x1Scale | x2Scale | x2OffsetOptional | yScaleOptional | biasOptional | yOffsetOptional | out | |
| 358 | | ------------------------- | ------------------------- | ----------- | ----------- | ----------- | ------- | ------------ | -----------| -------------------------------------- | | 359 | | ------------------------- | ------------------------- | ----------- | ----------- | ----------- | ------- | ------------ | -----------| -------------------------------------- | |
| 359 | | INT8 | INT8 | FLOAT32| FLOAT32/BFLOAT16| null | null | null/INT32/BFLOAT16/FLOAT32 | null | BFLOAT16 | | 360 | | INT8 | INT8 | FLOAT32| FLOAT32/BFLOAT16| null | null | null/INT32/BFLOAT16/FLOAT32 | null | BFLOAT16 | |
| @@ -361,7 +362,6 @@ aclnnStatus aclnnFusedQuantMatmul( | |||
| 361 | | INT4/INT32 | INT4/INT32 | FLOAT32 | FLOAT32/BFLOAT16| null | null | null/INT32/BFLOAT16/FLOAT32 | null | BFLOAT16 | | 362 | | INT4/INT32 | INT4/INT32 | FLOAT32 | FLOAT32/BFLOAT16| null | null | null/INT32/BFLOAT16/FLOAT32 | null | BFLOAT16 | |
| 362 | | INT4/INT32 | INT4/INT32 | FLOAT32 | FLOAT32 | null | null | null/INT32/FLOAT16/FLOAT32 | null | FLOAT16 | | 363 | | INT4/INT32 | INT4/INT32 | FLOAT32 | FLOAT32 | null | null | null/INT32/FLOAT16/FLOAT32 | null | FLOAT16 | |
| 363 | 364 | ||
| 364 | - | ||
| 365 | - 当前接口支持x1 pertoken量化和x2 perchannel/pertensor量化,不同的[量化模式](../../../docs/zh/context/量化介绍.md)支持的x1、 x2、x1Scale和x2Scale的输入dtype组合约束为: | 365 | - 当前接口支持x1 pertoken量化和x2 perchannel/pertensor量化,不同的[量化模式](../../../docs/zh/context/量化介绍.md)支持的x1、 x2、x1Scale和x2Scale的输入dtype组合约束为: |
| 366 | - x1数据类型支持INT8、INT32、INT4。 | 366 | - x1数据类型支持INT8、INT32、INT4。 |
| 367 | - 当数据类型为INT32、INT4时,为INT4量化场景: | 367 | - 当数据类型为INT32、INT4时,为INT4量化场景: |
| @@ -579,4 +579,5 @@ x1为INT8,x2为INT8,x1Scale为FLOAT32,x2Scale为FLOAT32。 | |||
| 579 | Finalize(deviceId, stream); | 579 | Finalize(deviceId, stream); |
| 580 | return 0; | 580 | return 0; |
| 581 | } | 581 | } |
| 582 | - ``` | 582 | + ``` |
| 583 | + | ||
| @@ -49,6 +49,7 @@ | |||
| 49 | $$ | 49 | $$ |
| 50 | 50 | ||
| 51 | ## 函数原型 | 51 | ## 函数原型 |
| 52 | + | ||
| 52 | 每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnFusedQuantMatmulWeightNzGetWorkspaceSize”接口获取计算所需workspace大小以及包含了算子计算流程的执行器,再调用“aclnnFusedQuantMatmulWeightNz”接口执行计算。 | 53 | 每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnFusedQuantMatmulWeightNzGetWorkspaceSize”接口获取计算所需workspace大小以及包含了算子计算流程的执行器,再调用“aclnnFusedQuantMatmulWeightNz”接口执行计算。 |
| 53 | 54 | ||
| 54 | ```c++ | 55 | ```c++ |
| @@ -69,6 +70,7 @@ aclnnStatus aclnnFusedQuantMatmulWeightNzGetWorkspaceSize( | |||
| 69 | uint64_t *workspaceSize, | 70 | uint64_t *workspaceSize, |
| 70 | aclOpExecutor **executor) | 71 | aclOpExecutor **executor) |
| 71 | ``` | 72 | ``` |
| 73 | + | ||
| 72 | ```c++ | 74 | ```c++ |
| 73 | aclnnStatus aclnnFusedQuantMatmulWeightNz( | 75 | aclnnStatus aclnnFusedQuantMatmulWeightNz( |
| 74 | void *workspace, | 76 | void *workspace, |
| @@ -306,7 +308,6 @@ aclnnStatus aclnnFusedQuantMatmulWeightNz( | |||
| 306 | </tbody> | 308 | </tbody> |
| 307 | </table> | 309 | </table> |
| 308 | 310 | ||
| 309 | - | ||
| 310 | ## aclnnFusedQuantMatmulWeightNz | 311 | ## aclnnFusedQuantMatmulWeightNz |
| 311 | 312 | ||
| 312 | - **参数说明:** | 313 | - **参数说明:** |
| @@ -355,6 +356,7 @@ aclnnStatus aclnnFusedQuantMatmulWeightNz( | |||
| 355 | - <term>Atlas 训练系列产品</term>、<term>Atlas 推理系列产品</term>:aclnnFusedQuantMatmulWeightNz默认确定性实现。 | 356 | - <term>Atlas 训练系列产品</term>、<term>Atlas 推理系列产品</term>:aclnnFusedQuantMatmulWeightNz默认确定性实现。 |
| 356 | 357 | ||
| 357 | - 输入和输出支持以下数据类型组合: | 358 | - 输入和输出支持以下数据类型组合: |
| 359 | + | ||
| 358 | | x1 | x2 | x1Scale | x2Scale | x2OffsetOptional | yScaleOptional | biasOptional | yOffsetOptional | out | | 360 | | x1 | x2 | x1Scale | x2Scale | x2OffsetOptional | yScaleOptional | biasOptional | yOffsetOptional | out | |
| 359 | | ------------------------- | ------------------------- | ----------- | ----------- | ----------- | ------- | ------------ | -----------| -------------------------------------- | | 361 | | ------------------------- | ------------------------- | ----------- | ----------- | ----------- | ------- | ------------ | -----------| -------------------------------------- | |
| 360 | | INT8 | INT8 | FLOAT32| FLOAT32/BFLOAT16| null | null | null/INT32/BFLOAT16/FLOAT32 | null | BFLOAT16 | | 362 | | INT8 | INT8 | FLOAT32| FLOAT32/BFLOAT16| null | null | null/INT32/BFLOAT16/FLOAT32 | null | BFLOAT16 | |
| @@ -362,7 +364,6 @@ aclnnStatus aclnnFusedQuantMatmulWeightNz( | |||
| 362 | | INT4/INT32 | INT4/INT32 | FLOAT32 | FLOAT32/BFLOAT16| null | null | null/INT32/BFLOAT16/FLOAT32 | null | BFLOAT16 | | 364 | | INT4/INT32 | INT4/INT32 | FLOAT32 | FLOAT32/BFLOAT16| null | null | null/INT32/BFLOAT16/FLOAT32 | null | BFLOAT16 | |
| 363 | | INT4/INT32 | INT4/INT32 | FLOAT32 | FLOAT32 | null | null | null/INT32/FLOAT16/FLOAT32 | null | FLOAT16 | | 365 | | INT4/INT32 | INT4/INT32 | FLOAT32 | FLOAT32 | null | null | null/INT32/FLOAT16/FLOAT32 | null | FLOAT16 | |
| 364 | 366 | ||
| 365 | - | ||
| 366 | - 当前接口支持x1 pertoken量化和x2 perchannel/pertensor量化,不同的[量化模式](../../../docs/zh/context/量化介绍.md)支持的x1、 x2、x1Scale和x2Scale的输入dtype组合约束为: | 367 | - 当前接口支持x1 pertoken量化和x2 perchannel/pertensor量化,不同的[量化模式](../../../docs/zh/context/量化介绍.md)支持的x1、 x2、x1Scale和x2Scale的输入dtype组合约束为: |
| 367 | - x1数据类型支持INT8、INT32、INT4。 | 368 | - x1数据类型支持INT8、INT32、INT4。 |
| 368 | - 当数据类型为INT32、INT4时,为INT4量化场景: | 369 | - 当数据类型为INT32、INT4时,为INT4量化场景: |
| @@ -638,4 +639,5 @@ x1为INT8,x2为INT8,x1Scale为FLOAT32,x2Scale为FLOAT32。 | |||
| 638 | Finalize(deviceId, stream); | 639 | Finalize(deviceId, stream); |
| 639 | return 0; | 640 | return 0; |
| 640 | } | 641 | } |
| 641 | - ``` | 642 | + ``` |
| 643 | + | ||
| @@ -1,3 +1,3 @@ | |||
| 1 | # Gemm | 1 | # Gemm |
| 2 | 2 | ||
| 3 | -本目录仅包含Gemm算子对应的aclnn接口;如您想要贡献该算子的AscendC实现,请参考[贡献流程](../../CONTRIBUTING.md)。 | 3 | +本目录仅包含Gemm算子对应的aclnn接口;如您想要贡献该算子的AscendC实现,请参考[贡献流程](../../CONTRIBUTING.md)。 |
| @@ -44,6 +44,7 @@ aclnnStatus aclnnGemmGetWorkspaceSize( | |||
| 44 | uint64_t *workspaceSize, | 44 | uint64_t *workspaceSize, |
| 45 | aclOpExecutor **executor) | 45 | aclOpExecutor **executor) |
| 46 | ``` | 46 | ``` |
| 47 | + | ||
| 47 | ```cpp | 48 | ```cpp |
| 48 | aclnnStatus aclnnGemm( | 49 | aclnnStatus aclnnGemm( |
| 49 | void *workspace, | 50 | void *workspace, |
| @@ -302,6 +303,7 @@ aclnnStatus aclnnGemm( | |||
| 302 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 303 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| 303 | 304 | ||
| 304 | ## 约束说明 | 305 | ## 约束说明 |
| 306 | + | ||
| 305 | - 确定性说明: | 307 | - 确定性说明: |
| 306 | - <term>Atlas 训练系列产品</term>、<term>Atlas 推理系列产品</term>:aclnnGemm默认确定性实现。 | 308 | - <term>Atlas 训练系列产品</term>、<term>Atlas 推理系列产品</term>:aclnnGemm默认确定性实现。 |
| 307 | 309 | ||
| @@ -1,7 +1,6 @@ | |||
| 1 | # GemmV2 | 1 | # GemmV2 |
| 2 | 2 | ||
| 3 | - | 3 | +## 产品支持情况 |
| 4 | -## 产品支持情况 | ||
| 5 | 4 | ||
| 6 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| 7 | | ---- | :----:| | 6 | | ---- | :----:| |
| @@ -80,6 +79,7 @@ | |||
| 80 | </tbody></table> | 79 | </tbody></table> |
| 81 | 80 | ||
| 82 | - Kirin X90/Kirin 9030处理器系列产品:不支持BFLOAT16。 | 81 | - Kirin X90/Kirin 9030处理器系列产品:不支持BFLOAT16。 |
| 82 | + | ||
| 83 | ## 约束说明 | 83 | ## 约束说明 |
| 84 | 84 | ||
| 85 | - 不支持空tensor。 | 85 | - 不支持空tensor。 |
| @@ -89,4 +89,4 @@ | |||
| 89 | 89 | ||
| 90 | | 调用方式 | 样例代码 | 说明 | | 90 | | 调用方式 | 样例代码 | 说明 | |
| 91 | | ---------------- | --------------------------- | --------------------------------------------------- | | 91 | | ---------------- | --------------------------- | --------------------------------------------------- | |
| 92 | -| 图模式调用 | [test_geir_gemm_v2](./examples/test_geir_gemm_v2.cpp) | 通过[算子IR](op_graph/gemm_v2_proto.h)等方式调用GemmV2算子。 | | 92 | +| 图模式调用 | [test_geir_gemm_v2](./examples/test_geir_gemm_v2.cpp) | 通过[算子IR](op_graph/gemm_v2_proto.h)等方式调用GemmV2算子。 | |
| @@ -1,7 +1,6 @@ | |||
| 1 | # MatMulV3 | 1 | # MatMulV3 |
| 2 | 2 | ||
| 3 | - | 3 | +## 产品支持情况 |
| 4 | -## 产品支持情况 | ||
| 5 | 4 | ||
| 6 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| 7 | | ---- | :----:| | 6 | | ---- | :----:| |
| @@ -78,6 +77,7 @@ | |||
| 78 | - Ascend 950PR/Ascend 950DT:只有输入b支持FRACTAL_NZ格式。 | 77 | - Ascend 950PR/Ascend 950DT:只有输入b支持FRACTAL_NZ格式。 |
| 79 | 78 | ||
| 80 | - Kirin X90/Kirin 9030处理器系列产品:不支持BFLOAT16、FLOAT32。 | 79 | - Kirin X90/Kirin 9030处理器系列产品:不支持BFLOAT16、FLOAT32。 |
| 80 | + | ||
| 81 | ## 约束说明 | 81 | ## 约束说明 |
| 82 | 82 | ||
| 83 | - 支持空tensor,空tensor场景下不支持bias。 | 83 | - 支持空tensor,空tensor场景下不支持bias。 |
| @@ -87,4 +87,4 @@ | |||
| 87 | 87 | ||
| 88 | | 调用方式 | 样例代码 | 说明 | | 88 | | 调用方式 | 样例代码 | 说明 | |
| 89 | | ---------------- | --------------------------- | --------------------------------------------------- | | 89 | | ---------------- | --------------------------- | --------------------------------------------------- | |
| 90 | -| aclnn接口 | [test_aclnn_addmm](examples/test_aclnn_addmm_aclnninplace_addmm.cpp) | 通过<br> - [aclnnAddmm&aclnnInplaceAddmm](./docs/aclnnAddmm&aclnnInplaceAddmm.md)<br> - [aclnnMatmul](docs/aclnnMatmul.md)<br> - [aclnnMatmulWeightNz](docs/aclnnMatmulWeightNz.md)<br> - [aclnnMm](docs/aclnnMm.md)<br>- [aclnnAddmmWeightNz](docs/aclnnAddmmWeightNz.md)<br>等方式调用MatMulV3算子。 | | 90 | +| aclnn接口 | [test_aclnn_addmm](examples/test_aclnn_addmm_aclnninplace_addmm.cpp) | 通过<br> - [aclnnAddmm&aclnnInplaceAddmm](./docs/aclnnAddmm&aclnnInplaceAddmm.md)<br> - [aclnnMatmul](docs/aclnnMatmul.md)<br> - [aclnnMatmulWeightNz](docs/aclnnMatmulWeightNz.md)<br> - [aclnnMm](docs/aclnnMm.md)<br>- [aclnnAddmmWeightNz](docs/aclnnAddmmWeightNz.md)<br>等方式调用MatMulV3算子。 | |
| @@ -37,6 +37,7 @@ aclnnStatus aclnnMatmulCompressGetWorkspaceSize( | |||
| 37 | uint64_t* workspaceSize, | 37 | uint64_t* workspaceSize, |
| 38 | aclOpExecutor** executor) | 38 | aclOpExecutor** executor) |
| 39 | ``` | 39 | ``` |
| 40 | + | ||
| 40 | ```cpp | 41 | ```cpp |
| 41 | aclnnStatus aclnnMatmulCompress( | 42 | aclnnStatus aclnnMatmulCompress( |
| 42 | void* workspace, | 43 | void* workspace, |
| @@ -273,6 +274,7 @@ bias = random.randn(n).astype(np.float32) | |||
| 273 | write2file(bias, "./data/bias.bin") | 274 | write2file(bias, "./data/bias.bin") |
| 274 | ``` | 275 | ``` |
| 275 | 执行gen_data.py,假设mat1和mat2的shape入参为m=512、k=1024、n=1024。 | 276 | 执行gen_data.py,假设mat1和mat2的shape入参为m=512、k=1024、n=1024。 |
| 277 | + | ||
| 276 | ```shell | 278 | ```shell |
| 277 | python3 gen_data.py 512 1024 1024 | 279 | python3 gen_data.py 512 1024 1024 |
| 278 | ``` | 280 | ``` |
| @@ -1,3 +1,3 @@ | |||
| 1 | # Mv | 1 | # Mv |
| 2 | 2 | ||
| 3 | -本目录仅包含Mv算子对应的aclnn接口;如您想要贡献该算子的AscendC实现,请参考[贡献流程](../../CONTRIBUTING.md)。 | 3 | +本目录仅包含Mv算子对应的aclnn接口;如您想要贡献该算子的AscendC实现,请参考[贡献流程](../../CONTRIBUTING.md)。 |
| @@ -35,6 +35,7 @@ | |||
| 35 | ## 函数原型 | 35 | ## 函数原型 |
| 36 | 36 | ||
| 37 | 每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnMvGetWorkspaceSize”接口获取计算所需workspace大小以及包含了算子计算流程的执行器,再调用“aclnnMv”接口执行计算。 | 37 | 每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnMvGetWorkspaceSize”接口获取计算所需workspace大小以及包含了算子计算流程的执行器,再调用“aclnnMv”接口执行计算。 |
| 38 | + | ||
| 38 | ```cpp | 39 | ```cpp |
| 39 | aclnnStatus aclnnMvGetWorkspaceSize( | 40 | aclnnStatus aclnnMvGetWorkspaceSize( |
| 40 | const aclTensor *self, | 41 | const aclTensor *self, |
| @@ -44,6 +45,7 @@ aclnnStatus aclnnMvGetWorkspaceSize( | |||
| 44 | uint64_t *workspaceSize, | 45 | uint64_t *workspaceSize, |
| 45 | aclOpExecutor **executor) | 46 | aclOpExecutor **executor) |
| 46 | ``` | 47 | ``` |
| 48 | + | ||
| 47 | ```cpp | 49 | ```cpp |
| 48 | aclnnStatus aclnnMv( | 50 | aclnnStatus aclnnMv( |
| 49 | void *workspace, | 51 | void *workspace, |
| @@ -235,9 +237,11 @@ aclnnStatus aclnnMv( | |||
| 235 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 237 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| 236 | 238 | ||
| 237 | ## 约束说明 | 239 | ## 约束说明 |
| 240 | + | ||
| 238 | - 确定性说明: | 241 | - 确定性说明: |
| 239 | - <term>Atlas 训练系列产品</term>、<term>Atlas 推理系列产品</term>:aclnnMv默认非确定性实现,支持通过aclrtCtxSetSysParamOpt开启确定性。 | 242 | - <term>Atlas 训练系列产品</term>、<term>Atlas 推理系列产品</term>:aclnnMv默认非确定性实现,支持通过aclrtCtxSetSysParamOpt开启确定性。 |
| 240 | - <term>Ascend 950PR/Ascend 950DT</term>:aclnnMv默认确定性实现。 | 243 | - <term>Ascend 950PR/Ascend 950DT</term>:aclnnMv默认确定性实现。 |
| 244 | + | ||
| 241 | ## 调用示例 | 245 | ## 调用示例 |
| 242 | 246 | ||
| 243 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 247 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| @@ -380,4 +384,4 @@ int main() { | |||
| 380 | aclFinalize(); | 384 | aclFinalize(); |
| 381 | return 0; | 385 | return 0; |
| 382 | } | 386 | } |
| 383 | -``` | 387 | +``` |
| @@ -1,7 +1,6 @@ | |||
| 1 | # QuantBatchMatmulV3 | 1 | # QuantBatchMatmulV3 |
| 2 | 2 | ||
| 3 | - | 3 | +## 产品支持情况 |
| 4 | -## 产品支持情况 | ||
| 5 | 4 | ||
| 6 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| 7 | | ---- | :----:| | 6 | | ---- | :----:| |
| @@ -153,6 +152,7 @@ | |||
| 153 | - bias只支持INT32数据类型。 | 152 | - bias只支持INT32数据类型。 |
| 154 | - pertoken_scale只支持FLOAT32数据类型。 | 153 | - pertoken_scale只支持FLOAT32数据类型。 |
| 155 | - y只支持FLOAT16和INT8数据类型。 | 154 | - y只支持FLOAT16和INT8数据类型。 |
| 155 | + | ||
| 156 | ## 约束说明 | 156 | ## 约束说明 |
| 157 | 157 | ||
| 158 | - 不支持空tensor。 | 158 | - 不支持空tensor。 |
| @@ -162,4 +162,4 @@ | |||
| 162 | 162 | ||
| 163 | | 调用方式 | 样例代码 | 说明 | | 163 | | 调用方式 | 样例代码 | 说明 | |
| 164 | | ---------------- | --------------------------- | --------------------------------------------------- | | 164 | | ---------------- | --------------------------- | --------------------------------------------------- | |
| 165 | -| aclnn接口 | [test_aclnn_quant_matmul_v3](examples/test_aclnn_quant_matmul_v3_at.cpp) | 通过<br>[aclnnQuantMatmulV3](docs/aclnnQuantMatmulV3.md)<br>[aclnnQuantMatmulV4](docs/aclnnQuantMatmulV4.md)<br>[aclnnQuantMatmulWeightNz](docs/aclnnQuantMatmulWeightNz.md)<br>[aclnnQuantMatmulV5](../quant_batch_matmul_v4/docs/aclnnQuantMatmulV5.md)<br>等方式调用QuantBatchMatmulV3算子。 | | 165 | +| aclnn接口 | [test_aclnn_quant_matmul_v3](examples/test_aclnn_quant_matmul_v3_at.cpp) | 通过<br>[aclnnQuantMatmulV3](docs/aclnnQuantMatmulV3.md)<br>[aclnnQuantMatmulV4](docs/aclnnQuantMatmulV4.md)<br>[aclnnQuantMatmulWeightNz](docs/aclnnQuantMatmulWeightNz.md)<br>[aclnnQuantMatmulV5](../quant_batch_matmul_v4/docs/aclnnQuantMatmulV5.md)<br>等方式调用QuantBatchMatmulV3算子。 | |
| @@ -282,30 +282,29 @@ aclnnStatus aclnnQuantMatmulV4( | |||
| 282 | 282 | ||
| 283 | - <term>Atlas 推理系列产品</term>: | 283 | - <term>Atlas 推理系列产品</term>: |
| 284 | - x1与x2的最后一维大小不能超过65535(x1的最后一维指transposeX1为true时的m或transposeX1为false时的k,x2的最后一维指transposeX2为true时的k或transposeX2为false时的n)。 | 284 | - x1与x2的最后一维大小不能超过65535(x1的最后一维指transposeX1为true时的m或transposeX1为false时的k,x2的最后一维指transposeX2为true时的k或transposeX2为false时的n)。 |
| 285 | - - x1数据类型支持INT8。 | 285 | + - x1数据类型支持INT8。 |
| 286 | - - x2数据类型支持INT8,为NZ格式时,不支持transposeX2为false的场景。 | 286 | + - x2数据类型支持INT8,为NZ格式时,不支持transposeX2为false的场景。 |
| 287 | - - bias数据类型支持INT32。 | 287 | + - bias数据类型支持INT32。 |
| 288 | - - scale数据类型支持UINT64、INT64。 | 288 | + - scale数据类型支持UINT64、INT64。 |
| 289 | - - 不支持pertokenScaleOptional。 | 289 | + - 不支持pertokenScaleOptional。 |
| 290 | - - out数据类型支持FLOAT16、INT8。 | 290 | + - out数据类型支持FLOAT16、INT8。 |
| 291 | 291 | ||
| 292 | - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>: | 292 | - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>: |
| 293 | - - x1与x2的最后一维大小不能超过65535。 | 293 | + - x1与x2的最后一维大小不能超过65535。 |
| 294 | - - x1数据类型支持INT8、INT32、INT4。当数据类型为INT32、INT4时,为INT4量化场景,当前仅支持2-6维ND格式,transposeX1为false情况。其中当x1数据类型为INT4时,维度表示:(batch,m,k),要求k为偶数,当x1数据类型为INT32时,每个INT32数据存放8个INT4数据,对应维度表示:(batch,m,k // 8),要求k为8的倍数。 | 294 | + - x1数据类型支持INT8、INT32、INT4。当数据类型为INT32、INT4时,为INT4量化场景,当前仅支持2-6维ND格式,transposeX1为false情况。其中当x1数据类型为INT4时,维度表示:(batch,m,k),要求k为偶数,当x1数据类型为INT32时,每个INT32数据存放8个INT4数据,对应维度表示:(batch,m,k // 8),要求k为8的倍数。 |
| 295 | - - x2数据类型支持INT8、INT32、INT4。当数据类型为INT32、INT4时,为INT4量化场景,当前仅支持2维ND格式。 | 295 | + - x2数据类型支持INT8、INT32、INT4。当数据类型为INT32、INT4时,为INT4量化场景,当前仅支持2维ND格式。 |
| 296 | - - 数据类型为INT4时,在transposeX2为true情况下各个维度表示:(n,k),要求k为偶数;在transposeX2为false情况下各个维度表示:(k,n),要求n为偶数。 | 296 | + - 数据类型为INT4时,在transposeX2为true情况下各个维度表示:(n,k),要求k为偶数;在transposeX2为false情况下各个维度表示:(k,n),要求n为偶数。 |
| 297 | - - 数据类型为INT32时,每个INT32数据存放8个INT4数据,在transposeX2为true情况下各个维度表示:(n,k // 8),要求k为8的倍数;在transposeX2为false情况下各个维度表示:(k,n // 8),要求n为8的倍数。 | 297 | + - 数据类型为INT32时,每个INT32数据存放8个INT4数据,在transposeX2为true情况下各个维度表示:(n,k // 8),要求k为8的倍数;在transposeX2为false情况下各个维度表示:(k,n // 8),要求n为8的倍数。 |
| 298 | - - 可使用aclnnConvertWeightToINT4Pack接口完成x2从INT32(1个int32在0~3bit位存储1个int4)到INT32(1个int32存储8个int4)或INT4(1个int4表示1个int4)的数据格式转换,具体参见[aclnnConvertWeightToINT4Pack接口](../../convert_weight_to_int4_pack/docs/aclnnConvertWeightToINT4Pack.md)。 | 298 | + - 可使用aclnnConvertWeightToINT4Pack接口完成x2从INT32(1个int32在0~3bit位存储1个int4)到INT32(1个int32存储8个int4)或INT4(1个int4表示1个int4)的数据格式转换,具体参见[aclnnConvertWeightToINT4Pack接口](../../convert_weight_to_int4_pack/docs/aclnnConvertWeightToINT4Pack.md)。 |
| 299 | - - bias数据类型支持INT32,BFLOAT16,FLOAT16,FLOAT32。当x1和x2为INT32、INT4时,bias的shape只支持1维(n,)。 | 299 | + - bias数据类型支持INT32,BFLOAT16,FLOAT16,FLOAT32。当x1和x2为INT32、INT4时,bias的shape只支持1维(n,)。 |
| 300 | - - x1和x2为INT32、INT4时,transposeX1仅支持false。 | 300 | + - x1和x2为INT32、INT4时,transposeX1仅支持false。 |
| 301 | - - out数据类型支持FLOAT16、INT8、BFLOAT16、INT32。 | 301 | + - out数据类型支持FLOAT16、INT8、BFLOAT16、INT32。 |
| 302 | - <term>Ascend 950PR/Ascend 950DT</term>: | 302 | - <term>Ascend 950PR/Ascend 950DT</term>: |
| 303 | - - x1数据类型支持INT8。 | 303 | + - x1数据类型支持INT8。 |
| 304 | - - x2数据类型支持INT8,当最后两根轴其中一根轴为1(即n=1或k=1)时,x2不支持私有格式,仅支持ND格式。 | 304 | + - x2数据类型支持INT8,当最后两根轴其中一根轴为1(即n=1或k=1)时,x2不支持私有格式,仅支持ND格式。 |
| 305 | - - bias数据类型支持INT32,BFLOAT16,FLOAT16,FLOAT32。 | 305 | + - bias数据类型支持INT32,BFLOAT16,FLOAT16,FLOAT32。 |
| 306 | - - out数据类型支持FLOAT16、INT8、BFLOAT16、INT32。 | 306 | + - out数据类型支持FLOAT16、INT8、BFLOAT16、INT32。 |
| 307 | - - x2为ND格式时,当输入x1为m=0的空tensor或x2为n=0的空tensor时,输出为空tensor;x2为FRACTAL_NZ格式时,当输入x1中m=0的空tensor时,输出为空tensor。 | 307 | + - x2为ND格式时,当输入x1为m=0的空tensor或x2为n=0的空tensor时,输出为空tensor;x2为FRACTAL_NZ格式时,当输入x1中m=0的空tensor时,输出为空tensor。 |
| 308 | - | ||
| 309 | 308 | ||
| 310 | - **返回值:** | 309 | - **返回值:** |
| 311 | 310 | ||
| @@ -387,6 +386,7 @@ aclnnStatus aclnnQuantMatmulV4( | |||
| 387 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 386 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| 388 | 387 | ||
| 389 | ## 约束说明 | 388 | ## 约束说明 |
| 389 | + | ||
| 390 | - 确定性说明: | 390 | - 确定性说明: |
| 391 | - <term>Atlas 训练系列产品</term>、<term>Atlas 推理系列产品</term>:aclnnQuantMatmulV4默认确定性实现。 | 391 | - <term>Atlas 训练系列产品</term>、<term>Atlas 推理系列产品</term>:aclnnQuantMatmulV4默认确定性实现。 |
| 392 | - <term>Ascend 950PR/Ascend 950DT</term>: aclnnQuantMatmulV4默认确定性实现。 | 392 | - <term>Ascend 950PR/Ascend 950DT</term>: aclnnQuantMatmulV4默认确定性实现。 |
| @@ -397,6 +397,7 @@ aclnnStatus aclnnQuantMatmulV4( | |||
| 397 | 2.当原始ND的后两维中存在某一维度为1时,不建议转NZ格式,默认x2为非连续,且仅支持x2为非连续的tensor。 | 397 | 2.当原始ND的后两维中存在某一维度为1时,不建议转NZ格式,默认x2为非连续,且仅支持x2为非连续的tensor。 |
| 398 | 398 | ||
| 399 | 输入和输出支持以下数据类型组合: | 399 | 输入和输出支持以下数据类型组合: |
| 400 | + | ||
| 400 | - <term>Atlas 推理系列产品</term>: | 401 | - <term>Atlas 推理系列产品</term>: |
| 401 | 402 | ||
| 402 | | x1 | x2 | scale | offset | bias | pertokenScaleOptional | out | | 403 | | x1 | x2 | scale | offset | bias | pertokenScaleOptional | out | |
| @@ -1,7 +1,6 @@ | |||
| 1 | # QuantBatchMatmulV4 | 1 | # QuantBatchMatmulV4 |
| 2 | 2 | ||
| 3 | - | 3 | +## 产品支持情况 |
| 4 | -## 产品支持情况 | ||
| 5 | 4 | ||
| 6 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| 7 | | ---- | :----:| | 6 | | ---- | :----:| |
| @@ -209,6 +208,7 @@ | |||
| 209 | - 输入和输出支持以下数据类型组合: | 208 | - 输入和输出支持以下数据类型组合: |
| 210 | 209 | ||
| 211 | - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>: | 210 | - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>: |
| 211 | + | ||
| 212 | | x1 | x2 | x1_scale | x2_scale | x2_offset | y_scale | bias | y_offset | y | | 212 | | x1 | x2 | x1_scale | x2_scale | x2_offset | y_scale | bias | y_offset | y | |
| 213 | | ------------------------- | ------------------------- | ----------- | ----------- | ----------- | ------- | ------------ | -----------| -------------------------------------- | | 213 | | ------------------------- | ------------------------- | ----------- | ----------- | ----------- | ------- | ------------ | -----------| -------------------------------------- | |
| 214 | | INT8 | INT32 | FLOAT32 | UINT64 | nullptr | nullptr | nullptr | FLOAT32 | FLOAT16/BFLOAT16 | | 214 | | INT8 | INT32 | FLOAT32 | UINT64 | nullptr | nullptr | nullptr | FLOAT32 | FLOAT16/BFLOAT16 | |
| @@ -224,6 +224,7 @@ | |||
| 224 | | INT4 | INT4 | FLOAT32 | FLOAT32 | FLOAT16 | nullptr | nullptr | nullptr | BFLOAT16 | | 224 | | INT4 | INT4 | FLOAT32 | FLOAT32 | FLOAT16 | nullptr | nullptr | nullptr | BFLOAT16 | |
| 225 | 225 | ||
| 226 | - <term>Ascend 950PR/Ascend 950DT</term>: | 226 | - <term>Ascend 950PR/Ascend 950DT</term>: |
| 227 | + | ||
| 227 | | x1 | x2 | x1_scale | x2_scale | x2_offset | y_scale | bias | y | | 228 | | x1 | x2 | x1_scale | x2_scale | x2_offset | y_scale | bias | y | |
| 228 | | ------------------------- | ------------------------- | ----------- | ----------- | -------- | -------| ------- | -------------------------------------- | | 229 | | ------------------------- | ------------------------- | ----------- | ----------- | -------- | -------| ------- | -------------------------------------- | |
| 229 | | INT8 | INT8 | nullptr | UINT64/INT64 | nullptr | nullptr | nullptr/INT32 | FLOAT16/BFLOAT16 | | 230 | | INT8 | INT8 | nullptr | UINT64/INT64 | nullptr | nullptr | nullptr/INT32 | FLOAT16/BFLOAT16 | |
| @@ -239,15 +240,16 @@ | |||
| 239 | | FLOAT8_E4M3FN | FLOAT4_E2M1 | FLOAT8_E8M0 | FLOAT8_E8M0 | nullptr | nullptr | nullptr/BFLOAT16| BFLOAT16 | | 240 | | FLOAT8_E4M3FN | FLOAT4_E2M1 | FLOAT8_E8M0 | FLOAT8_E8M0 | nullptr | nullptr | nullptr/BFLOAT16| BFLOAT16 | |
| 240 | | FLOAT8_E4M3FN | FLOAT4_E2M1 | nullptr | BFLOAT16 | nullptr | INT64/UINT64 | nullptr | BFLOAT16 | | 241 | | FLOAT8_E4M3FN | FLOAT4_E2M1 | nullptr | BFLOAT16 | nullptr | INT64/UINT64 | nullptr | BFLOAT16 | |
| 241 | 242 | ||
| 242 | - | ||
| 243 | - | ||
| 244 | ## 调用说明 | 243 | ## 调用说明 |
| 244 | + | ||
| 245 | - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品、Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>: | 245 | - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品、Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>: |
| 246 | + | ||
| 246 | | 调用方式 | 样例代码 | 说明 | | 247 | | 调用方式 | 样例代码 | 说明 | |
| 247 | | ---------------- | --------------------------- | --------------------------------------------------- | | 248 | | ---------------- | --------------------------- | --------------------------------------------------- | |
| 248 | | aclnn接口 | [test_aclnn_quant_matmul_v5](examples/test_aclnn_quant_matmul_v5_at2_at3.cpp) | 通过<br>[aclnnQuantMatmulV5](docs/aclnnQuantMatmulV5.md)<br>等方式调用QuantBatchMatmulV4算子。 | | 249 | | aclnn接口 | [test_aclnn_quant_matmul_v5](examples/test_aclnn_quant_matmul_v5_at2_at3.cpp) | 通过<br>[aclnnQuantMatmulV5](docs/aclnnQuantMatmulV5.md)<br>等方式调用QuantBatchMatmulV4算子。 | |
| 249 | 250 | ||
| 250 | - <term>Ascend 950PR/Ascend 950DT</term>: | 251 | - <term>Ascend 950PR/Ascend 950DT</term>: |
| 252 | + | ||
| 251 | | 调用方式 | 样例代码 | 说明 | | 253 | | 调用方式 | 样例代码 | 说明 | |
| 252 | | ---------------- | --------------------------- | --------------------------------------------------- | | 254 | | ---------------- | --------------------------- | --------------------------------------------------- | |
| 253 | | aclnn接口 | [test_aclnn_quant_matmul_v5](examples/arch35/test_aclnn_quant_matmul_v5_f8f4_nd.cpp) | 通过<br>[aclnnQuantMatmulV5](docs/aclnnQuantMatmulV5.md)<br>等方式调用QuantBatchMatmulV4算子。 | | 255 | | aclnn接口 | [test_aclnn_quant_matmul_v5](examples/arch35/test_aclnn_quant_matmul_v5_f8f4_nd.cpp) | 通过<br>[aclnnQuantMatmulV5](docs/aclnnQuantMatmulV5.md)<br>等方式调用QuantBatchMatmulV4算子。 | |
| @@ -514,7 +514,6 @@ aclnnStatus aclnnQuantMatmulV5( | |||
| 514 | </tr> | 514 | </tr> |
| 515 | </tbody></table> | 515 | </tbody></table> |
| 516 | 516 | ||
| 517 | - | ||
| 518 | ## aclnnQuantMatmulV5 | 517 | ## aclnnQuantMatmulV5 |
| 519 | 518 | ||
| 520 | - **参数说明** | 519 | - **参数说明** |
| @@ -581,6 +580,7 @@ aclnnStatus aclnnQuantMatmulV5( | |||
| 581 | | x1 | x2 | x1Scale | x2Scale | x1Offset | x2Offset | yScale | yOffset | bias | out | | 580 | | x1 | x2 | x1Scale | x2Scale | x1Offset | x2Offset | yScale | yOffset | bias | out | |
| 582 | | -----------| ------------ | ----------- | ----------- | ----------- |----------- | ------- | -----------| ------------ | -------------------| | 581 | | -----------| ------------ | ----------- | ----------- | ----------- |----------- | ------- | -----------| ------------ | -------------------| |
| 583 | | INT8 | INT8 | FLOAT32 | FLOAT32 | null | null | null | null | null/INT32 | FLOAT16 | | 582 | | INT8 | INT8 | FLOAT32 | FLOAT32 | null | null | null | null | null/INT32 | FLOAT16 | |
| 583 | + | ||
| 584 | - x1的约束: | 584 | - x1的约束: |
| 585 | - x1的最后一维大小不能超过65535,transposeX1仅支持false。 | 585 | - x1的最后一维大小不能超过65535,transposeX1仅支持false。 |
| 586 | - x2的约束: | 586 | - x2的约束: |
| @@ -683,7 +683,8 @@ aclnnStatus aclnnQuantMatmulV5( | |||
| 683 | - 当前仅支持2维ND格式。 | 683 | - 当前仅支持2维ND格式。 |
| 684 | - transposeX2为true时维度为:(n,ceil(k / 8)),要求k为8的倍数。 | 684 | - transposeX2为true时维度为:(n,ceil(k / 8)),要求k为8的倍数。 |
| 685 | - transposeX2为false时维度为:(k,ceil(n / 8)),要求n为8的倍数。 | 685 | - transposeX2为false时维度为:(k,ceil(n / 8)),要求n为8的倍数。 |
| 686 | - - 可使用aclnnConvertWeightToINT4Pack接口完成x2从INT32(1个int32在0~3bit位存储1个int4)到INT32(1个int32存储8个int4)或INT4(1个int4表示1个int4)的数据格式转换,具体参见[aclnnConvertWeightToINT4Pack接口](../../convert_weight_to_int4_pack/docs/aclnnConvertWeightToINT4Pack.md)。 | 686 | + - 可使用aclnnConvertWeightToINT4Pack接口完成x2从INT32(1个int32在0~3bit位存储1个int4)到INT32(1个int32存储8个int4)或INT4(1个int4表示1个int4)的数据格式转换,具体参见[aclnnConvertWeightToINT4Pack接口](../../convert_weight_to_int4_pack/docs/aclnnConvertWeightToINT4Pack.md)。 |
| 687 | + | ||
| 687 | - x1Scale的约束:数据格式支持ND,shape是1维(t,),t = m,其中m与x1的m一致。 | 688 | - x1Scale的约束:数据格式支持ND,shape是1维(t,),t = m,其中m与x1的m一致。 |
| 688 | - x2Scale的约束:数据格式支持ND,shape是1维(t,),t = 1或n,其中n与x2的n一致。 | 689 | - x2Scale的约束:数据格式支持ND,shape是1维(t,),t = 1或n,其中n与x2的n一致。 |
| 689 | - x2Offset的约束:数据格式支持ND,shape是1维(t,),t = 1或n,其中n与x2的n一致。 | 690 | - x2Offset的约束:数据格式支持ND,shape是1维(t,),t = 1或n,其中n与x2的n一致。 |
| @@ -702,12 +703,14 @@ aclnnStatus aclnnQuantMatmulV5( | |||
| 702 | 703 | ||
| 703 | - 输入和输出支持以下数据类型组合: | 704 | - 输入和输出支持以下数据类型组合: |
| 704 | <a id="输入和输出支持以下数据类型组合K-G"></a> | 705 | <a id="输入和输出支持以下数据类型组合K-G"></a> |
| 706 | + | ||
| 705 | | x1 | x2 | x1Scale | x2Scale | x2Offset | yScale | bias | yOffset | out | | 707 | | x1 | x2 | x1Scale | x2Scale | x2Offset | yScale | bias | yOffset | out | |
| 706 | | ------------------------- | ------------------------- | ----------- | ----------- | ----------- | ------- | ------------ | -----------| -------------------------------------- | | 708 | | ------------------------- | ------------------------- | ----------- | ----------- | ----------- | ------- | ------------ | -----------| -------------------------------------- | |
| 707 | | INT8 | INT32 | FLOAT32 | UINT64/INT64 | null | null | null | FLOAT32 | FLOAT16/BFLOAT16 | | 709 | | INT8 | INT32 | FLOAT32 | UINT64/INT64 | null | null | null | FLOAT32 | FLOAT16/BFLOAT16 | |
| 708 | | INT4 | INT4 | FLOAT32 | FLOAT32 | FLOAT16 | null | null | null | BFLOAT16 | | 710 | | INT4 | INT4 | FLOAT32 | FLOAT32 | FLOAT16 | null | null | null | BFLOAT16 | |
| 709 | 711 | ||
| 710 | - x1、x2、x1Scale、x2Scale和groupSize的取值关系: | 712 | - x1、x2、x1Scale、x2Scale和groupSize的取值关系: |
| 713 | + | ||
| 711 | |量化类型| x1数据类型 | x2数据类型 | x1Scale数据类型| x2Scale数据类型| x1 shape | x2 shape| x1Scale shape| x2Scale shape|x2Offset shape| yOffset shape| [gsM,gsN,gsK]| | 714 | |量化类型| x1数据类型 | x2数据类型 | x1Scale数据类型| x2Scale数据类型| x1 shape | x2 shape| x1Scale shape| x2Scale shape|x2Offset shape| yOffset shape| [gsM,gsN,gsK]| |
| 712 | | ----- | ------------------------- | ------------------------- | -------------- | ------------- | -------- | ------- | ------------ | ------ |------------ | ------------ | ------------ | | 715 | | ----- | ------------------------- | ------------------------- | -------------- | ------------- | -------- | ------- | ------------ | ------ |------------ | ------------ | ------------ | |
| 713 | | K-G量化 | INT8 |INT32 |FLOAT32 |UINT64/INT64 |(m, k) |(k, ceil(n / 8))|(m, 1)|(ceil(k / 256), n)|null| (n) | [0, 0, 256]| | 716 | | K-G量化 | INT8 |INT32 |FLOAT32 |UINT64/INT64 |(m, k) |(k, ceil(n / 8))|(m, 1)|(ceil(k / 256), n)|null| (n) | [0, 0, 256]| |
| @@ -774,6 +777,7 @@ aclnnStatus aclnnQuantMatmulV5( | |||
| 774 | 777 | ||
| 775 | - 输入和输出支持以下数据类型组合: | 778 | - 输入和输出支持以下数据类型组合: |
| 776 | <a id="输入和输出支持以下数据类型组合TC/TT"></a> | 779 | <a id="输入和输出支持以下数据类型组合TC/TT"></a> |
| 780 | + | ||
| 777 | | x1 | x2 | x1Scale | x2Scale | x2Offset | yScale | bias | out | | 781 | | x1 | x2 | x1Scale | x2Scale | x2Offset | yScale | bias | out | |
| 778 | | ------------------------- | ------------------------- | ----------- | ----------- | -------- | -------| ------- | -------------------------------------- | | 782 | | ------------------------- | ------------------------- | ----------- | ----------- | -------- | -------| ------- | -------------------------------------- | |
| 779 | | INT8 | INT8 | null | UINT64/INT64 | null | null | null/INT32 | FLOAT16/BFLOAT16 | | 783 | | INT8 | INT8 | null | UINT64/INT64 | null | null | null/INT32 | FLOAT16/BFLOAT16 | |
| @@ -799,6 +803,7 @@ aclnnStatus aclnnQuantMatmulV5( | |||
| 799 | 803 | ||
| 800 | - 输入和输出支持以下数据类型组合: | 804 | - 输入和输出支持以下数据类型组合: |
| 801 | <a id="输入和输出支持以下数据类型组合KC/KT"></a> | 805 | <a id="输入和输出支持以下数据类型组合KC/KT"></a> |
| 806 | + | ||
| 802 | | x1 | x2 | x1Scale | x2Scale | x2Offset | yScale | bias | out | | 807 | | x1 | x2 | x1Scale | x2Scale | x2Offset | yScale | bias | out | |
| 803 | | ------------------------- | ------------------------- | ----------- | ----------- | -------- | -------| ------- | -------------------------------------- | | 808 | | ------------------------- | ------------------------- | ----------- | ----------- | -------- | -------| ------- | -------------------------------------- | |
| 804 | | INT8 | INT8 | FLOAT32| FLOAT32/BFLOAT16 | null | null | null/INT32/FLOAT32/BFLOAT16 | BFLOAT16 | | 809 | | INT8 | INT8 | FLOAT32| FLOAT32/BFLOAT16 | null | null | null/INT32/FLOAT32/BFLOAT16 | BFLOAT16 | |
| @@ -818,16 +823,20 @@ aclnnStatus aclnnQuantMatmulV5( | |||
| 818 | 823 | ||
| 819 | - 输入和输出支持以下数据类型组合: | 824 | - 输入和输出支持以下数据类型组合: |
| 820 | <a id="输入和输出支持以下数据类型组合GB/BB"></a> | 825 | <a id="输入和输出支持以下数据类型组合GB/BB"></a> |
| 826 | + | ||
| 821 | | x1 | x2 | x1Scale | x2Scale | x2Offset | yScale | bias | out | | 827 | | x1 | x2 | x1Scale | x2Scale | x2Offset | yScale | bias | out | |
| 822 | | ------------------------- | ------------------------- | ----------- | ----------- | -------- | -------| ------- | -------------------------------------- | | 828 | | ------------------------- | ------------------------- | ----------- | ----------- | -------- | -------| ------- | -------------------------------------- | |
| 823 | | FLOAT8_E4M3FN/FLOAT8_E5M2 | FLOAT8_E4M3FN/FLOAT8_E5M2 | FLOAT32 | FLOAT32 | null | null | null | FLOAT16/BFLOAT16/ FLOAT32 | | 829 | | FLOAT8_E4M3FN/FLOAT8_E5M2 | FLOAT8_E4M3FN/FLOAT8_E5M2 | FLOAT32 | FLOAT32 | null | null | null | FLOAT16/BFLOAT16/ FLOAT32 | |
| 824 | | HIFLOAT8 | HIFLOAT8 | FLOAT32 | FLOAT32 | null | null | null | FLOAT16/BFLOAT16/ FLOAT32 | | 830 | | HIFLOAT8 | HIFLOAT8 | FLOAT32 | FLOAT32 | null | null | null | FLOAT16/BFLOAT16/ FLOAT32 | |
| 825 | | INT8 |INT8 | FLOAT32 | FLOAT32 | null | null | FLOAT32 |BFLOAT16 | | 831 | | INT8 |INT8 | FLOAT32 | FLOAT32 | null | null | FLOAT32 |BFLOAT16 | |
| 832 | + | ||
| 826 | - x1、x2、x1Scale、x2Scale和groupSize的取值关系: | 833 | - x1、x2、x1Scale、x2Scale和groupSize的取值关系: |
| 834 | + | ||
| 827 | |量化类型|x1 shape|x2 shape|x1Scale shape|x2Scale shape|yScale shape|[gsM,gsN,gsK]|groupSize| | 835 | |量化类型|x1 shape|x2 shape|x1Scale shape|x2Scale shape|yScale shape|[gsM,gsN,gsK]|groupSize| |
| 828 | |-------|--------|--------|-------------|-------------|------------|---|---| | 836 | |-------|--------|--------|-------------|-------------|------------|---|---| |
| 829 | |B-B量化|<li>非转置:(batch, m, k)</li><li>转置:(batch, k, m)</li>|<li>非转置:(batch, k, n)</li><li>转置:(batch, n, k)</li>|<li>非转置:(batch, ceil(m / 128), ceil(k / 128))</li><li>转置:(batch, ceil(k / 128), ceil(m / 128))</li>|<li>非转置:(batch, ceil(k / 128), ceil(n / 128))</li><li>转置:(batch, ceil(n / 128), ceil(k / 128))</li>|null|[128, 128, 128]|549764202624| | 837 | |B-B量化|<li>非转置:(batch, m, k)</li><li>转置:(batch, k, m)</li>|<li>非转置:(batch, k, n)</li><li>转置:(batch, n, k)</li>|<li>非转置:(batch, ceil(m / 128), ceil(k / 128))</li><li>转置:(batch, ceil(k / 128), ceil(m / 128))</li>|<li>非转置:(batch, ceil(k / 128), ceil(n / 128))</li><li>转置:(batch, ceil(n / 128), ceil(k / 128))</li>|null|[128, 128, 128]|549764202624| |
| 830 | |G-B量化|<li>非转置:(batch, m, k)</li><li>转置:(batch, k, m)</li>|<li>非转置:(batch, k, n)</li><li>转置:(batch, n, k)</li>|<li>非转置:(batch, m, ceil(k / 128))</li><li>转置:(batch, ceil(k / 128), m)</li>|<li>非转置:(batch, ceil(k / 128), ceil(n / 128))</li><li>转置:(batch, ceil(n / 128), ceil(k / 128))</li>|null|[1, 128, 128]|4303356032| | 838 | |G-B量化|<li>非转置:(batch, m, k)</li><li>转置:(batch, k, m)</li>|<li>非转置:(batch, k, n)</li><li>转置:(batch, n, k)</li>|<li>非转置:(batch, m, ceil(k / 128))</li><li>转置:(batch, ceil(k / 128), m)</li>|<li>非转置:(batch, ceil(k / 128), ceil(n / 128))</li><li>转置:(batch, ceil(n / 128), ceil(k / 128))</li>|null|[1, 128, 128]|4303356032| |
| 839 | + | ||
| 831 | - 注:上表中gsM、gsK和gsN分别表示groupSizeM、groupSizeK和groupSizeN。 | 840 | - 注:上表中gsM、gsK和gsN分别表示groupSizeM、groupSizeK和groupSizeN。 |
| 832 | - G-B量化和B-B量化场景下,x1和x1Scale的转置属性需要保持一致,x2和x2Scale的转置属性需要保持一致。 | 841 | - G-B量化和B-B量化场景下,x1和x1Scale的转置属性需要保持一致,x2和x2Scale的转置属性需要保持一致。 |
| 833 | - G-B量化场景下,仅INT8输入支持bias,其余场景不支持bias。 | 842 | - G-B量化场景下,仅INT8输入支持bias,其余场景不支持bias。 |
| @@ -842,12 +851,15 @@ aclnnStatus aclnnQuantMatmulV5( | |||
| 842 | 851 | ||
| 843 | - 输入和输出支持以下数据类型组合: | 852 | - 输入和输出支持以下数据类型组合: |
| 844 | <a id="输入和输出支持以下数据类型组合mx"></a> | 853 | <a id="输入和输出支持以下数据类型组合mx"></a> |
| 854 | + | ||
| 845 | |量化类型| x1 | x2 | x1Scale | x2Scale | x2Offset | yScale | bias | out | | 855 | |量化类型| x1 | x2 | x1Scale | x2Scale | x2Offset | yScale | bias | out | |
| 846 | |-------| ------------------------- | ------------------------- | ----------- | ----------- | -------- | -------| ------- | -------------------------------------- | | 856 | |-------| ------------------------- | ------------------------- | ----------- | ----------- | -------- | -------| ------- | -------------------------------------- | |
| 847 | |mx 全量化| FLOAT8_E4M3FN/FLOAT8_E5M2 | FLOAT8_E4M3FN/FLOAT8_E5M2 | FLOAT8_E8M0 | FLOAT8_E8M0 | null | null | null/FLOAT32 | FLOAT16/BFLOAT16/FLOAT32 | | 857 | |mx 全量化| FLOAT8_E4M3FN/FLOAT8_E5M2 | FLOAT8_E4M3FN/FLOAT8_E5M2 | FLOAT8_E8M0 | FLOAT8_E8M0 | null | null | null/FLOAT32 | FLOAT16/BFLOAT16/FLOAT32 | |
| 848 | |mx 全量化| FLOAT4_E2M1 | FLOAT4_E2M1 | FLOAT8_E8M0 | FLOAT8_E8M0 | null | null | null/FLOAT32 | FLOAT16/BFLOAT16/FLOAT32 | | 858 | |mx 全量化| FLOAT4_E2M1 | FLOAT4_E2M1 | FLOAT8_E8M0 | FLOAT8_E8M0 | null | null | null/FLOAT32 | FLOAT16/BFLOAT16/FLOAT32 | |
| 849 | |mx 伪量化| FLOAT8_E4M3FN | FLOAT4_E2M1 | FLOAT8_E8M0 | FLOAT8_E8M0 | null | null | null/BFLOAT16| BFLOAT16 | | 859 | |mx 伪量化| FLOAT8_E4M3FN | FLOAT4_E2M1 | FLOAT8_E8M0 | FLOAT8_E8M0 | null | null | null/BFLOAT16| BFLOAT16 | |
| 860 | + | ||
| 850 | - x1数据类型、x2数据类型、x1、x2、x1Scale、x2Scale和groupSize的取值关系: | 861 | - x1数据类型、x2数据类型、x1、x2、x1Scale、x2Scale和groupSize的取值关系: |
| 862 | + | ||
| 851 | |量化类型|x1数据类型|x2数据类型|x1 shape|x2 shape|x1Scale shape|x2Scale shape|bias shape|yScale shape|[gsM,gsN,gsK]|groupSize| | 863 | |量化类型|x1数据类型|x2数据类型|x1 shape|x2 shape|x1Scale shape|x2Scale shape|bias shape|yScale shape|[gsM,gsN,gsK]|groupSize| |
| 852 | |-------|--------|--------|--------|--------|-------------|-------------|------------|---------------------------------------|--|--| | 864 | |-------|--------|--------|--------|--------|-------------|-------------|------------|---------------------------------------|--|--| |
| 853 | |mx 全量化|FLOAT8_E4M3FN/FLOAT8_E5M2|FLOAT8_E4M3FN/FLOAT8_E5M2|<li>非转置:(batch, m, k)</li><li>转置:(batch, k, m)</li>|<li>非转置:(batch, k, n)</li><li>转置:(batch, n, k)</li>|<li>非转置:(m, ceil(k / 64), 2)</li><li>转置:(ceil(k / 64), m, 2)</li>|<li>非转置:(ceil(k / 64), n, 2)</li><li>转置:(n, ceil(k / 64), 2)</li>|(n,)或(batch, 1, n)|null|[1, 1, 32]|4295032864| | 865 | |mx 全量化|FLOAT8_E4M3FN/FLOAT8_E5M2|FLOAT8_E4M3FN/FLOAT8_E5M2|<li>非转置:(batch, m, k)</li><li>转置:(batch, k, m)</li>|<li>非转置:(batch, k, n)</li><li>转置:(batch, n, k)</li>|<li>非转置:(m, ceil(k / 64), 2)</li><li>转置:(ceil(k / 64), m, 2)</li>|<li>非转置:(ceil(k / 64), n, 2)</li><li>转置:(n, ceil(k / 64), 2)</li>|(n,)或(batch, 1, n)|null|[1, 1, 32]|4295032864| |
| @@ -869,13 +881,17 @@ aclnnStatus aclnnQuantMatmulV5( | |||
| 869 | 881 | ||
| 870 | - 输入和输出支持以下数据类型组合: | 882 | - 输入和输出支持以下数据类型组合: |
| 871 | <a id="输入和输出支持以下数据类型组合TCG"></a> | 883 | <a id="输入和输出支持以下数据类型组合TCG"></a> |
| 884 | + | ||
| 872 | | x1 | x2 | x1Scale | x2Scale | x2Offset | yScale | bias | out | | 885 | | x1 | x2 | x1Scale | x2Scale | x2Offset | yScale | bias | out | |
| 873 | | ------------------------- | ------------------------- | ----------- | ----------- | -------- | -------| ------- | -------------------------------------- | | 886 | | ------------------------- | ------------------------- | ----------- | ----------- | -------- | -------| ------- | -------------------------------------- | |
| 874 | | FLOAT8_E4M3FN | FLOAT4_E2M1 | null | BFLOAT16 | null | INT64/UINT64 | null | BFLOAT16 | | 887 | | FLOAT8_E4M3FN | FLOAT4_E2M1 | null | BFLOAT16 | null | INT64/UINT64 | null | BFLOAT16 | |
| 888 | + | ||
| 875 | - x1、x2、x1Scale、x2Scale和groupSize的取值关系: | 889 | - x1、x2、x1Scale、x2Scale和groupSize的取值关系: |
| 890 | + | ||
| 876 | |量化类型|x1 shape|x2 shape|x1Scale shape|x2Scale shape|yScale shape|[gsM,gsN,gsK]|groupSize| | 891 | |量化类型|x1 shape|x2 shape|x1Scale shape|x2Scale shape|yScale shape|[gsM,gsN,gsK]|groupSize| |
| 877 | |-------|--------|--------|-------------|-------------|------------|---------------------------------------|--| | 892 | |-------|--------|--------|-------------|-------------|------------|---------------------------------------|--| |
| 878 | |T-CG量化|(m, k)|(n, k)/(k, n)|null|(n, ceil(k / 32))/(ceil(k / 32), n)|(1, n)|[0, 0, 32]/[1, 1, 32]|32/4295032864| | 893 | |T-CG量化|(m, k)|(n, k)/(k, n)|null|(n, ceil(k / 32))/(ceil(k / 32), n)|(1, n)|[0, 0, 32]/[1, 1, 32]|32/4295032864| |
| 894 | + | ||
| 879 | - T-CG量化模式下,yScale数据类型支持INT64和UINT64,数据格式支持ND,shape支持2维,shape表示为(1, n)。当原始输入类型不满足约束和限制中的数据类型组合时,需要提前调用TransQuantParamV2算子的aclnn接口来将其转成UINT64数据类型。当输入数据类型是INT64时,内部会把INT64当成UINT64处理。 | 895 | - T-CG量化模式下,yScale数据类型支持INT64和UINT64,数据格式支持ND,shape支持2维,shape表示为(1, n)。当原始输入类型不满足约束和限制中的数据类型组合时,需要提前调用TransQuantParamV2算子的aclnn接口来将其转成UINT64数据类型。当输入数据类型是INT64时,内部会把INT64当成UINT64处理。 |
| 880 | - T-CG量化模式下,bias是预留参数,当前版本不支持,需要传入nullptr。 | 896 | - T-CG量化模式下,bias是预留参数,当前版本不支持,需要传入nullptr。 |
| 881 | - T-CG量化模式下,transposeX1为false。数据格式支持ND和AI处理器亲和数据排布格式。当数据格式为ND格式时,要求支持k是64的倍数,transposeX2为true。当数据格式为AI处理器亲和数据排布格式时,要求k,n都是64的倍数,transposeX2为false。 | 897 | - T-CG量化模式下,transposeX1为false。数据格式支持ND和AI处理器亲和数据排布格式。当数据格式为ND格式时,要求支持k是64的倍数,transposeX2为true。当数据格式为AI处理器亲和数据排布格式时,要求k,n都是64的倍数,transposeX2为false。 |
| @@ -1126,6 +1142,7 @@ x1为FLOAT8_E4M3FN,x2为FLOAT4_E2M1,x2Scale为BFLOAT16,yScale为UINT64。 | |||
| 1126 | 1142 | ||
| 1127 | - <term>Ascend 950PR/Ascend 950DT</term>: | 1143 | - <term>Ascend 950PR/Ascend 950DT</term>: |
| 1128 | x1为INT8,x2为INT8,x1Scale为FLOAT32,x2Scale为FLOAT32,bias为INT32。 | 1144 | x1为INT8,x2为INT8,x1Scale为FLOAT32,x2Scale为FLOAT32,bias为INT32。 |
| 1145 | + | ||
| 1129 | ```cpp | 1146 | ```cpp |
| 1130 | #include <iostream> | 1147 | #include <iostream> |
| 1131 | #include <memory> | 1148 | #include <memory> |
| @@ -1734,4 +1751,5 @@ x1为INT8,x2为INT32,x1Scale为FLOAT32,x2Scale为UINT64。 | |||
| 1734 | Finalize(deviceId, stream); | 1751 | Finalize(deviceId, stream); |
| 1735 | return 0; | 1752 | return 0; |
| 1736 | } | 1753 | } |
| 1737 | - ``` | 1754 | + ``` |
| 1755 | + | ||
| @@ -1,7 +1,6 @@ | |||
| 1 | # QuantMatmul | 1 | # QuantMatmul |
| 2 | 2 | ||
| 3 | - | 3 | +## 产品支持情况 |
| 4 | -## 产品支持情况 | ||
| 5 | 4 | ||
| 6 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| 7 | | ---- | :----: | | 6 | | ---- | :----: | |
| @@ -258,6 +258,7 @@ aclnnStatus aclnnQuantMatmulV2( | |||
| 258 | - <term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>、<term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>:aclnnQuantMatmulV2默认确定性实现。 | 258 | - <term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>、<term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>:aclnnQuantMatmulV2默认确定性实现。 |
| 259 | 259 | ||
| 260 | 该接口迁移到aclnnQuantMatmulV4接口的方法: | 260 | 该接口迁移到aclnnQuantMatmulV4接口的方法: |
| 261 | + | ||
| 261 | - 输入x1,x2,bias,adjX1和adjX2可以直接转为aclnnQuantMatmulV4接口中的x1,x2,bias,transposeX1和transposeX2。 | 262 | - 输入x1,x2,bias,adjX1和adjX2可以直接转为aclnnQuantMatmulV4接口中的x1,x2,bias,transposeX1和transposeX2。 |
| 262 | - 输入deqScale为UINT64的aclTensor,数据类型与aclnnQuantMatmulV4接口中的scale一致。aclnnQuantMatmulV2接口的deqScale shape是1维(t,),t = align(n, 16)。aclnnQuantMatmulV4接口中的scale shape是1维(t,),t = 1或n。直接将原始FLOAT型量化参数调用aclnnTransQuantParamV2输出数据类型为UINT64且shape为(n,)的aclTensor(参考[aclnnQuantMatmulV4调用示例](../../quant_batch_matmul_v3/docs/aclnnQuantMatmulV4.md#调用示例)),记为**scale**,对标aclnnQuantMatmulV4接口中的scale。 | 263 | - 输入deqScale为UINT64的aclTensor,数据类型与aclnnQuantMatmulV4接口中的scale一致。aclnnQuantMatmulV2接口的deqScale shape是1维(t,),t = align(n, 16)。aclnnQuantMatmulV4接口中的scale shape是1维(t,),t = 1或n。直接将原始FLOAT型量化参数调用aclnnTransQuantParamV2输出数据类型为UINT64且shape为(n,)的aclTensor(参考[aclnnQuantMatmulV4调用示例](../../quant_batch_matmul_v3/docs/aclnnQuantMatmulV4.md#调用示例)),记为**scale**,对标aclnnQuantMatmulV4接口中的scale。 |
| 263 | - aclnnQuantMatmulV4接口中的可选输入offset/pertokenScaleOptional设置为nullptr。 | 264 | - aclnnQuantMatmulV4接口中的可选输入offset/pertokenScaleOptional设置为nullptr。 |
| @@ -514,4 +514,4 @@ int main() { | |||
| 514 | 514 | ||
| 515 | return 0; | 515 | return 0; |
| 516 | } | 516 | } |
| 517 | -``` | 517 | +``` |
| @@ -1,7 +1,6 @@ | |||
| 1 | # Sparse4to2QuantMatmul | 1 | # Sparse4to2QuantMatmul |
| 2 | 2 | ||
| 3 | - | 3 | +## 产品支持情况 |
| 4 | -## 产品支持情况 | ||
| 5 | 4 | ||
| 6 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| 7 | | ---- | :----:| | 6 | | ---- | :----:| |
| @@ -89,4 +88,4 @@ | |||
| 89 | 88 | ||
| 90 | | 调用方式 | 样例代码 | 说明 | | 89 | | 调用方式 | 样例代码 | 说明 | |
| 91 | | ---------------- | --------------------------- | --------------------------------------------------- | | 90 | | ---------------- | --------------------------- | --------------------------------------------------- | |
| 92 | -| aclnn接口 | [test_aclnn_sparse4to2quant_matmul](examples/test_aclnn_sparse4to2quant_matmul.cpp) | 通过<br>[aclnnSparse4to2QuantMatmulWeightNz](docs/aclnnSparse4to2QuantMatmulWeightNz.md)<br>等方式调用Sparse4to2QuantMatmul算子。 | | 91 | +| aclnn接口 | [test_aclnn_sparse4to2quant_matmul](examples/test_aclnn_sparse4to2quant_matmul.cpp) | 通过<br>[aclnnSparse4to2QuantMatmulWeightNz](docs/aclnnSparse4to2QuantMatmulWeightNz.md)<br>等方式调用Sparse4to2QuantMatmul算子。 | |
| @@ -163,7 +163,6 @@ aclnnStatus aclnnSparse4to2QuantMatmulWeightNz( | |||
| 163 | </tbody> | 163 | </tbody> |
| 164 | </table> | 164 | </table> |
| 165 | 165 | ||
| 166 | - | ||
| 167 | - **返回值:** | 166 | - **返回值:** |
| 168 | 167 | ||
| 169 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 168 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| @@ -1,7 +1,6 @@ | |||
| 1 | # TransposeQuantBatchMatMul | 1 | # TransposeQuantBatchMatMul |
| 2 | 2 | ||
| 3 | - | 3 | +## 产品支持情况 |
| 4 | -## 产品支持情况 | ||
| 5 | 4 | ||
| 6 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| 7 | | :----------------------------------------------------------- |:-------:| | 6 | | :----------------------------------------------------------- |:-------:| |
| @@ -1,7 +1,6 @@ | |||
| 1 | # WeightQuantBatchMatmul | 1 | # WeightQuantBatchMatmul |
| 2 | 2 | ||
| 3 | - | 3 | +## 产品支持情况 |
| 4 | -## 产品支持情况 | ||
| 5 | 4 | ||
| 6 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| 7 | | ---- | :----:| | 6 | | ---- | :----:| |
| @@ -120,4 +119,4 @@ | |||
| 120 | 119 | ||
| 121 | | 调用方式 | 样例代码 | 说明 | | 120 | | 调用方式 | 样例代码 | 说明 | |
| 122 | | ---------------- | --------------------------- | --------------------------------------------------- | | 121 | | ---------------- | --------------------------- | --------------------------------------------------- | |
| 123 | -| aclnn接口 | [test_aclnn_weight_quant_batch_mat_mul](examples/test_aclnn_weight_quant_batch_mat_mul.cpp) | 通过<br>[aclnnWeightQuantBatchMatmul](docs/aclnnWeightQuantBatchMatmul.md)<br> 调用WeightQuantBatchMatmul算子。 | | 122 | +| aclnn接口 | [test_aclnn_weight_quant_batch_mat_mul](examples/test_aclnn_weight_quant_batch_mat_mul.cpp) | 通过<br>[aclnnWeightQuantBatchMatmul](docs/aclnnWeightQuantBatchMatmul.md)<br> 调用WeightQuantBatchMatmul算子。 | |
| @@ -44,6 +44,7 @@ aclnnStatus aclnnWeightQuantBatchMatmulGetWorkspaceSize( | |||
| 44 | uint64_t *workspaceSize, | 44 | uint64_t *workspaceSize, |
| 45 | aclOpExecutor **executor) | 45 | aclOpExecutor **executor) |
| 46 | ``` | 46 | ``` |
| 47 | + | ||
| 47 | ```cpp | 48 | ```cpp |
| 48 | aclnnStatus aclnnWeightQuantBatchMatmul( | 49 | aclnnStatus aclnnWeightQuantBatchMatmul( |
| 49 | void *workspace, | 50 | void *workspace, |
| @@ -304,7 +305,6 @@ aclnnStatus aclnnWeightQuantBatchMatmul( | |||
| 304 | 305 | ||
| 305 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 306 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| 306 | 307 | ||
| 307 | - | ||
| 308 | ## 约束说明 | 308 | ## 约束说明 |
| 309 | 309 | ||
| 310 | - 确定性说明: | 310 | - 确定性说明: |
| @@ -627,4 +627,4 @@ int main() { | |||
| 627 | free(deqScaleData); | 627 | free(deqScaleData); |
| 628 | return 0; | 628 | return 0; |
| 629 | } | 629 | } |
| 630 | -``` | 630 | +``` |
| @@ -1,7 +1,6 @@ | |||
| 1 | # WeightQuantBatchMatmulV2 | 1 | # WeightQuantBatchMatmulV2 |
| 2 | 2 | ||
| 3 | - | 3 | +## 产品支持情况 |
| 4 | -## 产品支持情况 | ||
| 5 | 4 | ||
| 6 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| 7 | | ---- | :----:| | 6 | | ---- | :----:| |
| @@ -125,4 +124,4 @@ | |||
| 125 | 124 | ||
| 126 | | 调用方式 | 样例代码 | 说明 | | 125 | | 调用方式 | 样例代码 | 说明 | |
| 127 | | ---------------- | --------------------------- | --------------------------------------------------- | | 126 | | ---------------- | --------------------------- | --------------------------------------------------- | |
| 128 | -| aclnn接口 | [test_aclnn_weight_quant_batch_matmul_v2](examples/test_aclnn_weight_quant_batch_matmul_v2.cpp) | 通过<br>[aclnnWeightQuantBatchMatmulV2](docs/aclnnWeightQuantBatchMatmulV2.md)<br>[aclnnWeightQuantBatchMatmulV3](docs/aclnnWeightQuantBatchMatmulV3.md)<br>[aclnnWeightQuantBatchMatmulNz](docs/aclnnWeightQuantBatchMatmulNz.md)<br>等方式调用WeightQuantBatchMatmulV2算子。| | 127 | +| aclnn接口 | [test_aclnn_weight_quant_batch_matmul_v2](examples/test_aclnn_weight_quant_batch_matmul_v2.cpp) | 通过<br>[aclnnWeightQuantBatchMatmulV2](docs/aclnnWeightQuantBatchMatmulV2.md)<br>[aclnnWeightQuantBatchMatmulV3](docs/aclnnWeightQuantBatchMatmulV3.md)<br>[aclnnWeightQuantBatchMatmulNz](docs/aclnnWeightQuantBatchMatmulNz.md)<br>等方式调用WeightQuantBatchMatmulV2算子。| |
| @@ -290,13 +290,13 @@ aclnnStatus aclnnWeightQuantBatchMatmulNz( | |||
| 290 | 290 | ||
| 291 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 291 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| 292 | 292 | ||
| 293 | - | ||
| 294 | ## 约束说明 | 293 | ## 约束说明 |
| 295 | 294 | ||
| 296 | - 确定性说明:aclnnWeightQuantBatchMatmulNz默认确定性实现。 | 295 | - 确定性说明:aclnnWeightQuantBatchMatmulNz默认确定性实现。 |
| 297 | - 支持的量化模式:perchannel[量化模式](../../../docs/zh/context/量化介绍.md)、pergroup[量化模式](../../../docs/zh/context/量化介绍.md)和mx[量化模式](../../../docs/zh/context/量化介绍.md)。 | 296 | - 支持的量化模式:perchannel[量化模式](../../../docs/zh/context/量化介绍.md)、pergroup[量化模式](../../../docs/zh/context/量化介绍.md)和mx[量化模式](../../../docs/zh/context/量化介绍.md)。 |
| 298 | - 输入和输出支持以下数据类型和shape组合: | 297 | - 输入和输出支持以下数据类型和shape组合: |
| 299 | - <term>Ascend 950PR/Ascend 950DT</term>: | 298 | - <term>Ascend 950PR/Ascend 950DT</term>: |
| 299 | + | ||
| 300 | |[量化模式](../../../docs/zh/context/量化介绍.md)| x | weight | antiquantScale | antiquantOffsetOptional | biasOptional | y | antiquantScale shape | antiquantOffsetOptional shape | | 300 | |[量化模式](../../../docs/zh/context/量化介绍.md)| x | weight | antiquantScale | antiquantOffsetOptional | biasOptional | y | antiquantScale shape | antiquantOffsetOptional shape | |
| 301 | |------------| ---- | ----------------- | ----------- | ------------- | --------------------- | -------- | ------------------------------- | ------------------------------------ | | 301 | |------------| ---- | ----------------- | ----------- | ------------- | --------------------- | -------- | ------------------------------- | ------------------------------------ | |
| 302 | | perchannel | BFLOAT16 | INT32/INT4 | BFLOAT16 | null/BFLOAT16 | null/BFLOAT16/FLOAT32 | BFLOAT16 | (1, n)/(n,) | null/(1, n)/(n,) | | 302 | | perchannel | BFLOAT16 | INT32/INT4 | BFLOAT16 | null/BFLOAT16 | null/BFLOAT16/FLOAT32 | BFLOAT16 | (1, n)/(n,) | null/(1, n)/(n,) | |
| @@ -309,6 +309,7 @@ aclnnStatus aclnnWeightQuantBatchMatmulNz( | |||
| 309 | | pergroup | FLOAT16 | FLOAT/FLOAT4_E2M1 | FLOAT16 | null | null/FLOAT16 | FLOAT16 | (ceil(k/antiquantGroupSize), n) | null | | 309 | | pergroup | FLOAT16 | FLOAT/FLOAT4_E2M1 | FLOAT16 | null | null/FLOAT16 | FLOAT16 | (ceil(k/antiquantGroupSize), n) | null | |
| 310 | | mx | BFLOAT16 | FLOAT/FLOAT4_E2M1 | FLOAT8_E8M0 | null | null/BFLOAT16 | BFLOAT16 | (ceil(k/32), n) | null | | 310 | | mx | BFLOAT16 | FLOAT/FLOAT4_E2M1 | FLOAT8_E8M0 | null | null/BFLOAT16 | BFLOAT16 | (ceil(k/32), n) | null | |
| 311 | | mx | FLOAT16 | FLOAT/FLOAT4_E2M1 | FLOAT8_E8M0 | null | null/FLOAT16 | FLOAT16 | (ceil(k/32), n) | null | | 311 | | mx | FLOAT16 | FLOAT/FLOAT4_E2M1 | FLOAT8_E8M0 | null | null/FLOAT16 | FLOAT16 | (ceil(k/32), n) | null | |
| 312 | + | ||
| 312 | - x的shape均为(m, k),y的shape均为(m, n),biasOptional的shape为null/(1, n)/(n,)。 | 313 | - x的shape均为(m, k),y的shape均为(m, n),biasOptional的shape为null/(1, n)/(n,)。 |
| 313 | - weight的数据类型为INT32或FLOAT时,表示紧密排布的INT4或FLOAT4_E2M1,需要满足以下约束: | 314 | - weight的数据类型为INT32或FLOAT时,表示紧密排布的INT4或FLOAT4_E2M1,需要满足以下约束: |
| 314 | - 原始ND矩阵的最后一维8对齐; | 315 | - 原始ND矩阵的最后一维8对齐; |
| @@ -668,6 +669,7 @@ aclnnStatus aclnnWeightQuantBatchMatmulNz( | |||
| 668 | ``` | 669 | ``` |
| 669 | 670 | ||
| 670 | - x为FLOAT16,weight为INT8调用示例,需要调用 `aclnnTransMatmulWeight` 接口辅助完成调用: | 671 | - x为FLOAT16,weight为INT8调用示例,需要调用 `aclnnTransMatmulWeight` 接口辅助完成调用: |
| 672 | + | ||
| 671 | ```Cpp | 673 | ```Cpp |
| 672 | #include <cmath> | 674 | #include <cmath> |
| 673 | #include <iostream> | 675 | #include <iostream> |
| @@ -924,4 +926,5 @@ aclnnStatus aclnnWeightQuantBatchMatmulNz( | |||
| 924 | Finalize(deviceId, stream); | 926 | Finalize(deviceId, stream); |
| 925 | return 0; | 927 | return 0; |
| 926 | } | 928 | } |
| 927 | - ``` | 929 | + ``` |
| 930 | + | ||
| @@ -460,6 +460,7 @@ aclnnStatus aclnnWeightQuantBatchMatmulV2( | |||
| 460 | - mx[量化模式](../../../docs/zh/context/量化介绍.md):`weight`的数据类型为FLOAT4_E2M1/FLOAT,`weight`非转置,`x`非转置。 | 460 | - mx[量化模式](../../../docs/zh/context/量化介绍.md):`weight`的数据类型为FLOAT4_E2M1/FLOAT,`weight`非转置,`x`非转置。 |
| 461 | 461 | ||
| 462 | <a id="ascend_950pr_ascend950dt_性能优化建议"></a> | 462 | <a id="ascend_950pr_ascend950dt_性能优化建议"></a> |
| 463 | + | ||
| 463 | - **性能优化建议** | 464 | - **性能优化建议** |
| 464 | 465 | ||
| 465 | - pertensor[量化模式](../../../docs/zh/context/量化介绍.md):当[数据格式](../../../docs/zh/context/数据格式.md)为ND时,推荐使用转置后的`weight`输入;当[数据格式](../../../docs/zh/context/数据格式.md)为FRACTAL_NZ时,推荐使用非转置的`weight`输入。 | 466 | - pertensor[量化模式](../../../docs/zh/context/量化介绍.md):当[数据格式](../../../docs/zh/context/数据格式.md)为ND时,推荐使用转置后的`weight`输入;当[数据格式](../../../docs/zh/context/数据格式.md)为FRACTAL_NZ时,推荐使用非转置的`weight`输入。 |
| @@ -467,9 +468,11 @@ aclnnStatus aclnnWeightQuantBatchMatmulV2( | |||
| 467 | - pergroup[量化模式](../../../docs/zh/context/量化介绍.md)和mx[量化模式](../../../docs/zh/context/量化介绍.md):推荐使用非转置的`weight`输入。 | 468 | - pergroup[量化模式](../../../docs/zh/context/量化介绍.md)和mx[量化模式](../../../docs/zh/context/量化介绍.md):推荐使用非转置的`weight`输入。 |
| 468 | 469 | ||
| 469 | </details> | 470 | </details> |
| 471 | + | ||
| 470 | </details> | 472 | </details> |
| 471 | 473 | ||
| 472 | ## 调用示例 | 474 | ## 调用示例 |
| 475 | + | ||
| 473 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 476 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| 474 | 477 | ||
| 475 | - A16W8调用示例: | 478 | - A16W8调用示例: |
| @@ -1043,4 +1046,5 @@ aclnnStatus aclnnWeightQuantBatchMatmulV2( | |||
| 1043 | Finalize(deviceId, stream); | 1046 | Finalize(deviceId, stream); |
| 1044 | return 0; | 1047 | return 0; |
| 1045 | } | 1048 | } |
| 1046 | - ``` | 1049 | + ``` |
| 1050 | + | ||
| @@ -351,7 +351,6 @@ aclnnStatus aclnnWeightQuantBatchMatmulV3( | |||
| 351 | 351 | ||
| 352 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 352 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| 353 | 353 | ||
| 354 | - | ||
| 355 | ## 约束说明 | 354 | ## 约束说明 |
| 356 | 355 | ||
| 357 | <a id="a2_a3_系列产品"></a> | 356 | <a id="a2_a3_系列产品"></a> |
| @@ -372,6 +371,7 @@ aclnnStatus aclnnWeightQuantBatchMatmulV3( | |||
| 372 | - **性能优化建议** | 371 | - **性能优化建议** |
| 373 | - per_channel模式:为提高性能,推荐使用transpose后的weight输入。m范围为[65, 96]时,推荐使用数据类型为UINT64/INT64的antiquantScale。 | 372 | - per_channel模式:为提高性能,推荐使用transpose后的weight输入。m范围为[65, 96]时,推荐使用数据类型为UINT64/INT64的antiquantScale。 |
| 374 | - per_group模式:在A16W4,batchSize<=16的场景下可设置innerPrecise参数为1,并且weight数据格式设为FRACTAL_NZ,来提升性能,但会存在一定的精度下降。 | 373 | - per_group模式:在A16W4,batchSize<=16的场景下可设置innerPrecise参数为1,并且weight数据格式设为FRACTAL_NZ,来提升性能,但会存在一定的精度下降。 |
| 374 | + | ||
| 375 | </details> | 375 | </details> |
| 376 | 376 | ||
| 377 | <a id="ascend_950pr_ascend950dt"></a> | 377 | <a id="ascend_950pr_ascend950dt"></a> |
| @@ -427,6 +427,7 @@ aclnnStatus aclnnWeightQuantBatchMatmulV3( | |||
| 427 | - 若`weight`数据类型为INT32/FLOAT时,必须配合`aclnnConvertWeightToINT4Pack`接口完成从INT32/FLOAT到紧密排布的INT4/FLOAT4_E2M1的转换,[详情可参考样例](../../convert_weight_to_int4_pack/docs/aclnnConvertWeightToINT4Pack.md)。 | 427 | - 若`weight`数据类型为INT32/FLOAT时,必须配合`aclnnConvertWeightToINT4Pack`接口完成从INT32/FLOAT到紧密排布的INT4/FLOAT4_E2M1的转换,[详情可参考样例](../../convert_weight_to_int4_pack/docs/aclnnConvertWeightToINT4Pack.md)。 |
| 428 | 428 | ||
| 429 | <a id="ascend_950pr_ascend950dt_性能优化建议"></a> | 429 | <a id="ascend_950pr_ascend950dt_性能优化建议"></a> |
| 430 | + | ||
| 430 | - **性能优化建议** | 431 | - **性能优化建议** |
| 431 | 432 | ||
| 432 | - pertensor[量化模式](../../../docs/zh/context/量化介绍.md):当[数据格式](../../../docs/zh/context/数据格式.md)为ND时,推荐使用转置后的`weight`输入; | 433 | - pertensor[量化模式](../../../docs/zh/context/量化介绍.md):当[数据格式](../../../docs/zh/context/数据格式.md)为ND时,推荐使用转置后的`weight`输入; |
| @@ -434,6 +435,7 @@ aclnnStatus aclnnWeightQuantBatchMatmulV3( | |||
| 434 | - pergroup[量化模式](../../../docs/zh/context/量化介绍.md)和mx[量化模式](../../../docs/zh/context/量化介绍.md):推荐使用非转置的`weight`输入。 | 435 | - pergroup[量化模式](../../../docs/zh/context/量化介绍.md)和mx[量化模式](../../../docs/zh/context/量化介绍.md):推荐使用非转置的`weight`输入。 |
| 435 | 436 | ||
| 436 | </details> | 437 | </details> |
| 438 | + | ||
| 437 | </details> | 439 | </details> |
| 438 | 440 | ||
| 439 | ## 调用示例 | 441 | ## 调用示例 |
| @@ -666,8 +668,10 @@ A16W8调用示例。 | |||
| 666 | return 0; | 668 | return 0; |
| 667 | } | 669 | } |
| 668 | ``` | 670 | ``` |
| 671 | + | ||
| 669 | - <term>Ascend 950PR/Ascend 950DT</term>: | 672 | - <term>Ascend 950PR/Ascend 950DT</term>: |
| 670 | A16MxFp4调用示例。 | 673 | A16MxFp4调用示例。 |
| 674 | + | ||
| 671 | ```Cpp | 675 | ```Cpp |
| 672 | #include <iostream> | 676 | #include <iostream> |
| 673 | #include <memory> | 677 | #include <memory> |
| @@ -992,4 +996,5 @@ A16MxFp4调用示例。 | |||
| 992 | Finalize(deviceId, stream); | 996 | Finalize(deviceId, stream); |
| 993 | return 0; | 997 | return 0; |
| 994 | } | 998 | } |
| 995 | - ``` | 999 | + ``` |
| 1000 | + | ||
| @@ -142,4 +142,4 @@ $output_2 = input_3 - (\frac{output_1}{\sqrt(output_0) + add_2\_y}) \times input | |||
| 142 | 142 | ||
| 143 | | 调用方式 | 调用样例 | 说明 | | 143 | | 调用方式 | 调用样例 | 说明 | |
| 144 | |--------------|------------------------------------------------------------------------|--------------------------------------------------------------| | 144 | |--------------|------------------------------------------------------------------------|--------------------------------------------------------------| |
| 145 | -| 图模式调用 | [test_geir_adam_apply_one](./examples/test_geir_adam_apply_one.cpp) | 通过[算子IR](./op_graph/adam_apply_one_proto.h)构图方式调用AdamApplyOne算子。 | | 145 | +| 图模式调用 | [test_geir_adam_apply_one](./examples/test_geir_adam_apply_one.cpp) | 通过[算子IR](./op_graph/adam_apply_one_proto.h)构图方式调用AdamApplyOne算子。 | |
| @@ -1,6 +1,6 @@ | |||
| 1 | # AdamApplyOneWithDecay | 1 | # AdamApplyOneWithDecay |
| 2 | 2 | ||
| 3 | -## 产品支持情况 | 3 | +## 产品支持情况 |
| 4 | 4 | ||
| 5 | |产品 | 是否支持 | | 5 | |产品 | 是否支持 | |
| 6 | |:-------------------------|:----------:| | 6 | |:-------------------------|:----------:| |
| @@ -149,4 +149,4 @@ $output_2 = input_3 - ((\frac{output_1}{\sqrt(output_0) + add_2\_y}) + input_3 \ | |||
| 149 | 149 | ||
| 150 | | 调用方式 | 调用样例 | 说明 | | 150 | | 调用方式 | 调用样例 | 说明 | |
| 151 | |--------------|------------------------------------------------------------------------|--------------------------------------------------------------| | 151 | |--------------|------------------------------------------------------------------------|--------------------------------------------------------------| |
| 152 | -| 图模式调用 | [test_geir_adam_apply_one_with_decay](./examples/test_geir_adam_apply_one_with_decay.cpp) | 通过[算子IR](./op_graph/adam_apply_one_with_decay_proto.h)构图方式调用AdamApplyOne算子。 | | 152 | +| 图模式调用 | [test_geir_adam_apply_one_with_decay](./examples/test_geir_adam_apply_one_with_decay.cpp) | 通过[算子IR](./op_graph/adam_apply_one_with_decay_proto.h)构图方式调用AdamApplyOne算子。 | |
| @@ -1,6 +1,6 @@ | |||
| 1 | # AdamApplyOneWithDecayAssign | 1 | # AdamApplyOneWithDecayAssign |
| 2 | 2 | ||
| 3 | -## 产品支持情况 | 3 | +## 产品支持情况 |
| 4 | 4 | ||
| 5 | |产品 | 是否支持 | | 5 | |产品 | 是否支持 | |
| 6 | |:-------------------------|:----------:| | 6 | |:-------------------------|:----------:| |
| @@ -142,4 +142,4 @@ $output_2 = input_3 - (\frac{output_1}{\sqrt(output_0) + add_2\_y}) \times input | |||
| 142 | 142 | ||
| 143 | | 调用方式 | 调用样例 | 说明 | | 143 | | 调用方式 | 调用样例 | 说明 | |
| 144 | |--------------|------------------------------------------------------------------------|--------------------------------------------------------------| | 144 | |--------------|------------------------------------------------------------------------|--------------------------------------------------------------| |
| 145 | -| 图模式调用 | [test_geir_adam_apply_one_with_decay_assign](./examples/test_geir_adam_apply_one_with_decay_assign.cpp) | 通过[算子IR](./op_graph/adam_apply_one_with_decay_assign_proto.h)构图方式调用AdamApplyOne算子。 | | 145 | +| 图模式调用 | [test_geir_adam_apply_one_with_decay_assign](./examples/test_geir_adam_apply_one_with_decay_assign.cpp) | 通过[算子IR](./op_graph/adam_apply_one_with_decay_assign_proto.h)构图方式调用AdamApplyOne算子。 | |
| @@ -136,4 +136,4 @@ | |||
| 136 | |--------------|------------------------------------------------------------------------|----------------------------------------------------------------| | 136 | |--------------|------------------------------------------------------------------------|----------------------------------------------------------------| |
| 137 | | aclnn调用 | [test_aclnn_advance_step](./examples/test_aclnn_advance_step.cpp) | 通过[aclnnAdvanceStep](./docs/aclnnAdvanceStep.md)接口方式调用AdvanceStep算子。 | | 137 | | aclnn调用 | [test_aclnn_advance_step](./examples/test_aclnn_advance_step.cpp) | 通过[aclnnAdvanceStep](./docs/aclnnAdvanceStep.md)接口方式调用AdvanceStep算子。 | |
| 138 | | aclnn调用 | [test_aclnn_advance_step_v2](./examples/test_aclnn_advance_step_v2.cpp) | 通过[aclnnAdvanceStepV2](./docs/aclnnAdvanceStepV2.md)接口方式调用AdvanceStep算子。 | | 138 | | aclnn调用 | [test_aclnn_advance_step_v2](./examples/test_aclnn_advance_step_v2.cpp) | 通过[aclnnAdvanceStepV2](./docs/aclnnAdvanceStepV2.md)接口方式调用AdvanceStep算子。 | |
| 139 | -| 图模式调用 | - | 通过[算子IR](./op_graph/advance_step_proto.h)构图方式调用AdvanceStep算子。 | | 139 | +| 图模式调用 | - | 通过[算子IR](./op_graph/advance_step_proto.h)构图方式调用AdvanceStep算子。 | |
| @@ -85,8 +85,6 @@ | |||
| 85 | </tr> | 85 | </tr> |
| 86 | </tbody></table> | 86 | </tbody></table> |
| 87 | 87 | ||
| 88 | - | ||
| 89 | - | ||
| 90 | ## 调用说明 | 88 | ## 调用说明 |
| 91 | 89 | ||
| 92 | | 调用方式 | 样例代码 | 说明 | | 90 | | 调用方式 | 样例代码 | 说明 | |
| @@ -23,22 +23,18 @@ | |||
| 23 | m_{t}=\beta_{1} m_{t-1}+\left(1-\beta_{1}\right) g_{t} \\ | 23 | m_{t}=\beta_{1} m_{t-1}+\left(1-\beta_{1}\right) g_{t} \\ |
| 24 | $$ | 24 | $$ |
| 25 | 25 | ||
| 26 | - | ||
| 27 | $$ | 26 | $$ |
| 28 | v_{t}=\beta_{2} v_{t-1}+\left(1-\beta_{2}\right) g_{t}^{2} | 27 | v_{t}=\beta_{2} v_{t-1}+\left(1-\beta_{2}\right) g_{t}^{2} |
| 29 | $$ | 28 | $$ |
| 30 | 29 | ||
| 31 | - | ||
| 32 | $$ | 30 | $$ |
| 33 | \hat{m}_{t}=\frac{m_{t}}{1-\beta_{1}^{t}} \\ | 31 | \hat{m}_{t}=\frac{m_{t}}{1-\beta_{1}^{t}} \\ |
| 34 | $$ | 32 | $$ |
| 35 | 33 | ||
| 36 | - | ||
| 37 | $$ | 34 | $$ |
| 38 | \hat{v}_{t}=\frac{v_{t}}{1-\beta_{2}^{t}} \\ | 35 | \hat{v}_{t}=\frac{v_{t}}{1-\beta_{2}^{t}} \\ |
| 39 | $$ | 36 | $$ |
| 40 | 37 | ||
| 41 | - | ||
| 42 | $$ | 38 | $$ |
| 43 | \theta_{t+1}=\theta_{t}-\frac{\eta}{\sqrt{\hat{v}_{t}}+\epsilon} \hat{m}_{t}-\eta \cdot \lambda \cdot \theta_{t-1} | 39 | \theta_{t+1}=\theta_{t}-\frac{\eta}{\sqrt{\hat{v}_{t}}+\epsilon} \hat{m}_{t}-\eta \cdot \lambda \cdot \theta_{t-1} |
| 44 | $$ | 40 | $$ |
| @@ -190,4 +186,4 @@ | |||
| 190 | 186 | ||
| 191 | | 调用方式 | 调用样例 | 说明 | | 187 | | 调用方式 | 调用样例 | 说明 | |
| 192 | |--------------|------------------------------------------------------------------------|----------------------------------------------------------------| | 188 | |--------------|------------------------------------------------------------------------|----------------------------------------------------------------| |
| 193 | -| aclnn调用 | [test_aclnn_apply_adam_w_quant](./examples/test_aclnn_apply_adam_w_quant.cpp) | 通过[aclnnApplyAdamWQuant](./docs/aclnnApplyAdamWQuant.md)接口方式调用ApplyAdamWQuant算子。 | | 189 | +| aclnn调用 | [test_aclnn_apply_adam_w_quant](./examples/test_aclnn_apply_adam_w_quant.cpp) | 通过[aclnnApplyAdamWQuant](./docs/aclnnApplyAdamWQuant.md)接口方式调用ApplyAdamWQuant算子。 | |
| @@ -342,7 +342,9 @@ aclnnStatus aclnnApplyAdamWV2( | |||
| 342 | - aclnnApplyAdamWV2默认确定性实现。 | 342 | - aclnnApplyAdamWV2默认确定性实现。 |
| 343 | 343 | ||
| 344 | ## 调用示例 | 344 | ## 调用示例 |
| 345 | + | ||
| 345 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 346 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| 347 | + | ||
| 346 | ```Cpp | 348 | ```Cpp |
| 347 | #include <iostream> | 349 | #include <iostream> |
| 348 | #include <vector> | 350 | #include <vector> |
| @@ -23,7 +23,6 @@ | |||
| 23 | \end{cases} | 23 | \end{cases} |
| 24 | $$ | 24 | $$ |
| 25 | 25 | ||
| 26 | - | ||
| 27 | $$ | 26 | $$ |
| 28 | grad=\begin{cases} | 27 | grad=\begin{cases} |
| 29 | grad+weightDecay*var,&mode=0\\ | 28 | grad+weightDecay*var,&mode=0\\ |
| @@ -31,32 +30,26 @@ | |||
| 31 | \end{cases} | 30 | \end{cases} |
| 32 | $$ | 31 | $$ |
| 33 | 32 | ||
| 34 | - | ||
| 35 | $$ | 33 | $$ |
| 36 | m_{out}=\beta_1*m+(1-\beta_1)*grad | 34 | m_{out}=\beta_1*m+(1-\beta_1)*grad |
| 37 | $$ | 35 | $$ |
| 38 | 36 | ||
| 39 | - | ||
| 40 | $$ | 37 | $$ |
| 41 | v_{out}=\beta_2*v+(1-\beta_2)*grad^2 | 38 | v_{out}=\beta_2*v+(1-\beta_2)*grad^2 |
| 42 | $$ | 39 | $$ |
| 43 | 40 | ||
| 44 | - | ||
| 45 | $$ | 41 | $$ |
| 46 | m_{next}=m_{out}/correction_{\beta_1} | 42 | m_{next}=m_{out}/correction_{\beta_1} |
| 47 | $$ | 43 | $$ |
| 48 | 44 | ||
| 49 | - | ||
| 50 | $$ | 45 | $$ |
| 51 | v_{next}=v_{out}/correction_{\beta_2} | 46 | v_{next}=v_{out}/correction_{\beta_2} |
| 52 | $$ | 47 | $$ |
| 53 | 48 | ||
| 54 | - | ||
| 55 | $$ | 49 | $$ |
| 56 | denom=\sqrt{v_{next}}+eps | 50 | denom=\sqrt{v_{next}}+eps |
| 57 | $$ | 51 | $$ |
| 58 | 52 | ||
| 59 | - | ||
| 60 | $$ | 53 | $$ |
| 61 | update=\begin{cases} | 54 | update=\begin{cases} |
| 62 | m_{next}/denom,&mode=0\\ | 55 | m_{next}/denom,&mode=0\\ |
| @@ -64,17 +57,14 @@ | |||
| 64 | \end{cases} | 57 | \end{cases} |
| 65 | $$ | 58 | $$ |
| 66 | 59 | ||
| 67 | - | ||
| 68 | $$ | 60 | $$ |
| 69 | var_{out}=var-lr*update | 61 | var_{out}=var-lr*update |
| 70 | $$ | 62 | $$ |
| 71 | 63 | ||
| 72 | - | ||
| 73 | $$ | 64 | $$ |
| 74 | s_{out}=emaDecay*s+(1-emaDecay)*var_{out} | 65 | s_{out}=emaDecay*s+(1-emaDecay)*var_{out} |
| 75 | $$ | 66 | $$ |
| 76 | 67 | ||
| 77 | - | ||
| 78 | ## 参数说明 | 68 | ## 参数说明 |
| 79 | 69 | ||
| 80 | <table style="undefined;table-layout: fixed; width: 1080px"><colgroup> | 70 | <table style="undefined;table-layout: fixed; width: 1080px"><colgroup> |
| @@ -201,4 +191,4 @@ | |||
| 201 | 191 | ||
| 202 | | 调用方式 | 样例代码 | 说明 | | 192 | | 调用方式 | 样例代码 | 说明 | |
| 203 | | --------- | ------------------------------------------------------------ | ------------------------------------------------------------ | | 193 | | --------- | ------------------------------------------------------------ | ------------------------------------------------------------ | |
| 204 | -| aclnn接口 | [test_aclnn_apply_fused_ema_adam](./examples/test_aclnn_apply_fused_ema_adam.cpp) | 通过[aclnnApplyFusedEmaAdam](docs/aclnnApplyFusedEmaAdam.md)接口方式调用ApplyFusedEmaAdam算子。 | | 194 | +| aclnn接口 | [test_aclnn_apply_fused_ema_adam](./examples/test_aclnn_apply_fused_ema_adam.cpp) | 通过[aclnnApplyFusedEmaAdam](docs/aclnnApplyFusedEmaAdam.md)接口方式调用ApplyFusedEmaAdam算子。 | |
| @@ -79,4 +79,4 @@ | |||
| 79 | 79 | ||
| 80 | | 调用方式 | 调用样例 | 说明 | | 80 | | 调用方式 | 调用样例 | 说明 | |
| 81 | |--------------|------------------------------------------------------------------------|--------------------------------------------------------------| | 81 | |--------------|------------------------------------------------------------------------|--------------------------------------------------------------| |
| 82 | -| 图模式调用 | [test_geir_apply_gradient_descent](./examples/test_geir_apply_gradient_descent.cpp) | 通过[算子IR](./op_graph/apply_gradient_descent_proto.h)构图方式调用ApplyGradientDescent算子。 | | 82 | +| 图模式调用 | [test_geir_apply_gradient_descent](./examples/test_geir_apply_gradient_descent.cpp) | 通过[算子IR](./op_graph/apply_gradient_descent_proto.h)构图方式调用ApplyGradientDescent算子。 | |
| @@ -1,6 +1,6 @@ | |||
| 1 | # AdaptiveAvgPool3d | 1 | # AdaptiveAvgPool3d |
| 2 | 2 | ||
| 3 | -## 产品支持情况 | 3 | +## 产品支持情况 |
| 4 | 4 | ||
| 5 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| 6 | | ---- | :----:| | 6 | | ---- | :----:| |
| @@ -17,7 +17,6 @@ | |||
| 17 | 17 | ||
| 18 | - 算子功能:在指定三维输出shape信息的情况下,完成输入张量的3D自适应平均池化计算。 | 18 | - 算子功能:在指定三维输出shape信息的情况下,完成输入张量的3D自适应平均池化计算。 |
| 19 | 19 | ||
| 20 | - | ||
| 21 | ## 参数说明 | 20 | ## 参数说明 |
| 22 | 21 | ||
| 23 | <table style="undefined;table-layout: fixed; width: 1100px"><colgroup> | 22 | <table style="undefined;table-layout: fixed; width: 1100px"><colgroup> |
| @@ -61,11 +60,11 @@ | |||
| 61 | 60 | ||
| 62 | - Atlas 推理系列产品:不支持BFLOAT16。 | 61 | - Atlas 推理系列产品:不支持BFLOAT16。 |
| 63 | - Kirin X90/Kirin 9030 处理器系列产品: 不支持BFLOAT16。 | 62 | - Kirin X90/Kirin 9030 处理器系列产品: 不支持BFLOAT16。 |
| 63 | + | ||
| 64 | ## 约束说明 | 64 | ## 约束说明 |
| 65 | 65 | ||
| 66 | 无。 | 66 | 无。 |
| 67 | 67 | ||
| 68 | - | ||
| 69 | ## 调用说明 | 68 | ## 调用说明 |
| 70 | 69 | ||
| 71 | | 调用方式 | 样例代码 | 说明 | | 70 | | 调用方式 | 样例代码 | 说明 | |
| @@ -29,6 +29,7 @@ aclnnStatus aclnnAdaptiveAvgPool2dGetWorkspaceSize( | |||
| 29 | uint64_t *workspaceSize, | 29 | uint64_t *workspaceSize, |
| 30 | aclOpExecutor **executor) | 30 | aclOpExecutor **executor) |
| 31 | ``` | 31 | ``` |
| 32 | + | ||
| 32 | ```Cpp | 33 | ```Cpp |
| 33 | aclnnStatus aclnnAdaptiveAvgPool2d( | 34 | aclnnStatus aclnnAdaptiveAvgPool2d( |
| 34 | void *workspace, | 35 | void *workspace, |
| @@ -36,6 +37,7 @@ aclnnStatus aclnnAdaptiveAvgPool2d( | |||
| 36 | aclOpExecutor *executor, | 37 | aclOpExecutor *executor, |
| 37 | const aclrtStream stream) | 38 | const aclrtStream stream) |
| 38 | ``` | 39 | ``` |
| 40 | + | ||
| 39 | ## aclnnAdaptiveAvgPool2dGetWorkspaceSize | 41 | ## aclnnAdaptiveAvgPool2dGetWorkspaceSize |
| 40 | 42 | ||
| 41 | - **参数说明:** | 43 | - **参数说明:** |
| @@ -164,6 +166,7 @@ aclnnStatus aclnnAdaptiveAvgPool2d( | |||
| 164 | </table> | 166 | </table> |
| 165 | 167 | ||
| 166 | ## aclnnAdaptiveAvgPool2d | 168 | ## aclnnAdaptiveAvgPool2d |
| 169 | + | ||
| 167 | - **参数说明:** | 170 | - **参数说明:** |
| 168 | <table style="undefined;table-layout: fixed; width: 1166px"><colgroup> | 171 | <table style="undefined;table-layout: fixed; width: 1166px"><colgroup> |
| 169 | <col style="width: 173px"> | 172 | <col style="width: 173px"> |
| @@ -199,11 +202,13 @@ aclnnStatus aclnnAdaptiveAvgPool2d( | |||
| 199 | </tr> | 202 | </tr> |
| 200 | </tbody> | 203 | </tbody> |
| 201 | </table> | 204 | </table> |
| 202 | -- **返回值:** | 205 | + |
| 206 | +- **返回值:** | ||
| 203 | 207 | ||
| 204 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 208 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| 205 | 209 | ||
| 206 | ## 约束说明 | 210 | ## 约束说明 |
| 211 | + | ||
| 207 | - 确定性计算: | 212 | - 确定性计算: |
| 208 | - aclnnAdaptiveAvgPool2d默认确定性实现。 | 213 | - aclnnAdaptiveAvgPool2d默认确定性实现。 |
| 209 | 214 | ||
| @@ -15,7 +15,6 @@ | |||
| 15 | 15 | ||
| 16 | - 算子功能:AdaptiveAvgPool3d的反向计算。 | 16 | - 算子功能:AdaptiveAvgPool3d的反向计算。 |
| 17 | 17 | ||
| 18 | - | ||
| 19 | ## 参数说明 | 18 | ## 参数说明 |
| 20 | 19 | ||
| 21 | <table style="undefined;table-layout: fixed; width: 1250px"><colgroup> | 20 | <table style="undefined;table-layout: fixed; width: 1250px"><colgroup> |
| @@ -57,7 +56,6 @@ | |||
| 57 | </tr> | 56 | </tr> |
| 58 | </tbody></table> | 57 | </tbody></table> |
| 59 | 58 | ||
| 60 | - | ||
| 61 | ## 约束说明 | 59 | ## 约束说明 |
| 62 | 60 | ||
| 63 | 无 | 61 | 无 |
| @@ -18,7 +18,9 @@ | |||
| 18 | [aclnnAdaptiveAvgPool2d](../../adaptive_avg_pool3d/docs/aclnnAdaptiveAvgPool2d.md) 的反向计算。 | 18 | [aclnnAdaptiveAvgPool2d](../../adaptive_avg_pool3d/docs/aclnnAdaptiveAvgPool2d.md) 的反向计算。 |
| 19 | 19 | ||
| 20 | ## 函数原型 | 20 | ## 函数原型 |
| 21 | + | ||
| 21 | 每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnAdaptiveAvgPool2dBackwardGetWorkspaceSize”接口获取计算所需workspace大小以及包含了算子计算流程的执行器,再调用“aclnnAdaptiveAvgPool2dBackward”接口执行计算。 | 22 | 每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnAdaptiveAvgPool2dBackwardGetWorkspaceSize”接口获取计算所需workspace大小以及包含了算子计算流程的执行器,再调用“aclnnAdaptiveAvgPool2dBackward”接口执行计算。 |
| 23 | + | ||
| 22 | ```Cpp | 24 | ```Cpp |
| 23 | aclnnStatus aclnnAdaptiveAvgPool2dBackwardGetWorkspaceSize( | 25 | aclnnStatus aclnnAdaptiveAvgPool2dBackwardGetWorkspaceSize( |
| 24 | const aclTensor *gradOutput, | 26 | const aclTensor *gradOutput, |
| @@ -27,6 +29,7 @@ aclnnStatus aclnnAdaptiveAvgPool2dBackwardGetWorkspaceSize( | |||
| 27 | uint64_t *workspaceSize, | 29 | uint64_t *workspaceSize, |
| 28 | aclOpExecutor **executor) | 30 | aclOpExecutor **executor) |
| 29 | ``` | 31 | ``` |
| 32 | + | ||
| 30 | ```Cpp | 33 | ```Cpp |
| 31 | aclnnStatus aclnnAdaptiveAvgPool2dBackward( | 34 | aclnnStatus aclnnAdaptiveAvgPool2dBackward( |
| 32 | void *workspace, | 35 | void *workspace, |
| @@ -34,7 +37,9 @@ aclnnStatus aclnnAdaptiveAvgPool2dBackward( | |||
| 34 | aclOpExecutor *executor, | 37 | aclOpExecutor *executor, |
| 35 | const aclrtStream stream) | 38 | const aclrtStream stream) |
| 36 | ``` | 39 | ``` |
| 40 | + | ||
| 37 | ## aclnnAdaptiveAvgPool2dBackwardGetWorkspaceSize | 41 | ## aclnnAdaptiveAvgPool2dBackwardGetWorkspaceSize |
| 42 | + | ||
| 38 | - **参数说明:** | 43 | - **参数说明:** |
| 39 | <table style="undefined;table-layout: fixed; width: 1453px"><colgroup> | 44 | <table style="undefined;table-layout: fixed; width: 1453px"><colgroup> |
| 40 | <col style="width: 154px"> | 45 | <col style="width: 154px"> |
| @@ -110,7 +115,7 @@ aclnnStatus aclnnAdaptiveAvgPool2dBackward( | |||
| 110 | </tr> | 115 | </tr> |
| 111 | </tbody></table> | 116 | </tbody></table> |
| 112 | 117 | ||
| 113 | - - <term>Atlas 推理系列产品</term>、<term>Atlas 训练系列产品</term>:参数`self`、`out`的数据类型不支持BFLOAT16。 | 118 | + - <term>Atlas 推理系列产品</term>、<term>Atlas 训练系列产品</term>:参数`self`、`out`的数据类型不支持BFLOAT16。 |
| 114 | 119 | ||
| 115 | - **返回值:** | 120 | - **返回值:** |
| 116 | 121 | ||
| @@ -158,6 +163,7 @@ aclnnStatus aclnnAdaptiveAvgPool2dBackward( | |||
| 158 | </table> | 163 | </table> |
| 159 | 164 | ||
| 160 | ## aclnnAdaptiveAvgPool2dBackward | 165 | ## aclnnAdaptiveAvgPool2dBackward |
| 166 | + | ||
| 161 | - **参数说明:** | 167 | - **参数说明:** |
| 162 | <table style="undefined;table-layout: fixed; width: 1166px"><colgroup> | 168 | <table style="undefined;table-layout: fixed; width: 1166px"><colgroup> |
| 163 | <col style="width: 173px"> | 169 | <col style="width: 173px"> |
| @@ -193,16 +199,20 @@ aclnnStatus aclnnAdaptiveAvgPool2dBackward( | |||
| 193 | </tr> | 199 | </tr> |
| 194 | </tbody> | 200 | </tbody> |
| 195 | </table> | 201 | </table> |
| 196 | -- **返回值:** | 202 | + |
| 203 | +- **返回值:** | ||
| 197 | 204 | ||
| 198 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 205 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| 199 | 206 | ||
| 200 | ## 约束说明 | 207 | ## 约束说明 |
| 208 | + | ||
| 201 | - 确定性计算: | 209 | - 确定性计算: |
| 202 | - aclnnAdaptiveAvgPool2dBackward默认非确定性实现,支持通过aclrtCtxSetSysParamOpt开启确定性。 | 210 | - aclnnAdaptiveAvgPool2dBackward默认非确定性实现,支持通过aclrtCtxSetSysParamOpt开启确定性。 |
| 203 | 211 | ||
| 204 | ## 调用示例 | 212 | ## 调用示例 |
| 213 | + | ||
| 205 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 214 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| 215 | + | ||
| 206 | ```Cpp | 216 | ```Cpp |
| 207 | #include <iostream> | 217 | #include <iostream> |
| 208 | #include <vector> | 218 | #include <vector> |
| @@ -1,7 +1,8 @@ | |||
| 1 | # aclnnAdaptiveAvgPool3dBackward | 1 | # aclnnAdaptiveAvgPool3dBackward |
| 2 | -## 产品支持情况 | ||
| 3 | -[📄 查看源码](https://gitcode.com/cann/ops-nn/tree/master/pooling/adaptive_avg_pool3d_grad) | ||
| 4 | 2 | ||
| 3 | +## 产品支持情况 | ||
| 4 | + | ||
| 5 | +[📄 查看源码](https://gitcode.com/cann/ops-nn/tree/master/pooling/adaptive_avg_pool3d_grad) | ||
| 5 | 6 | ||
| 6 | | 产品 | 是否支持 | | 7 | | 产品 | 是否支持 | |
| 7 | | :----------------------------------------------------------- | :------: | | 8 | | :----------------------------------------------------------- | :------: | |
| @@ -17,7 +18,9 @@ | |||
| 17 | [aclnnAdaptiveAvgPool3d](../../adaptive_avg_pool3d/docs/aclnnAdaptiveAvgPool3d.md) 的反向计算。 | 18 | [aclnnAdaptiveAvgPool3d](../../adaptive_avg_pool3d/docs/aclnnAdaptiveAvgPool3d.md) 的反向计算。 |
| 18 | 19 | ||
| 19 | ## 函数原型 | 20 | ## 函数原型 |
| 21 | + | ||
| 20 | 每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnAdaptiveAvgPool3dBackwardGetWorkspaceSize”接口获取计算所需workspace大小以及包含了算子计算流程的执行器,再调用“aclnnAdaptiveAvgPool3dBackward”接口执行计算。 | 22 | 每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnAdaptiveAvgPool3dBackwardGetWorkspaceSize”接口获取计算所需workspace大小以及包含了算子计算流程的执行器,再调用“aclnnAdaptiveAvgPool3dBackward”接口执行计算。 |
| 23 | + | ||
| 21 | ```Cpp | 24 | ```Cpp |
| 22 | aclnnStatus aclnnAdaptiveAvgPool3dBackwardGetWorkspaceSize( | 25 | aclnnStatus aclnnAdaptiveAvgPool3dBackwardGetWorkspaceSize( |
| 23 | const aclTensor *gradOutput, | 26 | const aclTensor *gradOutput, |
| @@ -26,6 +29,7 @@ aclnnStatus aclnnAdaptiveAvgPool3dBackwardGetWorkspaceSize( | |||
| 26 | uint64_t *workspaceSize, | 29 | uint64_t *workspaceSize, |
| 27 | aclOpExecutor **executor) | 30 | aclOpExecutor **executor) |
| 28 | ``` | 31 | ``` |
| 32 | + | ||
| 29 | ```Cpp | 33 | ```Cpp |
| 30 | aclnnStatus aclnnAdaptiveAvgPool3dBackward( | 34 | aclnnStatus aclnnAdaptiveAvgPool3dBackward( |
| 31 | void *workspace, | 35 | void *workspace, |
| @@ -33,6 +37,7 @@ aclnnStatus aclnnAdaptiveAvgPool3dBackward( | |||
| 33 | aclOpExecutor *executor, | 37 | aclOpExecutor *executor, |
| 34 | aclrtStream stream) | 38 | aclrtStream stream) |
| 35 | ``` | 39 | ``` |
| 40 | + | ||
| 36 | ## aclnnAdaptiveAvgPool3dBackwardGetWorkspaceSize | 41 | ## aclnnAdaptiveAvgPool3dBackwardGetWorkspaceSize |
| 37 | 42 | ||
| 38 | - **参数说明:** | 43 | - **参数说明:** |
| @@ -200,6 +205,7 @@ aclnnStatus aclnnAdaptiveAvgPool3dBackward( | |||
| 200 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 205 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| 201 | 206 | ||
| 202 | ## 约束说明 | 207 | ## 约束说明 |
| 208 | + | ||
| 203 | - 确定性计算: | 209 | - 确定性计算: |
| 204 | - aclnnAdaptiveAvgPool3dBackward默认非确定性实现,支持通过aclrtCtxSetSysParamOpt开启确定性。 | 210 | - aclnnAdaptiveAvgPool3dBackward默认非确定性实现,支持通过aclrtCtxSetSysParamOpt开启确定性。 |
| 205 | 211 | ||
| @@ -348,4 +354,3 @@ int main() { | |||
| 348 | return 0; | 354 | return 0; |
| 349 | } | 355 | } |
| 350 | ``` | 356 | ``` |
| 351 | - | ||
| @@ -1,6 +1,6 @@ | |||
| 1 | # AdaptiveMaxPool2d | 1 | # AdaptiveMaxPool2d |
| 2 | 2 | ||
| 3 | -## 产品支持情况 | 3 | +## 产品支持情况 |
| 4 | 4 | ||
| 5 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| 6 | | ---- | :----:| | 6 | | ---- | :----:| |
| @@ -18,6 +18,7 @@ | |||
| 18 | 根据输入的outputSize计算每次kernel的大小,对输入self进行2维最大池化操作,输出池化后的值out和索引indices。aclnnAdaptiveMaxPool2d与aclnnMaxPool2d的区别在于,只需指定outputSize大小,并按outputSize的大小来划分pooling区域。 | 18 | 根据输入的outputSize计算每次kernel的大小,对输入self进行2维最大池化操作,输出池化后的值out和索引indices。aclnnAdaptiveMaxPool2d与aclnnMaxPool2d的区别在于,只需指定outputSize大小,并按outputSize的大小来划分pooling区域。 |
| 19 | 19 | ||
| 20 | ## 函数原型 | 20 | ## 函数原型 |
| 21 | + | ||
| 21 | 每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnAdaptiveMaxPool2dGetWorkspaceSize”接口获取计算所需workspace大小以及包含了算子计算流程的执行器,再调用“aclnnAdaptiveMaxPool2d”接口执行计算。 | 22 | 每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnAdaptiveMaxPool2dGetWorkspaceSize”接口获取计算所需workspace大小以及包含了算子计算流程的执行器,再调用“aclnnAdaptiveMaxPool2d”接口执行计算。 |
| 22 | 23 | ||
| 23 | ```Cpp | 24 | ```Cpp |
| @@ -29,6 +30,7 @@ aclnnStatus aclnnAdaptiveMaxPool2dGetWorkspaceSize( | |||
| 29 | uint64_t *workspaceSize, | 30 | uint64_t *workspaceSize, |
| 30 | aclOpExecutor **executor) | 31 | aclOpExecutor **executor) |
| 31 | ``` | 32 | ``` |
| 33 | + | ||
| 32 | ```Cpp | 34 | ```Cpp |
| 33 | aclnnStatus aclnnAdaptiveMaxPool2d( | 35 | aclnnStatus aclnnAdaptiveMaxPool2d( |
| 34 | void *workspace, | 36 | void *workspace, |
| @@ -225,11 +227,13 @@ aclnnStatus aclnnAdaptiveMaxPool2d( | |||
| 225 | </tr> | 227 | </tr> |
| 226 | </tbody> | 228 | </tbody> |
| 227 | </table> | 229 | </table> |
| 228 | -- **返回值:** | 230 | + |
| 231 | +- **返回值:** | ||
| 229 | 232 | ||
| 230 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 233 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| 231 | 234 | ||
| 232 | ## 约束说明 | 235 | ## 约束说明 |
| 236 | + | ||
| 233 | - 确定性计算: | 237 | - 确定性计算: |
| 234 | - aclnnAdaptiveMaxPool2d默认确定性实现。 | 238 | - aclnnAdaptiveMaxPool2d默认确定性实现。 |
| 235 | 239 | ||
| @@ -240,7 +244,9 @@ aclnnStatus aclnnAdaptiveMaxPool2d( | |||
| 240 | - indicesOut.shape = (N, C, Hout, Wout) 或者 (C, Hout, Wout) 或 (N, Hout, Wout, C) | 244 | - indicesOut.shape = (N, C, Hout, Wout) 或者 (C, Hout, Wout) 或 (N, Hout, Wout, C) |
| 241 | 245 | ||
| 242 | ## 调用示例 | 246 | ## 调用示例 |
| 247 | + | ||
| 243 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 248 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| 249 | + | ||
| 244 | ```Cpp | 250 | ```Cpp |
| 245 | #include <cstdio> | 251 | #include <cstdio> |
| 246 | #include <iostream> | 252 | #include <iostream> |
| @@ -394,4 +400,4 @@ int main() { | |||
| 394 | aclFinalize(); | 400 | aclFinalize(); |
| 395 | return 0; | 401 | return 0; |
| 396 | } | 402 | } |
| 397 | -``` | 403 | +``` |
| @@ -1,6 +1,6 @@ | |||
| 1 | # AdaptiveMaxPool3d | 1 | # AdaptiveMaxPool3d |
| 2 | 2 | ||
| 3 | -## 产品支持情况 | 3 | +## 产品支持情况 |
| 4 | 4 | ||
| 5 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| 6 | | ---- | :----:| | 6 | | ---- | :----:| |
| @@ -101,14 +101,15 @@ | |||
| 101 | </tbody></table> | 101 | </tbody></table> |
| 102 | 102 | ||
| 103 | - Kirin X90/Kirin 9030 处理器系列产品: 不支持BFLOAT16。 | 103 | - Kirin X90/Kirin 9030 处理器系列产品: 不支持BFLOAT16。 |
| 104 | + | ||
| 104 | ## 约束说明 | 105 | ## 约束说明 |
| 106 | + | ||
| 105 | Shape描述: | 107 | Shape描述: |
| 106 | - self.shape = (N, C, Din, Hin, Win) | 108 | - self.shape = (N, C, Din, Hin, Win) |
| 107 | - outputSize = [Dout, Hout, Wout] | 109 | - outputSize = [Dout, Hout, Wout] |
| 108 | - outputOut.shape = (N, C, Dout, Hout, Wout) | 110 | - outputOut.shape = (N, C, Dout, Hout, Wout) |
| 109 | - indicesOut.shape = (N, C, Dout, Hout, Wout) | 111 | - indicesOut.shape = (N, C, Dout, Hout, Wout) |
| 110 | 112 | ||
| 111 | - | ||
| 112 | ## 调用说明 | 113 | ## 调用说明 |
| 113 | 114 | ||
| 114 | | 调用方式 | 样例代码 | 说明 | | 115 | | 调用方式 | 样例代码 | 说明 | |
| @@ -1,7 +1,8 @@ | |||
| 1 | # aclnnAdaptiveMaxPool3d | 1 | # aclnnAdaptiveMaxPool3d |
| 2 | -## 产品支持情况 | ||
| 3 | -[📄 查看源码](https://gitcode.com/cann/ops-nn/tree/master/pooling/adaptive_max_pool3d) | ||
| 4 | 2 | ||
| 3 | +## 产品支持情况 | ||
| 4 | + | ||
| 5 | +[📄 查看源码](https://gitcode.com/cann/ops-nn/tree/master/pooling/adaptive_max_pool3d) | ||
| 5 | 6 | ||
| 6 | | 产品 | 是否支持 | | 7 | | 产品 | 是否支持 | |
| 7 | | :----------------------------------------------------------- | :------: | | 8 | | :----------------------------------------------------------- | :------: | |
| @@ -52,8 +53,8 @@ | |||
| 52 | indices(N,C,l,m,n)=\underset {i \in [D^{l}_{left}, D^{l}_{right}],j\in [H^m_{left},H^m_{right}], k \in [W^n_{left},W^n_{right}] }{argmax} input(N,C,i,j,k) | 53 | indices(N,C,l,m,n)=\underset {i \in [D^{l}_{left}, D^{l}_{right}],j\in [H^m_{left},H^m_{right}], k \in [W^n_{left},W^n_{right}] }{argmax} input(N,C,i,j,k) |
| 53 | $$ | 54 | $$ |
| 54 | 55 | ||
| 55 | - | ||
| 56 | ## 函数原型 | 56 | ## 函数原型 |
| 57 | + | ||
| 57 | 每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnAdaptiveMaxPool3dGetWorkspaceSize”接口获取计算所需workspace大小以及包含了算子计算流程的执行器,再调用“aclnnAdaptiveMaxPool3d”接口执行计算。 | 58 | 每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnAdaptiveMaxPool3dGetWorkspaceSize”接口获取计算所需workspace大小以及包含了算子计算流程的执行器,再调用“aclnnAdaptiveMaxPool3d”接口执行计算。 |
| 58 | 59 | ||
| 59 | ```Cpp | 60 | ```Cpp |
| @@ -65,6 +66,7 @@ aclnnStatus aclnnAdaptiveMaxPool3dGetWorkspaceSize( | |||
| 65 | uint64_t *workspaceSize, | 66 | uint64_t *workspaceSize, |
| 66 | aclOpExecutor **executor) | 67 | aclOpExecutor **executor) |
| 67 | ``` | 68 | ``` |
| 69 | + | ||
| 68 | ```Cpp | 70 | ```Cpp |
| 69 | aclnnStatus aclnnAdaptiveMaxPool3d( | 71 | aclnnStatus aclnnAdaptiveMaxPool3d( |
| 70 | void *workspace, | 72 | void *workspace, |
| @@ -161,7 +163,7 @@ aclnnStatus aclnnAdaptiveMaxPool3d( | |||
| 161 | </tr> | 163 | </tr> |
| 162 | </tbody></table> | 164 | </tbody></table> |
| 163 | 165 | ||
| 164 | - - <term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>、<term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>: 参数`indicesOut`的数据类型不支持INT64, | 166 | + - <term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>、<term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>:参数`indicesOut`的数据类型不支持INT64, |
| 165 | 167 | ||
| 166 | - **返回值:** | 168 | - **返回值:** |
| 167 | 169 | ||
| @@ -252,6 +254,7 @@ aclnnStatus aclnnAdaptiveMaxPool3d( | |||
| 252 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 254 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| 253 | 255 | ||
| 254 | ## 约束说明 | 256 | ## 约束说明 |
| 257 | + | ||
| 255 | - 确定性计算: | 258 | - 确定性计算: |
| 256 | - aclnnAdaptiveMaxPool3d默认确定性实现。 | 259 | - aclnnAdaptiveMaxPool3d默认确定性实现。 |
| 257 | 260 | ||
| @@ -419,4 +422,3 @@ int main() { | |||
| 419 | return 0; | 422 | return 0; |
| 420 | } | 423 | } |
| 421 | ``` | 424 | ``` |
| 422 | - | ||
| @@ -1,6 +1,6 @@ | |||
| 1 | # AdaptiveMaxPool3DGrad | 1 | # AdaptiveMaxPool3DGrad |
| 2 | 2 | ||
| 3 | -## 产品支持情况 | 3 | +## 产品支持情况 |
| 4 | 4 | ||
| 5 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| 6 | | ---- | :----:| | 6 | | ---- | :----:| |
| @@ -15,7 +15,6 @@ | |||
| 15 | 15 | ||
| 16 | - 算子功能:正向自适应最大池化的反向传播,将梯度回填到每个自适应窗口最大值的坐标处,相同坐标处累加。 | 16 | - 算子功能:正向自适应最大池化的反向传播,将梯度回填到每个自适应窗口最大值的坐标处,相同坐标处累加。 |
| 17 | 17 | ||
| 18 | - | ||
| 19 | ## 参数说明 | 18 | ## 参数说明 |
| 20 | 19 | ||
| 21 | <table style="undefined;table-layout: fixed; width: 1250px"><colgroup> | 20 | <table style="undefined;table-layout: fixed; width: 1250px"><colgroup> |
| @@ -64,7 +63,6 @@ | |||
| 64 | </tr> | 63 | </tr> |
| 65 | </tbody></table> | 64 | </tbody></table> |
| 66 | 65 | ||
| 67 | - | ||
| 68 | ## 约束说明 | 66 | ## 约束说明 |
| 69 | 67 | ||
| 70 | 无 | 68 | 无 |
| @@ -41,6 +41,7 @@ aclnnStatus aclnnAdaptiveMaxPool2dBackwardGetWorkspaceSize( | |||
| 41 | uint64_t *workspaceSize, | 41 | uint64_t *workspaceSize, |
| 42 | aclOpExecutor **executor) | 42 | aclOpExecutor **executor) |
| 43 | ``` | 43 | ``` |
| 44 | + | ||
| 44 | ```Cpp | 45 | ```Cpp |
| 45 | aclnnStatus aclnnAdaptiveMaxPool2dBackward( | 46 | aclnnStatus aclnnAdaptiveMaxPool2dBackward( |
| 46 | void *workspace, | 47 | void *workspace, |
| @@ -177,6 +178,7 @@ aclnnStatus aclnnAdaptiveMaxPool2dBackward( | |||
| 177 | </tr> | 178 | </tr> |
| 178 | </tbody> | 179 | </tbody> |
| 179 | </table> | 180 | </table> |
| 181 | + | ||
| 180 | ## aclnnAdaptiveMaxPool2dBackward | 182 | ## aclnnAdaptiveMaxPool2dBackward |
| 181 | 183 | ||
| 182 | - **参数说明:** | 184 | - **参数说明:** |
| @@ -214,16 +216,18 @@ aclnnStatus aclnnAdaptiveMaxPool2dBackward( | |||
| 214 | </tr> | 216 | </tr> |
| 215 | </tbody> | 217 | </tbody> |
| 216 | </table> | 218 | </table> |
| 217 | -- **返回值:** | 219 | +- **返回值:** |
| 218 | 220 | ||
| 219 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 221 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| 220 | 222 | ||
| 221 | ## 约束说明 | 223 | ## 约束说明 |
| 224 | + | ||
| 222 | - 确定性计算: | 225 | - 确定性计算: |
| 223 | - aclnnAdaptiveMaxPool2dBackward默认非确定性实现,支持通过aclrtCtxSetSysParamOpt开启确定性。 | 226 | - aclnnAdaptiveMaxPool2dBackward默认非确定性实现,支持通过aclrtCtxSetSysParamOpt开启确定性。 |
| 224 | 227 | ||
| 225 | - 非整除场景下(self的后两个维度的维度值对gradOutput后两个维度的维度值取余不为0),shape不超过2的24次方。整除场景下,没有这个限制。 | 228 | - 非整除场景下(self的后两个维度的维度值对gradOutput后两个维度的维度值取余不为0),shape不超过2的24次方。整除场景下,没有这个限制。 |
| 226 | - 举例整除场景:self=[a,b,c,d],gradOutput=[a,b,e,f]。 c%e为0并且d%f为0就是整除场景。 | 229 | - 举例整除场景:self=[a,b,c,d],gradOutput=[a,b,e,f]。 c%e为0并且d%f为0就是整除场景。 |
| 230 | + | ||
| 227 | ## 调用示例 | 231 | ## 调用示例 |
| 228 | 232 | ||
| 229 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 233 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| @@ -381,4 +385,4 @@ int main() { | |||
| 381 | aclFinalize(); | 385 | aclFinalize(); |
| 382 | return 0; | 386 | return 0; |
| 383 | } | 387 | } |
| 384 | -``` | 388 | +``` |
| @@ -66,6 +66,7 @@ aclnnStatus aclnnAdaptiveMaxPool3dBackwardGetWorkspaceSize( | |||
| 66 | uint64_t *workspaceSize, | 66 | uint64_t *workspaceSize, |
| 67 | aclOpExecutor **executor) | 67 | aclOpExecutor **executor) |
| 68 | ``` | 68 | ``` |
| 69 | + | ||
| 69 | ```Cpp | 70 | ```Cpp |
| 70 | aclnnStatus aclnnAdaptiveMaxPool3dBackward( | 71 | aclnnStatus aclnnAdaptiveMaxPool3dBackward( |
| 71 | void *workspace, | 72 | void *workspace, |
| @@ -73,6 +74,7 @@ aclnnStatus aclnnAdaptiveMaxPool3dBackward( | |||
| 73 | aclOpExecutor *executor, | 74 | aclOpExecutor *executor, |
| 74 | aclrtStream stream) | 75 | aclrtStream stream) |
| 75 | ``` | 76 | ``` |
| 77 | + | ||
| 76 | ## aclnnAdaptiveMaxPool3dBackwardGetWorkspaceSize | 78 | ## aclnnAdaptiveMaxPool3dBackwardGetWorkspaceSize |
| 77 | 79 | ||
| 78 | - **参数说明:** | 80 | - **参数说明:** |
| @@ -239,11 +241,13 @@ aclnnStatus aclnnAdaptiveMaxPool3dBackward( | |||
| 239 | </tr> | 241 | </tr> |
| 240 | </tbody> | 242 | </tbody> |
| 241 | </table> | 243 | </table> |
| 242 | -- **返回值:** | 244 | + |
| 245 | +- **返回值:** | ||
| 243 | 246 | ||
| 244 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 247 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| 245 | 248 | ||
| 246 | ## 约束说明 | 249 | ## 约束说明 |
| 250 | + | ||
| 247 | - 确定性计算: | 251 | - 确定性计算: |
| 248 | - aclnnAdaptiveMaxPool3dBackward默认非确定性实现,支持通过aclrtCtxSetSysParamOpt开启确定性。 | 252 | - aclnnAdaptiveMaxPool3dBackward默认非确定性实现,支持通过aclrtCtxSetSysParamOpt开启确定性。 |
| 249 | 253 | ||
| @@ -405,4 +409,4 @@ int main() { | |||
| 405 | aclFinalize(); | 409 | aclFinalize(); |
| 406 | return 0; | 410 | return 0; |
| 407 | } | 411 | } |
| 408 | -``` | 412 | +``` |
| @@ -1,6 +1,6 @@ | |||
| 1 | # AvgPool3D | 1 | # AvgPool3D |
| 2 | 2 | ||
| 3 | -## 产品支持情况 | 3 | +## 产品支持情况 |
| 4 | 4 | ||
| 5 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| 6 | | ---- | :----:| | 6 | | ---- | :----:| |
| @@ -12,6 +12,7 @@ | |||
| 12 | |Atlas 训练系列产品|×| | 12 | |Atlas 训练系列产品|×| |
| 13 | |Kirin X90 处理器系列产品|√| | 13 | |Kirin X90 处理器系列产品|√| |
| 14 | |Kirin 9030 处理器系列产品|√| | 14 | |Kirin 9030 处理器系列产品|√| |
| 15 | + | ||
| 15 | ## 功能说明 | 16 | ## 功能说明 |
| 16 | 17 | ||
| 17 | - 算子功能:对输入Tensor进行窗口为$kD * kH * kW$、步长为$sD * sH * sW$的三维平均池化操作,其中$k$为kernelSize,表示池化窗口的大小,$s$为stride,表示池化操作的步长。 | 18 | - 算子功能:对输入Tensor进行窗口为$kD * kH * kW$、步长为$sD * sH * sW$的三维平均池化操作,其中$k$为kernelSize,表示池化窗口的大小,$s$为stride,表示池化操作的步长。 |
| @@ -119,11 +120,11 @@ $$ | |||
| 119 | </tbody></table> | 120 | </tbody></table> |
| 120 | 121 | ||
| 121 | - Kirin X90/Kirin 9030 处理器系列产品: 不支持BFLOAT16。 | 122 | - Kirin X90/Kirin 9030 处理器系列产品: 不支持BFLOAT16。 |
| 123 | + | ||
| 122 | ## 约束说明 | 124 | ## 约束说明 |
| 123 | 125 | ||
| 124 | 无。 | 126 | 无。 |
| 125 | 127 | ||
| 126 | - | ||
| 127 | ## 调用说明 | 128 | ## 调用说明 |
| 128 | 129 | ||
| 129 | | 调用方式 | 样例代码 | 说明 | | 130 | | 调用方式 | 样例代码 | 说明 | |
| @@ -47,6 +47,7 @@ aclnnStatus aclnnAvgPool2dGetWorkspaceSize( | |||
| 47 | uint64_t *workspaceSize, | 47 | uint64_t *workspaceSize, |
| 48 | aclOpExecutor **executor) | 48 | aclOpExecutor **executor) |
| 49 | ``` | 49 | ``` |
| 50 | + | ||
| 50 | ```Cpp | 51 | ```Cpp |
| 51 | aclnnStatus aclnnAvgPool2d( | 52 | aclnnStatus aclnnAvgPool2d( |
| 52 | void *workspace, | 53 | void *workspace, |
| @@ -54,6 +55,7 @@ aclnnStatus aclnnAvgPool2d( | |||
| 54 | aclOpExecutor *executor, | 55 | aclOpExecutor *executor, |
| 55 | aclrtStream stream) | 56 | aclrtStream stream) |
| 56 | ``` | 57 | ``` |
| 58 | + | ||
| 57 | ## aclnnAvgPool2dGetWorkspaceSize | 59 | ## aclnnAvgPool2dGetWorkspaceSize |
| 58 | 60 | ||
| 59 | - **参数说明**: | 61 | - **参数说明**: |
| @@ -248,6 +250,7 @@ aclnnStatus aclnnAvgPool2d( | |||
| 248 | </tr> | 250 | </tr> |
| 249 | </tbody> | 251 | </tbody> |
| 250 | </table> | 252 | </table> |
| 253 | + | ||
| 251 | ## aclnnAvgPool2d | 254 | ## aclnnAvgPool2d |
| 252 | 255 | ||
| 253 | - **参数说明:** | 256 | - **参数说明:** |
| @@ -285,18 +288,22 @@ aclnnStatus aclnnAvgPool2d( | |||
| 285 | </tr> | 288 | </tr> |
| 286 | </tbody> | 289 | </tbody> |
| 287 | </table> | 290 | </table> |
| 288 | -- **返回值:** | 291 | + |
| 292 | +- **返回值:** | ||
| 289 | 293 | ||
| 290 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 294 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| 291 | 295 | ||
| 292 | ## 约束说明 | 296 | ## 约束说明 |
| 297 | + | ||
| 293 | - 确定性计算: | 298 | - 确定性计算: |
| 294 | - aclnnAvgPool2d默认确定性实现。 | 299 | - aclnnAvgPool2d默认确定性实现。 |
| 295 | 300 | ||
| 296 | - <term>Atlas 训练系列产品</term>:Cube单元不支持FLOAT32计算。当输入为FLOAT32,可通过设置cubeMathType=1(ALLOW_FP32_DOWN_PRECISION)来允许接口内部cast到FLOAT16进行计算。 | 301 | - <term>Atlas 训练系列产品</term>:Cube单元不支持FLOAT32计算。当输入为FLOAT32,可通过设置cubeMathType=1(ALLOW_FP32_DOWN_PRECISION)来允许接口内部cast到FLOAT16进行计算。 |
| 297 | 302 | ||
| 298 | ## 调用示例 | 303 | ## 调用示例 |
| 304 | + | ||
| 299 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 305 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| 306 | + | ||
| 300 | ```Cpp | 307 | ```Cpp |
| 301 | #include <cstdio> | 308 | #include <cstdio> |
| 302 | #include <iostream> | 309 | #include <iostream> |
| @@ -50,6 +50,7 @@ aclnnStatus aclnnAvgPool3dGetWorkspaceSize( | |||
| 50 | uint64_t *workspaceSize, | 50 | uint64_t *workspaceSize, |
| 51 | aclOpExecutor **executor) | 51 | aclOpExecutor **executor) |
| 52 | ``` | 52 | ``` |
| 53 | + | ||
| 53 | ```Cpp | 54 | ```Cpp |
| 54 | aclnnStatus aclnnAvgPool3d( | 55 | aclnnStatus aclnnAvgPool3d( |
| 55 | void *workspace, | 56 | void *workspace, |
| @@ -231,6 +232,7 @@ aclnnStatus aclnnAvgPool3d( | |||
| 231 | </tr> | 232 | </tr> |
| 232 | </tbody> | 233 | </tbody> |
| 233 | </table> | 234 | </table> |
| 235 | + | ||
| 234 | ## aclnnAvgPool3d | 236 | ## aclnnAvgPool3d |
| 235 | 237 | ||
| 236 | - **参数说明:** | 238 | - **参数说明:** |
| @@ -268,16 +270,20 @@ aclnnStatus aclnnAvgPool3d( | |||
| 268 | </tr> | 270 | </tr> |
| 269 | </tbody> | 271 | </tbody> |
| 270 | </table> | 272 | </table> |
| 271 | -- **返回值:** | 273 | + |
| 274 | +- **返回值:** | ||
| 272 | 275 | ||
| 273 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 276 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| 274 | 277 | ||
| 275 | ## 约束说明 | 278 | ## 约束说明 |
| 279 | + | ||
| 276 | - 确定性计算: | 280 | - 确定性计算: |
| 277 | - aclnnAvgPool3d默认确定性实现。 | 281 | - aclnnAvgPool3d默认确定性实现。 |
| 278 | 282 | ||
| 279 | ## 调用示例 | 283 | ## 调用示例 |
| 284 | + | ||
| 280 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 285 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| 286 | + | ||
| 281 | ```Cpp | 287 | ```Cpp |
| 282 | #include <cstdio> | 288 | #include <cstdio> |
| 283 | #include <iostream> | 289 | #include <iostream> |
| @@ -122,7 +122,6 @@ $$ | |||
| 122 | 122 | ||
| 123 | 无。 | 123 | 无。 |
| 124 | 124 | ||
| 125 | - | ||
| 126 | ## 调用说明 | 125 | ## 调用说明 |
| 127 | 126 | ||
| 128 | | 调用方式 | 样例代码 | 说明 | | 127 | | 调用方式 | 样例代码 | 说明 | |
| @@ -52,6 +52,7 @@ aclnnStatus aclnnAvgPool2dBackwardGetWorkspaceSize( | |||
| 52 | uint64_t *workspaceSize, | 52 | uint64_t *workspaceSize, |
| 53 | aclOpExecutor **executor) | 53 | aclOpExecutor **executor) |
| 54 | ``` | 54 | ``` |
| 55 | + | ||
| 55 | ```Cpp | 56 | ```Cpp |
| 56 | aclnnStatus aclnnAvgPool2dBackward( | 57 | aclnnStatus aclnnAvgPool2dBackward( |
| 57 | void *workspace, | 58 | void *workspace, |
| @@ -59,6 +60,7 @@ aclnnStatus aclnnAvgPool2dBackward( | |||
| 59 | aclOpExecutor *executor, | 60 | aclOpExecutor *executor, |
| 60 | aclrtStream stream) | 61 | aclrtStream stream) |
| 61 | ``` | 62 | ``` |
| 63 | + | ||
| 62 | ## aclnnAvgPool2dBackwardGetWorkspaceSize | 64 | ## aclnnAvgPool2dBackwardGetWorkspaceSize |
| 63 | 65 | ||
| 64 | - **参数说明**: | 66 | - **参数说明**: |
| @@ -268,6 +270,7 @@ aclnnStatus aclnnAvgPool2dBackward( | |||
| 268 | </tr> | 270 | </tr> |
| 269 | </tbody> | 271 | </tbody> |
| 270 | </table> | 272 | </table> |
| 273 | + | ||
| 271 | ## aclnnAvgPool2dBackward | 274 | ## aclnnAvgPool2dBackward |
| 272 | 275 | ||
| 273 | - **参数说明:** | 276 | - **参数说明:** |
| @@ -305,18 +308,22 @@ aclnnStatus aclnnAvgPool2dBackward( | |||
| 305 | </tr> | 308 | </tr> |
| 306 | </tbody> | 309 | </tbody> |
| 307 | </table> | 310 | </table> |
| 308 | -- **返回值:** | 311 | + |
| 312 | +- **返回值:** | ||
| 309 | 313 | ||
| 310 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 314 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| 311 | 315 | ||
| 312 | ## 约束说明 | 316 | ## 约束说明 |
| 317 | + | ||
| 313 | - 确定性计算: | 318 | - 确定性计算: |
| 314 | - aclnnAvgPool2dBackward默认非确定性实现,支持通过aclrtCtxSetSysParamOpt开启确定性。 | 319 | - aclnnAvgPool2dBackward默认非确定性实现,支持通过aclrtCtxSetSysParamOpt开启确定性。 |
| 315 | 320 | ||
| 316 | - <term>Atlas 训练系列产品</term>、<term>Atlas 推理系列产品</term>:Cube单元不支持FLOAT32计算。当输入为FLOAT32,可通过设置cubeMathType=1(ALLOW_FP32_DOWN_PRECISION)来允许接口内部cast到FLOAT16进行计算。 | 321 | - <term>Atlas 训练系列产品</term>、<term>Atlas 推理系列产品</term>:Cube单元不支持FLOAT32计算。当输入为FLOAT32,可通过设置cubeMathType=1(ALLOW_FP32_DOWN_PRECISION)来允许接口内部cast到FLOAT16进行计算。 |
| 317 | 322 | ||
| 318 | ## 调用示例 | 323 | ## 调用示例 |
| 324 | + | ||
| 319 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 325 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| 326 | + | ||
| 320 | ```Cpp | 327 | ```Cpp |
| 321 | #include <cstdio> | 328 | #include <cstdio> |
| 322 | #include <iostream> | 329 | #include <iostream> |
| @@ -492,4 +499,4 @@ int main() { | |||
| 492 | 499 | ||
| 493 | return 0; | 500 | return 0; |
| 494 | } | 501 | } |
| 495 | -``` | 502 | +``` |
| @@ -58,6 +58,7 @@ aclnnStatus aclnnAvgPool3dBackwardGetWorkspaceSize( | |||
| 58 | uint64_t *workspaceSize, | 58 | uint64_t *workspaceSize, |
| 59 | aclOpExecutor **executor) | 59 | aclOpExecutor **executor) |
| 60 | ``` | 60 | ``` |
| 61 | + | ||
| 61 | ```Cpp | 62 | ```Cpp |
| 62 | aclnnStatus aclnnAvgPool3dBackward( | 63 | aclnnStatus aclnnAvgPool3dBackward( |
| 63 | void *workspace, | 64 | void *workspace, |
| @@ -65,6 +66,7 @@ aclnnStatus aclnnAvgPool3dBackward( | |||
| 65 | aclOpExecutor *executor, | 66 | aclOpExecutor *executor, |
| 66 | const aclrtStream stream) | 67 | const aclrtStream stream) |
| 67 | ``` | 68 | ``` |
| 69 | + | ||
| 68 | ## aclnnAvgPool3dBackwardGetWorkspaceSize | 70 | ## aclnnAvgPool3dBackwardGetWorkspaceSize |
| 69 | 71 | ||
| 70 | - **参数说明**: | 72 | - **参数说明**: |
| @@ -246,6 +248,7 @@ aclnnStatus aclnnAvgPool3dBackward( | |||
| 246 | </tr> | 248 | </tr> |
| 247 | </tbody> | 249 | </tbody> |
| 248 | </table> | 250 | </table> |
| 251 | + | ||
| 249 | ## aclnnAvgPool3dBackward | 252 | ## aclnnAvgPool3dBackward |
| 250 | 253 | ||
| 251 | - **参数说明:** | 254 | - **参数说明:** |
| @@ -283,16 +286,19 @@ aclnnStatus aclnnAvgPool3dBackward( | |||
| 283 | </tr> | 286 | </tr> |
| 284 | </tbody> | 287 | </tbody> |
| 285 | </table> | 288 | </table> |
| 286 | -- **返回值:** | 289 | +- **返回值:** |
| 287 | 290 | ||
| 288 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 291 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| 289 | 292 | ||
| 290 | ## 约束说明 | 293 | ## 约束说明 |
| 294 | + | ||
| 291 | - 确定性计算: | 295 | - 确定性计算: |
| 292 | - aclnnAvgPool3dBackward默认非确定性实现,支持通过aclrtCtxSetSysParamOpt开启确定性。 | 296 | - aclnnAvgPool3dBackward默认非确定性实现,支持通过aclrtCtxSetSysParamOpt开启确定性。 |
| 293 | 297 | ||
| 294 | ## 调用示例 | 298 | ## 调用示例 |
| 299 | + | ||
| 295 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 300 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| 301 | + | ||
| 296 | ```Cpp | 302 | ```Cpp |
| 297 | #include <cstdio> | 303 | #include <cstdio> |
| 298 | #include <iostream> | 304 | #include <iostream> |
| @@ -466,4 +472,4 @@ int main() { | |||
| 466 | 472 | ||
| 467 | return 0; | 473 | return 0; |
| 468 | } | 474 | } |
| 469 | -``` | 475 | +``` |
| @@ -106,6 +106,7 @@ | |||
| 106 | </tbody></table> | 106 | </tbody></table> |
| 107 | 107 | ||
| 108 | ## 约束说明 | 108 | ## 约束说明 |
| 109 | + | ||
| 109 | - **值域限制说明:** | 110 | - **值域限制说明:** |
| 110 | - ksize:数组长度必须为5,且N和C维度对应的值必须为1。 | 111 | - ksize:数组长度必须为5,且N和C维度对应的值必须为1。 |
| 111 | - strides:数组长度必须为5,且N和C维度对应的值必须为1。 | 112 | - strides:数组长度必须为5,且N和C维度对应的值必须为1。 |
| @@ -114,9 +115,8 @@ | |||
| 114 | - dilations:数组长度必须为5,且N和C维度对应的值必须为1。 | 115 | - dilations:数组长度必须为5,且N和C维度对应的值必须为1。 |
| 115 | - ceilMode:取值为0时,代表False,向下取整;非0值时,代表True,向上取整,该参数仅在padding模式为“CALCULATED”时生效。 | 116 | - ceilMode:取值为0时,代表False,向下取整;非0值时,代表True,向上取整,该参数仅在padding模式为“CALCULATED”时生效。 |
| 116 | 117 | ||
| 117 | - | ||
| 118 | ## 调用说明 | 118 | ## 调用说明 |
| 119 | 119 | ||
| 120 | | 调用方式 | 样例代码 | 说明 | | 120 | | 调用方式 | 样例代码 | 说明 | |
| 121 | | ---------------- | --------------------------- | --------------------------------------------------- | | 121 | | ---------------- | --------------------------- | --------------------------------------------------- | |
| 122 | -| 图模式接口 | [test_max_pool_3d](examples/test_max_pool_3d.cpp) | 通过IR[MaxPool3D](./op_graph/max_pool3_d_proto.h)构图方式调用MaxPool3D算子。 | | 122 | +| 图模式接口 | [test_max_pool_3d](examples/test_max_pool_3d.cpp) | 通过IR[MaxPool3D](./op_graph/max_pool3_d_proto.h)构图方式调用MaxPool3D算子。 | |
| @@ -1,6 +1,6 @@ | |||
| 1 | # MaxPool3DGradWithArgmax | 1 | # MaxPool3DGradWithArgmax |
| 2 | 2 | ||
| 3 | -## 产品支持情况 | 3 | +## 产品支持情况 |
| 4 | 4 | ||
| 5 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| 6 | | ---- | :----:| | 6 | | ---- | :----:| |
| @@ -99,12 +99,11 @@ | |||
| 99 | </tbody></table> | 99 | </tbody></table> |
| 100 | 100 | ||
| 101 | ## 约束说明 | 101 | ## 约束说明 |
| 102 | -无。 | ||
| 103 | 102 | ||
| 103 | +无。 | ||
| 104 | 104 | ||
| 105 | ## 调用说明 | 105 | ## 调用说明 |
| 106 | 106 | ||
| 107 | | 调用方式 | 样例代码 | 说明 | | 107 | | 调用方式 | 样例代码 | 说明 | |
| 108 | | ---------------- | --------------------------- | --------------------------------------------------- | | 108 | | ---------------- | --------------------------- | --------------------------------------------------- | |
| 109 | | aclnn接口 | [test_aclnn_max_pool3d_with_argmax_backward.cpp](examples/test_aclnn_max_pool3d_with_argmax_backward.cpp) | 通过[aclnnMaxPool3dWithArgmaxBackward](docs/aclnnMaxPool3dWithArgmaxBackward.md)接口方式调用MaxPool3DGradWithArgmax算子。 | | 109 | | aclnn接口 | [test_aclnn_max_pool3d_with_argmax_backward.cpp](examples/test_aclnn_max_pool3d_with_argmax_backward.cpp) | 通过[aclnnMaxPool3dWithArgmaxBackward](docs/aclnnMaxPool3dWithArgmaxBackward.md)接口方式调用MaxPool3DGradWithArgmax算子。 | |
| 110 | - | ||
| @@ -16,7 +16,9 @@ | |||
| 16 | ## 功能说明 | 16 | ## 功能说明 |
| 17 | 17 | ||
| 18 | 正向最大池化[aclnnMaxPool2dWithIndices](../../max_pool3d_with_argmax_v2/docs/aclnnMaxPool2dWithIndices.md)的反向传播。 | 18 | 正向最大池化[aclnnMaxPool2dWithIndices](../../max_pool3d_with_argmax_v2/docs/aclnnMaxPool2dWithIndices.md)的反向传播。 |
| 19 | + | ||
| 19 | - 输入tensor的推导公式: | 20 | - 输入tensor的推导公式: |
| 21 | + | ||
| 20 | - 当ceilMode=False时,indices tensor的shape中H和W维度推导公式: | 22 | - 当ceilMode=False时,indices tensor的shape中H和W维度推导公式: |
| 21 | $$ | 23 | $$ |
| 22 | [H_{out}, W_{out}]=[\lfloor{\frac{H_{in}+ padding\_size_{Htop} + padding\_size_{Hbottom} - {dilation\_size \times(k_h - 1) - 1}}{s_h}}\rfloor + 1,\lfloor{\frac{W_{in}+ padding\_size_{Wleft} + padding\_size_{Wright} - {dilation\_size \times(k_w - 1) - 1}}{s_w}}\rfloor + 1] | 24 | [H_{out}, W_{out}]=[\lfloor{\frac{H_{in}+ padding\_size_{Htop} + padding\_size_{Hbottom} - {dilation\_size \times(k_h - 1) - 1}}{s_h}}\rfloor + 1,\lfloor{\frac{W_{in}+ padding\_size_{Wleft} + padding\_size_{Wright} - {dilation\_size \times(k_w - 1) - 1}}{s_w}}\rfloor + 1] |
| @@ -34,7 +36,9 @@ | |||
| 34 | W_{out}=W_{out} - 1& \text{if } (W_{out}-1)*s_w>=W_{in}+padding\_size_{Wleft} \\ | 36 | W_{out}=W_{out} - 1& \text{if } (W_{out}-1)*s_w>=W_{in}+padding\_size_{Wleft} \\ |
| 35 | \end{cases}\\ | 37 | \end{cases}\\ |
| 36 | $$ | 38 | $$ |
| 39 | + | ||
| 37 | ## 函数原型 | 40 | ## 函数原型 |
| 41 | + | ||
| 38 | 每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnMaxPool2dWithIndicesBackwardGetWorkspaceSize”接口获取计算所需workspace大小以及包含了算子计算流程的执行器,再调用“aclnnMaxPool2dWithIndicesBackward”接口执行计算。 | 42 | 每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnMaxPool2dWithIndicesBackwardGetWorkspaceSize”接口获取计算所需workspace大小以及包含了算子计算流程的执行器,再调用“aclnnMaxPool2dWithIndicesBackward”接口执行计算。 |
| 39 | 43 | ||
| 40 | ```Cpp | 44 | ```Cpp |
| @@ -51,6 +55,7 @@ aclnnStatus aclnnMaxPool2dWithIndicesBackwardGetWorkspaceSize( | |||
| 51 | uint64_t *workspaceSize, | 55 | uint64_t *workspaceSize, |
| 52 | aclOpExecutor **executor) | 56 | aclOpExecutor **executor) |
| 53 | ``` | 57 | ``` |
| 58 | + | ||
| 54 | ```Cpp | 59 | ```Cpp |
| 55 | aclnnStatus aclnnMaxPool2dWithIndicesBackward( | 60 | aclnnStatus aclnnMaxPool2dWithIndicesBackward( |
| 56 | void *workspace, | 61 | void *workspace, |
| @@ -256,6 +261,7 @@ aclnnStatus aclnnMaxPool2dWithIndicesBackward( | |||
| 256 | </tr> | 261 | </tr> |
| 257 | </tbody> | 262 | </tbody> |
| 258 | </table> | 263 | </table> |
| 264 | + | ||
| 259 | ## aclnnMaxPool2dWithIndicesBackward | 265 | ## aclnnMaxPool2dWithIndicesBackward |
| 260 | 266 | ||
| 261 | - **参数说明:** | 267 | - **参数说明:** |
| @@ -298,13 +304,16 @@ aclnnStatus aclnnMaxPool2dWithIndicesBackward( | |||
| 298 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 304 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| 299 | 305 | ||
| 300 | ## 约束说明 | 306 | ## 约束说明 |
| 307 | + | ||
| 301 | - 确定性计算: | 308 | - 确定性计算: |
| 302 | - aclnnMaxPool2dWithIndicesBackward默认非确定性实现,支持通过aclrtCtxSetSysParamOpt开启确定性。 | 309 | - aclnnMaxPool2dWithIndicesBackward默认非确定性实现,支持通过aclrtCtxSetSysParamOpt开启确定性。 |
| 303 | 310 | ||
| 304 | - 输入数据暂不支持NaN、-Inf。indices值不能超过公式中的$H\_in*W\_in$,且需要大于等于0。 | 311 | - 输入数据暂不支持NaN、-Inf。indices值不能超过公式中的$H\_in*W\_in$,且需要大于等于0。 |
| 305 | 312 | ||
| 306 | ## 调用示例 | 313 | ## 调用示例 |
| 314 | + | ||
| 307 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 315 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| 316 | + | ||
| 308 | ```Cpp | 317 | ```Cpp |
| 309 | #include <cstdio> | 318 | #include <cstdio> |
| 310 | #include <iostream> | 319 | #include <iostream> |
| @@ -14,9 +14,11 @@ | |||
| 14 | | <term>Atlas 训练系列产品</term> | √ | | 14 | | <term>Atlas 训练系列产品</term> | √ | |
| 15 | 15 | ||
| 16 | ## 功能说明 | 16 | ## 功能说明 |
| 17 | + | ||
| 17 | 正向最大池化[aclnnMaxPool2dWithMask](../../max_pool3d_with_argmax_v2/docs/aclnnMaxPool2dWithMask.md)的反向传播。 | 18 | 正向最大池化[aclnnMaxPool2dWithMask](../../max_pool3d_with_argmax_v2/docs/aclnnMaxPool2dWithMask.md)的反向传播。 |
| 18 | 19 | ||
| 19 | ## 函数原型 | 20 | ## 函数原型 |
| 21 | + | ||
| 20 | 每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnMaxPool2dWithMaskBackwardGetWorkspaceSize”接口获取计算所需workspace大小以及包含了算子计算流程的执行器,再调用“aclnnMaxPool2dWithMaskBackward”接口执行计算。 | 22 | 每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnMaxPool2dWithMaskBackwardGetWorkspaceSize”接口获取计算所需workspace大小以及包含了算子计算流程的执行器,再调用“aclnnMaxPool2dWithMaskBackward”接口执行计算。 |
| 21 | 23 | ||
| 22 | ```Cpp | 24 | ```Cpp |
| @@ -33,6 +35,7 @@ aclnnStatus aclnnMaxPool2dWithMaskBackwardGetWorkspaceSize( | |||
| 33 | uint64_t *workspaceSize, | 35 | uint64_t *workspaceSize, |
| 34 | aclOpExecutor **executor) | 36 | aclOpExecutor **executor) |
| 35 | ``` | 37 | ``` |
| 38 | + | ||
| 36 | ```Cpp | 39 | ```Cpp |
| 37 | aclnnStatus aclnnMaxPool2dWithMaskBackward( | 40 | aclnnStatus aclnnMaxPool2dWithMaskBackward( |
| 38 | void *workspace, | 41 | void *workspace, |
| @@ -40,6 +43,7 @@ aclnnStatus aclnnMaxPool2dWithMaskBackward( | |||
| 40 | aclOpExecutor *executor, | 43 | aclOpExecutor *executor, |
| 41 | aclrtStream stream) | 44 | aclrtStream stream) |
| 42 | ``` | 45 | ``` |
| 46 | + | ||
| 43 | ## aclnnMaxPool2dWithMaskBackwardGetWorkspaceSize | 47 | ## aclnnMaxPool2dWithMaskBackwardGetWorkspaceSize |
| 44 | 48 | ||
| 45 | - **参数说明:** | 49 | - **参数说明:** |
| @@ -232,6 +236,7 @@ aclnnStatus aclnnMaxPool2dWithMaskBackward( | |||
| 232 | </tr> | 236 | </tr> |
| 233 | </tbody> | 237 | </tbody> |
| 234 | </table> | 238 | </table> |
| 239 | + | ||
| 235 | ## aclnnMaxPool2dWithMaskBackward | 240 | ## aclnnMaxPool2dWithMaskBackward |
| 236 | 241 | ||
| 237 | - **参数说明:** | 242 | - **参数说明:** |
| @@ -269,11 +274,13 @@ aclnnStatus aclnnMaxPool2dWithMaskBackward( | |||
| 269 | </tr> | 274 | </tr> |
| 270 | </tbody> | 275 | </tbody> |
| 271 | </table> | 276 | </table> |
| 272 | -- **返回值:** | 277 | + |
| 278 | +- **返回值:** | ||
| 273 | 279 | ||
| 274 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 280 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| 275 | 281 | ||
| 276 | ## 约束说明 | 282 | ## 约束说明 |
| 283 | + | ||
| 277 | - 确定性计算: | 284 | - 确定性计算: |
| 278 | - aclnnMaxPool2dWithMaskBackward默认非确定性实现,支持通过aclrtCtxSetSysParamOpt开启确定性。 | 285 | - aclnnMaxPool2dWithMaskBackward默认非确定性实现,支持通过aclrtCtxSetSysParamOpt开启确定性。 |
| 279 | 286 | ||
| @@ -282,7 +289,9 @@ aclnnStatus aclnnMaxPool2dWithMaskBackward( | |||
| 282 | - <term>Atlas 训练系列产品</term>:当输入数据是FLOAT类型时,会转换为FLOAT16类型进行计算,存在一定程度的精度损失。 | 289 | - <term>Atlas 训练系列产品</term>:当输入数据是FLOAT类型时,会转换为FLOAT16类型进行计算,存在一定程度的精度损失。 |
| 283 | 290 | ||
| 284 | ## 调用示例 | 291 | ## 调用示例 |
| 292 | + | ||
| 285 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 293 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| 294 | + | ||
| 286 | ```Cpp | 295 | ```Cpp |
| 287 | #include <cstdio> | 296 | #include <cstdio> |
| 288 | #include <iostream> | 297 | #include <iostream> |
| @@ -14,9 +14,11 @@ | |||
| 14 | | <term>Atlas 训练系列产品</term> | × | | 14 | | <term>Atlas 训练系列产品</term> | × | |
| 15 | 15 | ||
| 16 | ## 功能说明 | 16 | ## 功能说明 |
| 17 | + | ||
| 17 | 正向最大池化[aclnnMaxPool3dWithArgmax](../../max_pool3d_with_argmax_v2/docs/aclnnMaxPool3dWithArgmax.md)的反向传播,将梯度回填到每个窗口最大值的坐标处,相同坐标处累加。 | 18 | 正向最大池化[aclnnMaxPool3dWithArgmax](../../max_pool3d_with_argmax_v2/docs/aclnnMaxPool3dWithArgmax.md)的反向传播,将梯度回填到每个窗口最大值的坐标处,相同坐标处累加。 |
| 18 | 19 | ||
| 19 | ## 函数原型 | 20 | ## 函数原型 |
| 21 | + | ||
| 20 | 每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnMaxPool3dWithArgmaxBackwardGetWorkspaceSize”接口获取计算所需workspace大小以及包含了算子计算流程的执行器,再调用“aclnnMaxPool3dWithArgmaxBackward”接口执行计算。 | 22 | 每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnMaxPool3dWithArgmaxBackwardGetWorkspaceSize”接口获取计算所需workspace大小以及包含了算子计算流程的执行器,再调用“aclnnMaxPool3dWithArgmaxBackward”接口执行计算。 |
| 21 | 23 | ||
| 22 | ```Cpp | 24 | ```Cpp |
| @@ -41,6 +43,7 @@ aclnnStatus aclnnMaxPool3dWithArgmaxBackward( | |||
| 41 | aclOpExecutor *executor, | 43 | aclOpExecutor *executor, |
| 42 | aclrtStream stream) | 44 | aclrtStream stream) |
| 43 | ``` | 45 | ``` |
| 46 | + | ||
| 44 | ## aclnnMaxPool3dWithArgmaxBackwardGetWorkspaceSize | 47 | ## aclnnMaxPool3dWithArgmaxBackwardGetWorkspaceSize |
| 45 | 48 | ||
| 46 | - **参数说明:** | 49 | - **参数说明:** |
| @@ -277,11 +280,13 @@ aclnnStatus aclnnMaxPool3dWithArgmaxBackward( | |||
| 277 | </tr> | 280 | </tr> |
| 278 | </tbody> | 281 | </tbody> |
| 279 | </table> | 282 | </table> |
| 280 | -- **返回值:** | 283 | + |
| 284 | +- **返回值:** | ||
| 281 | 285 | ||
| 282 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 286 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| 283 | 287 | ||
| 284 | ## 约束说明 | 288 | ## 约束说明 |
| 289 | + | ||
| 285 | - 确定性计算: | 290 | - 确定性计算: |
| 286 | - aclnnMaxPool3dWithArgmaxBackward默认非确定性实现,支持通过aclrtCtxSetSysParamOpt开启确定性。 | 291 | - aclnnMaxPool3dWithArgmaxBackward默认非确定性实现,支持通过aclrtCtxSetSysParamOpt开启确定性。 |
| 287 | 292 | ||
| @@ -294,7 +299,9 @@ aclnnStatus aclnnMaxPool3dWithArgmaxBackward( | |||
| 294 | - 当输入是NaN时,输出为NaN。 | 299 | - 当输入是NaN时,输出为NaN。 |
| 295 | 300 | ||
| 296 | ## 调用示例 | 301 | ## 调用示例 |
| 302 | + | ||
| 297 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 303 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| 304 | + | ||
| 298 | ```Cpp | 305 | ```Cpp |
| 299 | #include <cstdio> | 306 | #include <cstdio> |
| 300 | #include <iostream> | 307 | #include <iostream> |
| @@ -118,7 +118,8 @@ | |||
| 118 | </tbody></table> | 118 | </tbody></table> |
| 119 | 119 | ||
| 120 | - <term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>、<term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>:`argmax` 数据类型不支持INT64。输入数据排布不支持NDHWC。 | 120 | - <term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>、<term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>:`argmax` 数据类型不支持INT64。输入数据排布不支持NDHWC。 |
| 121 | -- Kirin X90/Kirin 9030 处理器系列产品: 输入/输出不支持BFLOAT16;`argmax` 数据类型不支持INT64。 | 121 | + - Kirin X90/Kirin 9030 处理器系列产品: 输入/输出不支持BFLOAT16;`argmax` 数据类型不支持INT64。 |
| 122 | + | ||
| 122 | ## 约束说明 | 123 | ## 约束说明 |
| 123 | 124 | ||
| 124 | 无。 | 125 | 无。 |
| @@ -107,6 +107,7 @@ | |||
| 107 | </tbody></table> | 107 | </tbody></table> |
| 108 | 108 | ||
| 109 | ## 约束说明 | 109 | ## 约束说明 |
| 110 | + | ||
| 110 | - **值域限制说明:** | 111 | - **值域限制说明:** |
| 111 | - kernelShape:对应公式中的k_h和k_w,长度为1或2,且数组元素必须都大于0。 | 112 | - kernelShape:对应公式中的k_h和k_w,长度为1或2,且数组元素必须都大于0。 |
| 112 | - strides:对应公式中的s_h和s_w,数组长度为0、1或2,且数组元素必须都大于0。当数组长度为0时,strides取默认值为1。 | 113 | - strides:对应公式中的s_h和s_w,数组长度为0、1或2,且数组元素必须都大于0。当数组长度为0时,strides取默认值为1。 |
| @@ -115,9 +116,8 @@ | |||
| 115 | - dilations:只支持数值为1的输入场景。长度为0、1、2或4。 | 116 | - dilations:只支持数值为1的输入场景。长度为0、1、2或4。 |
| 116 | - ceilMode:取值为0时,代表False,向下取整;非0值时,代表True,向上取整。 | 117 | - ceilMode:取值为0时,代表False,向下取整;非0值时,代表True,向上取整。 |
| 117 | 118 | ||
| 118 | - | ||
| 119 | ## 调用说明 | 119 | ## 调用说明 |
| 120 | 120 | ||
| 121 | | 调用方式 | 样例代码 | 说明 | | 121 | | 调用方式 | 样例代码 | 说明 | |
| 122 | | ---------------- | --------------------------- | --------------------------------------------------- | | 122 | | ---------------- | --------------------------- | --------------------------------------------------- | |
| 123 | -| aclnn接口 | [test_aclnn_max_pool](examples/test_aclnn_max_pool.cpp) | 通过[aclnnMaxPool](docs/aclnnMaxPool.md)接口方式调用MaxPoolV3算子。 | | 123 | +| aclnn接口 | [test_aclnn_max_pool](examples/test_aclnn_max_pool.cpp) | 通过[aclnnMaxPool](docs/aclnnMaxPool.md)接口方式调用MaxPoolV3算子。 | |
| @@ -40,6 +40,7 @@ | |||
| 40 | $$ | 40 | $$ |
| 41 | 41 | ||
| 42 | ## 函数原型 | 42 | ## 函数原型 |
| 43 | + | ||
| 43 | 每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnMaxPoolGetWorkspaceSize”接口获取计算所需workspace大小以及包含了算子计算流程的执行器,再调用“aclnnMaxPool”接口执行计算。 | 44 | 每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnMaxPoolGetWorkspaceSize”接口获取计算所需workspace大小以及包含了算子计算流程的执行器,再调用“aclnnMaxPool”接口执行计算。 |
| 44 | 45 | ||
| 45 | ```Cpp | 46 | ```Cpp |
| @@ -55,6 +56,7 @@ aclnnStatus aclnnMaxPoolGetWorkspaceSize( | |||
| 55 | uint64_t *workspaceSize, | 56 | uint64_t *workspaceSize, |
| 56 | aclOpExecutor **executor) | 57 | aclOpExecutor **executor) |
| 57 | ``` | 58 | ``` |
| 59 | + | ||
| 58 | ```Cpp | 60 | ```Cpp |
| 59 | aclnnStatus aclnnMaxPool( | 61 | aclnnStatus aclnnMaxPool( |
| 60 | void *workspace, | 62 | void *workspace, |
| @@ -62,6 +64,7 @@ aclnnStatus aclnnMaxPool( | |||
| 62 | aclOpExecutor *executor, | 64 | aclOpExecutor *executor, |
| 63 | aclrtStream stream) | 65 | aclrtStream stream) |
| 64 | ``` | 66 | ``` |
| 67 | + | ||
| 65 | ## aclnnMaxPoolGetWorkspaceSize | 68 | ## aclnnMaxPoolGetWorkspaceSize |
| 66 | 69 | ||
| 67 | - **参数说明:** | 70 | - **参数说明:** |
| @@ -188,9 +191,10 @@ aclnnStatus aclnnMaxPool( | |||
| 188 | <td>-</td> | 191 | <td>-</td> |
| 189 | </tr> | 192 | </tr> |
| 190 | </tbody></table> | 193 | </tbody></table> |
| 191 | - - <term>Atlas 训练系列产品</term>:参数self、out的数据类型不支持FLOAT、BFLOAT16、INT32、INT64、UINT8、INT16、INT8、UINT16。 | 194 | + - <term>Atlas 训练系列产品</term>:参数self、out的数据类型不支持FLOAT、BFLOAT16、INT32、INT64、UINT8、INT16、INT8、UINT16。 |
| 195 | + | ||
| 196 | + - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>:参数self、out的数据类型不支持BFLOAT16、INT32、INT64、UINT8、INT16、INT8、UINT16。 | ||
| 192 | 197 | ||
| 193 | - - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>:参数self、out的数据类型不支持BFLOAT16、INT32、INT64、UINT8、INT16、INT8、UINT16。 | ||
| 194 | - **返回值:** | 198 | - **返回值:** |
| 195 | 199 | ||
| 196 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 200 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| @@ -249,6 +253,7 @@ aclnnStatus aclnnMaxPool( | |||
| 249 | </table> | 253 | </table> |
| 250 | 254 | ||
| 251 | ## aclnnMaxPool | 255 | ## aclnnMaxPool |
| 256 | + | ||
| 252 | - **参数说明:** | 257 | - **参数说明:** |
| 253 | <table style="undefined;table-layout: fixed; width: 1166px"><colgroup> | 258 | <table style="undefined;table-layout: fixed; width: 1166px"><colgroup> |
| 254 | <col style="width: 173px"> | 259 | <col style="width: 173px"> |
| @@ -284,16 +289,20 @@ aclnnStatus aclnnMaxPool( | |||
| 284 | </tr> | 289 | </tr> |
| 285 | </tbody> | 290 | </tbody> |
| 286 | </table> | 291 | </table> |
| 287 | -- **返回值:** | 292 | + |
| 293 | +- **返回值:** | ||
| 288 | 294 | ||
| 289 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 | 295 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn返回码.md)。 |
| 290 | 296 | ||
| 291 | ## 约束说明 | 297 | ## 约束说明 |
| 298 | + | ||
| 292 | - 确定性计算: | 299 | - 确定性计算: |
| 293 | - aclnnMaxPool默认确定性实现。 | 300 | - aclnnMaxPool默认确定性实现。 |
| 294 | 301 | ||
| 295 | ## 调用示例 | 302 | ## 调用示例 |
| 303 | + | ||
| 296 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 304 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| 305 | + | ||
| 297 | ```Cpp | 306 | ```Cpp |
| 298 | #include <cstdio> | 307 | #include <cstdio> |
| 299 | #include <iostream> | 308 | #include <iostream> |
| @@ -189,4 +189,4 @@ | |||
| 189 | 189 | ||
| 190 | | 调用方式 | 调用样例 | 说明 | | 190 | | 调用方式 | 调用样例 | 说明 | |
| 191 | |--------------|------------------------------------------------------------------------|----------------------------------------------------------------| | 191 | |--------------|------------------------------------------------------------------------|----------------------------------------------------------------| |
| 192 | -| aclnn调用 | [test_aclnn_bidirection_lstm](examples/arch20/test_aclnn_bidirection_lstm.cpp) | 通过[aclnnBidirectionLSTM](docs/aclnnBidirectionLSTM.md)接口方式调用BidirectionLSTM算子。 | | 192 | +| aclnn调用 | [test_aclnn_bidirection_lstm](examples/arch20/test_aclnn_bidirection_lstm.cpp) | 通过[aclnnBidirectionLSTM](docs/aclnnBidirectionLSTM.md)接口方式调用BidirectionLSTM算子。 | |
| @@ -1,6 +1,6 @@ | |||
| 1 | # DynamicRnn | 1 | # DynamicRnn |
| 2 | 2 | ||
| 3 | -## 产品支持情况 | 3 | +## 产品支持情况 |
| 4 | 4 | ||
| 5 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| 6 | | ---- | :----:| | 6 | | ---- | :----:| |
| @@ -75,7 +75,6 @@ aclnnStatus aclnnLSTM( | |||
| 75 | aclrtStream stream) | 75 | aclrtStream stream) |
| 76 | ``` | 76 | ``` |
| 77 | 77 | ||
| 78 | - | ||
| 79 | ## aclnnLSTMGetWorkspaceSize | 78 | ## aclnnLSTMGetWorkspaceSize |
| 80 | 79 | ||
| 81 | - **参数说明:** | 80 | - **参数说明:** |
| @@ -1,6 +1,6 @@ | |||
| 1 | # DynamicRnnV2 | 1 | # DynamicRnnV2 |
| 2 | 2 | ||
| 3 | -## 产品支持情况 | 3 | +## 产品支持情况 |
| 4 | 4 | ||
| 5 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| 6 | | ---- | :----:| | 6 | | ---- | :----:| |
| @@ -1,4 +1,5 @@ | |||
| 1 | # ThnnFusedLstmCell | 1 | # ThnnFusedLstmCell |
| 2 | + | ||
| 2 | ## 产品支持情况 | 3 | ## 产品支持情况 |
| 3 | 4 | ||
| 4 | | 产品 | 是否支持 | | 5 | | 产品 | 是否支持 | |
| @@ -52,6 +53,7 @@ | |||
| 52 | * $\sigma$ 为 Sigmoid 激活函数,$\odot$ 为逐元素乘积 | 53 | * $\sigma$ 为 Sigmoid 激活函数,$\odot$ 为逐元素乘积 |
| 53 | 54 | ||
| 54 | ## 参数说明 | 55 | ## 参数说明 |
| 56 | + | ||
| 55 | <table style="undefined;table-layout: fixed; width: 970px"><colgroup> | 57 | <table style="undefined;table-layout: fixed; width: 970px"><colgroup> |
| 56 | <col style="width: 130px"> | 58 | <col style="width: 130px"> |
| 57 | <col style="width: 144px"> | 59 | <col style="width: 144px"> |
| @@ -134,4 +136,4 @@ | |||
| 134 | 136 | ||
| 135 | | 调用方式 | 样例代码 | 说明 | | 137 | | 调用方式 | 样例代码 | 说明 | |
| 136 | | ---------------- | --------------------------- | --------------------------------------------------- | | 138 | | ---------------- | --------------------------- | --------------------------------------------------- | |
| 137 | -| aclnn接口 | [test_aclnn_thnn_fused_lstm_cell.cpp](examples/test_aclnn_thnn_fused_lstm_cell.cpp) | 通过[aclnnThnnFusedLstmCell](docs/aclnnThnnFusedLstmCell.md)接口方式调用ThnnFusedLstmCell算子。 | | | 139 | +| aclnn接口 | [test_aclnn_thnn_fused_lstm_cell.cpp](examples/test_aclnn_thnn_fused_lstm_cell.cpp) | 通过[aclnnThnnFusedLstmCell](docs/aclnnThnnFusedLstmCell.md)接口方式调用ThnnFusedLstmCell算子。 | | |
| @@ -76,5 +76,3 @@ | |||
| 76 | | 调用方式 | 调用样例 | 说明 | | 76 | | 调用方式 | 调用样例 | 说明 | |
| 77 | |--------------|------------------------------------------------------------------------|----------------------------------------------------------------| | 77 | |--------------|------------------------------------------------------------------------|----------------------------------------------------------------| |
| 78 | | aclnn调用 | [test_aclnn_modulate](./examples/test_aclnn_modulate.cpp) | 通过[aclnnModulate](./docs/aclnnModulate.md)接口方式调用Modulate算子。 | | 78 | | aclnn调用 | [test_aclnn_modulate](./examples/test_aclnn_modulate.cpp) | 通过[aclnnModulate](./docs/aclnnModulate.md)接口方式调用Modulate算子。 | |
| 79 | - | ||
| 80 | - | ||
| @@ -32,6 +32,7 @@ aclnnStatus aclnnModulateGetWorkspaceSize( | |||
| 32 | uint64_t* workspaceSize, | 32 | uint64_t* workspaceSize, |
| 33 | aclOpExecutor** executor) | 33 | aclOpExecutor** executor) |
| 34 | ``` | 34 | ``` |
| 35 | + | ||
| 35 | ```Cpp | 36 | ```Cpp |
| 36 | aclnnStatus aclnnModulate( | 37 | aclnnStatus aclnnModulate( |
| 37 | void* workspace, | 38 | void* workspace, |
| @@ -208,6 +209,7 @@ aclnnStatus aclnnModulate( | |||
| 208 | ## 调用示例 | 209 | ## 调用示例 |
| 209 | 210 | ||
| 210 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 211 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| 212 | + | ||
| 211 | ```Cpp | 213 | ```Cpp |
| 212 | #include <iostream> | 214 | #include <iostream> |
| 213 | #include <vector> | 215 | #include <vector> |
| @@ -26,7 +26,7 @@ | |||
| 26 | 符号说明: | 26 | 符号说明: |
| 27 | - $\odot$: 表示逐元素乘法; | 27 | - $\odot$: 表示逐元素乘法; |
| 28 | - $\sum_{l=1}^{L}$: 求和操作,沿序列维度$L$(即dim=1)进行 | 28 | - $\sum_{l=1}^{L}$: 求和操作,沿序列维度$L$(即dim=1)进行 |
| 29 | - - $b,l,d$:下标,表示张量的维度索引(通常为Batch,Length,Dimension) | 29 | + - $b,l,d$:下标,表示张量的维度索引(通常为Batch,Length,Dimension) |
| 30 | - $\text{scale}^{\uparrow L}$: 表示将scale张量在序列维度 $L$ 上进行广播(扩展) | 30 | - $\text{scale}^{\uparrow L}$: 表示将scale张量在序列维度 $L$ 上进行广播(扩展) |
| 31 | 31 | ||
| 32 | ## 参数说明 | 32 | ## 参数说明 |
| @@ -107,5 +107,3 @@ | |||
| 107 | | 调用方式 | 调用样例 | 说明 | | 107 | | 调用方式 | 调用样例 | 说明 | |
| 108 | |--------------|------------------------------------------------------------------------|----------------------------------------------------------------| | 108 | |--------------|------------------------------------------------------------------------|----------------------------------------------------------------| |
| 109 | | aclnn调用 | [test_aclnn_modulatebackward](./examples/test_aclnn_modulatebackward.cpp) | 通过[aclnnModulateBackward](./docs/aclnnModulate.md)接口方式调用ModulateGrad算子。 | | 109 | | aclnn调用 | [test_aclnn_modulatebackward](./examples/test_aclnn_modulatebackward.cpp) | 通过[aclnnModulateBackward](./docs/aclnnModulate.md)接口方式调用ModulateGrad算子。 | |
| 110 | - | ||
| 111 | - | ||
| @@ -26,7 +26,7 @@ | |||
| 26 | 符号说明: | 26 | 符号说明: |
| 27 | - $\odot$: 表示逐元素乘法; | 27 | - $\odot$: 表示逐元素乘法; |
| 28 | - $\sum_{l=1}^{L}$: 求和操作,沿序列维度$L$(即dim=1)进行 | 28 | - $\sum_{l=1}^{L}$: 求和操作,沿序列维度$L$(即dim=1)进行 |
| 29 | - - $b,l,d$:下标,表示张量的维度索引(通常为Batch,Length,Dimension) | 29 | + - $b,l,d$:下标,表示张量的维度索引(通常为Batch,Length,Dimension) |
| 30 | - $\text{scale}^{\uparrow L}$: 表示将scale张量在序列维度 $L$ 上进行广播(扩展) | 30 | - $\text{scale}^{\uparrow L}$: 表示将scale张量在序列维度 $L$ 上进行广播(扩展) |
| 31 | 31 | ||
| 32 | ## 函数原型 | 32 | ## 函数原型 |
| @@ -45,6 +45,7 @@ aclnnStatus aclnnModulateBackwardGetWorkspaceSize( | |||
| 45 | uint64_t* workspaceSize, | 45 | uint64_t* workspaceSize, |
| 46 | aclOpExecutor** executor) | 46 | aclOpExecutor** executor) |
| 47 | ``` | 47 | ``` |
| 48 | + | ||
| 48 | ```Cpp | 49 | ```Cpp |
| 49 | aclnnStatus aclnnModulateBackward( | 50 | aclnnStatus aclnnModulateBackward( |
| 50 | void* workspaceAddr, | 51 | void* workspaceAddr, |
| @@ -205,7 +206,6 @@ aclnnStatus aclnnModulateBackward( | |||
| 205 | </tbody> | 206 | </tbody> |
| 206 | </table> | 207 | </table> |
| 207 | 208 | ||
| 208 | - | ||
| 209 | ## aclnnModulateBackward | 209 | ## aclnnModulateBackward |
| 210 | 210 | ||
| 211 | - **参数说明**: | 211 | - **参数说明**: |
| @@ -283,10 +283,10 @@ aclnnStatus aclnnModulateBackward( | |||
| 283 | - scale和shift是二维向量,第一维需要和input的第一维shape相同,第二维需要和input的第三维shape相同。 | 283 | - scale和shift是二维向量,第一维需要和input的第一维shape相同,第二维需要和input的第三维shape相同。 |
| 284 | - 输入gradoutput的shape需要和输入input的shape保持一致。 | 284 | - 输入gradoutput的shape需要和输入input的shape保持一致。 |
| 285 | 285 | ||
| 286 | - | ||
| 287 | ## 调用示例 | 286 | ## 调用示例 |
| 288 | 287 | ||
| 289 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 | 288 | 示例代码如下,仅供参考,具体编译和执行过程请参考[编译与运行样例](../../../docs/zh/context/编译与运行样例.md)。 |
| 289 | + | ||
| 290 | ```Cpp | 290 | ```Cpp |
| 291 | #include <iostream> | 291 | #include <iostream> |
| 292 | #include <vector> | 292 | #include <vector> |
| @@ -25,7 +25,6 @@ | |||
| 25 | \tilde{G}_{b,q,h,\ell,p,:} = A_{b,q,h,\ell,p} \cdot G^{\text{out}}_{b,q,h,:} | 25 | \tilde{G}_{b,q,h,\ell,p,:} = A_{b,q,h,\ell,p} \cdot G^{\text{out}}_{b,q,h,:} |
| 26 | $$ | 26 | $$ |
| 27 | 27 | ||
| 28 | - | ||
| 29 | 计算 Value 的梯度,对每个邻点 (y,x): | 28 | 计算 Value 的梯度,对每个邻点 (y,x): |
| 30 | 29 | ||
| 31 | $$ | 30 | $$ |
| @@ -67,6 +66,7 @@ | |||
| 67 | $$ | 66 | $$ |
| 68 | 67 | ||
| 69 | ## 参数说明 | 68 | ## 参数说明 |
| 69 | + | ||
| 70 | <table style="undefined;table-layout: fixed; width: 970px"><colgroup> | 70 | <table style="undefined;table-layout: fixed; width: 970px"><colgroup> |
| 71 | <col style="width: 181px"> | 71 | <col style="width: 181px"> |
| 72 | <col style="width: 144px"> | 72 | <col style="width: 144px"> |
| @@ -115,4 +115,4 @@ | |||
| 115 | 115 | ||
| 116 | | 调用方式 | 调用样例 | 说明 | | 116 | | 调用方式 | 调用样例 | 说明 | |
| 117 | |--------------|------------------------------------------------------------------------|----------------------------------------------------------------| | 117 | |--------------|------------------------------------------------------------------------|----------------------------------------------------------------| |
| 118 | -| aclnn调用 | [test_aclnn_multi_scale_deformable_attention_grad](./examples/test_aclnn_multi_scale_deformable_attention_grad.cpp) | 通过[aclnnMultiScaleDeformableAttentionGrad](./docs/aclnnMultiScaleDeformableAttentionGrad.md)接口方式调用aclnnMultiScaleDeformableAttentionGrad算子。 | | 118 | +| aclnn调用 | [test_aclnn_multi_scale_deformable_attention_grad](./examples/test_aclnn_multi_scale_deformable_attention_grad.cpp) | 通过[aclnnMultiScaleDeformableAttentionGrad](./docs/aclnnMultiScaleDeformableAttentionGrad.md)接口方式调用aclnnMultiScaleDeformableAttentionGrad算子。 | |
| @@ -31,6 +31,7 @@ aclnnStatus aclnnMultiScaleDeformableAttentionGradGetWorkspaceSize( | |||
| 31 | uint64_t* workspaceSize, | 31 | uint64_t* workspaceSize, |
| 32 | aclOpExecutor** executor) | 32 | aclOpExecutor** executor) |
| 33 | ``` | 33 | ``` |
| 34 | + | ||
| 34 | ```Cpp | 35 | ```Cpp |
| 35 | aclnnStatus aclnnMultiScaleDeformableAttentionGrad( | 36 | aclnnStatus aclnnMultiScaleDeformableAttentionGrad( |
| 36 | void* workspace, | 37 | void* workspace, |
| @@ -456,4 +457,4 @@ int main() { | |||
| 456 | aclFinalize(); | 457 | aclFinalize(); |
| 457 | return 0; | 458 | return 0; |
| 458 | } | 459 | } |
| 459 | -``` | 460 | +``` |
| @@ -20,7 +20,6 @@ | |||
| 20 | x = u \cdot W_\ell - 0.5, \qquad y = v \cdot H_\ell - 0.5 | 20 | x = u \cdot W_\ell - 0.5, \qquad y = v \cdot H_\ell - 0.5 |
| 21 | $$ | 21 | $$ |
| 22 | 22 | ||
| 23 | - | ||
| 24 | 确定采样点落在哪四个整数网格点之间: | 23 | 确定采样点落在哪四个整数网格点之间: |
| 25 | 24 | ||
| 26 | $$ | 25 | $$ |
| @@ -108,7 +107,9 @@ | |||
| 108 | - Atlas推理系列产品:不支持BFLOAT16 | 107 | - Atlas推理系列产品:不支持BFLOAT16 |
| 109 | 108 | ||
| 110 | ## 约束说明 | 109 | ## 约束说明 |
| 110 | + | ||
| 111 | - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>: | 111 | - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>: |
| 112 | + | ||
| 112 | - 通道数channels%8 = 0,且channels <= 256 | 113 | - 通道数channels%8 = 0,且channels <= 256 |
| 113 | - 查询的数量32 <= num_queries < 500000 | 114 | - 查询的数量32 <= num_queries < 500000 |
| 114 | - 特征图的数量num_levels <= 16 | 115 | - 特征图的数量num_levels <= 16 |
| @@ -119,4 +120,4 @@ | |||
| 119 | 120 | ||
| 120 | | 调用方式 | 调用样例 | 说明 | | 121 | | 调用方式 | 调用样例 | 说明 | |
| 121 | |--------------|------------------------------------------------------------------------|----------------------------------------------------------------| | 122 | |--------------|------------------------------------------------------------------------|----------------------------------------------------------------| |
| 122 | -| aclnn调用 | [test_aclnn_multi_scale_deformable_attn_function](./examples/test_aclnn_multi_scale_deformable_attn_function.cpp) | 通过[aclnnMultiScaleDeformableAttnFunction](./docs/aclnnMultiScaleDeformableAttnFunction.md)接口方式调用aclnnMultiScaleDeformableAttnFunction算子。 | | 123 | +| aclnn调用 | [test_aclnn_multi_scale_deformable_attn_function](./examples/test_aclnn_multi_scale_deformable_attn_function.cpp) | 通过[aclnnMultiScaleDeformableAttnFunction](./docs/aclnnMultiScaleDeformableAttnFunction.md)接口方式调用aclnnMultiScaleDeformableAttnFunction算子。 | |
| @@ -70,6 +70,7 @@ | |||
| 70 | ## 函数原型 | 70 | ## 函数原型 |
| 71 | 71 | ||
| 72 | 每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnMultiScaleDeformableAttnFunctionGetWorkspaceSize”接口获取计算所需workspace大小以及包含了算子计算流程的执行器,再调用“aclnnMultiScaleDeformableAttnFunction”接口执行计算。 | 72 | 每个算子分为[两段式接口](../../../docs/zh/context/两段式接口.md),必须先调用“aclnnMultiScaleDeformableAttnFunctionGetWorkspaceSize”接口获取计算所需workspace大小以及包含了算子计算流程的执行器,再调用“aclnnMultiScaleDeformableAttnFunction”接口执行计算。 |
| 73 | + | ||
| 73 | ```Cpp | 74 | ```Cpp |
| 74 | aclnnStatus aclnnMultiScaleDeformableAttnFunctionGetWorkspaceSize( | 75 | aclnnStatus aclnnMultiScaleDeformableAttnFunctionGetWorkspaceSize( |
| 75 | const aclTensor* value, | 76 | const aclTensor* value, |
| @@ -81,6 +82,7 @@ aclnnStatus aclnnMultiScaleDeformableAttnFunctionGetWorkspaceSize( | |||
| 81 | uint64_t* workspaceSize, | 82 | uint64_t* workspaceSize, |
| 82 | aclOpExecutor** executor) | 83 | aclOpExecutor** executor) |
| 83 | ``` | 84 | ``` |
| 85 | + | ||
| 84 | ```Cpp | 86 | ```Cpp |
| 85 | aclnnStatus aclnnMultiScaleDeformableAttnFunction( | 87 | aclnnStatus aclnnMultiScaleDeformableAttnFunction( |
| 86 | void* workspace, | 88 | void* workspace, |
| @@ -382,7 +384,7 @@ int main() { | |||
| 382 | auto ret = Init(deviceId, &stream); | 384 | auto ret = Init(deviceId, &stream); |
| 383 | // check根据自己的需要处理 | 385 | // check根据自己的需要处理 |
| 384 | CHECK_RET(ret == 0, LOG_PRINT("Init acl failed. ERROR: %d\n", ret); return ret); | 386 | CHECK_RET(ret == 0, LOG_PRINT("Init acl failed. ERROR: %d\n", ret); return ret); |
| 385 | - // 2.构造输入与输出,需要根据API的接口自定义构造 | 387 | + // 2.构造输入与输出,需要根据API的接口自定义构造 |
| 386 | std::vector<int64_t> valueShape = {1, 1, 2, 32}; | 388 | std::vector<int64_t> valueShape = {1, 1, 2, 32}; |
| 387 | std::vector<int64_t> spatialShapeShape = {1, 2}; | 389 | std::vector<int64_t> spatialShapeShape = {1, 2}; |
| 388 | std::vector<int64_t> levelStartIndexShape = {1}; | 390 | std::vector<int64_t> levelStartIndexShape = {1}; |
| @@ -478,4 +480,4 @@ int main() { | |||
| 478 | aclFinalize(); | 480 | aclFinalize(); |
| 479 | return 0; | 481 | return 0; |
| 480 | } | 482 | } |
| 481 | -``` | 483 | +``` |
| @@ -20,7 +20,6 @@ | |||
| 20 | \end{cases} | 20 | \end{cases} |
| 21 | $$ | 21 | $$ |
| 22 | 22 | ||
| 23 | - | ||
| 24 | ## 参数说明 | 23 | ## 参数说明 |
| 25 | 24 | ||
| 26 | <table style="undefined;table-layout: fixed; width: 970px"><colgroup> | 25 | <table style="undefined;table-layout: fixed; width: 970px"><colgroup> |
| @@ -83,7 +82,6 @@ | |||
| 83 | </tr> | 82 | </tr> |
| 84 | </tbody></table> | 83 | </tbody></table> |
| 85 | 84 | ||
| 86 | - | ||
| 87 | ## 约束说明 | 85 | ## 约束说明 |
| 88 | 86 | ||
| 89 | 无 | 87 | 无 |
| @@ -78,6 +78,7 @@ | |||
| 78 | </tbody></table> | 78 | </tbody></table> |
| 79 | 79 | ||
| 80 | - Kirin X90/Kirin 9030 处理器系列产品: 不支持BFLOAT16。 | 80 | - Kirin X90/Kirin 9030 处理器系列产品: 不支持BFLOAT16。 |
| 81 | + | ||
| 81 | ## 约束说明 | 82 | ## 约束说明 |
| 82 | 83 | ||
| 83 | 无 | 84 | 无 |
| @@ -34,6 +34,7 @@ aclnnStatus aclnnScaledMaskedSoftmaxGetWorkspaceSize( | |||
| 34 | uint64_t* workspaceSize, | 34 | uint64_t* workspaceSize, |
| 35 | aclOpExecutor** executor) | 35 | aclOpExecutor** executor) |
| 36 | ``` | 36 | ``` |
| 37 | + | ||
| 37 | ```Cpp | 38 | ```Cpp |
| 38 | aclnnStatus aclnnScaledMaskedSoftmax( | 39 | aclnnStatus aclnnScaledMaskedSoftmax( |
| 39 | void* workspace, | 40 | void* workspace, |
| @@ -399,4 +400,4 @@ int main() { | |||
| 399 | 400 | ||
| 400 | return 0; | 401 | return 0; |
| 401 | } | 402 | } |
| 402 | -``` | 403 | +``` |