已合并
【PR】: 修复 Broadcast/Tile + Reduce 时 Reshape 输入输出定义 #4474
JacsonPile创建于 6 天前
【PR】: 修复 Broadcast/Tile + Reduce 时 Reshape 输入输出定义 #4474
已合并
JacsonPile创建于 6 天前
JacsonPile
JacsonPile成员
6 天前

Pull Request

描述

修复 AutoFuse BroadcastReduceEliminationPass 消除 Broadcast/Tile + Reduce 模式后,替换生成的 Reshape 节点结构不完整、输出 shape 描述不一致的问题。

原实现手工创建 Reshape OpDesc,只连接数据输入,并通过 shape 属性记录目标 shape;同时,Reshape 输出描述由输入描述复制而来,仅更新了 GeShape,可能继续保留原输入的 OriginShape 和 symbolic shape。以复现用例为例,静态 shape 已变为 [256, 10],但 origin/symbolic shape 仍可能是 [256, 1, 10],导致后续 Concat 符号 shape 推导发现输入 rank 不一致并报错:

input_3_dim_num(2) != first_input_dim_num(3)

本次变更包括:

  1. 按 Reshape 算子原型创建 data + shape 两个输入,其中目标 shape 由 DT_INT64 Const 节点提供,并连接到 Reshape 的第二个输入。
  2. 将 Reshape 输出的 GeShapeOriginShapeSymbolicDescAttr.origin_symbol_shape 同步为同一个目标 shape,避免静态描述与符号描述的 rank 不一致。
  3. 补充 UT 校验,覆盖 Reshape 双输入结构、shape Const 的类型和值、三类 shape 描述以及数据边连接关系。
  4. 补充 UT 使用 NodeUtils 所需的直接头文件依赖。

变更类型

请选择本次引入的变更类型:

关联的Issue

暂无关联 Issue。

如何测试

  1. 编译并执行 autofusion_ut,重点运行 BroadcastReduceMax_EliminateWithSqueeze,确认:
    • Reshape 包含 data 和 shape 两个输入;
    • shape 输入来自 DT_INT64 Const,内容等于目标 shape;
    • 输出 GeShapeOriginShape 和 symbolic shape 一致;
    • 数据连接保持为 data -> Reshape -> relu
  2. 执行复现用例回归,确认不再出现 Concat 输入 rank 不一致错误。
  3. 将输出与 CPU golden 比较。

当前验证结果:

  • 复现环境中的 ATC 编译已通过,不再出现 Concat symbolic shape rank 错误。
  • ACL 执行返回 aclmdlExecute: ret=0,两个输出与 CPU golden 比对通过。

核对清单

其他信息

  • 影响文件:
    • compiler/graph/optimize/autofuse/autofuse/pattern_fusion/broadcast_reduce_elimination_pass.cpp
    • tests/autofuse/ut/autofuse/broadcast_reduce_elimination_pass_unittest.cpp
likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 JacsonPile 的贡献)
JacsonPileJacsonPile成员
6 天前 添加了label:enhancement
JacsonPileJacsonPile成员
6 天前 创建了 pull request,commit 70c8cdfe
atomgit-bot
atomgit-bot
6 天前 评论:

变更摘要

本 PR 修复 AutoFuse BroadcastReduceEliminationPass 消除 Broadcast/Tile + Reduce 模式后替换生成的 Reshape 节点结构不完整、输出 shape 描述不一致的问题。原实现手工创建 Reshape OpDesc,仅连接数据输入并通过 shape 属性记录目标 shape,输出描述由输入描述复制而来、只更新 GeShape,导致 OriginShape 与 symbolic shape 可能仍保留原输入 rank,触发后续 Concat 符号 shape 推导报 input_3_dim_num(2) != first_input_dim_num(3)。本次改为按 Reshape 算子原型创建 data + shape 双输入,目标 shape 由 DT_INT64 Const 节点提供并接入第二个输入,同时将输出的 GeShapeOriginShapeSymbolicDescAttr.origin_symbol_shape 同步为同一目标 shape,并补充相应 UT 校验。

主要改动

  • Reshape 双输入结构: CreateReshapeNode 按原型通过 AddInputDesc("x", ...)AddInputDesc("shape", ...) 创建数据与 shape 两个输入,目标 shape 由 CreateConstOpZeroCopy 生成的 DT_INT64 Const 节点提供,并经 GraphUtils::AddEdge 连接到 Reshape 第二个数据输入。
  • 输出 shape 描述同步: 输出描述同时设置 GeShapeOriginShape,并将 SymbolicDescAttrsymbolic_tensor.MutableOriginSymbolShape() 按目标 shape 各维度构造为 Symbol(dim) 表达式,保证静态与符号描述的 rank 一致。
  • 移除 shape 属性写法: 删除 kAttrNameShape 常量及 AttrUtils::SetListInt 设置 shape 属性的逻辑,目标 shape 改由输入 Const 节点承载,并新增 kOpTypeReshape 常量与 attr_group_symbolic_desc.h 头文件依赖。
  • UT 校验增强: 扩展 BroadcastReduceMax_EliminateWithSqueeze 用例,断言 Reshape 双输入、shape Const 的 DT_INT64 类型与取值、GeShape/OriginShape/symbolic shape 三类描述的一致性,以及 data -> Reshape -> relu 数据边连接,并补充 NodeUtils 等直接头文件依赖。
likedislike
atomgit-bot
atomgit-bot
6 天前 评论:

代码审查

✅ 未发现问题

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

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
repo-cann/ge 张德鹏, 盛楠, wangxiaotian995 (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

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

likedislike
CANN-robotCANN-robot成员
6 天前 将yangyongqiang0606,kobemini,ClarkXie,tangqunzhang,xchu42,hugo111,lining23666,fu-jun2,depeng1994,wqtshg_wt,peiyang,shengnan666,zhangfan_hanq,zhanj,zhujingjing,Mexyy,wangxiaotian995,stevenaw0,yuht9设为评审人
CANN-robotCANN-robot成员
6 天前 将yangyongqiang0606,kobemini,ClarkXie,tangqunzhang,xchu42,hugo111,lining23666,fu-jun2,depeng1994,wqtshg_wt,peiyang,shengnan666,zhangfan_hanq,zhanj,zhujingjing,Mexyy,wangxiaotian995,stevenaw0,yuht9设为审查人
JacsonPile
JacsonPile成员
6 天前 评论:

compile

likedislike
JacsonPileJacsonPile成员
6 天前 update merge request[project id: 8824148, iid: 4474, commit_id: 048df34533b8de6df2a9f788c80422828f1715d1] virtual merging success
CANN-robotCANN-robot成员
6 天前 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
6 天前 评论:

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

任务名称状态日志下载链接
pre_comment ✅ SUCCESS >>>>>
Compile_ARM_compiler ✅ SUCCESS >>>>> >>>>>
Compile_ARM_executor ✅ SUCCESS >>>>> >>>>>
Compile_ARM_dflow ✅ SUCCESS >>>>> >>>>>
API_Check ✅ SUCCESS >>>>>
PreSmoke_A900_npupool ✅ SUCCESS >>>>>

[2026-08-20 12:45:01]    CI执行结束

likedislike
CANN-robot
CANN-robot成员
6 天前 评论:

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

任务名称状态日志下载链接
pre_comment ✅ SUCCESS >>>>>
Compile_X86_compiler ✅ SUCCESS >>>>> >>>>>
Compile_X86_executor ✅ SUCCESS >>>>> >>>>>
Compile_X86_dflow ✅ SUCCESS >>>>> >>>>>
UT_Test_dflow ✅ SUCCESS
UT_Test_ge_common ✅ SUCCESS
UT_Test_parser ✅ SUCCESS
UT_Test_python ✅ SUCCESS >>>>>
UT_Test_rt ✅ SUCCESS
UT_Test_acl ✅ SUCCESS
UT_Test_autofuse ✅ SUCCESS
UT_Test_executor ✅ SUCCESS
UT_Test_autofuse_ascendc_api ✅ SUCCESS
ST_Test_dflow ✅ SUCCESS
ST_Test_ge_common ✅ SUCCESS
ST_Test_parser ✅ SUCCESS
ST_Test_python ✅ SUCCESS >>>>>
ST_Test_rt ✅ SUCCESS
ST_Test_autofuse ✅ SUCCESS
ST_Test_executor ✅ SUCCESS
ST_Test_hetero ✅ SUCCESS
ST_Test_autofuse_ascendc_api ✅ SUCCESS
ST_Test_autofuse_e2e ✅ SUCCESS
UT_Test_fe ✅ SUCCESS
UT_Test_tefusion ✅ SUCCESS
ST_Test_fe ✅ SUCCESS
ST_Test_tefusion ✅ SUCCESS
ST_Test_ge_common_atc ✅ SUCCESS
UT_Test_Report_graphengine ✅ SUCCESS >>>>>
UT_Test_Report_ge_executor_c ✅ SUCCESS >>>>>
UT_Test_Report_ge_autofuse ✅ SUCCESS >>>>>
ST_Test_Report_graphengine ✅ SUCCESS >>>>>
ST_Test_Report_ge_executor_c ✅ SUCCESS >>>>>
ST_Test_Report_ge_autofuse ✅ SUCCESS >>>>>
UT_Test_Report_fe ✅ SUCCESS >>>>>
ST_Test_Report_fe ✅ SUCCESS >>>>>

[2026-08-20 12:52:42]    CI执行结束

likedislike
CANN-robot
CANN-robot成员
6 天前 评论:

流水线任务触发成功
任务链接 [259aed83fc3c42b0aa564e4eb6a0b4ba][流水线指导]

任务名称状态日志下载链接
codecheck_Pr ✅ SUCCESS
antipoison ✅ SUCCESS >>>>>
SCA ✅ SUCCESS >>>>>
codecheck_dt ❌ FAILED >>>>>
codecheck_precommit ✅ SUCCESS >>>>>
StaticCheck_codespell ✅ SUCCESS
StaticCheck_link_validity ✅ SUCCESS
StaticCheck_resource_existence ✅ SUCCESS
StaticCheck_tag_closed ✅ SUCCESS
StaticCheck_markdownlint ✅ SUCCESS
likedislike
CANN-robotCANN-robot成员
6 天前 添加了label:api-check-pass
此处折叠了8条事件消息 查看更多
CANN-robotCANN-robot成员
6 天前 添加了label:cann-cla/yes
JacsonPile
JacsonPile成员
6 天前 评论:

compile

likedislike
JacsonPileJacsonPile成员
6 天前 update merge request[project id: 8824148, iid: 4474, commit_id: 561e3638209fd6058a98ad59a8619ae060af0c4c] virtual merging success
CANN-robotCANN-robot成员
6 天前 删除了label:ci-pipeline-failed
CANN-robotCANN-robot成员
6 天前 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
6 天前 评论:

流水线任务触发成功
任务链接 [695a274d51564e26944973b0d571bac2][流水线指导]

任务名称状态日志下载链接
pre_comment ✅ SUCCESS >>>>>
Compile_ARM_compiler ✅ SUCCESS >>>>> >>>>>
Compile_ARM_executor ✅ SUCCESS >>>>> >>>>>
Compile_ARM_dflow ✅ SUCCESS >>>>> >>>>>
API_Check ✅ SUCCESS >>>>>
PreSmoke_A900_npupool ✅ SUCCESS >>>>>

[2026-08-20 13:09:04]    CI执行结束

likedislike
CANN-robot
CANN-robot成员
6 天前 评论:

流水线任务触发成功
任务链接 [490f7f58c2164a8689a85241e45ecfd2][流水线指导]

任务名称状态日志下载链接
pre_comment ✅ SUCCESS >>>>>
Compile_X86_compiler ✅ SUCCESS >>>>> >>>>>
Compile_X86_executor ✅ SUCCESS >>>>> >>>>>
Compile_X86_dflow ✅ SUCCESS >>>>> >>>>>
UT_Test_dflow ✅ SUCCESS
UT_Test_ge_common ✅ SUCCESS
UT_Test_parser ✅ SUCCESS
UT_Test_python ✅ SUCCESS >>>>>
UT_Test_rt ✅ SUCCESS
UT_Test_acl ✅ SUCCESS
UT_Test_autofuse ✅ SUCCESS
UT_Test_executor ✅ SUCCESS
UT_Test_autofuse_ascendc_api ✅ SUCCESS
ST_Test_dflow ✅ SUCCESS
ST_Test_ge_common ✅ SUCCESS
ST_Test_parser ✅ SUCCESS
ST_Test_python ✅ SUCCESS >>>>>
ST_Test_rt ✅ SUCCESS
ST_Test_autofuse ✅ SUCCESS
ST_Test_executor ✅ SUCCESS
ST_Test_hetero ✅ SUCCESS
ST_Test_autofuse_ascendc_api ✅ SUCCESS
ST_Test_autofuse_e2e ✅ SUCCESS
UT_Test_fe ✅ SUCCESS
UT_Test_tefusion ✅ SUCCESS
ST_Test_fe ✅ SUCCESS
ST_Test_tefusion ✅ SUCCESS
ST_Test_ge_common_atc ✅ SUCCESS
UT_Test_Report_graphengine ✅ SUCCESS >>>>>
UT_Test_Report_ge_executor_c ✅ SUCCESS >>>>>
UT_Test_Report_ge_autofuse ✅ SUCCESS >>>>>
ST_Test_Report_graphengine ✅ SUCCESS >>>>>
ST_Test_Report_ge_executor_c ✅ SUCCESS >>>>>
ST_Test_Report_ge_autofuse ✅ SUCCESS >>>>>
UT_Test_Report_fe ✅ SUCCESS >>>>>
ST_Test_Report_fe ✅ SUCCESS >>>>>

[2026-08-20 13:16:23]    CI执行结束

likedislike
CANN-robot
CANN-robot成员
6 天前 评论:

流水线任务触发成功
任务链接 [8b6bb4a123f94cb18443aacb5f418bc9][流水线指导]

任务名称状态日志下载链接
codecheck_Pr ✅ SUCCESS
antipoison ✅ SUCCESS >>>>>
SCA ✅ SUCCESS >>>>>
codecheck_dt ✅ SUCCESS >>>>>
codecheck_precommit ✅ SUCCESS >>>>>
StaticCheck_codespell ✅ SUCCESS
StaticCheck_link_validity ✅ SUCCESS
StaticCheck_resource_existence ✅ SUCCESS
StaticCheck_tag_closed ✅ SUCCESS
StaticCheck_markdownlint ✅ SUCCESS

[2026-08-20 13:07:04]    CI执行结束

likedislike
CANN-robotCANN-robot成员
6 天前 添加了label:api-check-pass
CANN-robotCANN-robot成员
6 天前 删除了label:api-check-pass
CANN-robotCANN-robot成员
6 天前 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
6 天前 添加了label:ci-pipeline-passed
JacsonPile
JacsonPile成员
6 天前 评论:

@shengnan666 @wangxiaotian995 帮忙review一下代码

likedislike
shengnan成员
6 天前 评论:

/lgtm

likedislike
wangxiaotian995成员
6 天前 评论:

/lgtm

likedislike
CANN-robotCANN-robot成员
6 天前 添加了label:lgtm
张德鹏成员
6 天前 评论:

/approve

likedislike
CANN-robotCANN-robot成员
6 天前 添加了label:approved
CANN-robotCANN-robot成员
6 天前 合入了pull request