Merged
fix issue #13356
liuyun_njAdd on 20 days ago
fix issue #13356
Merged
Merged fromliuyun_nj/ops-nn_1masterintocann/ops-nnmaster
Pull Request has been successfully merged by CANN-robot.
(Thank you for liuyun_nj's contribution.)atomgit-bot
20 days ago Comments:
20 days ago Comments:
变更摘要
本次变更聚焦 AddLayerNorm、RmsNorm 与 RmsNormQuant 三个算子的 tiling 与 aclnn 接口校验逻辑,属于缺陷修复类改动。核心是修正 UB 空间预算中 gamma/beta/bias 常驻参数被重复计入双缓冲导致的 UB 占用估算偏差,补齐非 regbase 平台下 rstd 元素数与归一化行数的校验以避免越界写,并统一 aclnnRmsNormQuant 的 shape 校验与错误信息、调整 INT4 输出打包条件及空 Tensor 的成功空转行为。
主要改动
AddLayerNormtiling 中权重缓冲区不再乘bufferNum:add_layer_norm_tiling.cpp中betaGammaBufSize、biasBufSize、ubCacheSize、singleRowBufSize、ubConstSlice、ubColNumSlice等公式均去掉* bufferNum,并在注释中说明gamma/beta/bias为常驻参数、只在Process()起始处加载一次并全核复用,不参与CopyIn->Compute->CopyOut轮转。RmsNorm增加非 regbase 平台的rstd元素数校验:在CheckInputShape4RmsNorm中,当 shape 全部已知时校验rstd元素数等于归一化行数x.numel / gamma.numel,不满足则通过OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON报错返回失败,防止内核按行写rstd造成越界写。aclnnRmsNormQuant的 scale 校验与错误码表达统一:将scale维度/长度及x、y形状相关的OP_LOGE替换为OP_LOGE_FOR_INVALID_SHAPEDIM、OP_LOGE_FOR_INVALID_SHAPEDIM_WITH_REASON等结构化错误宏,并把scaleLength的取值移入各平台分支内部。x/y前置维度一致性校验扩展到所有平台:DT_INT32输出分支中CheckShapeDimWithFrontN不再仅在 regbase 生效;非INT32分支也新增了对x、y前置 n 维一致性的校验,不一致时报 "x shape should be the same as y shape"。INT4打包条件收紧与非 regbase 空 Tensor 空转:Int42Int32PackedTensor仅在yType == DT_INT4且y的 dtype 为DT_INT32时执行;非 regbase 路径在CheckParams通过后若x->IsEmpty(),直接返回workspaceSize = 0与ACLNN_SUCCESS,不进入第二段计算。相应 UT 用例被替换为scale非法、x/y前置维不匹配及空 Tensor 成功返回等新场景。
🧩 本次 Review 已使用自定义 Skill:


Incorrect?
atomgit-bot
20 days ago Comments:
20 days ago Comments:


Incorrect?
20 days ago Added label: cann-cla/yes
CANN-robot
20 days ago Comments:
20 days ago Comments:
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 |
|---|---|---|
| */*/docs/acl*.md | ✅ 杜慧萍, 冯英, 陈昊文, 刘杰 (4/2) | ✅ 冯英, 杜慧萍 (2/1) |
| norm | ✅ 陈昊文, 刘杰 (2/2) | ✅ 陈昊文, 刘杰 (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
liuyun_nj, thanks for your pull request. All authors of the commits have signed the CLA. 👍


64 messages are collapsed here。 See more
18 days ago Added label: approved
liujie12345678
17 days ago Comments:
17 days ago Comments:
/approve
/lgtm


17 days ago Added label: lgtm
17 days ago Closed associated issue
17 days ago Merged pull request
描述
批量修复issue,主要改动点:
AddLayerNorm tiling 中权重缓冲区不再乘 bufferNum:add_layer_norm_tiling.cpp 中 betaGammaBufSize、biasBufSize、ubCacheSize、singleRowBufSize、ubConstSlice、ubColNumSlice 等公式均去掉 * bufferNum,并在注释中说明 gamma/beta/bias 为常驻参数、只在 Process() 起始处加载一次并全核复用,不参与 CopyIn->Compute->CopyOut 轮转。
RmsNorm 增加非 regbase 平台的 rstd 元素数校验:在 CheckInputShape4RmsNorm 中,当 shape 全部已知时校验 rstd 元素数等于归一化行数 x.numel / gamma.numel,不满足则通过 OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON 报错返回失败,防止内核按行写 rstd 造成越界写。
aclnnRmsNormQuant 的 scale 校验与错误码表达统一:将 scale 维度/长度及 x、y 形状相关的 OP_LOGE 替换为 OP_LOGE_FOR_INVALID_SHAPEDIM、OP_LOGE_FOR_INVALID_SHAPEDIM_WITH_REASON 等结构化错误宏,并把 scaleLength 的取值移入各平台分支内部。
x/y 前置维度一致性校验扩展到所有平台:DT_INT32 输出分支中 CheckShapeDimWithFrontN 不再仅在 regbase 生效;非 INT32 分支也新增了对 x、y 前置 n 维一致性的校验,不一致时报 "x shape should be the same as y shape"。
INT4 打包条件收紧与非 regbase 空 Tensor 空转:Int42Int32PackedTensor 仅在 yType == DT_INT4 且 y 的 dtype 为 DT_INT32 时执行;非 regbase 路径在 CheckParams 通过后若 x->IsEmpty(),直接返回 workspaceSize = 0 与 ACLNN_SUCCESS,不进入第二段计算。相应 UT 用例被替换为 scale 非法、x/y 前置维不匹配及空 Tensor 成功返回等新场景。
关联的Issue
#7400 #7401 #7402 #7403 #7333 #7213 #7348 #7405
测试
文档更新
aclnnGemmaRmsNorm.md
aclnnGroupNorm.md
aclnnRmsNormQuant.md
类型标签
AI/Agent生成声明