已合并
【PR】: 重构,使用InsertNode收编节点插入行为 #1677
【PR】: 重构,使用InsertNode收编节点插入行为 #1677
已合并
shengnan创建于 8月7日
shengnan成员
8月7日

Pull Request

描述

使用InsertNode收编节点插入行为

变更类型

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

关联的Issue

如何测试

描述测试此变更的步骤和前提条件:
1.
2.

核对清单

其他信息

在此添加任何其他关于本次 PR 的说明。

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 shengnan 的贡献)
Sshengnan成员
8月7日 添加了label:enhancement
Sshengnan成员
8月7日 创建了 pull request,commit 6b41ceae
atomgit-bot
atomgit-bot
8月7日 评论:

变更摘要

本次 PR 将节点插入逻辑从通用框架层 GraphUtils 重构到 AscendC IR 专用工具类 AscGraphUtils 中,目的是收编 Autofuse 场景下的节点插入行为。新的 AscGraphUtils::InsertNodeAfter 和 AscGraphUtils::InsertNodeBefore 仅维护数据边,不再处理控制边;属性继承方面,从参考节点继承 AscNodeAttr::sched(调度信息),并从源 tensor 继承 AscTensorAttr 的 axis/repeats/strides 字段。所有调用方(共 6 处)从原先手动断边-加边-拷贝属性的模式统一切换为调用新接口,同时补充了对应的单元测试。

主要改动

  • 将 InsertNodeAfter/InsertNodeBefore 从 GraphUtils 迁移至 AscGraphUtils:graph_utils.cc 中移除了原有的两个方法及其辅助函数 InheritAttr 和相关常量,asc_graph_utils.cc 中新增了简化版本,仅维护数据边并继承 Autofuse 特有的 AscNodeAttr::sched 和 AscTensorAttr(axis/repeats/strides)。
  • 新增 InheritAutofuseAttr 辅助函数:从源 tensor 描述复制 axis、repeats、strides 到插入节点的输出 tensor 描述,替代原先通过 InheritAttr 继承白名单字符串属性的机制。
  • buf_que_allocator.cpp 调用方简化:ShortenVecinLifetime 和 ShortenVecoutLifetime 中将多步手动断边-加边-设 sched 的操作替换为 AscGraphUtils::InsertNodeAfter 单次调用。
  • dtype_consistency.cpp / improve_precision.cpp / cast_optimization_pass.cpp / concat_inputs_unification_pass.cpp / base_alignment_strategy.cpp 调用方统一:原先分散的手动 RemoveEdge+AddEdge+手动属性拷贝模式统一为调用 AscGraphUtils::InsertNodeBefore 或 InsertNodeAfter,删除了冗余的属性逐字段拷贝代码。
  • 新增单元测试 test_asc_graph_utils.cpp 和 test_buf_que_allocator.cpp 补充用例:覆盖 InsertNodeBefore 继承 consumer 调度和 producer tensor 属性、InsertNodeAfter 继承 producer 属性、多 consumer 场景、指定输入输出 index、跨图节点拒绝等场景,以及 ShortenVecoutLifetime 插入 ub2ub 节点的集成验证。
likedislike
不准确?
atomgit-bot
atomgit-bot
8月7日 评论:

代码审查

✅ 未发现问题

likedislike
不准确?
CANN-robotCANN-robot成员
8月7日 添加了label:stat/needs-squash
CANN-robotCANN-robot成员
8月7日 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
8月7日 评论:

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
repo-cann/graph-autofusion ✅ 张德鹏, zhang_shengjie, xchu42 (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

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

likedislike
CANN-robotCANN-robot成员
8月7日 将niuyuhu,yangyongqiang0606,liyuewei,xchu42,zhang_shengjie,depeng1994,wqtshg_wt,peiyang,XuebinYang,sjtulxh,zhanj,zhujingjing,xuyafei,wangxiaotian995设为评审人
CANN-robotCANN-robot成员
8月7日 将niuyuhu,yangyongqiang0606,liyuewei,xchu42,zhang_shengjie,depeng1994,wqtshg_wt,peiyang,XuebinYang,sjtulxh,zhanj,zhujingjing,xuyafei,wangxiaotian995设为审查人
shengnan成员
8月7日 评论:

compile

likedislike
Sshengnan成员
8月7日 预合并成功(commit_id: 14f12bc46d6a431996d3357f79ddc95f18a834b4)
CANN-robotCANN-robot成员
8月7日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
8月7日 评论:

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

任务名称状态日志下载链接
codecheck ✅ SUCCESS >>>>>
SCA ✅ SUCCESS >>>>>
antipoison ✅ SUCCESS >>>>>
codecheck_checkpr ✅ SUCCESS
pre_comment ✅ SUCCESS >>>>>
codecheck_codestyle ⚠️ WARNING >>>>>
codecheck_precommit ✅ SUCCESS >>>>>

[2026-08-07 15:30:15]    CI执行结束

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

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

任务名称状态日志下载链接
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM ✅ SUCCESS >>>>> >>>>>
pre_comment ✅ SUCCESS >>>>>
PreSmoke_A900_npupool ✅ SUCCESS >>>>>

[2026-08-07 15:44:15]    CI执行结束

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

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

任务名称状态日志下载链接
UT_Test_Python_superkernel ✅ SUCCESS >>>>>
ST_Test_Python_superkernel ✅ SUCCESS >>>>>
UT_Test_superkernel ✅ SUCCESS >>>>>
UT_Test_autofuse_framework ✅ SUCCESS >>>>>
ST_Test_autofuse_framework ✅ SUCCESS >>>>>
UT_Test_autofuse_ascendc_api ✅ SUCCESS >>>>>
ST_Test_autofuse_ascendc_api ✅ SUCCESS >>>>>
ST_Test_autofuse_e2e ✅ SUCCESS >>>>>
pre_comment ✅ SUCCESS >>>>>
UT_Test_Report ✅ SUCCESS >>>>>
ST_Test_Report ✅ SUCCESS >>>>>

[2026-08-07 15:49:52]    CI执行结束

likedislike
CANN-robotCANN-robot成员
8月7日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
8月7日 添加了label:ci-pipeline-passed
zhang_shengjie成员
8月7日 评论:

/lgtm

likedislike
xchu42
xchu42成员
8月7日 评论:

/lgtm

likedislike
CANN-robotCANN-robot成员
8月7日 添加了label:lgtm
张德鹏成员
8月10日 评论:

/approve

likedislike
CANN-robotCANN-robot成员
8月10日 添加了label:approved
CANN-robotCANN-robot成员
8月10日 合入了pull request