已合并
RIG infershape 除0报错修改 #8440
wuao创建于 23 天前
RIG infershape 除0报错修改 #8440
已合并
wuao创建于 23 天前
wuao
23 天前

描述

构造repeat_inter_leave_grad的repeat = 0的场景,出现coredump

关联的Issue

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

测试

执行报错场景,执行算子相关冒烟用例。

文档更新

类型标签

AI/Agent生成声明

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 wuao 的贡献)
Wwuao
23 天前 创建了 pull request,commit 3cf7b2de
atomgit-bot
atomgit-bot
23 天前 评论:

变更摘要

此 PR 在 repeat_interleave_grad_infershape.cppInferShape4RepeatInterleaveGrad 函数中新增了对 repeats 参数为 0 的防御性检查,防止因除零导致的运行时错误。当 repeats 张量的 shape size 为 1 且其值为 0 时,提前终止推理并返回 ge::GRAPH_FAILED,避免后续计算中出现除零异常。

主要改动

  • 新增 repeats 值为 0 的校验逻辑:在推断形状前,通过 repeatsShape->GetShapeSize() == 1repeatsInput->GetData<T>()[0] == 0 判断 repeats 是否为标量 0,若成立则直接返回失败,拦截可能引发除零的非法输入。
  • 新增错误日志输出:当检测到 repeats 为 0 时,通过 OP_LOGE 输出明确的错误信息 "InferShape4RepeatInterleaveGrad FAILED, repeats must not be 0",便于问题定位。
  • 提前返回失败状态码:校验失败后返回 ge::GRAPH_FAILED,避免继续执行后续依赖 repeats 值的形状推断逻辑,从而消除除零隐患。
likedislike
atomgit-bot
atomgit-bot
23 天前 评论:

代码审查

审查总结

审查文件

  • index/repeat_interleave_grad/op_host/repeat_interleave_grad_infershape.cpp发现 1 个问题

各优先级问题统计

优先级 数量
P0 1
P1 0
P2 0
P3 0

整体风险判断

高风险(构建阻断):该变更在第 91 行使用了未定义的标识符 TT 仅在 GetOutputZeroAxisLen 模板函数中作为模板参数存在,在 InferShape4RepeatInterleaveGrad 非模板函数中无效),导致算子无法通过编译。除零保护意图正确,但实现需基于 repeatsDtype 的具体类型重写。建议在合入前修复此编译错误。

类型 数量
🔴 阻塞 1
🟡 建议 0

⛔ 需要修改

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

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
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
index 黄迪, 苏跃明 (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

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

likedislike
此处折叠了45条消息 查看更多
CANN-robot
CANN-robot成员
16 天前 评论:

The MR can not be merged, because of CodeReview discussion not resolved

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

likedislike
RRuiWang_成员
16 天前 解决了最后一个问题
CANN-robotCANN-robot成员
16 天前 关闭了关联的issue
CANN-robotCANN-robot成员
16 天前 合入了pull request
CANN-robot
CANN-robot成员
16 天前 评论:

Pull Request 已合并或已关闭。

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

likedislike