已合并
修复SeluGrad、ApplyAddSign、SoftMarginLossGrad算子原型重复问题 #8552
yulianjie创建于 26 天前
修复SeluGrad、ApplyAddSign、SoftMarginLossGrad算子原型重复问题 #8552
已合并
yulianjie创建于 26 天前
yulianjie成员
26 天前

描述

修复SeluGrad、ApplyAddSign、SoftMarginLossGrad算子原型重复问题,为了防止重复定义,统一使用宏定义隔开

关联的Issue

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

测试

compile通过

文档更新

类型标签

AI/Agent生成声明

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 yulianjie 的贡献)
Yyulianjie成员
26 天前 创建了 pull request,commit d5fddfea
atomgit-bot
atomgit-bot
26 天前 评论:

变更摘要

此 PR 修复了 SeluGradApplyAddSignSoftMarginLossGrad 三个算子原型的重复定义问题。通过在三个头文件中分别添加 #ifndef/#define/#endif 宏守卫,防止这些 REG_OP 注册宏在多次包含时被重复展开,从而避免编译阶段的重复定义错误。

主要改动

  • SeluGrad 算子原型增加头文件守卫:在 selu_grad_proto.h 中为 REG_OP(SeluGrad) 添加 OPS_PROTO_DEF_SELUGRAD 宏守卫,防止该算子原型被重复注册。
  • ApplyAddSign 算子原型增加头文件守卫:在 op_nn_proto_extend.h 中为 REG_OP(ApplyAddSign) 添加 OPS_PROTO_DEF_APPLYADDSIGN 宏守卫,防止该算子原型被重复注册。
  • SoftMarginLossGrad 算子原型增加头文件守卫:在 soft_margin_loss_grad_proto.h 中为 REG_OP(SoftMarginLossGrad) 添加 OPS_PROTO_DEF_SOFTMARGINLOSSGRAD 宏守卫,防止该算子原型被重复注册。
likedislike
atomgit-bot
atomgit-bot
26 天前 评论:

代码审查

我已对所有三个变更文件完成审查。以下是审查结果汇总:


审查结果

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

发现详情

P0common/inc/op_graph/op_nn_proto_extend.h 第 145 行:#ifdef 应为 #ifndef

这是本次 PR 唯一的实质性问题。ApplyAddSign 算子的防重复宏使用了 #ifdef("如果已定义")而非 #ifndef("如果未定义"),导致宏 OPS_PROTO_DEF_APPLYADDSIGN 初始未定义时条件为 false,整个 REG_OP(ApplyAddSign) 注册块被跳过且永远无法执行。这意味着 ApplyAddSign 算子原型将永远不会被注册,任何依赖该算子的图编译/运行将失败。

对比证明这是一个笔误:另外两个文件 (selu_grad_proto.hsoft_margin_loss_grad_proto.h) 均正确使用了 #ifndef

逐文件确认

文件 审查结论
activation/selu_grad/op_graph/selu_grad_proto.h ✅ 无问题(#ifndef 模式正确)
common/inc/op_graph/op_nn_proto_extend.h ❌ 1 个 P0 问题(#ifdef 笔误)
loss/soft_margin_loss_grad/op_graph/soft_margin_loss_grad_proto.h ✅ 无问题(#ifndef 模式正确)

整体风险评估

高风险。第 145 行的一字之差(#ifdef vs #ifndef)将导致 ApplyAddSign 算子完全失效,属于阻断性缺陷,必须在合入前修复。将 #ifdef 改为 #ifndef 即可解决,修复成本极低。

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

⛔ 需要修改

likedislike
CANN-robotCANN-robot成员
26 天前 添加了label:cann-cla/yes
Yyulianjie成员
26 天前 修改了pull request 的描述
此处折叠了61条消息 查看更多
Yyulianjie成员
26 天前 解决了最后一个问题
CANN-robotCANN-robot成员
26 天前 关闭了关联的issue
CANN-robotCANN-robot成员
26 天前 合入了pull request
CANN-robot
CANN-robot成员
26 天前 评论:

Pull Request 已合并或已关闭。

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

likedislike
conv2d_ci
25 天前 评论:
pipeline history
TimeNameResultChangeidTimeStamp
2026-08-12 22:36:59commit2026-08-11T20:48:15+08:0061a05df4
SC_Result :x: FAILUREI997fc01
RDV_Result :x: RUNNINGI997fc01
本次未执行的rdv任务为
序号任务名未执行理由
1tbe该组的RDV疑似不需要运行:[1951DC, 1951MDC, rdv_tbe_1971_01, rdv_tbe_1981_01, rdv_tbe_1951dc_01, Smoke_1951lite, Smoke_1911mdc, rdv_tbe_1971_02, rdv_tbe_1911rc_01, rdv_tbe_1911ep_01, Smoke_davinci_rdv_Nano, Smoke_nanoc11, rdv_tbe_1952_01]
2David该组的RDV疑似不需要运行:[rdv_tbe_david_01, rdv_tbe_david_02, rdv_tbe_david_03]
3transpose该组的RDV疑似不需要运行:[Davinci_RDV_conv_back_V121, conv_backward_1982_rdv, conv_backward_1971_rdv, conv_transpose_1952_rdv]
likedislike