| Files | Last commit | Last update |
|---|---|---|
master分支alcnn文档英文合入 Co-authored-by: y60124828<yanglou1@h-partners.com> # message auto-generated for no-merge-commit merge: !13019 merge master into master master分支alcnn文档英文合入 Created-by: yanglu-1 Commit-by: y60124828 Merged-by: cann-robot Description: ## 描述 master分支alcnn文档英文合入 ## 关联的Issue 关联Issue [#6089](https://gitcode.com/cann/ops-nn/issues/6089) ## 测试 <!--描述进行了哪些测试来验证你的改动。--> ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [x] 文档更新 - [ ] 其他,请描述: ## AI/Agent生成声明 <!-- [x] 表示选中 --> - [ ] AI辅助编写 See merge request: cann/ops-nn!13019 | 23 days ago | |
format cpp Co-authored-by: yang-di52<yangdi52@huawei.com> # message auto-generated for no-merge-commit merge: !6784 merge issue_fix into master format cpp Created-by: yang-di52 Commit-by: yang-di52 Merged-by: cann-robot Description: ## 描述 批量刷新cpp代码格式 ## 关联的Issue [#3791](https://gitcode.com/cann/ops-nn/issues/3791) ## 测试 <!--描述进行了哪些测试来验证你的改动。--> ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [x] 其他,请描述:代码格式化 ## AI/Agent生成声明 <!-- [x] 表示选中 --> - [ ] AI辅助编写 See merge request: cann/ops-nn!6784 | 4 months ago | |
DynamicQuant等22个算子支持Ascend960dt Co-authored-by: TH_HW<taohai2@huawei.com> # message auto-generated for no-merge-commit merge: !11335 merge backBlue into master DynamicQuant等22个算子支持Ascend960dt Created-by: TH_HW Commit-by: TH_HW Merged-by: cann-robot Description: ## 描述 (+17812 / -2151)为一批 ops-nn 算子补齐 **Ascend 960DT(NPU Arch 9201)** 平台支持,并重构 GeGluV2 arch35 内核、为 Erfinv 增加 inplace 通路。 主要改动如下: 1. **Ascend960DT 平台适配(22 个算子)** - activation:Relu、ReluV2、ReluGrad、ReluGradV2、Sigmoid、SigmoidGrad、PRelu、PReluGradUpdate、SiluGrad、Softplus、Swish、SwishGrad、SwiGluGrad、GeGluV2。 - index:MapIndex、SparseSlice、QuantUpdateScatter。 - quant:Quantize、DynamicQuant、DynamicQuantV2、AntiMxQuant、GroupedDynamicMxQuant。 - 具体做法:CMakeLists.txt 的 SUPPORT_COMPUTE_UNIT / SUPPORT_TILING_DIR 增加 ascend960dt;*_def.cpp 增加 AddConfig("ascend960dt", ...);aclnn/op_api 与 infershape 增加 NpuArch::DAV_9201 / Ascend960DT 分支;kernel 增加 __NPU_ARCH__ == 9201 分支;新增 op_host/config/ascend960dt/ 下的算子二进制配置(共 22 个,如 relu_binary.json、p_relu.json 等);scripts/kernel/binary_config/ascendc_config.json 为相关算子登记 ascend960dt 计算单元与编译选项。 2. **GeGluV2 arch35 内核重构** - 将 arch35 模板按 erf / tanh 两类拆分,并补齐 align、align_last_axis_big、vreduce × fp16/bf16/fp32 变体,统一命名 *_arch35.h。 - tiling 新增 RegBase per-template per-element UB 预算模型(GetRegbasePerElem),并支持 ascend960dt。 - aclnnGeGlu 参数校验重构(CheckShape 支持 0D 输入与 dim 范围校验),新增 ST 用例(all_aclnnGeGlu(.V3).json)并调整 UT。 3. **Erfinv 支持 inplace**:新增 inplace dtype 支持列表与校验(GetInplaceDtypeSupportList / CheckInplaceDtypeValid),并补充 op_api UT。 4. **内核与接口修复** - SparseSlice:9201 路径改用 SetValue 写入 sliceStart/sliceEnd(替代 DataCopy),Reg::Reduce 使用完整命名空间限定。 - QuantUpdateScatter:9201 增加 FLOAT_OVERFLOW_MODE_CTRL 保护。 - ReluV2 infershape:Ascend960DT 不支持 NC1HWC0,UINT1 支持列表加入 Ascend960DT。 - DynamicQuant / Mx 量化:9201 上 fp8 scale 改为 bf16 乘法后再 cast 到 e8m0。 5. **代码规范**:统一 License 头注释格式、补齐文件末尾换行、调整 quant 系列 UT 的 CMakeLists;新增 MapIndex、SparseSlice 的 GE IR 图模式示例。 ## 关联的Issue 无。 ## 测试 - 新增 GeGluV2 ST 用例与 Erfinv inplace UT,补充/调整 GeGluV2 相关 UT。 - 新增 MapIndex / SparseSlice 的 GE IR 示例(examples/test_geir_*.cpp)。 - 通过 ascend960dt 编译与静态检查。 ## 文档更新 无。 ## 类型标签 <!-- [x] 表示选中 --> - [x] 新特性 - [ ] Bug修复 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: ## AI/Agent生成声明 <!-- [x] 表示选中 --> - [x] AI辅助编写 See merge request: cann/ops-nn!11335 | 1 month ago | |
refactor: NpuArch整改——activation类39算子注册迁移AddConfigByArch,CMake arch折叠,op_api枚举统一 Co-authored-by: ywx1080114<yuanbin22@huawei.com> # message auto-generated for no-merge-commit merge: !11992 merge npuarch-migration into master refactor: NpuArch整改——activation类39算子注册迁移AddConfigByArch,CMake arch折叠,op_api枚举统一 Created-by: yuanbin_22 Commit-by: ywx1080114 Merged-by: cann-robot Description: ## 描述 <!--在这里详细描述你的改动,包括改动的原因和所采取的方法。--> 基础与扩展算子 NpuArch 整改第一批(activation 39 个),共 107 个文件(+306 -268): **1. 注册面迁移(39 个 activation 类 _def.cpp):** - 算子注册从 this->AICore().AddConfig("ascend950"/"ascend350"/"ascend960dt"/"ascend960pr", aicoreConfig) 迁移为 **opbase::ArchConfigHelper::AddConfigByArch(this->AICore(), Ops::Base::DAV_3510/DAV_9201/DAV_9202, aicoreConfig)**(include op_common/op_host/util/op_arch_helper.h); - 147 处旧 AddConfig 收敛为 108 处 AddConfigByArch:**Ascend950/Ascend350 折叠到 DAV_3510**(同 arch 共享一份注册),960dt=DAV_9201、960pr=DAV_9202 保留显式注册; - 涉及算子(39 个):elu、elu_grad、elu_grad_v2、erfinv、fast_gelu、fast_gelu_grad、ge_glu_grad_v2、ge_glu_v2、gelu、gelu_grad、gelu_grad_v2、gelu_quant、gelu_v2、glu_grad、hardtanh_grad、leaky_relu、leaky_relu_grad、log_sigmoid、logsigmoid_grad、mish、mish_grad、p_relu、p_relu_grad_reduce、p_relu_grad_update、relu、relu_grad、relu_grad_v2、relu_v2、sigmoid、sigmoid_grad、silu_grad、softmax_grad_ext、softplus、swi_glu_grad、swish、swish_grad、threshold、threshold_grad_v2、threshold_grad_v2_d。 **2. CMake arch 折叠同步(35 个 CMakeLists.txt):** - SUPPORT_COMPUTE_UNIT 由 soc 名折叠为 arch 名(ascend950/ascend350 → dav_3510,ascend960dt → dav_9201,ascend960pr → dav_9202),保留各算子原有其他 soc(mc62 等);SUPPORT_TILING_DIR 相应调整。 **3. op_api / op_host tiling 枚举统一(33 个文件,低风险面):** - 运行时 NpuArch::DAV_* 判断统一替换为 Ops::Base::DAV_*(约 51 处,include op_common/op_host/util/op_const_def.h,枚举同值纯改名),分支逻辑与 dtype 支持列表不变。 **三批拆分说明:** activation 批 39 个(本 PR)、quant/index 批 26 个(!14673)、长尾批 43 个(!14522)。拆分依据:Compile_single 逐算子串行构建实测 49 算子 57.0min(70s/算子,上限 3600s),65 算子合并必超时。 ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在这里提供Issue链接。例如:关联Issue #000--> - 关联 Issue #9085 ## 测试 <!--描述进行了哪些测试来验证你的改动。包括但不限于二级冒烟、算子泛化等。--> - 注册迁移为等价替换(AddConfigByArch(DAV_3510) 展开覆盖 950/350 两个 soc,9201/9202 显式注册不变),编译期配置产物一致; - op_api/tiling 侧仅枚举命名空间统一(NpuArch::DAV_* → Ops::Base::DAV_*,枚举同值),分支逻辑不变; - 本地构建回归通过;CI compile 待触发。 ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> - 无需文档更新。 ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述:重构(注册面/平台判断统一) ## AI/Agent生成声明 <!-- [x] 表示选中 --> - [ ] AI辅助编写 See merge request: cann/ops-nn!11992 | 3 days ago | |
feat: Infershape整改,30个算子InferDataType注册迁移至op_graph目录(IMPL_OP独立链)及UT看护 Co-authored-by: ywx1080114<yuanbin22@huawei.com> # message auto-generated for no-merge-commit merge: !11929 merge infershape-dtype into master feat: Infershape整改,30个算子InferDataType注册迁移至op_graph目录(IMPL_OP独立链)及UT看护 Created-by: yuanbin_22 Commit-by: ywx1080114 Merged-by: cann-robot Description: ## 描述 <!--在这里详细描述你的改动,包括改动的原因和所采取的方法。--> 作为 Infershape 整改的一部分,为 30 个算子在 op_graph/ 目录新增 InferDataType(输出数据类型推导)独立注册及 UT 看护,共 103 个文件(+2848 -1),对齐仓内方案(threshold 样板): **注册方案(IMPL_OP 独立链):** - 每个算子新增 op_graph/<op>_graph_infer.cpp,通过 IMPL_OP(X).InferDataType(InferDataTypeX) 独立注册链注册,与 op_host 的 IMPL_OP_INFERSHAPE(InferShape)链解耦; - 13 个原本无 op_graph/ 目录的算子(erfinv、fast_gelu、fast_gelu_grad、hardtanh_grad、leaky_relu、leaky_relu_grad、log_sigmoid、p_relu、sigmoid_grad、softplus、swish、swish_grad、quant_update_scatter)配套新增 op_graph/CMakeLists.txt(add_graph_plugin_sources()); - 涉及 30 个算子:elu、elu_grad、elu_grad_v2、erfinv、fast_gelu、fast_gelu_grad、ge_glu_v2、gelu、gelu_grad、gelu_grad_v2、gelu_v2、glu_grad、hardtanh_grad、leaky_relu、leaky_relu_grad、log_sigmoid、logsigmoid_grad、mish、mish_grad、p_relu、relu、relu_grad、relu_grad_v2、sigmoid、sigmoid_grad、softplus、swish、swish_grad、ge_glu_grad_v2 及 quant_update_scatter; **实现分类:** - 27 个算子输出 dtype 与第一个输入一致(SetOutputDataType(0, GetInputDataType(0)),含 QuantUpdateScatter); - 3 个梯度类算子按各自契约推导: - GeGluGradV2:输出 dx 随输入 x(输入1); - GeluGradV2:dy 与 x dtype 一致时输出随 x,不一致(混合 dtype)时输出 FLOAT(与 aclnn 层 isMixDataType 契约一致); - GLUGrad:输出 out 随输入 self(输入1)。 **UT 看护(30 个测试文件,30 个参数化用例):** - 每算子新增 tests/ut/op_graph/test_<op>_graph_infer_pass.cpp,直接调用导出的 ops::InferDataTypeX 函数,通过 OpInferDataTypeContextBuilder 构造上下文,参数化覆盖 DT_BF16/DT_FLOAT16/DT_FLOAT(GeluGradV2 等梯度类覆盖混合 dtype 组合),断言推导返回 GRAPH_SUCCESS 且输出 dtype 符合预期; - 29 个算子配套新增 tests/ut/op_graph/CMakeLists.txt 纳入构建(gelu_v2 沿用既有收集机制,无需新增)。 **顺带修正:** - activation/elu/CMakeLists.txt:DEPENDENCIES 由 threshold 修正为 threshold_v2。 ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在这里提供Issue链接。例如:关联Issue #000--> - 关联 Issue #7149 ## 补充说明(冒烟依赖修正) - activation/elu/CMakeLists.txt 的 DEPENDENCIES 由 threshold 改为 threshold_v2:上游 c105aafb0([Threshold] 算子质量加固)将 threshold 的 op_api 整体迁移至 threshold_v2/op_api/,threshold 本体不再提供 l0op::Threshold 符号,但漏改 elu 的依赖声明,导致 elu 单算子包示例链接失败(undefined reference to l0op::Threshold,即此前 PreSmoke_A2 失败根因,非本 PR 引入)。实测改后包内 U 引用消除,aclnn_threshold.h 与 ThresholdV2 kernel 均随包。 - UT 按真实契约对齐:GeGluV2 双输出断言;relu_grad_v2/quant_update_scatter 等多输入算子补混合 dtype 参数化;GeluGrad/SigmoidGrad/HardtanhGrad 按 def 签名补多输入(IONum 3/2/2)。 ## 测试 <!--描述进行了哪些测试来验证你的改动。--> - 30 个算子各新增 InferDataTypeTest 参数化 UT 用例(直接函数调用),全部通过; - 用例逐一断言 InferDataTypeX 返回 GRAPH_SUCCESS 且输出 dtype 符合预期(27 个等于第一个输入、3 个梯度类按各自契约),覆盖各算子支持的输入 dtype 集合。 ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> - 无需文档更新。 ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: ## AI/Agent生成声明 <!-- [x] 表示选中 --> - [x] AI辅助编写 See merge request: cann/ops-nn!11929 | 18 days ago | |
refactor: NpuArch整改——activation类39算子注册迁移AddConfigByArch,CMake arch折叠,op_api枚举统一 Co-authored-by: ywx1080114<yuanbin22@huawei.com> # message auto-generated for no-merge-commit merge: !11992 merge npuarch-migration into master refactor: NpuArch整改——activation类39算子注册迁移AddConfigByArch,CMake arch折叠,op_api枚举统一 Created-by: yuanbin_22 Commit-by: ywx1080114 Merged-by: cann-robot Description: ## 描述 <!--在这里详细描述你的改动,包括改动的原因和所采取的方法。--> 基础与扩展算子 NpuArch 整改第一批(activation 39 个),共 107 个文件(+306 -268): **1. 注册面迁移(39 个 activation 类 _def.cpp):** - 算子注册从 this->AICore().AddConfig("ascend950"/"ascend350"/"ascend960dt"/"ascend960pr", aicoreConfig) 迁移为 **opbase::ArchConfigHelper::AddConfigByArch(this->AICore(), Ops::Base::DAV_3510/DAV_9201/DAV_9202, aicoreConfig)**(include op_common/op_host/util/op_arch_helper.h); - 147 处旧 AddConfig 收敛为 108 处 AddConfigByArch:**Ascend950/Ascend350 折叠到 DAV_3510**(同 arch 共享一份注册),960dt=DAV_9201、960pr=DAV_9202 保留显式注册; - 涉及算子(39 个):elu、elu_grad、elu_grad_v2、erfinv、fast_gelu、fast_gelu_grad、ge_glu_grad_v2、ge_glu_v2、gelu、gelu_grad、gelu_grad_v2、gelu_quant、gelu_v2、glu_grad、hardtanh_grad、leaky_relu、leaky_relu_grad、log_sigmoid、logsigmoid_grad、mish、mish_grad、p_relu、p_relu_grad_reduce、p_relu_grad_update、relu、relu_grad、relu_grad_v2、relu_v2、sigmoid、sigmoid_grad、silu_grad、softmax_grad_ext、softplus、swi_glu_grad、swish、swish_grad、threshold、threshold_grad_v2、threshold_grad_v2_d。 **2. CMake arch 折叠同步(35 个 CMakeLists.txt):** - SUPPORT_COMPUTE_UNIT 由 soc 名折叠为 arch 名(ascend950/ascend350 → dav_3510,ascend960dt → dav_9201,ascend960pr → dav_9202),保留各算子原有其他 soc(mc62 等);SUPPORT_TILING_DIR 相应调整。 **3. op_api / op_host tiling 枚举统一(33 个文件,低风险面):** - 运行时 NpuArch::DAV_* 判断统一替换为 Ops::Base::DAV_*(约 51 处,include op_common/op_host/util/op_const_def.h,枚举同值纯改名),分支逻辑与 dtype 支持列表不变。 **三批拆分说明:** activation 批 39 个(本 PR)、quant/index 批 26 个(!14673)、长尾批 43 个(!14522)。拆分依据:Compile_single 逐算子串行构建实测 49 算子 57.0min(70s/算子,上限 3600s),65 算子合并必超时。 ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在这里提供Issue链接。例如:关联Issue #000--> - 关联 Issue #9085 ## 测试 <!--描述进行了哪些测试来验证你的改动。包括但不限于二级冒烟、算子泛化等。--> - 注册迁移为等价替换(AddConfigByArch(DAV_3510) 展开覆盖 950/350 两个 soc,9201/9202 显式注册不变),编译期配置产物一致; - op_api/tiling 侧仅枚举命名空间统一(NpuArch::DAV_* → Ops::Base::DAV_*,枚举同值),分支逻辑不变; - 本地构建回归通过;CI compile 待触发。 ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> - 无需文档更新。 ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述:重构(注册面/平台判断统一) ## AI/Agent生成声明 <!-- [x] 表示选中 --> - [ ] AI辅助编写 See merge request: cann/ops-nn!11992 | 3 days ago | |
MicroAPI namespace to Reg for arch35 kernels Co-authored-by: gcw_DS4cmz2b<1312925094@qq.com> # message auto-generated for no-merge-commit merge: !9267 merge rename into master MicroAPI namespace to Reg for arch35 kernels Created-by: gcw_DS4cmz2b Commit-by: gcw_DS4cmz2b Merged-by: cann-robot Description: ## 描述 修改了index,activation,matmul,conv,foreach,optim,experimental,vfusion,hash这几个文件夹内的命名空间,将MicroAPI-->Reg ## 关联的Issue [多个文件夹内的算子命名空间使用的MicroAPI,应改为Reg](https://gitcode.com/cann/ops-nn/issues/5218) ## 测试 验证方法 严格按四步流程,逐算子验证: 1. Step 1:编译原始代码,保存 baseline binary .o 文件 MD5 2. Step 2:执行 MicroAPI → Reg 替换 3. Step 3:编译替换后代码,保存 after binary .o 文件 MD5 4. Step 4:对比 A_before.md5 与 B_after.md5 平台:ascend950,编译参数:--soc=ascend950 --ops=<op> -j16 验证替换前后 binary 产物 MD5 完全一致。 冒烟,代码审查均通过 ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: ## AI/Agent生成声明 <!-- [x] 表示选中 --> - [ ] AI辅助编写 See merge request: cann/ops-nn!9267 | 2 months ago | |
feat(aicpu): AICPU built-in整包准入manifest机制 Co-authored-by: liu-wei<lovline.liuwei@huawei.com> # message auto-generated for no-merge-commit merge: !11655 merge feat/aicpu-builtin-package-manifest into master feat(aicpu): AICPU built-in整包准入manifest机制 Created-by: liu-wei Commit-by: liu-wei Merged-by: cann-robot Description: ## 描述 为 ops-nn 移植 AICPU built-in 整包准入 manifest 机制: 通过白名单控制 AICPU 算子是否准入 built-in 整包,默认全 OFF(与 ops-math 上线口径一致,算子准入由后续 PR 按需登记 xxx=ON),将"隐式排除"显式化为白名单机制。 **主要改动:** - 新增 cmake/config/aicpu_builtin_package_manifest.cmake:准入清单(AICPU_BUILTIN_PACKAGE_FORCE_ALL 默认 OFF + 空 manifest),在进入算子子目录前 include - cmake/func.cmake 新增 check_aicpu_builtin_pkg_allowed() 门控 helper - 23 个 AICPU 算子 op_kernel_aicpu/CMakeLists.txt 的 op_def 收集与 cust obj 编译包进 if (ENABLE_CUSTOM OR _AICPU_BUILTIN_PKG_ALLOWED) 门控 - gen_norm_symbol() 补 built-in 产出接线:NO_AICPU=OFF && ENABLE_PACKAGE=ON 时生成 aicpu_nn.json + libnn_aicpu_kernels.so(安装至 opp/built-in/op_impl/aicpu/{config,kernel}) - 顺手规范化 elu、adaptive_max_pool2d 的变体版权头(master 遗留问题,OAT 合规要求) **不受 manifest 控制(行为不变):** ENABLE_CUSTOM(custom 包直通)、UT(AddAicpuOpTestCase 与收集逻辑解耦)、host 常量折叠(libopconstant_folding_nn.so) **默认行为无回退:** master 上 gen_norm_symbol() 本无 AICPU 产出调用(收集物无消费者),空 manifest 下整包产物与 master 完全一致 ## 关联的Issue https://gitcode.com/cann/ops-nn/issues/6515 ## 测试 本地 5 组 configure/build 验证: | 场景 | 结果 | |---|---| | 空 manifest 整包(ENABLE_PACKAGE=ON) | 干净跳过,无 aicpu 产物,与 master 一致 | | elu=ON | aicpu_nn.json 仅含 Elu;libnn_aicpu_kernels.so 仅链接 elu_cust_obj;安装路径正确 | | FORCE_ALL=ON | 23 算子全准入,json 含全部 23 个算子定义 | | ENABLE_CUSTOM=ON | 23 算子全收集,产出 cust_aicpu_kernel.json(→ vendors/custom_nn),与 master 无差异 | | UT(UT_TEST_ALL=ON) | 23 个算子 UT 用例正常创建 | pre-commit 全部通过(codespell、OAT 合规等)。 ## 文档更新 无需文档更新(纯构建配置改动) ## 类型标签 - 🐛 Bug修复 - ✅ ✨ 新特性 - ⚡ 性能优化 - ♻️ 重构 - 🧪 测试 - ✅ 📦 构建/CI - 🔧 配置变更 - 📝 文档更新 - ⬆️ 依赖升级 - 🔒 安全修复 - 🧹 代码清理 - ❓ 其他,请描述: See merge request: cann/ops-nn!11655 | 1 month ago | |
feat: Infershape整改,30个算子InferDataType注册迁移至op_graph目录(IMPL_OP独立链)及UT看护 Co-authored-by: ywx1080114<yuanbin22@huawei.com> # message auto-generated for no-merge-commit merge: !11929 merge infershape-dtype into master feat: Infershape整改,30个算子InferDataType注册迁移至op_graph目录(IMPL_OP独立链)及UT看护 Created-by: yuanbin_22 Commit-by: ywx1080114 Merged-by: cann-robot Description: ## 描述 <!--在这里详细描述你的改动,包括改动的原因和所采取的方法。--> 作为 Infershape 整改的一部分,为 30 个算子在 op_graph/ 目录新增 InferDataType(输出数据类型推导)独立注册及 UT 看护,共 103 个文件(+2848 -1),对齐仓内方案(threshold 样板): **注册方案(IMPL_OP 独立链):** - 每个算子新增 op_graph/<op>_graph_infer.cpp,通过 IMPL_OP(X).InferDataType(InferDataTypeX) 独立注册链注册,与 op_host 的 IMPL_OP_INFERSHAPE(InferShape)链解耦; - 13 个原本无 op_graph/ 目录的算子(erfinv、fast_gelu、fast_gelu_grad、hardtanh_grad、leaky_relu、leaky_relu_grad、log_sigmoid、p_relu、sigmoid_grad、softplus、swish、swish_grad、quant_update_scatter)配套新增 op_graph/CMakeLists.txt(add_graph_plugin_sources()); - 涉及 30 个算子:elu、elu_grad、elu_grad_v2、erfinv、fast_gelu、fast_gelu_grad、ge_glu_v2、gelu、gelu_grad、gelu_grad_v2、gelu_v2、glu_grad、hardtanh_grad、leaky_relu、leaky_relu_grad、log_sigmoid、logsigmoid_grad、mish、mish_grad、p_relu、relu、relu_grad、relu_grad_v2、sigmoid、sigmoid_grad、softplus、swish、swish_grad、ge_glu_grad_v2 及 quant_update_scatter; **实现分类:** - 27 个算子输出 dtype 与第一个输入一致(SetOutputDataType(0, GetInputDataType(0)),含 QuantUpdateScatter); - 3 个梯度类算子按各自契约推导: - GeGluGradV2:输出 dx 随输入 x(输入1); - GeluGradV2:dy 与 x dtype 一致时输出随 x,不一致(混合 dtype)时输出 FLOAT(与 aclnn 层 isMixDataType 契约一致); - GLUGrad:输出 out 随输入 self(输入1)。 **UT 看护(30 个测试文件,30 个参数化用例):** - 每算子新增 tests/ut/op_graph/test_<op>_graph_infer_pass.cpp,直接调用导出的 ops::InferDataTypeX 函数,通过 OpInferDataTypeContextBuilder 构造上下文,参数化覆盖 DT_BF16/DT_FLOAT16/DT_FLOAT(GeluGradV2 等梯度类覆盖混合 dtype 组合),断言推导返回 GRAPH_SUCCESS 且输出 dtype 符合预期; - 29 个算子配套新增 tests/ut/op_graph/CMakeLists.txt 纳入构建(gelu_v2 沿用既有收集机制,无需新增)。 **顺带修正:** - activation/elu/CMakeLists.txt:DEPENDENCIES 由 threshold 修正为 threshold_v2。 ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在这里提供Issue链接。例如:关联Issue #000--> - 关联 Issue #7149 ## 补充说明(冒烟依赖修正) - activation/elu/CMakeLists.txt 的 DEPENDENCIES 由 threshold 改为 threshold_v2:上游 c105aafb0([Threshold] 算子质量加固)将 threshold 的 op_api 整体迁移至 threshold_v2/op_api/,threshold 本体不再提供 l0op::Threshold 符号,但漏改 elu 的依赖声明,导致 elu 单算子包示例链接失败(undefined reference to l0op::Threshold,即此前 PreSmoke_A2 失败根因,非本 PR 引入)。实测改后包内 U 引用消除,aclnn_threshold.h 与 ThresholdV2 kernel 均随包。 - UT 按真实契约对齐:GeGluV2 双输出断言;relu_grad_v2/quant_update_scatter 等多输入算子补混合 dtype 参数化;GeluGrad/SigmoidGrad/HardtanhGrad 按 def 签名补多输入(IONum 3/2/2)。 ## 测试 <!--描述进行了哪些测试来验证你的改动。--> - 30 个算子各新增 InferDataTypeTest 参数化 UT 用例(直接函数调用),全部通过; - 用例逐一断言 InferDataTypeX 返回 GRAPH_SUCCESS 且输出 dtype 符合预期(27 个等于第一个输入、3 个梯度类按各自契约),覆盖各算子支持的输入 dtype 集合。 ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> - 无需文档更新。 ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: ## AI/Agent生成声明 <!-- [x] 表示选中 --> - [x] AI辅助编写 See merge request: cann/ops-nn!11929 | 18 days ago | |
refactor: NpuArch整改——activation类39算子注册迁移AddConfigByArch,CMake arch折叠,op_api枚举统一 Co-authored-by: ywx1080114<yuanbin22@huawei.com> # message auto-generated for no-merge-commit merge: !11992 merge npuarch-migration into master refactor: NpuArch整改——activation类39算子注册迁移AddConfigByArch,CMake arch折叠,op_api枚举统一 Created-by: yuanbin_22 Commit-by: ywx1080114 Merged-by: cann-robot Description: ## 描述 <!--在这里详细描述你的改动,包括改动的原因和所采取的方法。--> 基础与扩展算子 NpuArch 整改第一批(activation 39 个),共 107 个文件(+306 -268): **1. 注册面迁移(39 个 activation 类 _def.cpp):** - 算子注册从 this->AICore().AddConfig("ascend950"/"ascend350"/"ascend960dt"/"ascend960pr", aicoreConfig) 迁移为 **opbase::ArchConfigHelper::AddConfigByArch(this->AICore(), Ops::Base::DAV_3510/DAV_9201/DAV_9202, aicoreConfig)**(include op_common/op_host/util/op_arch_helper.h); - 147 处旧 AddConfig 收敛为 108 处 AddConfigByArch:**Ascend950/Ascend350 折叠到 DAV_3510**(同 arch 共享一份注册),960dt=DAV_9201、960pr=DAV_9202 保留显式注册; - 涉及算子(39 个):elu、elu_grad、elu_grad_v2、erfinv、fast_gelu、fast_gelu_grad、ge_glu_grad_v2、ge_glu_v2、gelu、gelu_grad、gelu_grad_v2、gelu_quant、gelu_v2、glu_grad、hardtanh_grad、leaky_relu、leaky_relu_grad、log_sigmoid、logsigmoid_grad、mish、mish_grad、p_relu、p_relu_grad_reduce、p_relu_grad_update、relu、relu_grad、relu_grad_v2、relu_v2、sigmoid、sigmoid_grad、silu_grad、softmax_grad_ext、softplus、swi_glu_grad、swish、swish_grad、threshold、threshold_grad_v2、threshold_grad_v2_d。 **2. CMake arch 折叠同步(35 个 CMakeLists.txt):** - SUPPORT_COMPUTE_UNIT 由 soc 名折叠为 arch 名(ascend950/ascend350 → dav_3510,ascend960dt → dav_9201,ascend960pr → dav_9202),保留各算子原有其他 soc(mc62 等);SUPPORT_TILING_DIR 相应调整。 **3. op_api / op_host tiling 枚举统一(33 个文件,低风险面):** - 运行时 NpuArch::DAV_* 判断统一替换为 Ops::Base::DAV_*(约 51 处,include op_common/op_host/util/op_const_def.h,枚举同值纯改名),分支逻辑与 dtype 支持列表不变。 **三批拆分说明:** activation 批 39 个(本 PR)、quant/index 批 26 个(!14673)、长尾批 43 个(!14522)。拆分依据:Compile_single 逐算子串行构建实测 49 算子 57.0min(70s/算子,上限 3600s),65 算子合并必超时。 ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在这里提供Issue链接。例如:关联Issue #000--> - 关联 Issue #9085 ## 测试 <!--描述进行了哪些测试来验证你的改动。包括但不限于二级冒烟、算子泛化等。--> - 注册迁移为等价替换(AddConfigByArch(DAV_3510) 展开覆盖 950/350 两个 soc,9201/9202 显式注册不变),编译期配置产物一致; - op_api/tiling 侧仅枚举命名空间统一(NpuArch::DAV_* → Ops::Base::DAV_*,枚举同值),分支逻辑不变; - 本地构建回归通过;CI compile 待触发。 ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> - 无需文档更新。 ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述:重构(注册面/平台判断统一) ## AI/Agent生成声明 <!-- [x] 表示选中 --> - [ ] AI辅助编写 See merge request: cann/ops-nn!11992 | 3 days ago | |
修改产品名 Co-authored-by: fwx1169505<fengying27@h-partners.com> # message auto-generated for no-merge-commit merge: !11017 merge master into master 修改产品名 Created-by: fengying555682 Commit-by: fwx1169505 Merged-by: cann-robot Description: ## 描述 修改quant和activation文件夹中的md文档涉及的产品名称 ## 关联的Issue [#6056](https://gitcode.com/cann/ops-nn/issues/6056) ## 测试 已经完成文档语法和链接一致性检测 ## 文档更新 quant和activation文件夹中的md文档 ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [x ] 文档更新 - [ ] 其他,请描述: ## AI/Agent生成声明 <!-- [x] 表示选中 --> - [ ] AI辅助编写 See merge request: cann/ops-nn!11017 | 1 month ago | |
docs: add English translations for operator READMEs and repo docs Co-authored-by: jenny_xiang<jenny.xiang@huawei.com> # message auto-generated for no-merge-commit merge: !13351 merge docs/add-english-docs into master docs: add English translations for operator READMEs and repo docs Created-by: jenny_xiang Commit-by: jenny_xiang Merged-by: cann-robot Description: ## Description Add English translations for 652 markdown documents: - Repo-level guides: README_en.md, CONTRIBUTING_en.md, SECURITY_en.md, CHANGELOG_en.md, codearts_check_rule_config_en.md - Operator READMEs under activation/, conv/, control/, foreach/, hash/, index/, loss/, matmul/, norm/, optim/, pooling/, quant/, rnn/, vfusion/, etc. - API and design docs under docs/ (aclnn_*, ascendir_*, fusion pass docs) - examples/ and torch_extension/ guides Note: a few cross-reference links whose English targets are not published yet temporarily point to their Chinese counterparts to keep links valid; they will be switched back to the English docs in a follow-up PR after this one is merged. ## Related Issue N/A ## Test - Verified all 1,344 intra-repo markdown links in the added files resolve against master: 0 broken links, 0 missing targets. ## Documentation Update - This PR only adds English documentation files (*_en.md); no existing Chinese documents are modified. ## Type Labels - [ ] Bug fix - [ ] New feature - [ ] Performance optimization - [x] Documentation update - [ ] Other, please describe: ## AI/Agent-Generated Declaration - [x] AI-assisted authoring See merge request: cann/ops-nn!13351 | 18 days ago |
Elu
English | 简体中文
Applicable Products
| Product | Support |
|---|---|
| Ascend 950PR&950DT products | √ |
| Atlas A3 products | √ |
| Atlas A2 products | √ |
| Atlas 200I/500 A2 inference products | √ |
| Atlas inference products | √ |
| Atlas training products | √ |
Function
-
Description: Calls the exponential linear unit activation function ELU on each element x in the input tensor self, and stores the obtained result in the output tensor out.
-
Formula:
ELU(x)={scale∗x,x>0α∗scale∗(exp(x∗inputScale)−1),x≤0ELU(x) = \begin{cases} scale \ast x, \quad x > 0\\ \alpha \ast scale \ast (exp(x \ast inputScale)-1), \quad x \leq 0 \end{cases} ELU(x)={scale∗x,x>0α∗scale∗(exp(x∗inputScale)−1),x≤0
-
Parameters:
Parameter name Input/Output Description Usage instructions Data type Data format Dimensions (shape) Non-contiguous tensor self Input Represents the input of the ELU activation function; it is x in the formula. Empty tensors are supported. FLOAT, FLOAT16, BFLOAT16 ND 0-8 √ alpha Input Represents the activation coefficient of the ELU activation function; it is α in the formula. The data type must be a data type that can be converted to FLOAT. - - - - scale Input Represents the scaling coefficient of the ELU activation function; it is scale in the formula. The data type must be a data type that can be converted to FLOAT. - - - - inputScale Input Represents the scaling coefficient of the input of the ELU activation function; it is inputScale in the formula. The data type must be a data type that can be converted to FLOAT. - - - - out Output Represents the output of the ELU activation function. The shape must be consistent with that of self. FLOAT, FLOAT16, BFLOAT16 ND 0-8 √ - Atlas training products: The supported data types are FLOAT and FLOAT16.
Constraints
None
Invocation Description
| Invocation method | Invocation sample | Description |
|---|---|---|
| aclnn invocation | test_aclnn_elu | Invokes the Elu operator through the aclnnElu&aclnnInplaceElu interface. |
| aclnn invocation | test_aclnn_inplace_elu | Invokes the Elu operator through the aclnnElu&aclnnInplaceElu interface. |