Pull Request已成功合入, 合并人@CANN-robot
(感谢 wuao 的贡献)变更摘要
此 PR 在 repeat_interleave_grad_infershape.cpp 的 InferShape4RepeatInterleaveGrad 函数中新增了对 repeats 参数为 0 的防御性检查,防止因除零导致的运行时错误。当 repeats 张量的 shape size 为 1 且其值为 0 时,提前终止推理并返回 ge::GRAPH_FAILED,避免后续计算中出现除零异常。
主要改动
- 新增
repeats值为 0 的校验逻辑:在推断形状前,通过repeatsShape->GetShapeSize() == 1和repeatsInput->GetData<T>()[0] == 0判断repeats是否为标量 0,若成立则直接返回失败,拦截可能引发除零的非法输入。 - 新增错误日志输出:当检测到
repeats为 0 时,通过OP_LOGE输出明确的错误信息"InferShape4RepeatInterleaveGrad FAILED, repeats must not be 0",便于问题定位。 - 提前返回失败状态码:校验失败后返回
ge::GRAPH_FAILED,避免继续执行后续依赖repeats值的形状推断逻辑,从而消除除零隐患。


代码审查
审查总结
审查文件
index/repeat_interleave_grad/op_host/repeat_interleave_grad_infershape.cpp— 发现 1 个问题
各优先级问题统计
| 优先级 | 数量 |
|---|---|
| P0 | 1 |
| P1 | 0 |
| P2 | 0 |
| P3 | 0 |
整体风险判断
高风险(构建阻断):该变更在第 91 行使用了未定义的标识符 T(T 仅在 GetOutputZeroAxisLen 模板函数中作为模板参数存在,在 InferShape4RepeatInterleaveGrad 非模板函数中无效),导致算子无法通过编译。除零保护意图正确,但实现需基于 repeatsDtype 的具体类型重写。建议在合入前修复此编译错误。
| 类型 | 数量 |
|---|---|
| 🔴 阻塞 | 1 |
| 🟡 建议 | 0 |
⛔ 需要修改


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
/approveor/lgtm- Commenting
/approveimplies 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. 👍


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.


Pull Request 已合并或已关闭。
If you want to solve this problem, you can click here to do it in the FAQs.


描述
构造repeat_inter_leave_grad的repeat = 0的场景,出现coredump
关联的Issue
https://gitcode.com/cann/ops-nn/issues/4675
测试
执行报错场景,执行算子相关冒烟用例。
文档更新
类型标签
AI/Agent生成声明