Merged
error_code_fix #12386
佐助大王Add on Oct 20
error_code_fix #12386
Merged
佐助大王Add on Oct 20
佐助大王
佐助大王Collaborators
Oct 20

描述

本 PR 对 loss/optim 目录下 8 个算子的错误码上报路径进行整改,消除失败路径上无错误码上报的裸 OP_LOGE,统一错误码首报规范,并补齐对应负向 UT。

涉及算子:cross_v2、ctc_loss_v3、ctc_loss_v3_grad、mse_loss_grad_v2、apply_fused_ema_adam、fused_adam、fused_adamw、fused_sgd

主要改动:

  1. 空指针校验补齐:对 tiling/infershape 中未判空即解引用的输入 desc、shape、attrs、compileInfo 等指针,统一改为先持有局部指针、OP_CHECK_IF 验空后再使用,失败时通过 OP_LOGE_FOR_INVALID_ARGUMENT_WITH_REASON 上报 EZ0037(含参数名、op 名、失败原因)
  2. 输入张量数校验:fused_adam、fused_adamw、fused_sgd 的输入张量数校验点统一替换为 OP_LOGE_FOR_INVALID_TENSORNUM(EZ0022)
  3. tiling 失败上报:仿照 apply_top_k_top_p_with_sorted 的先例,在 7 个 tiling 文件中引入 ReportTilingFailure(REPORT_PREDEFINED_ERR_MSG 上报 EZ1008 + OP_LOGE_WITHOUT_REPORT),覆盖 coreNum/ubSize/sysWorkspaceSize/memset_s 等约 20 处失败出口
  4. 性能微优化:ctc_loss_v3_grad 中 nDims 相关字符串拼接移入失败宏内惰性构造,正常校验通过路径不再执行拼接
  5. 新增 48 个负向 UT 用例(8 个测试文件),覆盖 EZ0037/EZ0022/EZ1008 的首报路径;对不可构造的路径(如 GetAttrs 固定偏移永不为空)在测试文件中留注释说明,不写无效用例

关联的Issue

#7497

测试

  • 全量编译通过(build.sh -u --ophost,覆盖全部 8 个受影响算子)
  • 既有正向 UT 无回归;新增 48 个负向用例全部运行 PASS
  • plog 日志验证:EZ0037/EZ0022/EZ1008 首报与触发点一一对应,无双报 EZ9999

文档更新

无

类型标签

AI/Agent生成声明

关联issue

Closes #7497

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for 佐助大王's contribution.)
佐助大王佐助大王Collaborators
Oct 20 Created pull request, commit 8c1e6ab1
atomgit-bot
atomgit-bot
Oct 20 Comments:

变更摘要

本 PR 主要针对算子报错信息进行规范化改造,将原先通用的 OP_LOGE 日志替换为带结构化错误码的宏(如 OP_LOGE_FOR_INVALID_DTYPE、OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON、OP_LOGE_FOR_INVALID_TENSORNUM 等),使各类校验失败时能够携带输入/输出名称、实际取值以及失败原因,提升错误定位能力。改动覆盖 cross_v2、ctc_loss_v3、ctc_loss_v3_grad、mse_loss_grad_v2 以及 fused_adam、fused_adamw、fused_sgd 等算子的 tiling 与 infershape 逻辑。

主要改动

  • ctc_loss_v3 系列校验报错结构化: 在 ctc_loss_v3_tiling.cpp 与 ctc_loss_v3_grad_tiling.cpp 中,将 dtype、shape dim、batch/time/symbol 一致性等校验由 OP_LOGE 改为 OP_LOGE_FOR_INVALID_DTYPE、OP_LOGE_FOR_INVALID_DTYPES_WITH_REASON、OP_LOGE_FOR_INVALID_SHAPEDIM、OP_LOGE_FOR_INVALID_VALUES_WITH_REASON 等宏,并传入具体张量名、维度数与取值说明。
  • cross_v2 tiling 校验报错结构化: cross_v2_tiling.cpp 中空张量、dim 越界、batchSize/stepSize 非法、inputBytes 为 0 等场景改用 OP_LOGE_FOR_INVALID_SHAPESIZE_WITH_REASON、OP_LOGE_FOR_INVALID_VALUE_WITH_REASON、OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON、OP_LOGE_FOR_INVALID_DTYPE_WITH_REASON,并补充实际取值与约束原因。
  • mse_loss_grad_v2 infershape 报错补充: mse_loss_grad_v2_infershape.cpp 中原先仅 return ge::GRAPH_FAILED 的分支新增 OP_LOGE_FOR_INVALID_VALUE_WITH_REASON、OP_LOGE_FOR_INVALID_SHAPES_WITH_REASON、OP_LOGE_FOR_INVALID_SHAPEDIM_WITH_REASON、OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON 输出,覆盖 reduction、广播失败及 y 声明形状冲突场景。
  • fused_adam/adamw infershape 与 tiling 报错结构化: fused_adam_infershape.cpp、fused_adamw_infershape.cpp 将输入张量数为 0 与各张量列表形状不一致的 OP_LOGE 改为 OP_LOGE_FOR_INVALID_TENSORNUM、OP_LOGE_FOR_INVALID_SHAPES_WITH_REASON;fused_adam_tiling.cpp 的 state_steps 数量不匹配改用 OP_LOGE_FOR_INVALID_TENSORNUMS_WITH_REASON,fused_adamw_tiling.cpp 张量数为 0 改用 OP_LOGE_FOR_INVALID_TENSORNUM。
  • fused_sgd infershape 与 tiling 报错结构化: fused_sgd_infershape.cpp 将张量数为 0 及 params/grads/momentum_buffer_list 形状不一致的报错改为 OP_LOGE_FOR_INVALID_SHAPESIZE_WITH_REASON、OP_LOGE_FOR_INVALID_SHAPES_WITH_REASON,并按是否存在 momentum 分别组织错误信息;fused_sgd_tiling.cpp 张量数为 0 同样改用 OP_LOGE_FOR_INVALID_SHAPESIZE_WITH_REASON。

🧩 本次 Review 已使用自定义 Skill:

likedislike
Incorrect?
atomgit-bot
atomgit-bot
Oct 20 Comments:

代码审查

✅ 未发现问题


🧩 本次 Review 已使用自定义 Skill:

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Oct 20 Added label: cann-cla/no
CANN-robot
CANN-robotCollaborators
Oct 20 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
loss ✅ 陈风, 陈展熹 (2/2) ✅ 陈风, 陈展熹 (2/1)
optim ✅ 陈展熹, 陈风 (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

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

likedislike
70 messages are collapsed here。 See more
CANN-robotCANN-robotCollaborators
26 days ago Closed associated issue
CANN-robotCANN-robotCollaborators
26 days ago Merged pull request
佐助大王佐助大王Collaborators
26 days ago Modify description of pull request
CANN-robot
CANN-robotCollaborators
26 days ago Comments:

Pull Request 已合并或已关闭。

If you want to solve this problem, you can click here to do it in the FAQs.

likedislike
CANN-robot
CANN-robotCollaborators
26 days ago Comments:

Pull Request 已合并或已关闭。

If you want to solve this problem, you can click here to do it in the FAQs.

likedislike