已合并
【DW】增加dw转matmul的format拦截 #9452
yejiani创建于 8月28日
【DW】增加dw转matmul的format拦截 #9452
已合并
yejiani创建于 8月28日
yejiani
8月28日

描述

aclnnConvTbcBackward算子用例在主线版本有功能失败,主要原因是dw转matmul没有对format拦截,导致后面format校验失败

关联的Issue

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

测试

本地验证已通过、RDV验证通过

文档更新

不涉及

类型标签

AI/Agent生成声明

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 yejiani 的贡献)
Yyejiani
8月28日 创建了 pull request,commit 1100cdc0
atomgit-bot
atomgit-bot
8月28日 评论:

变更摘要

本 PR 针对 aclnnConvTbcBackward 算子用例在主线版本的功能失败问题,为 DW 转 matmul 的判定逻辑增加 format 拦截。原因在于 Is1x1DwTransToMm 在判断 5D NCDHW weight + 1x1x1 kernel 场景时未校验输入张量的存储格式,导致后续 format 校验失败。改动在 aclnn_convolution_backward.cpp 中为 Is1x1DwTransToMm 增加格式前置校验,若 gradOutput、input、weight 任一存储格式不是 FORMAT_NCDHW 则直接返回 false,不再走 DW 转 matmul 路径。

主要改动

  • 增加 format 拦截前置判断: 在 Is1x1DwTransToMm 中新增条件,当 gradOutput、input、weight 的 GetStorageFormat() 任一不等于 FORMAT_NCDHW 时返回 false,提前阻断非 NCDHW 格式的转换路径。
  • 避免后续格式校验失败: 通过在 DW 转 matmul 判定入口拦截不支持的存储格式,防止非 FORMAT_NCDHW 输入进入 matmul 转换流程,从而规避后续 format 校验导致的算子用例功能失败。
likedislike
不准确?
atomgit-bot
atomgit-bot
8月28日 评论:

代码审查

✅ 未发现问题

likedislike
不准确?
CANN-robotCANN-robot成员
8月28日 添加了label:cann-cla/yes
Yyejiani
8月28日 修改了pull request 的描述
CANN-robot
CANN-robot成员
8月28日 评论:

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
conv ✅ 余鑫, 沈承宗, 林睿涵 (3/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

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

likedislike
CANN-robotCANN-robot成员
8月28日 将zengjuan,cheng_gao,chaotang233,crystalhu,yangyang016,fanqirui,chenqi317,lileizheng,liubo75,LiuZonggu,tangweiwei2,pingchuantang,wangcimeng,huafeng793,linruihan,shenchengzong,yuxin5设为评审人
CANN-robotCANN-robot成员
8月28日 将cheng_gao,lileizheng,LiuZonggu,wangcimeng,huafeng793,linruihan,shenchengzong,yuxin5设为审查人
yejiani
8月31日 评论:

/compile

likedislike
Yyejiani
8月31日 预合并成功(commit_id: f2d416ca1d4c1af147b55c7374633615924e1288)
Yyejiani
8月31日 修改了pull request 的描述
CANN-robotCANN-robot成员
8月31日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
8月31日 评论:

流水线任务触发成功
任务链接 [91b01b8fa106416e8597f5484e1250ee][流水线指导]

任务名称状态日志下载链接
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 >>>>> >>>>>
Compile_Pre ✅ SUCCESS >>>>>
pre_comment ✅ SUCCESS >>>>>
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_950_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_single_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_experimental_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_950_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_910b ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_910c ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_950 ✅ SUCCESS >>>>> >>>>>
Compile_classify ✅ SUCCESS >>>>>
Compile_Ascend_X86_mobile_station_9030_ubuntu24 ✅ SUCCESS >>>>> >>>>>
UT_Test_ophost ✅ SUCCESS
UT_Test_opapi ✅ SUCCESS
UT_Test_kernel ✅ SUCCESS
UT_Test_opgraph ✅ SUCCESS
PreSmoke_A900 ✅ SUCCESS >>>>>
API_Check ✅ SUCCESS >>>>>
PreSmoke_ATK_Test_A2 ✅ SUCCESS >>>>>
UT_Test_report_lcov ✅ SUCCESS >>>>>

[2026-08-31 11:25:21]    CI执行结束

likedislike
CANN-robot
CANN-robot成员
8月31日 评论:

流水线任务触发成功
任务链接 [320c7ad569c04a649e8fb2e18512a996][流水线指导]

任务名称状态日志下载链接
antipoison ✅ SUCCESS >>>>>
codecheck_checkpr ✅ SUCCESS
codecheck_precommit ✅ SUCCESS >>>>>
SCA ✅ SUCCESS >>>>>
StaticCheck_md ✅ SUCCESS

[2026-08-31 11:10:18]    CI执行结束

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

/reject

likedislike
conv2d_ci
8月31日 评论:
pipeline history
TimeNameResultChangeidTimeStamp
2026-08-31 11:48:53Start_PipelineMR_440
likedislike
conv2d_ci
8月31日 评论:
pipeline history
TimeNameResultChangeidTimeStamp
2026-08-31 11:51:51Sync_PR :white_check_mark: 成功Ic3a636810e29207475b355d6870a2cb6311619b6
likedislike
conv2d_ci
8月31日 评论:
pipeline history
TimeNameResultChangeidTimeStamp
2026-08-31 11:52:12Trigger_SC :white_check_mark: 触发成功Ic3a636810e29207475b355d6870a2cb6311619b620260831_115712649
likedislike
conv2d_ci
8月31日 评论:
pipeline history
TimeNameResultChangeidTimeStamp
2026-08-31 12:18:39SC_Result :x: 失败Ic3a636810e29207475b355d6870a2cb6311619b6
likedislike
conv2d_ci
8月31日 评论:
pipeline history
TimeNameResultChangeidTimeStamp
2026-08-31 12:20:07CMETRICS :white_check_mark: 成功Ic3a636810e29207475b355d6870a2cb6311619b6
likedislike
conv2d_ci
8月31日 评论:
pipeline history
TimeNameResultChangeidTimeStamp
2026-08-31 12:20:28Trigger_RDV :white_check_mark: 触发成功Ic3a636810e29207475b355d6870a2cb6311619b620260831_122529045
likedislike
shenchengzong成员
8月31日 评论:

/lgtm

likedislike
linruihan成员8月31日进行代码检视2
conv/convolution_backward/op_api/aclnn_convolution_backward.cpp
@@ -2349,6 +2349,11 @@ static bool Is1x1DwTransToMm(const ConvolutionBackwardInputTensor& inputTensor,
23492349 }
23502350 op::Shape weightShape = inputTensor.weight->GetViewShape();
23512351 // 5D NCDHW weight + 1x1x1 kernel
2352+ if (inputTensor.gradOutput->GetStorageFormat() != op::Format::FORMAT_NCDHW ||
linruihan8月31日评论:

这里拦截NCDHW的原因是什么

likedislike
yejiani
8月31日 评论:

转matmul要求format都为NCDHW,aclnn默认进来都是NCDHW所以没拦截也不会有影响,但是TBC会转成TBC要求的format,所以需要拦截

linruihan成员
8月31日 评论:

/lgtm

likedislike
CANN-robotCANN-robot成员
8月31日 添加了label:lgtm
zhaozhongyao
zhaozhongyao成员8月31日进行代码检视1
conv/convolution_backward/op_api/aclnn_convolution_backward.cpp
@@ -2349,6 +2349,11 @@ static bool Is1x1DwTransToMm(const ConvolutionBackwardInputTensor& inputTensor,
23492349 }
23502350 op::Shape weightShape = inputTensor.weight->GetViewShape();
23512351 // 5D NCDHW weight + 1x1x1 kernel
zhaozhongyao
zhaozhongyao8月31日评论:

注释的位置放的不太合适

likedislike
Yyuxin5成员
8月31日 解决了最后一个问题
yuxin5成员
8月31日 评论:

/approve

likedislike
CANN-robotCANN-robot成员
8月31日 添加了label:approved
CANN-robotCANN-robot成员
8月31日 关闭了关联的issue
CANN-robotCANN-robot成员
8月31日 合入了pull request
CANN-robot
CANN-robot成员
8月31日 评论:

Pull Request 已合并或已关闭。

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

likedislike