已合并
fix: enable double path for remainder scalar tensor #4018
zhang-song-rui创建于 7月13日
fix: enable double path for remainder scalar tensor #4018
已合并
从已删除 :master合入到cann/ops-mathmaster
Pull Request已成功合入, 合并人@CANN-robot
(感谢 zhang-song-rui 的贡献)7月13日 创建了 pull request,commit 490f7ea3
atomgit-bot
7月13日 评论:
7月13日 评论:
变更摘要
本次变更修复了 aclnnRemainderScalarTensorGetWorkspaceSize 函数中对标量-张量取余运算的一个条件限制:原先当 NPU 架构为 IsRegBase 且提升后的数据类型为 DT_DOUBLE 时,会跳过类型转换和连续化处理路径,导致 double 路径被错误排除。变更移除了对 DT_DOUBLE 的排除条件,使 double 类型也能正常进入该处理分支。
主要改动
- 移除 double 类型排除条件:在
aclnnRemainderScalarTensorGetWorkspaceSize中,将if (IsRegBase(npuArch) && PromoteTypeScalarV35(...) != op::DataType::DT_DOUBLE)简化为if (IsRegBase(npuArch)),使DT_DOUBLE类型的输入也能进入类型提升和Contiguous的转换路径,不再被错误跳过。


atomgit-bot
7月13日 评论:
7月13日 评论:
代码审查
经过仔细审查,该 diff 仅从 aclnnRemainderScalarTensorGetWorkspaceSize 函数中移除了 PromoteTypeScalarV35(...) != op::DataType::DT_DOUBLE 的守卫条件,以启用 Scalar-Tensor 场景下的 double 路径。变更本身逻辑清晰、改动最小:
PromoteTypeScalarV35是无副作用的纯函数,原有代码在条件判断和块内各调用一次(冗余),修改后仅调用一次,消除了冗余。DT_DOUBLE已在ASCEND910B_DTYPE_DTYPE_SUPPORT_LIST等支持列表中声明(第 38 行),参数校验层CheckPromoteTypeScalarTensor也未排除 double 类型,说明此路径的 double 支持已具备前置条件。else分支的行为不受影响,仅对非 RegBase 架构生效。
未发现由此 diff 引入的正确性、安全性、可靠性或破坏性变更问题。
审查总结:
- 已审查文件:
math/floor_mod/op_api/aclnn_remainder.cpp(无问题) - 发现数量:P0: 0, P1: 0, P2: 0, P3: 0
- 整体风险判断:低风险,变更安全。
| 类型 | 数量 |
|---|---|
| 🔴 阻塞 | 1 |
| 🟡 建议 | 0 |
⛔ 需要修改


7月13日 添加了label:cann-cla/yes
CANN-robot
7月13日 评论:
7月13日 评论:
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 |
|---|---|---|
| math/floor_mod | ✅ 宋恺, 王林木 (2/2) | ✅ 宋恺, 王林木 (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
zhang-song-rui, thanks for your pull request. All authors of the commits have signed the CLA. 👍


此处折叠了106条消息 查看更多
zhang-song-rui
7月18日 评论:
7月18日 评论:
7月18日 添加了label:lgtm
7月18日 关闭了关联的issue
7月18日 合入了pull request
描述
修复 Ascend 950(RegBase)上
aclnnRemainderScalarTensor在类型提升结果为DT_DOUBLE时的计算路径不一致问题。修改前,RegBase 分支显式排除了
DT_DOUBLE。当PromoteTypeScalarV35(other.dtype, self.dtype)推导为DT_DOUBLE时,接口会进入通用分支,并按out的数据类型提前转换输入后再执行取余;若out为较低精度类型,会导致计算在降精度后进行,与类型提升规则不一致,存在精度损失风险。本次修改移除 RegBase 分支对
DT_DOUBLE的排除,使 Scalar-Tensor 场景统一按以下流程执行:PromoteTypeScalarV35推导计算类型;other连续化并转换到推导类型,同时将self转换为同类型 Tensor;l0op::FloorMod完成计算;out的数据类型并写回。对于
DT_DOUBLE,l0op::FloorMod会通过AICPU_DTYPE_SUPPORT_LIST分发到FloorModAiCpu,不会进入 arch35 仅支持 FP16/BF16/FP32/INT32/INT64 的 AICORE tiling/kernel 路径。影响范围仅限 RegBase、非空 Tensor 的
aclnnRemainderScalarTensor;非 RegBase 路径、空 Tensor 快速返回、其他 remainder 接口及接口签名均不受影响。代码整改
关联的Issue
测试
Ascend 950 全量验证
26972d8;87cdb6a。验证结果:
promoted=DOUBLE && out!=DOUBLE场景,符合本次修改的影响范围;out类型,修复了 PRE 版本提前降精度导致的结果偏差;测试结论:通过。
新增 Ascend950 回归 UT
math/floor_mod/tests/ut/op_api/test_aclnn_remainder_scalar_tensor.cpp,文件名符合test_aclnn_*.cpp收集规则;NpuArch::DAV_3510,覆盖 scalar double2049.0、tensor int322、out float16 的关键场景;TMPDIR=/tmp TMP=/tmp TEMP=/tmp CCACHE_TEMPDIR=/tmp/ops-math-ccache bash build.sh -u --opapi --ops=floor_mod --gtest_filter='l2_remainder_scalar_tensor_ascend950_test.*' -j21 test from 1 test suite,1 PASSED;git diff --check。静态检查
DT_DOUBLE后端分发:确认由l0op::FloorMod进入 AICPU 路径,不依赖 arch35 AICORE double kernel。文档更新
无接口或用户文档变更。
类型标签