已合并
repeat_interleave_grad r=0场景修改 #2938
wuao创建于 3月19日
repeat_interleave_grad r=0场景修改 #2938
已合并
wuao创建于 3月19日
wuao
3月19日

描述

repeat_interleave_grad算子,当repeat轴中存在0时,实际应该输出0,但是当前代码跳过了0,没有处理,导致精度失败。
修改:在kernel侧判断,当repeat轴出现0时,增加特殊处理的分支,直接搬出0.0到gm上。

关联的Issue

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

测试

执行repeat轴中存在0的repeat_interleave_grad 的单算子用例。

文档更新

类型标签

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 wuao 的贡献)
Wwuao
3月19日 创建了 pull request,commit 107bd10e
Wwuao
3月19日 关联了issue:[Bug-Report|缺陷反馈]: repeat_interleave_grad r=0场景,精度有问题
CANN-robot
CANN-robot成员
3月19日 评论:

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
index chenqi317, zhou-qilong (2/2) chenqi317, zhou-qilong (2/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
CANN-robotCANN-robot成员
3月19日 添加了label:cann-cla/yes
CANN-robotCANN-robot成员
3月19日 将FelixTang7,crystalhu,yangyang016,fanqirui,zhou-qilong,chenqi317,liubo75,tangweiwei2,wangyongguang,zhang-wu设为评审人
CANN-robotCANN-robot成员
3月19日 将FelixTang7,crystalhu,zhou-qilong,chenqi317,liubo75,tangweiwei2,wangyongguang,zhang-wu设为审查人
CANN-robot
CANN-robot成员
3月19日 评论:

🔵 source code change are detected, tasks labels is removed in this pull request!

likedislike
wuao
3月19日 评论:

compile

likedislike
CANN-robotCANN-robot成员
3月19日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
3月19日 评论:

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

任务名称状态日志下载链接
解析CI分支 ✅ SUCCESS
codecheck ✅ SUCCESS >>>>>
anti_virus ✅ SUCCESS >>>>>
Check_Pr ✅ SUCCESS >>>>>
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 >>>>> >>>>>
API_Check ✅ SUCCESS >>>>>
Pre_Compile ✅ SUCCESS
pre_comment ✅ SUCCESS >>>>>
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_X86_950_ubuntu24 ✅ SUCCESS >>>>>
StaticCheck_codespell_check ✅ SUCCESS
StaticCheck_link_validity_check ✅ SUCCESS
StaticCheck_resource_existence_check ✅ SUCCESS
StaticCheck_tag_closed_check ✅ SUCCESS
StaticCheck_markdownlint ✅ SUCCESS
Compile_Ascend_ARM_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_single_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_experimental_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_ARM_950_ubuntu24 ✅ SUCCESS >>>>>
UT_Test_ophost ✅ SUCCESS
UT_Test_opapi ✅ SUCCESS
UT_Test_kernel ✅ SUCCESS
UT_Test_opgraph ✅ SUCCESS
Smoke_A900_npupool ✅ SUCCESS >>>>>

[2026-03-19 17:44:52]    CI执行结束

likedislike
CANN-robot
CANN-robot成员
3月19日 评论:

问题/功能描述

本次PR修复了repeat_interleave_grad算子反向传播计算中的一个边界条件缺陷。原实现中,当重复因子r为0时,算子未对输出梯度进行显式初始化,可能导致输出梯度数据未定义(包含脏数据),从而影响模型训练的正确性。本次修改旨在完善算子的鲁棒性,确保在r=0时能输出正确的零梯度。

修改方案描述

修改在RepeatInterleaveGradDimNOneDavid类中实现。核心是在ProcessRepeatBlock函数中新增了对r == 0的特殊处理分支。该分支会调用新增的ProcessZeroR函数,该函数使用值为0.0的常量INIT_FLOAT_VALUE,通过Duplicate操作将计算缓冲区初始化为0,再通过CopyOut将结果写回全局内存的输出位置,并正确同步MTE3_V事件以保证数据一致性,从而确保对应输出梯度区域被正确填充为0。

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

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
3月19日 添加了label:approved
sunday成员
3月20日 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
3月20日 添加了label:lgtm
CANN-robot
CANN-robot成员
3月20日 评论:

Review Guide

This pull-request passes review.
Committers who wrote a comment of /approve are: chenqi317, zhou-qilong.
Reviewers who wrote a comment of /lgtm are: zhou-qilong, chenqi317.

likedislike
CANN-robotCANN-robot成员
3月20日 合入了pull request