已合并
refactor: 算子 tiling 报错日志整改 #6677
陈思创建于 6月27日
refactor: 算子 tiling 报错日志整改 #6677
已合并
陈思创建于 6月27日
陈思
陈思
6月27日

描述

对 conv / foreach / norm / quant 共 8 个算子 host 侧 tiling 代码中的 OP_LOGE(...) 报错日志进行整改,统一替换为按错误类型分类的 OP_LOGE_FOR_INVALID_*_WITH_REASON 系列宏,使报错信息携带参数名、实际值与原因描述,符合 op_loge 日志规范。

涉及的算子与文件:

  • conv/deformable_offsets(arch35):deformable_offsets_tiling_arch35.cpp
  • conv/deformable_offsets_grad(arch35):deformable_offsets_grad_tiling_arch35.cpp
  • foreach/foreach_non_finite_check_and_unscale:foreach_non_finite_check_and_unscale_tiling.cpp
  • norm/group_norm_grad:group_norm_grad_tiling.cpp
  • norm/group_norm_silu(arch35):group_norm_silu_tiling_arch35.cpp
  • norm/group_norm_v2(arch35):group_norm_v2_tiling_arch35.cpp
  • quant/dequant_swiglu_quant:dequant_swiglu_quant_tiling.cpp
  • quant/dequant_swiglu_quant(arch35):dequant_swiglu_quant_tiling_arch35.cpp

按错误类型采用的分类宏:

  • OP_LOGE_FOR_INVALID_VALUE_WITH_REASON / OP_LOGE_FOR_INVALID_VALUES_WITH_REASON:单值/多值非法(如 deformable_groups、quant_offset、group_index 维度、speGroupType)
  • OP_LOGE_FOR_INVALID_DTYPE_WITH_REASON / OP_LOGE_FOR_INVALID_DTYPES_WITH_REASON:dtype / dtype 组合非法(如 x、gamma、beta)
  • OP_LOGE_FOR_INVALID_SHAPESIZE_WITH_REASON / OP_LOGE_FOR_INVALID_SHAPESIZES_WITH_REASON:shape size 非法(如 scaled_grads 空 tensor、quant_scale 与 quant_offset size 不一致)
  • OP_LOGE_FOR_INVALID_SHAPEDIM / OP_LOGE_FOR_INVALID_SHAPEDIM_WITH_REASON:shape 维度数非法(如 group_index 仅支持 1D、scale 维度需比 y 少 1)
  • OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON:shape 非法(如 weight_scale、quant_scale、quant_offset、scale 与 y 的形状约束)

整改后每条报错均明确给出:参数名(如 strides、deformable_groups、quant_scale)、actual 值、以及符合报错规范的原因描述(reason);控制流与返回值未改动。

关联的Issue

https://gitcode.com/cann/ops-nn/issues/3631

测试

  • 全量编译通过:各算子 host tiling 工程编译无新增告警/报错。
  • 报错触发路径保持不变:仅日志格式由通用 OP_LOGE 升级为分类宏,校验逻辑与返回值未改动。
  • 报错字段顺序与平台 op_loge 规范一致:node → param_name → actual_value → reason。

文档更新

无(仅 host 侧 tiling 代码改动,不涉及对外接口或 README 变更)。

类型标签

AI/Agent生成声明

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 陈思 的贡献)
陈思陈思
6月27日 创建了 pull request,commit febdf451
CANN-robotCANN-robot成员
6月27日 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
6月27日 评论:

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
conv ✅ 陈琦, 杨阳 (2/2) ✅ 陈琦 (1/1)
foreach ✅ 陈琦, 杨阳 (2/2) ✅ 陈琦 (1/1)
norm ✅ 陈琦, 杨阳 (2/2) ✅ 陈琦 (1/1)
quant ✅ 杨阳, 陈琦 (2/2) ✅ 陈琦 (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

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

likedislike
陈思陈思
6月27日 修改标题为 “refactor: 算子 tiling 报错日志改用 OP_LOGE_FOR_INVALID_*_WITH_REASON 分类宏”,原标题为“op_loge日志整改”
陈思陈思
6月27日 修改了pull request 的描述
atomgit-bot
atomgit-bot
6月27日 评论:

变更摘要

此 PR 对多个算子 Tiling 层中 OP_LOGE 日志调用进行了统一整改,将原来含义模糊、信息不足的通用日志宏替换为一系列携带参数名、实际值及原因说明的专用日志宏(如 OP_LOGE_FOR_INVALID_VALUES_WITH_REASON、OP_LOGE_FOR_INVALID_DTYPE_WITH_REASON、OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON 等),使参数校验失败时的错误信息更加明确、可定位,便于快速排查输入参数问题。

主要改动

  • 使用 OP_LOGE_FOR_INVALID_VALUES_WITH_REASON 替代通用日志:在 deformable_offsets_tiling_arch35.cpp 中,strides 参数校验失败时,从仅提示 "StrideH not equal to 0" 改为输出完整的 strides 四元组值以及 H/W 维度在不同格式下的位置说明;在 dequant_swiglu_quant_tiling.cpp 中,speGroupType_ 与 bias/swiglu 模式冲突时输出当前值和约束条件。

  • 使用 OP_LOGE_FOR_INVALID_DTYPE(S)_WITH_REASON 替代通用日志:在 group_norm_grad_tiling.cpp 和 group_norm_v2_tiling_arch35.cpp 中,dtype 大小校验和 dtype 组合校验失败时,增加了具体 dtype 名称及序列化字符串;在 group_norm_silu_tiling_arch35.cpp 中同样对 gamma/beta 的 dtype 检查增加了 x, gamma / x, beta 的具体 dtype 信息。

  • 使用 OP_LOGE_FOR_INVALID_SHAPE(SIZE|DIM)_WITH_REASON 替代通用日志:在 foreach_non_finite_check_and_unscale_tiling.cpp 中 empty tensor 校验增加具体参数名和当前 shape size;在 dequant_swiglu_quant_tiling.cpp 和 dequant_swiglu_quant_tiling_arch35.cpp 中多处 shape 维度、尺寸校验改为携带参数名、实际 shape 字符串及明确约束描述。

  • 修复 group_norm_silu_tiling_arch35.cpp 中的接口误用:在 CheckGammaAndBetaParams 的 beta dtype 校验分支中,将原本错误调用的 context->GetNodeType() 修正为 context->GetNodeName(),确保日志输出节点名而非类型名。

  • 使用 OP_LOGE_FOR_INVALID_VALUE_WITH_REASON 替代通用日志:在 deformable_offsets_grad_tiling_arch35.cpp 中,deformable_groups 校验失败时增加实际值输出;在 dequant_swiglu_quant_tiling.cpp 中,quant_offset 不允许存在和 quant_scale 必须存在等场景也改为携带参数名和实际值/期望值。

likedislike
不准确?
atomgit-bot
atomgit-bot
6月27日 评论:

代码审查

Closing Summary

共审查 8 个变更文件,发现 3 个 P3 问题,无 P0/P1/P2 问题。

文件 审查结果
conv/deformable_offsets/op_host/arch35/deformable_offsets_tiling_arch35.cpp 无问题
conv/deformable_offsets_grad/op_host/arch35/deformable_offsets_grad_tiling_arch35.cpp 无问题
foreach/foreach_non_finite_check_and_unscale/op_host/foreach_non_finite_check_and_unscale_tiling.cpp 无问题
norm/group_norm_grad/op_host/group_norm_grad_tiling.cpp 无问题
norm/group_norm_silu/op_host/group_norm_silu_tiling_arch35.cpp 无问题(顺带修复了原代码 GetNodeType → GetNodeName 的 bug)
norm/group_norm_v2/op_host/arch35/group_norm_v2_tiling_arch35.cpp 无问题
quant/dequant_swiglu_quant/op_host/dequant_swiglu_quant_tiling.cpp 2 个 P3:speGroupType_ 三元表达式死代码
quant/dequant_swiglu_quant/op_host/dequant_swiglu_quant_tiling_arch35.cpp 1 个 P3:CheckOutputScale 逐维校验丢失维度索引

P3 问题清单:

  1. dequant_swiglu_quant_tiling.cpp:484 — speGroupType_ ? "2D" : "1D" 中的 : "1D" 分支死代码(恒为 true 时求值)
  2. dequant_swiglu_quant_tiling.cpp:493 — 同上第二处相同死代码
  3. dequant_swiglu_quant_tiling_arch35.cpp:662-664 — 逐维度 shape 校验日志丢失具体维度索引 i

整体风险评估:低风险。本次改动符合 PR 目标(将 OP_LOGE 替换为 OP_LOGE_FOR_INVALID_* 族标准化宏),无逻辑错误、无安全漏洞、无可靠性回归。3 个 P3 问题均为细微代码质量/诊断精度问题,不影响正确性和运行时行为。

⚠️ 已识别出整体风险,但无法提取行内评论,请参考整体评估。

likedislike
不准确?
陈思陈思
6月27日 预合并成功(commit_id: 1a6acf77a1906e2e7d7e7d9133587acf37a7ce0b)
此处折叠了14条事件消息 查看更多
陈思陈思
6月29日 预合并成功(commit_id: 5c13466deaab788c9e385f5761777faedb9b9923)
陈思
陈思
6月29日 评论:

compile

likedislike
陈思陈思
6月29日 预合并成功(commit_id: 44384e20bd03746a91567a6db17a2ad5fc155ae9)
CANN-robotCANN-robot成员
6月29日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
6月29日 评论:

流水线任务触发成功
任务链接 [63430ea228ee4d9b83fc32077f08cfc8][流水线指导]

任务名称状态日志下载链接
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 >>>>>
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_report_lcov ⚠️ WARNING >>>>>

[2026-06-29 15:01:49]    CI执行结束

likedislike
CANN-robot
CANN-robot成员
6月29日 评论:

流水线任务触发成功
任务链接 [ad01e45eb30d428db45ce84345d2c931][流水线指导]

任务名称状态日志下载链接
codecheck ❌ FAILED >>>>>
antipoison ✅ SUCCESS >>>>>
codecheck_checkpr ✅ SUCCESS
StaticCheck_codespell_check ✅ SUCCESS
StaticCheck_link_validity_check ✅ SUCCESS
StaticCheck_resource_existence_check ✅ SUCCESS
StaticCheck_tag_closed_check ✅ SUCCESS
StaticCheck_markdownlint ✅ SUCCESS
codecheck_style ✅ SUCCESS >>>>>
codecheck_precommit ⚠️ WARNING >>>>> >>>>>
SCA ✅ SUCCESS >>>>>
likedislike
陈思陈思
6月29日 预合并成功(commit_id: 2c8c826d8f1893066f6f29ee2604e401a99a7ef6)
陈思陈思
6月29日 强制推送  1 个提交:900f836e-op_loge日志整改
陈思陈思
6月29日 预合并成功(commit_id: 32ddcfcd0a5c40b7284bf52fb5e177cc47b16596)
CANN-robotCANN-robot成员
6月29日 添加了label:api-check-pass
CANN-robotCANN-robot成员
6月29日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
6月29日 添加了label:ci-pipeline-failed
陈思
陈思
6月29日 评论:

compile

likedislike
陈思陈思
6月29日 预合并成功(commit_id: 975949d1726783fe6bf2e9c159f09c737526b726)
CANN-robotCANN-robot成员
6月29日 删除了label:ci-pipeline-failedapi-check-pass
CANN-robotCANN-robot成员
6月29日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
6月29日 评论:

流水线任务触发成功
任务链接 [58de8e50dff449dca18f53eac2f35446][流水线指导]

任务名称状态日志下载链接
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 >>>>>
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_report_lcov ⚠️ WARNING >>>>>

[2026-06-29 15:23:55]    CI执行结束

likedislike
CANN-robot
CANN-robot成员
6月29日 评论:

流水线任务触发成功
任务链接 [67b0970d7fff4b6a8e23ba49411d61fa][流水线指导]

任务名称状态日志下载链接
codecheck ✅ SUCCESS >>>>>
antipoison ✅ SUCCESS >>>>>
codecheck_checkpr ✅ SUCCESS
StaticCheck_codespell_check ✅ SUCCESS
StaticCheck_link_validity_check ✅ SUCCESS
StaticCheck_resource_existence_check ✅ SUCCESS
StaticCheck_tag_closed_check ✅ SUCCESS
StaticCheck_markdownlint ✅ SUCCESS
codecheck_style ✅ SUCCESS >>>>>
codecheck_precommit ⚠️ WARNING >>>>> >>>>>
SCA ✅ SUCCESS >>>>>

[2026-06-29 15:10:43]    CI执行结束

likedislike
CANN-robotCANN-robot成员
6月29日 添加了label:api-check-pass
CANN-robotCANN-robot成员
6月29日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
6月29日 添加了label:ci-pipeline-passed
yangyang016成员
6月29日 评论:

/lgtm

likedislike
chenqi317成员
6月29日 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
6月29日 添加了label:lgtmapproved
CANN-robotCANN-robot成员
6月29日 关闭了关联的issue
CANN-robotCANN-robot成员
6月29日 合入了pull request