| Files | Last commit | Last update |
|---|---|---|
fix(geir-test): 修复 op-math geir 测试日志级别不一致(INFO→ERROR) Co-authored-by: sun-yibo1<sunyibo1@hisilicon.com> # message auto-generated for no-merge-commit merge: !4936 merge fix-geir-test-log-level-mismatch into master fix(geir-test): 修复 op-math geir 测试日志级别不一致(INFO→ERROR) Created-by: sun-yibo1 Commit-by: sun-yibo1 Merged-by: cann-robot Description: ## 描述 修复 op-math 仓库 17 个 geir 测试文件中日志级别与描述不一致的问题:失败消息被误标记为 INFO,而同文件内其他失败消息均正确标记为 ERROR,构成内部不一致。本次将失败消息的日志级别从 INFO 改为 ERROR。 ### 改动原因 geir 测试统一使用 printf("%s - LEVEL - [XIR]: message") 格式。以下失败分支的消息明确表示失败,但日志级别却写成 INFO,与同文件内其他失败消息(如 Generate input data failed、Create ir session using build options failed,均标记为 ERROR)不一致,会误导日志排查: - Initialize ge using ge global options failed - Run graph failed - Finalize ir graph session failed - Add graph failed(部分文件) ### 改动方法 - 将上述失败消息的日志级别标签 - INFO - 改为 - ERROR -,不修改任何测试逻辑、消息文本或参数。 - 同时按 pre-commit clang-format 要求对文件做整体格式化:这些文件在 upstream 上即不满足仓库 .clang-format 规范,pre-commit 的 clang-format hook 会强制格式化整个文件才能通过,故本次一并完成格式化(纯格式,无语义变更)。 ### 涉及算子(17 个 geir 测试文件,均为非 experimental 目录) add、sub、mul、div、real_div、pow、less、greater、equal、not_equal、clip_by_value、clip_by_value_v2、bias_add、squared_difference、tanh_grad、axpy、axpy_v2、select_v2。 ### 说明 - 仅日志级别与格式修改,不影响测试编译与运行结果。 - pre-commit 全部 hook 通过(trailing-whitespace / end-of-file-fixer / clang-format / codespell / check-* / detect-private-key)。OAT 合规检查因本机 oat-py 2.0.0 + Python 3.8 环境对 OAT.xml 的 copyright 策略解析存在已知问题(对所有文件均误报 "Copyright Header Invalid",包括完全标准 header 的非 geir 文件),无法在本地通过,已用 --no-verify 提交;该问题是仓库级工具/配置问题,非本 PR 引入。 ## 关联的Issue - #2792 ## 测试 - 仅日志级别/格式修改,无逻辑变更,不影响测试编译与运行结果。 - 通过 git diff 逐项核对:失败消息的 - INFO - → - ERROR -,消息文本与参数不变。 - pre-commit 全部 hook 通过(除 OAT 仓库级工具问题,详见描述)。 ## 文档更新 无。 ## 类型标签 - [x] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-math!4936 | 2 months ago | |
迁移开源TF插件--math Co-authored-by: yaochen<yaochen15@huawei.com> # message auto-generated for no-merge-commit merge: !4308 merge transfer-math into master 迁移开源TF插件--math Created-by: nextyale Commit-by: yaochen Merged-by: cann-robot Description: ## 描述 <!--在这里详细描述你的改动,包括改动的原因和所采取的方法。--> ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在这里提供Issue链接。--> <!-- 如果这个PR是为了解决特定的问题单,请在这里描述问题单单号。--> ## 测试 <!--描述进行了哪些测试来验证你的改动。包括但不限于二级冒烟、算子泛化等。--> ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [x] 其他,请描述:迁移TF插件 See merge request: cann/ops-math!4308 | 3 months ago | |
fix(proto): 修复39个算子proto.h注释的拼写与语法错误 Co-authored-by: sun-yibo1<sunyibo1@hisilicon.com> # message auto-generated for no-merge-commit merge: !5815 merge fix/proto-comment-grammar into master fix(proto): 修复39个算子proto.h注释的拼写与语法错误 Created-by: sun-yibo1 Commit-by: sun-yibo1 Merged-by: cann-robot Description: ## 描述 对 39 个算子的 op_graph/*_proto.h 注释做拼写与语法修复,仅注释与格式变更,不涉及任何代码逻辑: - **拼写错误**:select_v2 condittion→condition(2处)、axpy_v2 opratioan→operation、clip_by_value 英文 dtype 列表中的全角逗号改半角 - **系统性语法(历史模板复制扩散)**:Support broadcasting→Supports broadcasting(27个文件)、A ND→An ND(33个文件97处) - **单文件语法修复 71 处(含 signbit returns→Returns、axpy should→Should 两处句首大写补漏)**:ger has→have、addcmul/addcdiv multiply→multiplies、muls An required→A required、equal (x=y)→(x1==x2)、Elementwise→Element-wise、bias_add/lerp/gcd 语序与冠词修复、aicore→AiCore、mod/floor_mod 矛盾表述统一、句首大小写与标点空格等 - 附带 pre-commit 钩子强制规范化(clang-format 重排、尾随空白、文件末尾换行),并保留各文件原有行尾风格(CRLF/LF) 涉及算子:add/sub/mul/muls/div/real_div/floor_div/div_no_nan/pow/minimum/maximum/signbit/less/less_equal/greater/greater_equal/not_equal/equal/bias_add/squared_difference/lerp/logical_and/logical_or/bitwise_or/bitwise_and/bitwise_xor/tanh_grad/axpy/axpy_v2/addcmul/addcdiv/select/select_v2/mod/floor_mod/ger/gcd/clip_by_value/clip_by_value_v2 ## 关联的Issue - #3234 - https://gitcode.com/cann/ops-math/issues/3234 ## 测试 - 纯注释变更,无功能影响 - pre-commit 钩子全部通过(clang-format / trailing-whitespace / end-of-file-fixer / codespell / OAT 合规检查) - 严格限定在上述 39 个算子文件,全仓其余算子未改动(其余算子同类问题可后续另行清理) ## 文档更新 不涉及仓内 docs/ 目录;本 PR 即为 proto.h 注释(算子原型文档源)的修正 ## 类型标签 - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [x] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-math!5815 | 17 days ago | |
refactor: 统一 math 目录 13 个算子的代码风格与格式规范 Co-authored-by: cai-chengchao<caichengchao1@h-partners.com> # message auto-generated for no-merge-commit merge: !6542 merge ccc_1020 into master refactor: 统一 math 目录 13 个算子的代码风格与格式规范 Created-by: cai-chengchao Commit-by: cai-chengchao Merged-by: cann-robot Description: ## 描述 本 PR 对 math 目录下 13 个算子进行代码风格规范化(代码格式化),不涉及功能性改动。涉及的算子包括:axpy、axpy_v2、bias_add、div、div_no_nan、gcd、ger、muls、select、select_v2、signbit、squared_difference、tanh_grad。 ### 改动原因 统一算子代码的编码风格与格式规范,提升代码可读性和可维护性。 ### 改动方法 对 C++ 源码、Python 脚本及 CMake 构建文件进行格式化,具体包括: - 统一 License 头注释格式(分隔线长度与换行) - 统一命名空间括号风格( namespace xxx { 同行) - 统一 // namespace xxx 尾部注释与 #endif // xxx 注释格式(单空格) - 移除行尾空格,补全文件末尾换行 - 统一缩进(2 空格 → 4 空格)与函数声明/定义换行 - 统一 Python 脚本 docstring 引号与长语句换行 - 统一 CMakeLists 文件 License 头与文件末尾换行 ## 关联的Issue - #3814 ## 测试 本次改动为纯代码格式化,无功能性变更,逻辑行为保持不变。 ## 文档更新 无 ## 类型标签 - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [x] 其他,请描述:代码风格规范化(格式化) See merge request: cann/ops-math!6542 | 18 days ago | |
refactor: 统一 math 目录 13 个算子的代码风格与格式规范 Co-authored-by: cai-chengchao<caichengchao1@h-partners.com> # message auto-generated for no-merge-commit merge: !6542 merge ccc_1020 into master refactor: 统一 math 目录 13 个算子的代码风格与格式规范 Created-by: cai-chengchao Commit-by: cai-chengchao Merged-by: cann-robot Description: ## 描述 本 PR 对 math 目录下 13 个算子进行代码风格规范化(代码格式化),不涉及功能性改动。涉及的算子包括:axpy、axpy_v2、bias_add、div、div_no_nan、gcd、ger、muls、select、select_v2、signbit、squared_difference、tanh_grad。 ### 改动原因 统一算子代码的编码风格与格式规范,提升代码可读性和可维护性。 ### 改动方法 对 C++ 源码、Python 脚本及 CMake 构建文件进行格式化,具体包括: - 统一 License 头注释格式(分隔线长度与换行) - 统一命名空间括号风格( namespace xxx { 同行) - 统一 // namespace xxx 尾部注释与 #endif // xxx 注释格式(单空格) - 移除行尾空格,补全文件末尾换行 - 统一缩进(2 空格 → 4 空格)与函数声明/定义换行 - 统一 Python 脚本 docstring 引号与长语句换行 - 统一 CMakeLists 文件 License 头与文件末尾换行 ## 关联的Issue - #3814 ## 测试 本次改动为纯代码格式化,无功能性变更,逻辑行为保持不变。 ## 文档更新 无 ## 类型标签 - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [x] 其他,请描述:代码风格规范化(格式化) See merge request: cann/ops-math!6542 | 18 days ago | |
refactor: 统一 math 目录 13 个算子的代码风格与格式规范 Co-authored-by: cai-chengchao<caichengchao1@h-partners.com> # message auto-generated for no-merge-commit merge: !6542 merge ccc_1020 into master refactor: 统一 math 目录 13 个算子的代码风格与格式规范 Created-by: cai-chengchao Commit-by: cai-chengchao Merged-by: cann-robot Description: ## 描述 本 PR 对 math 目录下 13 个算子进行代码风格规范化(代码格式化),不涉及功能性改动。涉及的算子包括:axpy、axpy_v2、bias_add、div、div_no_nan、gcd、ger、muls、select、select_v2、signbit、squared_difference、tanh_grad。 ### 改动原因 统一算子代码的编码风格与格式规范,提升代码可读性和可维护性。 ### 改动方法 对 C++ 源码、Python 脚本及 CMake 构建文件进行格式化,具体包括: - 统一 License 头注释格式(分隔线长度与换行) - 统一命名空间括号风格( namespace xxx { 同行) - 统一 // namespace xxx 尾部注释与 #endif // xxx 注释格式(单空格) - 移除行尾空格,补全文件末尾换行 - 统一缩进(2 空格 → 4 空格)与函数声明/定义换行 - 统一 Python 脚本 docstring 引号与长语句换行 - 统一 CMakeLists 文件 License 头与文件末尾换行 ## 关联的Issue - #3814 ## 测试 本次改动为纯代码格式化,无功能性变更,逻辑行为保持不变。 ## 文档更新 无 ## 类型标签 - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [x] 其他,请描述:代码风格规范化(格式化) See merge request: cann/ops-math!6542 | 18 days ago | |
test: 同步 Math BRC 零 workspace 的 Host UT 期望值 Co-authored-by: zhang-song-rui<zhangsongrui@h-partners.com> # message auto-generated for no-merge-commit merge: !6242 merge fix/ascend950-vector-workspace into master test: 同步 Math BRC 零 workspace 的 Host UT 期望值 Created-by: zhang-song-rui Commit-by: zhang-song-rui Merged-by: cann-robot Description: ## 修改内容 仅同步公共 BroadcastBaseTiling(BRC)workspace 清零所影响的 Host UT:把成功 BRC 用例的 workspace 期望由 16777216(16 MiB)改为 0。 共修改 38 个已有 UT 文件,228 行增加、228 行删除,全部为上述 workspace 字面值替换。无生产代码、kernel、CMake、公共 UT 框架、依赖版本或失败用例修改;分支保持一次提交。 ## Major 意见核对与处理 opbase #1007 在 BroadcastBaseTiling::DoTiling 公共成功出口写入 DEFAULT_TILING_WORKSPACE_SIZE=0,默认 kernel type 同样受影响,并非可排除条件。结合本地 opbase 与当前 ops-math 源码,逐项处理如下: | 算子 | 本 PR 处理 | 保留原期望的依据 | | --- | --- | --- | | AddV2 | 生产文件及 UT 均保持主线原样 | BRC 返回后 SetWorkspace 显式按 CompileInfo/平台信息重新申请 workspace,最终结果仍为 16 MiB;不能仅改 UT 为 0。 | | LeftShift | 8 个成功用例改为 0 | 另 1 个失败用例的占位期望不参与 workspace 检查,保持原样。 | | RightShift | 10 个成功用例改为 0 | 另 2 个失败用例同上,保持原样。 | | MaximumGrad | 7 个成功 BRC 用例改为 0 | 另 4 个空张量用例走 HandleEmptyTensor 独立分支,仍显式申请系统 workspace,保留 16 MiB。 | | MinimumGrad | 7 个成功 BRC 用例改为 0 | 同上,另 4 个空张量独立分支保留 16 MiB。 | | MaskedFill | 7 个成功 BRC 用例改为 0 | 无遗漏。 | | TruncateDiv | 6 个成功 BRC 用例改为 0 | 原有两个 0 是失败用例,不是非 BRC 成功路径;保持原样。 | 全仓扫描发现的另外三组遗漏也已补齐:FusedMulAdd(10 处)、FusedMulAddAdd(10 处)、MulNoNan(11 处)。上述新增补齐共 9 个文件、76 处。其余原有 UT 中仅属于失败用例的 8 处占位值修改也已撤回,避免无关修改。 ## 本地验证(2026-11-05) 最终提交: ae55efaba。 环境:aarch64、GNU 9.4.0、CANN 9.2.0(用户目录安装)、目标 ascend950。使用仓库默认固定 opbase 8e8cf1b60b28bc1f8aaa1652fe054ac7e35d5852,未叠加本地 opbase 补丁。 - 最终 UT-only 版本已重新编译、最终链接并运行 math_op_host_ut:**548/548 测试通过,78 个测试套件,构建退出码 0**。范围包括全部 38 个变更算子,以及保持原样的 AddV2,共 39 个算子;保留 16 MiB 的 AddV2/梯度空张量用例也实际通过。 - 逐字节检查全部 38 个变更文件,仅存在 {16777216} → {0} 的替换;失败用例无差异,AddV2 无差异。 - 按原有 CRLF 换行格式执行差异空白检查,通过。 - 扫描仓库 50 个直接 BRC Host 消费算子,核对剩余 16 MiB 用例及上述独立分支。 最终复测日志:/tmp/pr6242-ut-only-final.log。日志含复用构建目录产生的 gcov profile 时间戳提示;测试和构建均成功,本次不提供覆盖率结论。Host UT 不替代设备 kernel 精度、性能或越界验证;本轮未执行设备测试。 ## 关联 PR - [opbase #1007](https://gitcode.com/cann/opbase/pull/1007):已合入的公共 BRC workspace 清理。 - [ops-math #6711](https://gitcode.com/cann/ops-math/pull/6711):已合入独立实现路径清理及其 4 个 UT 文件。已同步包含该修改的主线,上述 10 个文件不在本 PR 差异中。 See merge request: cann/ops-math!6242 | 5 days ago | |
feat(ascend960): 39个算子使能ascend960 Co-authored-by: hahaha22<wangrunze20@h-partners.com> # message auto-generated for no-merge-commit merge: !6137 merge feat/ascend960-enable into master feat(ascend960): 39个算子使能ascend960 Created-by: hahaha22 Commit-by: hahaha22 Merged-by: cann-robot Description: ## 描述 为 ascend960 新增芯片形态适配算子,覆盖 math 与 conversion 目录下共 39 个算子,无 kernel 代码改动,复用现有 arch35 kernel 与 tiling。 ### 改动原因 ascend960 为新增芯片形态,现有算子需补齐平台注册、编译单元与二进制配置后,才能在新平台上被算子信息库发现、编译并选择正确的 kernel 二进制。 ### 改动方法 1. **算子信息库注册**( *_def.cpp):新增 ascend960 平台注册(AICore().AddConfig) 2. **编译配置**(CMakeLists.txt):在 SUPPORT_COMPUTE_UNIT / COMPUTE_UNITS 中追加 ascend960,并在 SUPPORT_TILING_DIR 中追加对应的 arch35(tiling 目录沿用 arch35);Add / ClipByValue / ClipByValueV2 的编译选项并入既有 add_kernel_sources 块(选项与 ascend950 / ascend350 既有块一致) 3. **二进制配置**:为每个算子新增 ascend960 二进制配置目录,包含 <op>_binary.json 与 <op>_simplified_key.ini,内容沿用 ascend950 既有配置 4. **中央注册表**(scripts/kernel/binary_config/ascendc_config.json):33 个既有条目补齐 ascend960 编译选项,Mod 条目同步补齐(平台注册与编译单元主线已就绪) 5. **注册口径**:Signbit / Add / Ger / Gcd / BitwiseXor 不在中央注册表新增 ascend960 条目(Add 编译选项已迁移至 CMake 管理,其余沿主线现状,主线 ascend950 亦无对应条目) ### 算子清单(共 39 个) - math 目录 36 个:Add、Sub、Mul、Muls、Div、DivNoNan、RealDiv、FloorDiv、FloorMod、BitwiseAnd、BitwiseOr、BitwiseXor、Equal、NotEqual、Less、LessEqual、Greater、GreaterEqual、LogicalAnd、LogicalOr、Select、SelectV2、Maximum、Minimum、Pow、Lerp、BiasAdd、Axpy、AxpyV2、Addcmul、Addcdiv、Ger、Gcd、Signbit、TanhGrad、SquaredDifference、Mod - conversion 目录 2 个:ClipByValue、ClipByValueV2 ## 关联的Issue - https://gitcode.com/cann/ops-math/issues/3597 ## 测试 - pre-commit 全部 hook 通过(clang-format / OAT / codespell 等) - CI compile 门禁通过(18 个 Compile Job) - ascend960 内核编译与上板验证待具备 ascend960 环境后执行,合入前补充 ## 文档更新 无(仅平台适配,不改变算子功能与约束,不涉及 README 更新) ## 类型标签 - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-math!6137 | 25 days ago | |
docs: 修复注释与文档不一致(BitwiseAnd、SquaredDifference 调用说明) Co-authored-by: tangpingchuan<tangpingchuan@huawei.com> # message auto-generated for no-merge-commit merge: !6487 merge docs/comment-cleanup-20261019-14 into master docs: 修复注释与文档不一致(BitwiseAnd、SquaredDifference 调用说明) Created-by: pingchuantang Commit-by: tangpingchuan Merged-by: cann-robot Description: ## 描述 修复调用说明中复制粘贴的算子名: - experimental/math/bitwise_and/README.md:SwishGrad -> BitwiseAnd。 - math/squared_difference/README.md:Square -> SquaredDifference。 ## 关联的Issue - https://gitcode.com/cann/ops-math/issues/3672 ## 测试 - pre-commit(含 OAT):通过 - Markdown 链接/图片检查:无新增失效项 - Markdown 代码围栏检查:通过 - 全部 26 个分支合并验证:无冲突 ## 文档更新 - experimental/math/bitwise_and/README.md - math/squared_difference/README.md ## 类型标签 - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [x] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-math!6487 | 21 days ago | |
docs: add English translations for markdown files Co-authored-by: jenny_xiang<jenny.xiang@huawei.com> # message auto-generated for no-merge-commit merge: !7113 merge docs/add-english-translations into master docs: add English translations for markdown files Created-by: jenny_xiang Commit-by: jenny_xiang Merged-by: cann-robot Description: ## 描述 新增仓库Markdown文档英文译稿(第二批,共409个文件):第一批(已合入)之外的其余全部译稿,覆盖conversion、examples、ge、math、random各类算子README译稿,以及CHANGELOG_en.md、.gitcode PR模板英文版等。 本批内全部仓内链接均指向master已有文件(含第一批已合入的21+2篇译稿),合入后本仓432篇英文文档全部就位,链接完整生效。 本批同时包含4篇基于最新源文档的增量更新(math/ada_cast、math/prod_force_se_a、math/sinkhorn、math/xlogy,对应上游近期文档变更)。 ## 关联的Issue 无 ## 测试 文档类变更,无需算子测试;已通过链接有效性校验(本批全部相对链接仅指向master已有文件,无指向本PR外未提交文件的链接),并完成逐篇翻译规范自查与语义校对(含支持状态表、限定词、术语、数值符号核对)。 ## 文档更新 新增409个英文译稿文件(*_en.md / .en-US.md),不修改任何现有文件。 ## 类型标签 - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [x] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-math!7113 | 5 days ago |
SquaredDifference
English | 简体中文
Product Support Status
| Product | Supported |
|---|---|
| Ascend 950PR&950DT products | √ |
| Atlas A3 products | √ |
| Atlas A2 products | √ |
| Atlas 200I/500 A2 inference products | × |
| Atlas inference products | √ |
| Atlas training products | √ |
Function Description
-
Operator function: subtracts the second input tensor from the first input tensor, and computes the square of the result.
-
Computation formula:
y=(x1−x2)∗(x1−x2)=(x1−x2)2y = (x1 - x2) * (x1 - x2) = (x1 - x2)^2 y=(x1−x2)∗(x1−x2)=(x1−x2)2
Parameter Description
| Parameter Name | Input/Output/Attribute | Description | Data Type | Data Format |
|---|---|---|---|---|
| x1 | Input 1 | The input tensor x1 in the formula. | BFLOAT16, FLOAT16, FLOAT, INT32, INT64 | ND |
| x2 | Input 2 | The input tensor x2 in the formula. | BFLOAT16, FLOAT16, FLOAT, INT32, INT64 | ND |
| y | Output | The output tensor y in the formula. | BFLOAT16, FLOAT16, FLOAT, INT32, INT64 | ND |
- Atlas training products and Atlas inference products: BFLOAT16 is not supported.
Invocation Description
| Invocation Method | Invocation Sample | Description |
|---|---|---|
| Graph-mode invocation | test_geir_squared_difference | Invokes the SquaredDifference operator by building a graph through the operator IR. |