已合并
fix: validate RemainderScalarTensor compute dtype on regbase #5519
fix: validate RemainderScalarTensor compute dtype on regbase #5519
已合并
hahaha22创建于 7 天前
hahaha22成员
7 天前

描述

修复 aclnnRemainderScalarTensor 在 950/Regbase 上未校验实际计算类型的问题。例如 INT64 scalar 与 INT8 tensor 搭配 INT32 out 时,类型推导得到 INT8;原检查仅验证向 out 的转换关系及 out 类型白名单,导致 INT8 输入进入 FloorMod 内核选择阶段,报 Cannot find binary。

参考同文件 CheckPromoteTypeTensorScalar 的检查方式,在保留原有检查顺序的基础上,为 Regbase 增加 castDtype 白名单校验。非法组合在 GetWorkspaceSize 阶段返回 ACLNN_ERR_PARAM_INVALID(161002),日志明确指出 self、other 和推导后的计算类型。

行为边界

  • 非 Regbase 先按 out 类型转换输入,其原有路径保持不变。
  • FLOAT32 scalar 与 INT8 tensor 推导为 FLOAT32,继续支持;复用完整 API 白名单,保留 DOUBLE 路径。
  • 检查先于空 Tensor 快速返回:非法计算类型的空 Tensor 现在也返回参数错误;合法空 Tensor 仍成功且 workspace 为 0。

关联的Issue

暂无 Issue 链接。对应 error_log_compliance_report.xlsx 中该接口的 D 类第 8 行(计算类型漏检)。

测试

bash build.sh -u --opapi --ops=floor_mod --soc=ascend950 --gtest_filter='*remainder_scalar_tensor*' -j8

8 个 ACLNN UT 全部通过,包含原有 1 个用例及新增 7 个用例,覆盖:

  • INT8/UINT8/INT16 计算类型搭配 INT32/FLOAT32 out,校验返回 161002。
  • 浮点 scalar 提升 INT8 tensor、非 Regbase INT8 输入转 INT64 输出。
  • INT32/INT64/FLOAT16/FLOAT/DOUBLE/BFLOAT16 六种支持类型。
  • 合法和非法计算类型的空 Tensor、非法 out 类型。

git diff --check 通过。

上述 UT 在修复移植到 master 基线前执行;移植后核对目标文件内容一致,随后仅恢复了原有 out 报错格式串,该格式恢复未重新运行 UT。UT 使用平台 mock,修复后版本尚未部署到 CANN 进行 TTK 真机测试。

文档更新

无。

类型标签

AI/Agent生成声明

关联issue

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 hahaha22 的贡献)
Hhahaha22成员
7 天前 创建了 pull request,commit 598f9031
atomgit-bot
atomgit-bot
7 天前 评论:

变更摘要

该 PR 修复 aclnnRemainderScalarTensor 在 RegBase(950)场景下未校验实际计算类型的问题:此前类型推导得到 INT8 等非法计算类型时会进入 FloorMod 内核选择阶段并报 Cannot find binary。本次在 CheckPromoteTypeScalarTensor 中,于原有检查顺序之后为 RegBase 增加 castDtype 白名单校验(DTYPE_SUPPORT_LIST),非法组合在 GetWorkspaceSize 阶段即返回 ACLNN_ERR_PARAM_INVALID(161002),日志明确输出 self、other 及推导后的计算类型;非 RegBase 平台保持原有先按 out 类型转换输入的路径不变。

主要改动

  • RegBase 计算类型白名单校验:在 aclnn_remainder.cppCheckPromoteTypeScalarTensor 中新增 IsRegBase(npuArch) && !CheckType(castDtype, DTYPE_SUPPORT_LIST) 分支,非法 castDtype 直接返回 false,并记录 selfother 与推导计算类型的错误日志,使非法 dtype 在校验阶段即被拦截。
  • 原有检查顺序与路径保留:新增校验置于原有注释约束(无 complex、可 cast 至 outDtypeoutDtype 受支持)之后,非 RegBase 平台仍按 out 类型转换输入,行为不受影响。
  • 新增 7 个 UT 用例:在 test_aclnn_remainder_scalar_tensor.cpp 中覆盖 INT8/UINT8/INT16 计算类型搭配 INT32/FLOAT out 返回 161002、FLOAT32 scalar 提升 INT8 tensor 成功、非 RegBase 下 INT8 输入转 INT64 输出成功、合法与非法计算类型的空 Tensor(非法返回 161002、合法成功且 workspace 为 0)、INT32/INT64/FLOAT16/FLOAT/DOUBLE/BFLOAT16 六种支持类型及非法 out 类型。
likedislike
不准确?
atomgit-bot
atomgit-bot
7 天前 评论:

代码审查

✅ 未发现问题

likedislike
不准确?
CANN-robotCANN-robot成员
7 天前 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
7 天前 评论:

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.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.


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 /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

hahaha22, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
CANN-robot
CANN-robot成员
7 天前 评论:

CLA Signature Pass

hahaha22, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
CANN-robotCANN-robot成员
7 天前 将FelixTang7,yue-ma,zhou-qilong,wangrui_,rxtfeng,loov1,zhangzijie,jia0liang,zl_hw,songkai111,chenxingyu18,pingchuantang,llimwang,gubaocheng,andong_hw,xuejinghui,zhanw_coding设为评审人
此处折叠了7条事件消息 查看更多
CANN-robotCANN-robot成员
7 天前 添加了label:cann-cla/yes
hahaha22成员
7 天前 评论:

compile

likedislike
Hhahaha22成员
7 天前 预合并成功(commit_id: e94c075ed2226202c4610c74af7ac3a2ca5ee253)
CANN-robot
CANN-robot成员
7 天前 评论:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robot成员
7 天前 添加了label:ci-pipeline-running
CANN-robotCANN-robot成员
7 天前 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
7 天前 添加了label:ci-pipeline-passed
hahaha22成员7 天前进行代码检视2
math/floor_mod/op_api/aclnn_remainder.cpp
已过期
@@ -232,3 +232,3 @@
232232}
233233 
234-// 1. self和other没有complex 2. other能cast成outDtype 3. outDtype为算子支持的数据类型
234+// 1. No complex inputs. 2. castDtype can cast to outDtype.
hahaha227 天前评论:

这条注释改成了英文,但同文件里 CheckPromoteType(172 行)、CheckPromoteTypeTensorScalar(201 行)的同类注释还是中文,同一文件里两种语言混着,后续维护容易越来越乱,建议统一成一种。

likedislike
System
系统消息系统
6 天前 评论:

changed this line on f67dc28b view diff detail

Hhahaha22成员
7 天前 修改了pull request 的描述
Hhahaha22成员
6 天前 修改了pull request 的描述
Hhahaha22成员
6 天前 关联了issue:[Bug-Report|缺陷反馈]: 算子报错日志dtype支持列表双层中括号[[..]]及Pow/MaxN/IsIn资料dtype列表与代码不一致
Hhahaha22成员
6 天前 解决了最后一个问题
sunchun成员
6 天前 评论:

您好,PR已满足合入指标,请尽快联系Committer进行合入。如暂时不需要合入,请在PR标题前加[WIP]

likedislike
Hhahaha22成员
6 天前 预合并成功(commit_id: ff2001c41c344601b9db71ee543d2957ee7c6e35)
Hhahaha22成员
6 天前 强制推送  1 个提交:f67dc28b-fix: validate RemainderScalarTensor compute dtype on regbase
Hhahaha22成员
6 天前 预合并成功(commit_id: 5185c1b7aa8a14225055da7835a32f7fd07b0f53)
CANN-robotCANN-robot成员
6 天前 删除了label:cann-cla/yes
CANN-robotCANN-robot成员
6 天前 删除了label:ci-pipeline-passed
CANN-robot
CANN-robot成员
6 天前 评论:

Notification

This pull request has been changed(code update) or closed, so removes the following label(s): ci-pipeline-passed.

likedislike
CANN-robotCANN-robot成员
6 天前 添加了label:cann-cla/yes
hahaha22成员
6 天前 评论:

compile

likedislike
Hhahaha22成员
6 天前 预合并成功(commit_id: 37b1f6f17394d710b5de029367c9ee3c6a2bfa11)
CANN-robot
CANN-robot成员
6 天前 评论:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robot成员
6 天前 添加了label:ci-pipeline-running
CANN-robotCANN-robot成员
6 天前 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
6 天前 添加了label:ci-pipeline-passed
songkai111成员
6 天前 评论:

/approve

likedislike
CANN-robotCANN-robot成员
6 天前 添加了label:approved
hahaha22成员
6 天前 评论:
likedislike
RuiWang_成员
6 天前 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
6 天前 添加了label:lgtm
CANN-robotCANN-robot成员
6 天前 合入了pull request