Pull Request已成功合入, 合并人@CANN-robot
(感谢 raoliang_sac 的贡献)变更摘要
本 PR 按照新的 golden 规范对 AddV2 和 TensorRedirect 两个算子进行改造。AddV2 移除了混精度(mixed-dtype)支持,仅保留同 dtype 组合,并新增空 Tensor 处理分支与溢出防护;TensorRedirect 新增完整的 TestSpec golden 与图推导支持,同时加强 Tiling 阶段的边界校验。两个算子的 golden 均从旧式 __golden__ 字典迁移到 __spec__ TestSpec 注册,并保留旧入口以兼容仓库现有调用方。
主要改动
-
AddV2移除混精度通路:删除add_v2_graph_infer.cpp中庞大的类型提升查找表kPromoteTypesLookup及PromoteType函数,改为仅校验x1/x2同 dtype;同时移除add_v2_binary.json中BFLOAT16_FLOAT32、FLOAT16_FLOAT32、FLOAT32_BFLOAT16、FLOAT32_FLOAT16四组混精度二进制配置,add_v2_def.cpp的 dtype 列表从 13 项精简为 9 项同类型组合。 -
AddV2新增空 Tensor 处理:在add_v2_struct_arch35.h新增AddV2EmptyTilingData结构体及userDef模板参数(0=常规,1=空 Tensor);add_v2_tiling_arch35.cpp新增HandleEmptyTensor()方法,当输出元素数为 0 时设置blockDim=1并走schMode=999的自定义分支,kernel 侧(add_v2.cpp)对应新增userDef==1的空返回路径。 -
AddV2golden 迁移至 TestSpec:math/add_v2/tests/assets/golden.py从手动 numpy/torch 混算重写为AddV2KernelSpec类,third_party声明torch.add,按 dtype 配置分精度标准(整数binary_equal、浮点cross_checkL1、complex64用stat_rel_err)。 -
TensorRedirect新增 TestSpec golden 与图推导:新增tensor_redirect_graph_infer.cpp实现InferDataType4TensorRedirect(从tensor_redirect_infershape.cpp拆分);新增golden.py,以torch.clone实现逐 bit 拷贝,覆盖全部 11 种 dtype 且均标记binary_equal精度标准,并注册__spec__入口。 -
Tiling 边界防护增强:
AddV2和TensorRedirect的 Tiling 均新增维度乘积溢出int64_t时的显式拦截(numel < 0检查);TensorRedirect额外新增逐维非负校验,防止-1/-2等动态占位符穿透到切分计算。


Thanks for your pull-request.
The full list of commands accepted by me can be found at here。
You can get sig-info at here
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| repo-cann/ops-math | ✅ 宋恺, 汤平川 (2/2) | ✅ 汤平川, 宋恺 (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
raoliang_sac, thanks for your pull request. All authors of the commits have signed the CLA. 👍


compile


流水线任务触发成功
任务链接 [aaff64e10a904c0eaccaac330ee12a49][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_experimental_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_harmony-infer | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_ARM_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_experimental_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_single_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_910b | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_910c | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_950 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_A5_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_A5_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station_9030_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_single | ✅ SUCCESS | >>>>> | >>>>> |
| UT_Test | ✅ SUCCESS | ||
| UT_Test_experimental | ✅ SUCCESS | ||
| UT_Test_kernel | ✅ SUCCESS | ||
| PreSmoke_A900 | ✅ SUCCESS | >>>>> | |
| API_Check | ✅ SUCCESS | >>>>> | |
| PreSmoke_ATK_Test_A2 | ✅ SUCCESS | >>>>> | |
| UT_Test_harmony-infer-chs-math | ✅ SUCCESS | ||
| UT_Test_harmony-infer-cpro-math | ✅ SUCCESS |
[2026-08-10 19:23:25] CI执行结束


流水线任务触发成功
任务链接 [2a28baa5b30a4e0dad09372e186b2993][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| SCA | ✅ SUCCESS | >>>>> | |
| antipoison | ✅ SUCCESS | >>>>> | |
| codecheck_Pr | ✅ SUCCESS | ||
| StaticCheck_codespell | ✅ SUCCESS | ||
| StaticCheck_link_validity | ✅ SUCCESS | ||
| StaticCheck_resource_existence | ✅ SUCCESS | ||
| StaticCheck_tag_closed | ✅ SUCCESS | ||
| StaticCheck_markdownlint | ✅ SUCCESS | ||
| codecheck_precommit | ✅ SUCCESS | >>>>> |
[2026-08-10 19:12:10] CI执行结束


@zhangzijie 子杰哥帮我加个分,我是饶亮


/lgtm
/approve


/approve


描述
按照新的golden规范更新AddV2和TensorRedirect:
add_v2入口,并配置PyTorch三方标杆和分dtype精度标准。torch.clone实现逐bit拷贝,并覆盖全部11种支持的数据类型。__golden__入口,与TestSpec共用同一计算实现。ACLNNTYPE aclnn_exclude配置保持一致。本PR描述仅体现上述golden修改;前置PR尚未合入产生的其他diff不属于本PR说明范围。
关联的Issue
#2559
测试
pre-commit全部检查通过。git diff --check通过。文档更新
不涉及文档更新。
类型标签