| 产品名变更 Co-authored-by: gitcode-chenjiao<chenjiao31@huawei.com> # message auto-generated for no-merge-commit merge: !5912 merge master into master 产品名变更 Created-by: gitcode-chenjiao Commit-by: gitcode-chenjiao Merged-by: cann-robot Description: ## 描述 <!--在这里详细描述你的改动,包括改动的原因和所采取的方法。--> AI处理器对应的产品型号名称更新 ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在这里提供Issue链接。--> <!-- 如果这个PR是为了解决特定的问题单,请在这里描述问题单单号。--> [#3258](https://gitcode.com/cann/ops-math/issues/3258) ## 测试 <!--描述进行了哪些测试来验证你的改动。包括但不限于二级冒烟、算子泛化等。--> ok ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> *.md ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [x] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-math!5912 | 1 个月前 |
| 新增 SquaredDifference 算子的 Atlas 910B(A2)Ascend C 实现 Co-authored-by: lorcas<3162233587@qq.com> # message auto-generated for no-merge-commit merge: !4999 merge master into master 新增 SquaredDifference 算子的 Atlas 910B(A2)Ascend C 实现 Created-by: lorcas Commit-by: lorcas Merged-by: cann-robot Description: ## 描述 本PR为 ops-math 新增 SquaredDifference 算子的 Atlas 910B(A2)Ascend C 实现,对齐 CANN 内置 TBE 算子。 计算公式: \[ y = (x_1 - x_2) * (x_1 - x_2) = (x_1 - x_2)^2 \] 支持 float32 / float16 / bfloat16 / int32 / int64 五种数据类型、NumPy 广播语义与动态 shape;经算子注册(GE 图模式,构建框架自动生成 aclnn 接口)被上层框架调用。 主要改动如下: 1. 新增算子工程 - 新增 op_host(squared_difference_def.cpp / squared_difference_infershape.cpp / squared_difference_tiling.cpp)与 op_kernel(squared_difference.cpp / squared_difference.h)实现,以及 examples(aclnn 示例); - op_def 登记 5 种 dtype、FORMAT_ND、AutoContiguous()、AddConfig("ascend910b"); - InferShape 按 NumPy broadcast 语义逐维推导输出 shape(低维补 1 对齐、逐维广播、不可广播时报错)。 2. 新增 Host Tiling - CollapseDims 合轴:将广播标记相同(无广播 / x1 广播 / x2 广播)的相邻维合并,合并后维度数 ≤ 8; - OneDim(合轴后 1 维,同 shape / 标量广播)/ BRC(合轴后 >1 维,多维广播)双分支; - PlanBlocks 分派:fusedProduct >= coreNum 时满核参与计算,否则按 tile 数启用对应核数,blockBase/blockRemainder 均摊; - 单轴广播快速路径 ComputeTilingFastBrc(尾维/中间维),int64 广播路径 ComputeTilingInt64Bcast(广播轴= M、内轴 N 切分); - 共 10 个 tilingKey = 5 dtype × 2 mode;workspace 为 0。 3. 新增 Ascend C Kernel - 5 个 dtype 模板实例,if constexpr 隔离 UB buffer 避免溢出; - DataCopyPad(MTE2/MTE3)搬入/搬出 + 双缓冲(qDepth=2),广播快速路径采用预取流水线(下一 tile 搬入与当前 tile 计算重叠); - 计算:float32 / int32 为 Sub + Mul;float16 两步舍入(Sub → PipeBarrier → Mul);bfloat16 两步 7-op 舍入(对齐 Judge 精度);int64 标量逐元素计算(910B 向量单元无 int64 加减乘指令); - 广播按 BrcKind(0=无广播 / 1=M 轴 / 2=N 轴 / 3=标量)分类,单轴走 ProcessBrcFast、int64 广播走 ProcessBrcInt64Bcast、N 单行超预算走 ProcessBrcNSplit、其余走老 ProcessBrc; - 空 Tensor 直接返回,不初始化 UB / 不访问 GM。 4. 新增测试 - 新增 Host UT(tiling)、Kernel UT 与自验证用例(覆盖 5 种 dtype、同 shape、所有核参与计算场景)。 ## 关联的Issue https://gitcode.com/cann/ops-math/issues/2793 https://gitcode.com/cann/cann-ops-competitions/blob/master/04_tasks/01_community-task-2026/docs/202607/SquaredDifference_task_doc.md https://gitcode.com/cann/cann-ops-competitions/pull/580 ## 测试 ### 1. 构建与打包 - Ascend910B 构建:PASS; - 自定义算子 package 构建:PASS。 ### 2. 精度验证 - 自验证 12 个用例(覆盖 5 种 dtype、同 shape、所有核参与计算场景)精度全部通过; - 广播功能(单轴 / 多轴 / 标量)正确性验证通过。 ### 3. 性能验证 满核(所有核参与,40/40)场景: | shape | dtype | TBE(us) | AscendC(us) | 对比 | |---|---|---|---|---| | [128,64,32,128] | float32 | 384.62 | 334.88 | 优 13% | | [64,64,32,128] | float16 | 33.08 | 22.06 | 优 33% | | [128,64,32,128] | bfloat16 | 230.76 | 82.86 | 优 64% | | [64,64,32,128] | int32(非大数) | 231.82 | 53.26 | 优 77% | | [32,32,10,32,128] | int32(大数) | 683.04 | 420.60 | 优 38% | | [64,64,32,128] | int64 | 3223.60 | 3257.58 | 慢 1%(int64 标量) | 满核 6 个用例中 5 个(float32 / float16 / bfloat16 / int32 非大数 / int32 大数)优于 TBE 13%~77%,满足任务书「性能不低于原算子 95%」要求;int64 慢 1%(101%)。 非满核场景(各 shape 精度均通过): | shape | dtype | TBE(us) | AscendC(us) | 核数(TBE / AscendC) | |---|---|---|---|---| | [20,32,125] | float32 | 4.74 | 4.06 | 40 / 11 | | [20,32,125] | float16 | 4.74 | 3.44 | 40 / 9 | | [20,32,125] | bfloat16 | 4.94 | 4.08 | 40 / 9 | | [20,32,125] | int32(非大数) | 4.82 | 4.00 | 40 / 11 | | [20,32,125] | int32(大数) | 4.82 | 4.00 | 40 / 11 | | [8,16] | int64 | 3.08 | 6.92 | 40 / 32 | ## 文档更新 (无) ## 类型标签 - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-math!4999 | 2 个月前 |
| 新增 SquaredDifference 算子的 Atlas 910B(A2)Ascend C 实现 Co-authored-by: lorcas<3162233587@qq.com> # message auto-generated for no-merge-commit merge: !4999 merge master into master 新增 SquaredDifference 算子的 Atlas 910B(A2)Ascend C 实现 Created-by: lorcas Commit-by: lorcas Merged-by: cann-robot Description: ## 描述 本PR为 ops-math 新增 SquaredDifference 算子的 Atlas 910B(A2)Ascend C 实现,对齐 CANN 内置 TBE 算子。 计算公式: \[ y = (x_1 - x_2) * (x_1 - x_2) = (x_1 - x_2)^2 \] 支持 float32 / float16 / bfloat16 / int32 / int64 五种数据类型、NumPy 广播语义与动态 shape;经算子注册(GE 图模式,构建框架自动生成 aclnn 接口)被上层框架调用。 主要改动如下: 1. 新增算子工程 - 新增 op_host(squared_difference_def.cpp / squared_difference_infershape.cpp / squared_difference_tiling.cpp)与 op_kernel(squared_difference.cpp / squared_difference.h)实现,以及 examples(aclnn 示例); - op_def 登记 5 种 dtype、FORMAT_ND、AutoContiguous()、AddConfig("ascend910b"); - InferShape 按 NumPy broadcast 语义逐维推导输出 shape(低维补 1 对齐、逐维广播、不可广播时报错)。 2. 新增 Host Tiling - CollapseDims 合轴:将广播标记相同(无广播 / x1 广播 / x2 广播)的相邻维合并,合并后维度数 ≤ 8; - OneDim(合轴后 1 维,同 shape / 标量广播)/ BRC(合轴后 >1 维,多维广播)双分支; - PlanBlocks 分派:fusedProduct >= coreNum 时满核参与计算,否则按 tile 数启用对应核数,blockBase/blockRemainder 均摊; - 单轴广播快速路径 ComputeTilingFastBrc(尾维/中间维),int64 广播路径 ComputeTilingInt64Bcast(广播轴= M、内轴 N 切分); - 共 10 个 tilingKey = 5 dtype × 2 mode;workspace 为 0。 3. 新增 Ascend C Kernel - 5 个 dtype 模板实例,if constexpr 隔离 UB buffer 避免溢出; - DataCopyPad(MTE2/MTE3)搬入/搬出 + 双缓冲(qDepth=2),广播快速路径采用预取流水线(下一 tile 搬入与当前 tile 计算重叠); - 计算:float32 / int32 为 Sub + Mul;float16 两步舍入(Sub → PipeBarrier → Mul);bfloat16 两步 7-op 舍入(对齐 Judge 精度);int64 标量逐元素计算(910B 向量单元无 int64 加减乘指令); - 广播按 BrcKind(0=无广播 / 1=M 轴 / 2=N 轴 / 3=标量)分类,单轴走 ProcessBrcFast、int64 广播走 ProcessBrcInt64Bcast、N 单行超预算走 ProcessBrcNSplit、其余走老 ProcessBrc; - 空 Tensor 直接返回,不初始化 UB / 不访问 GM。 4. 新增测试 - 新增 Host UT(tiling)、Kernel UT 与自验证用例(覆盖 5 种 dtype、同 shape、所有核参与计算场景)。 ## 关联的Issue https://gitcode.com/cann/ops-math/issues/2793 https://gitcode.com/cann/cann-ops-competitions/blob/master/04_tasks/01_community-task-2026/docs/202607/SquaredDifference_task_doc.md https://gitcode.com/cann/cann-ops-competitions/pull/580 ## 测试 ### 1. 构建与打包 - Ascend910B 构建:PASS; - 自定义算子 package 构建:PASS。 ### 2. 精度验证 - 自验证 12 个用例(覆盖 5 种 dtype、同 shape、所有核参与计算场景)精度全部通过; - 广播功能(单轴 / 多轴 / 标量)正确性验证通过。 ### 3. 性能验证 满核(所有核参与,40/40)场景: | shape | dtype | TBE(us) | AscendC(us) | 对比 | |---|---|---|---|---| | [128,64,32,128] | float32 | 384.62 | 334.88 | 优 13% | | [64,64,32,128] | float16 | 33.08 | 22.06 | 优 33% | | [128,64,32,128] | bfloat16 | 230.76 | 82.86 | 优 64% | | [64,64,32,128] | int32(非大数) | 231.82 | 53.26 | 优 77% | | [32,32,10,32,128] | int32(大数) | 683.04 | 420.60 | 优 38% | | [64,64,32,128] | int64 | 3223.60 | 3257.58 | 慢 1%(int64 标量) | 满核 6 个用例中 5 个(float32 / float16 / bfloat16 / int32 非大数 / int32 大数)优于 TBE 13%~77%,满足任务书「性能不低于原算子 95%」要求;int64 慢 1%(101%)。 非满核场景(各 shape 精度均通过): | shape | dtype | TBE(us) | AscendC(us) | 核数(TBE / AscendC) | |---|---|---|---|---| | [20,32,125] | float32 | 4.74 | 4.06 | 40 / 11 | | [20,32,125] | float16 | 4.74 | 3.44 | 40 / 9 | | [20,32,125] | bfloat16 | 4.94 | 4.08 | 40 / 9 | | [20,32,125] | int32(非大数) | 4.82 | 4.00 | 40 / 11 | | [20,32,125] | int32(大数) | 4.82 | 4.00 | 40 / 11 | | [8,16] | int64 | 3.08 | 6.92 | 40 / 32 | ## 文档更新 (无) ## 类型标签 - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-math!4999 | 2 个月前 |
| 新增 SquaredDifference 算子的 Atlas 910B(A2)Ascend C 实现 Co-authored-by: lorcas<3162233587@qq.com> # message auto-generated for no-merge-commit merge: !4999 merge master into master 新增 SquaredDifference 算子的 Atlas 910B(A2)Ascend C 实现 Created-by: lorcas Commit-by: lorcas Merged-by: cann-robot Description: ## 描述 本PR为 ops-math 新增 SquaredDifference 算子的 Atlas 910B(A2)Ascend C 实现,对齐 CANN 内置 TBE 算子。 计算公式: \[ y = (x_1 - x_2) * (x_1 - x_2) = (x_1 - x_2)^2 \] 支持 float32 / float16 / bfloat16 / int32 / int64 五种数据类型、NumPy 广播语义与动态 shape;经算子注册(GE 图模式,构建框架自动生成 aclnn 接口)被上层框架调用。 主要改动如下: 1. 新增算子工程 - 新增 op_host(squared_difference_def.cpp / squared_difference_infershape.cpp / squared_difference_tiling.cpp)与 op_kernel(squared_difference.cpp / squared_difference.h)实现,以及 examples(aclnn 示例); - op_def 登记 5 种 dtype、FORMAT_ND、AutoContiguous()、AddConfig("ascend910b"); - InferShape 按 NumPy broadcast 语义逐维推导输出 shape(低维补 1 对齐、逐维广播、不可广播时报错)。 2. 新增 Host Tiling - CollapseDims 合轴:将广播标记相同(无广播 / x1 广播 / x2 广播)的相邻维合并,合并后维度数 ≤ 8; - OneDim(合轴后 1 维,同 shape / 标量广播)/ BRC(合轴后 >1 维,多维广播)双分支; - PlanBlocks 分派:fusedProduct >= coreNum 时满核参与计算,否则按 tile 数启用对应核数,blockBase/blockRemainder 均摊; - 单轴广播快速路径 ComputeTilingFastBrc(尾维/中间维),int64 广播路径 ComputeTilingInt64Bcast(广播轴= M、内轴 N 切分); - 共 10 个 tilingKey = 5 dtype × 2 mode;workspace 为 0。 3. 新增 Ascend C Kernel - 5 个 dtype 模板实例,if constexpr 隔离 UB buffer 避免溢出; - DataCopyPad(MTE2/MTE3)搬入/搬出 + 双缓冲(qDepth=2),广播快速路径采用预取流水线(下一 tile 搬入与当前 tile 计算重叠); - 计算:float32 / int32 为 Sub + Mul;float16 两步舍入(Sub → PipeBarrier → Mul);bfloat16 两步 7-op 舍入(对齐 Judge 精度);int64 标量逐元素计算(910B 向量单元无 int64 加减乘指令); - 广播按 BrcKind(0=无广播 / 1=M 轴 / 2=N 轴 / 3=标量)分类,单轴走 ProcessBrcFast、int64 广播走 ProcessBrcInt64Bcast、N 单行超预算走 ProcessBrcNSplit、其余走老 ProcessBrc; - 空 Tensor 直接返回,不初始化 UB / 不访问 GM。 4. 新增测试 - 新增 Host UT(tiling)、Kernel UT 与自验证用例(覆盖 5 种 dtype、同 shape、所有核参与计算场景)。 ## 关联的Issue https://gitcode.com/cann/ops-math/issues/2793 https://gitcode.com/cann/cann-ops-competitions/blob/master/04_tasks/01_community-task-2026/docs/202607/SquaredDifference_task_doc.md https://gitcode.com/cann/cann-ops-competitions/pull/580 ## 测试 ### 1. 构建与打包 - Ascend910B 构建:PASS; - 自定义算子 package 构建:PASS。 ### 2. 精度验证 - 自验证 12 个用例(覆盖 5 种 dtype、同 shape、所有核参与计算场景)精度全部通过; - 广播功能(单轴 / 多轴 / 标量)正确性验证通过。 ### 3. 性能验证 满核(所有核参与,40/40)场景: | shape | dtype | TBE(us) | AscendC(us) | 对比 | |---|---|---|---|---| | [128,64,32,128] | float32 | 384.62 | 334.88 | 优 13% | | [64,64,32,128] | float16 | 33.08 | 22.06 | 优 33% | | [128,64,32,128] | bfloat16 | 230.76 | 82.86 | 优 64% | | [64,64,32,128] | int32(非大数) | 231.82 | 53.26 | 优 77% | | [32,32,10,32,128] | int32(大数) | 683.04 | 420.60 | 优 38% | | [64,64,32,128] | int64 | 3223.60 | 3257.58 | 慢 1%(int64 标量) | 满核 6 个用例中 5 个(float32 / float16 / bfloat16 / int32 非大数 / int32 大数)优于 TBE 13%~77%,满足任务书「性能不低于原算子 95%」要求;int64 慢 1%(101%)。 非满核场景(各 shape 精度均通过): | shape | dtype | TBE(us) | AscendC(us) | 核数(TBE / AscendC) | |---|---|---|---|---| | [20,32,125] | float32 | 4.74 | 4.06 | 40 / 11 | | [20,32,125] | float16 | 4.74 | 3.44 | 40 / 9 | | [20,32,125] | bfloat16 | 4.94 | 4.08 | 40 / 9 | | [20,32,125] | int32(非大数) | 4.82 | 4.00 | 40 / 11 | | [20,32,125] | int32(大数) | 4.82 | 4.00 | 40 / 11 | | [8,16] | int64 | 3.08 | 6.92 | 40 / 32 | ## 文档更新 (无) ## 类型标签 - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-math!4999 | 2 个月前 |
| 新增 SquaredDifference 算子的 Atlas 910B(A2)Ascend C 实现 Co-authored-by: lorcas<3162233587@qq.com> # message auto-generated for no-merge-commit merge: !4999 merge master into master 新增 SquaredDifference 算子的 Atlas 910B(A2)Ascend C 实现 Created-by: lorcas Commit-by: lorcas Merged-by: cann-robot Description: ## 描述 本PR为 ops-math 新增 SquaredDifference 算子的 Atlas 910B(A2)Ascend C 实现,对齐 CANN 内置 TBE 算子。 计算公式: \[ y = (x_1 - x_2) * (x_1 - x_2) = (x_1 - x_2)^2 \] 支持 float32 / float16 / bfloat16 / int32 / int64 五种数据类型、NumPy 广播语义与动态 shape;经算子注册(GE 图模式,构建框架自动生成 aclnn 接口)被上层框架调用。 主要改动如下: 1. 新增算子工程 - 新增 op_host(squared_difference_def.cpp / squared_difference_infershape.cpp / squared_difference_tiling.cpp)与 op_kernel(squared_difference.cpp / squared_difference.h)实现,以及 examples(aclnn 示例); - op_def 登记 5 种 dtype、FORMAT_ND、AutoContiguous()、AddConfig("ascend910b"); - InferShape 按 NumPy broadcast 语义逐维推导输出 shape(低维补 1 对齐、逐维广播、不可广播时报错)。 2. 新增 Host Tiling - CollapseDims 合轴:将广播标记相同(无广播 / x1 广播 / x2 广播)的相邻维合并,合并后维度数 ≤ 8; - OneDim(合轴后 1 维,同 shape / 标量广播)/ BRC(合轴后 >1 维,多维广播)双分支; - PlanBlocks 分派:fusedProduct >= coreNum 时满核参与计算,否则按 tile 数启用对应核数,blockBase/blockRemainder 均摊; - 单轴广播快速路径 ComputeTilingFastBrc(尾维/中间维),int64 广播路径 ComputeTilingInt64Bcast(广播轴= M、内轴 N 切分); - 共 10 个 tilingKey = 5 dtype × 2 mode;workspace 为 0。 3. 新增 Ascend C Kernel - 5 个 dtype 模板实例,if constexpr 隔离 UB buffer 避免溢出; - DataCopyPad(MTE2/MTE3)搬入/搬出 + 双缓冲(qDepth=2),广播快速路径采用预取流水线(下一 tile 搬入与当前 tile 计算重叠); - 计算:float32 / int32 为 Sub + Mul;float16 两步舍入(Sub → PipeBarrier → Mul);bfloat16 两步 7-op 舍入(对齐 Judge 精度);int64 标量逐元素计算(910B 向量单元无 int64 加减乘指令); - 广播按 BrcKind(0=无广播 / 1=M 轴 / 2=N 轴 / 3=标量)分类,单轴走 ProcessBrcFast、int64 广播走 ProcessBrcInt64Bcast、N 单行超预算走 ProcessBrcNSplit、其余走老 ProcessBrc; - 空 Tensor 直接返回,不初始化 UB / 不访问 GM。 4. 新增测试 - 新增 Host UT(tiling)、Kernel UT 与自验证用例(覆盖 5 种 dtype、同 shape、所有核参与计算场景)。 ## 关联的Issue https://gitcode.com/cann/ops-math/issues/2793 https://gitcode.com/cann/cann-ops-competitions/blob/master/04_tasks/01_community-task-2026/docs/202607/SquaredDifference_task_doc.md https://gitcode.com/cann/cann-ops-competitions/pull/580 ## 测试 ### 1. 构建与打包 - Ascend910B 构建:PASS; - 自定义算子 package 构建:PASS。 ### 2. 精度验证 - 自验证 12 个用例(覆盖 5 种 dtype、同 shape、所有核参与计算场景)精度全部通过; - 广播功能(单轴 / 多轴 / 标量)正确性验证通过。 ### 3. 性能验证 满核(所有核参与,40/40)场景: | shape | dtype | TBE(us) | AscendC(us) | 对比 | |---|---|---|---|---| | [128,64,32,128] | float32 | 384.62 | 334.88 | 优 13% | | [64,64,32,128] | float16 | 33.08 | 22.06 | 优 33% | | [128,64,32,128] | bfloat16 | 230.76 | 82.86 | 优 64% | | [64,64,32,128] | int32(非大数) | 231.82 | 53.26 | 优 77% | | [32,32,10,32,128] | int32(大数) | 683.04 | 420.60 | 优 38% | | [64,64,32,128] | int64 | 3223.60 | 3257.58 | 慢 1%(int64 标量) | 满核 6 个用例中 5 个(float32 / float16 / bfloat16 / int32 非大数 / int32 大数)优于 TBE 13%~77%,满足任务书「性能不低于原算子 95%」要求;int64 慢 1%(101%)。 非满核场景(各 shape 精度均通过): | shape | dtype | TBE(us) | AscendC(us) | 核数(TBE / AscendC) | |---|---|---|---|---| | [20,32,125] | float32 | 4.74 | 4.06 | 40 / 11 | | [20,32,125] | float16 | 4.74 | 3.44 | 40 / 9 | | [20,32,125] | bfloat16 | 4.94 | 4.08 | 40 / 9 | | [20,32,125] | int32(非大数) | 4.82 | 4.00 | 40 / 11 | | [20,32,125] | int32(大数) | 4.82 | 4.00 | 40 / 11 | | [8,16] | int64 | 3.08 | 6.92 | 40 / 32 | ## 文档更新 (无) ## 类型标签 - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-math!4999 | 2 个月前 |
| 新增 SquaredDifference 算子的 Atlas 910B(A2)Ascend C 实现 Co-authored-by: lorcas<3162233587@qq.com> # message auto-generated for no-merge-commit merge: !4999 merge master into master 新增 SquaredDifference 算子的 Atlas 910B(A2)Ascend C 实现 Created-by: lorcas Commit-by: lorcas Merged-by: cann-robot Description: ## 描述 本PR为 ops-math 新增 SquaredDifference 算子的 Atlas 910B(A2)Ascend C 实现,对齐 CANN 内置 TBE 算子。 计算公式: \[ y = (x_1 - x_2) * (x_1 - x_2) = (x_1 - x_2)^2 \] 支持 float32 / float16 / bfloat16 / int32 / int64 五种数据类型、NumPy 广播语义与动态 shape;经算子注册(GE 图模式,构建框架自动生成 aclnn 接口)被上层框架调用。 主要改动如下: 1. 新增算子工程 - 新增 op_host(squared_difference_def.cpp / squared_difference_infershape.cpp / squared_difference_tiling.cpp)与 op_kernel(squared_difference.cpp / squared_difference.h)实现,以及 examples(aclnn 示例); - op_def 登记 5 种 dtype、FORMAT_ND、AutoContiguous()、AddConfig("ascend910b"); - InferShape 按 NumPy broadcast 语义逐维推导输出 shape(低维补 1 对齐、逐维广播、不可广播时报错)。 2. 新增 Host Tiling - CollapseDims 合轴:将广播标记相同(无广播 / x1 广播 / x2 广播)的相邻维合并,合并后维度数 ≤ 8; - OneDim(合轴后 1 维,同 shape / 标量广播)/ BRC(合轴后 >1 维,多维广播)双分支; - PlanBlocks 分派:fusedProduct >= coreNum 时满核参与计算,否则按 tile 数启用对应核数,blockBase/blockRemainder 均摊; - 单轴广播快速路径 ComputeTilingFastBrc(尾维/中间维),int64 广播路径 ComputeTilingInt64Bcast(广播轴= M、内轴 N 切分); - 共 10 个 tilingKey = 5 dtype × 2 mode;workspace 为 0。 3. 新增 Ascend C Kernel - 5 个 dtype 模板实例,if constexpr 隔离 UB buffer 避免溢出; - DataCopyPad(MTE2/MTE3)搬入/搬出 + 双缓冲(qDepth=2),广播快速路径采用预取流水线(下一 tile 搬入与当前 tile 计算重叠); - 计算:float32 / int32 为 Sub + Mul;float16 两步舍入(Sub → PipeBarrier → Mul);bfloat16 两步 7-op 舍入(对齐 Judge 精度);int64 标量逐元素计算(910B 向量单元无 int64 加减乘指令); - 广播按 BrcKind(0=无广播 / 1=M 轴 / 2=N 轴 / 3=标量)分类,单轴走 ProcessBrcFast、int64 广播走 ProcessBrcInt64Bcast、N 单行超预算走 ProcessBrcNSplit、其余走老 ProcessBrc; - 空 Tensor 直接返回,不初始化 UB / 不访问 GM。 4. 新增测试 - 新增 Host UT(tiling)、Kernel UT 与自验证用例(覆盖 5 种 dtype、同 shape、所有核参与计算场景)。 ## 关联的Issue https://gitcode.com/cann/ops-math/issues/2793 https://gitcode.com/cann/cann-ops-competitions/blob/master/04_tasks/01_community-task-2026/docs/202607/SquaredDifference_task_doc.md https://gitcode.com/cann/cann-ops-competitions/pull/580 ## 测试 ### 1. 构建与打包 - Ascend910B 构建:PASS; - 自定义算子 package 构建:PASS。 ### 2. 精度验证 - 自验证 12 个用例(覆盖 5 种 dtype、同 shape、所有核参与计算场景)精度全部通过; - 广播功能(单轴 / 多轴 / 标量)正确性验证通过。 ### 3. 性能验证 满核(所有核参与,40/40)场景: | shape | dtype | TBE(us) | AscendC(us) | 对比 | |---|---|---|---|---| | [128,64,32,128] | float32 | 384.62 | 334.88 | 优 13% | | [64,64,32,128] | float16 | 33.08 | 22.06 | 优 33% | | [128,64,32,128] | bfloat16 | 230.76 | 82.86 | 优 64% | | [64,64,32,128] | int32(非大数) | 231.82 | 53.26 | 优 77% | | [32,32,10,32,128] | int32(大数) | 683.04 | 420.60 | 优 38% | | [64,64,32,128] | int64 | 3223.60 | 3257.58 | 慢 1%(int64 标量) | 满核 6 个用例中 5 个(float32 / float16 / bfloat16 / int32 非大数 / int32 大数)优于 TBE 13%~77%,满足任务书「性能不低于原算子 95%」要求;int64 慢 1%(101%)。 非满核场景(各 shape 精度均通过): | shape | dtype | TBE(us) | AscendC(us) | 核数(TBE / AscendC) | |---|---|---|---|---| | [20,32,125] | float32 | 4.74 | 4.06 | 40 / 11 | | [20,32,125] | float16 | 4.74 | 3.44 | 40 / 9 | | [20,32,125] | bfloat16 | 4.94 | 4.08 | 40 / 9 | | [20,32,125] | int32(非大数) | 4.82 | 4.00 | 40 / 11 | | [20,32,125] | int32(大数) | 4.82 | 4.00 | 40 / 11 | | [8,16] | int64 | 3.08 | 6.92 | 40 / 32 | ## 文档更新 (无) ## 类型标签 - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-math!4999 | 2 个月前 |
| 产品名变更 Co-authored-by: gitcode-chenjiao<chenjiao31@huawei.com> # message auto-generated for no-merge-commit merge: !5912 merge master into master 产品名变更 Created-by: gitcode-chenjiao Commit-by: gitcode-chenjiao Merged-by: cann-robot Description: ## 描述 <!--在这里详细描述你的改动,包括改动的原因和所采取的方法。--> AI处理器对应的产品型号名称更新 ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在这里提供Issue链接。--> <!-- 如果这个PR是为了解决特定的问题单,请在这里描述问题单单号。--> [#3258](https://gitcode.com/cann/ops-math/issues/3258) ## 测试 <!--描述进行了哪些测试来验证你的改动。包括但不限于二级冒烟、算子泛化等。--> ok ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> *.md ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [x] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-math!5912 | 1 个月前 |