Pull Request已成功合入, 合并人@CANN-robot
(感谢 rk 的贡献)变更摘要
此 PR 主要对 batch_norm_v3 的 infer 内核和 rms_norm_grad 的 dgamma 计算进行了"还原内联写法"的重构:删除了中间层辅助函数模板 InferComputeImpl 和成员函数 ComputePreDgamma,将原本通过函数调用间接执行的 Queue 操作和 VFNormalize/VFCalcPreDgamma 调用直接展开到各 Compute 方法中,同时调整了相关成员函数的访问控制标签。
主要改动
-
移除
InferComputeImpl模板函数:在batch_norm_v3_regbase_common.h中删除了InferComputeImpl函数模板(-26 行),该函数原本封装了从 Queue 出队/入队、获取物理地址、调用VFNormalize的通用流程。 -
batch_norm_v3infer 三个内核的Compute方法内联化:在BatchNormV3InferLastChannelContinuousA、BatchNormV3InferLastChannelSmallA和BatchNormV3InferSmallAB1中,将原本对InferComputeImpl的调用替换为直接的内联实现,包括显式的DeQue/AllocTensor/GetPhyAddr/EnQue/FreeTensor调用及对VFNormalize的直接调用。 -
VFNormalize访问控制调整:在上述三个类中,将VFNormalize的可见性从public改为紧邻private:标签之前的默认(隐式public或 struct 默认)位置,同时相应移动了private:标签,使类结构更紧凑。 -
移除
ComputePreDgamma成员函数:在rms_norm_grad_regbase_dgamma.h中删除了ComputePreDgamma函数,将其内部逻辑(出队获取物理地址、调用VFCalcPreDgamma、释放 tensor)分别内联到CalcDgamma以及两个Compute循环分支中。 -
CalcDgamma和Compute循环体的内联展开:在CalcDgamma和两处Compute循环体内,将原来调用ComputePreDgamma+ 获取dgammaOutAddr的间接方式,替换为直接进行EnQue/DeQue/GetPhyAddr/VFCalcPreDgamma/FreeTensor的完整序列,消除了一层函数间接调用。


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


流水线任务触发成功
任务链接 [c0f191f08c94415ab83e286d0c81ae0b][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| 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-07-30 17:04:14] CI执行结束


流水线任务触发成功
任务链接 [f77c7dfb530e4721a280b9ef4acc99b4][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| 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-07-30 16:50:22] CI执行结束


/lgtm
/approve


/approve


描述
将 batch_norm_v3 三个 infer 变体(
InferLastChannelContinuousA、InferLastChannelSmallA、InferSmallAB1)的Compute方法与 rms_norm_grad 的CalcDgamma计算路径由 helper 间接调用改回内联实现,去掉InferComputeImpl、ComputePreDgamma两个间接层,使 arch35 设备侧计算路径更直观。改动原因
此前 infer Compute 统一通过
InferComputeImpl模板函数间接调用VFNormalize,rms_norm_grad dgamma 通过ComputePreDgamma间接组装 EnQue/DeQue/计算/Free 流程。间接层增加了阅读成本:调用点看不到实际的数据搬运与计算顺序,需跳转 helper 才能理解设备侧行为。改动方法
Compute内联 DeQue → AllocTensor → Get → GetPhyAddr →VFNormalize→ EnQue → FreeTensor 全流程,删除对InferComputeImpl的调用;同时移除为暴露VFNormalize而插入的public:/private:访问控制切换,恢复为类内私有方法。InferComputeImpl模板函数(-26 行)。ComputePreDgamma方法,将其逻辑(EnQue/DeQue/GetPhyAddr/VFCalcPreDgamma/FreeTensor)内联到CalcDgamma及两处循环调用点;dgammaOutAddr由输出参数改为局部变量。不改变计算逻辑、计算顺序与内存分配顺序。
关联的Issue
测试
pass
文档更新
无。
类型标签
AI/Agent生成声明