Pull Request已成功合入, 合并人@CANN-robot
(感谢 yulianjie 的贡献)变更摘要
此 PR 主要修复 softsign 算子在低精度(FP16/BF16)下的数值精度问题,并增加空 tensor 的防护。精度修复的核心是将 (abs(x) + 1) 的计算结果先显式窄化到原始低精度 dtype,再拓宽回 FP32 做除法,以对齐 TensorFlow 的原 dtype 计算语义。同时引入 GraphSoftsignByDtype 和 GraphSoftsignLowPrecision 模板结构,按 dtype 分派不同的 DAG 计算流程,并替换了 tiling 层和 kernel 层中的模板参数引用。此外在 kernel 入口处增加了 blockNum == 0 的提前返回,避免空 tensor 场景下的异常。
主要改动
- 低精度分母精度修复:在
softsign_dag.h中新增GraphSoftsignLowPrecision模板,在Abs → Adds(+1)之后插入CastDenomOut(FP32→原 dtype)和CastDenomIn(原 dtype→FP32),使分母(abs(x)+1)先舍入到原低精度再参与除法,对齐 TensorFlow 语义 - Dtype 分发重构:新增
GraphSoftsignByDtype模板(对float做特化沿用原有GraphSoftsign路径,其余类型走GraphSoftsignLowPrecision),并将 tiling 层softsign_tiling_arch35.cpp和 kernel 层softsign.cpp中的模板参数从GraphSoftsign<InputT, float>替换为GraphSoftsignByDtype<InputT> - 空 tensor 防护:在
softsign.cpp的 kernel 函数中增加tilingData.baseTiling.blockNum == 0判断,为空 tensor 场景提前return,避免后续调度异常


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 |
|---|---|---|
| activation | ✅ 王星, 唐玮玮 (2/2) | ✅ 王星 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
lianjieyu, thanks for your pull request. All authors of the commits have signed the CLA. 👍


流水线任务触发成功
任务链接 [bb1a3445a8c7445197dbf7c272460315][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| Compile_Ascend_X86_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_single | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_experimental | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_950 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_950 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Pre | ✅ SUCCESS | >>>>> | |
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_950_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_single_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_experimental_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_950_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_910b | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_910c | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_950 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_classify | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86_mobile_station_9030_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| UT_Test_ophost | ✅ SUCCESS | ||
| UT_Test_opapi | ✅ SUCCESS | ||
| UT_Test_kernel | ✅ SUCCESS | ||
| UT_Test_opgraph | ✅ SUCCESS | ||
| PreSmoke_A900 | ✅ SUCCESS | >>>>> | |
| API_Check | ✅ SUCCESS | >>>>> | |
| PreSmoke_ATK_Test_A2 | ✅ SUCCESS | >>>>> | |
| UT_Test_harmony-infer-chs-nn | ✅ SUCCESS | ||
| UT_Test_harmony-infer-chs-nn-1 | ✅ SUCCESS | ||
| UT_Test_harmony-infer-cpro-nn | ✅ SUCCESS | ||
| UT_Test_report_lcov | ✅ SUCCESS | >>>>> |
[2026-08-10 16:39:38] CI执行结束


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


/reject


| Time | Name | Result | Changeid | TimeStamp |
|---|---|---|---|---|
| 2026-08-10 16:52:08 | Start_Pipeline | MR_389 |


| Time | Name | Result | Changeid | TimeStamp |
|---|---|---|---|---|
| 2026-08-10 16:54:58 | Sync_PR | :white_check_mark: 成功 | I2e53a687aafe3704f909e585c9a606d72b8e693c |


| Time | Name | Result | Changeid | TimeStamp |
|---|---|---|---|---|
| 2026-08-10 16:55:20 | Trigger_SC | :white_check_mark: 触发成功 | I2e53a687aafe3704f909e585c9a606d72b8e693c | 20260810_165953776 |


| Time | Name | Result | Changeid | TimeStamp |
|---|---|---|---|---|
| 2026-08-10 17:21:48 | SC_Result | :x: 失败 | I2e53a687aafe3704f909e585c9a606d72b8e693c |


| Time | Name | Result | Changeid | TimeStamp |
|---|---|---|---|---|
| 2026-08-10 17:23:15 | CMETRICS | :white_check_mark: 成功 | I2e53a687aafe3704f909e585c9a606d72b8e693c |


| Time | Name | Result | Changeid | TimeStamp |
|---|---|---|---|---|
| 2026-08-10 17:23:37 | Trigger_RDV | :white_check_mark: 触发成功 | I2e53a687aafe3704f909e585c9a606d72b8e693c | 20260810_172810601 |


/lgtm


流水线任务触发成功
任务链接 [a8a52283b7bb4e53adcb7661bb2e6f1e][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| Compile_Ascend_X86_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_single | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_experimental | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_950 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_950 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Pre | ✅ SUCCESS | >>>>> | |
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_950_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_single_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_experimental_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_950_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_910b | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_910c | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_950 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_classify | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86_mobile_station_9030_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| UT_Test_ophost | ✅ SUCCESS | ||
| UT_Test_opapi | ✅ SUCCESS | ||
| UT_Test_kernel | ✅ SUCCESS | ||
| UT_Test_opgraph | ✅ SUCCESS | ||
| PreSmoke_A900 | ✅ SUCCESS | >>>>> | |
| API_Check | ✅ SUCCESS | >>>>> | |
| PreSmoke_ATK_Test_A2 | ✅ SUCCESS | >>>>> | |
| UT_Test_harmony-infer-chs-nn | ✅ SUCCESS | ||
| UT_Test_harmony-infer-chs-nn-1 | ✅ SUCCESS | ||
| UT_Test_harmony-infer-cpro-nn | ✅ SUCCESS | ||
| UT_Test_report_lcov | ✅ SUCCESS | >>>>> |
[2026-08-11 15:37:26] CI执行结束


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


| Time | Name | Result | Changeid | TimeStamp | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2026-08-11 17:24:07 | commit | 2026-08-10T15:38:28+08:00 | b967b529 | ||||||||||||
| SC_Result | :x: FAILURE | I2e53a68 | |||||||||||||
| RDV_Result | :x: RUNNING | I2e53a68 | |||||||||||||
|


/lgtm
/approve


描述
修复 Ascend950 Softsign 的低精度计算和空 Tensor kernel 直调问题,使实现逻辑与 TensorFlow
tf.nn.softsign对齐。问题原因
abs(x) + 1和除法,直到最终输出才回落到原 dtype,缺少 TensorFlow 低精度路径中的中间舍入。blockNum为 0,但 Kernel 仍进入ElementwiseSch,导致无有效任务时停留在动态性能采集阶段。修改内容
GraphSoftsignLowPrecision:FP16/BF16 在abs(x) + 1后显式窄化回输入 dtype,再拓宽进行除法,保留 TensorFlow 对应的舍入点。GraphSoftsignByDtype:FP32 继续使用原计算图,FP16/BF16 使用低精度对齐计算图。tilingData.baseTiling.blockNum == 0时直接返回,避免空 Tensor 进入 Elementwise 调度。本 PR 共修改 3 个文件,新增 44 行、删除 8 行;FP32 计算路径保持不变。
关联的Issue
关联 Issue #4673
测试
bash build.sh --ops=softsign --soc=ascend950 --opkernel -j8bash build.sh --ops=softsign --soc=ascend950 --pkg -j8tf.nn.softsign;BF16 直接使用tf.bfloat16计算。--compare close:500/500 PASS,无失败、无跳过。(0,)专项:FP32/FP16/BF16 3/3 PASS,输出 shape/dtype 保持不变,kernel 正常结束。文档更新
softsign_dag.h中 FP16/BF16 数据流和 TensorFlow 舍入语义说明。类型标签
AI/Agent生成声明