Pull Request已成功合入, 合并人@CANN-robot
(感谢 ling-DT 的贡献)变更摘要
本次 PR 修复了 ASCGraph 中同一个 Data 节点通过多个 Load 同时馈入 MatMul/Cube 与 Vector 后处理算子时,CubeFusionCaseGenerator 因共享输入无法将 Cube 与 Vector 切分为独立子图的问题。核心方案是在图切分前检测出被 Cube 和 Vector 两侧共享使用的 Data 节点,为 Vector 侧复制一份独立的 Data 副本并重连对应 Load 的边;图切分后再将副本 Data 的名称恢复为原始名,从而保持外部输入语义不变。
主要改动
- 新增
SplitSharedDataForCubeAndVector函数:遍历图中所有Data节点,通过 BFS(IsReachableToCube)判断其下游Load是否可达 Cube 算子,将不可达 Cube 的 Vector 侧Load重连至复制的Data副本,实现 Cube 与 Vector 的输入数据分离。 - 新增
RestoreSplitDataNames函数:在图切分完成后,将各子图中被复制的Data节点名称从{name}_shared_split_data恢复为原始Data名称,确保外部输入引用不因内部拆分而改变。 - 新增成员
split_data_names_:在CubeFusionCaseGenerator中记录拆分过程中创建的数据副本名与原始名的映射关系,供GenerateGeneralCase中填写映射、GeneratorTask中恢复名称使用。 - 修改
GenerateGeneralCase与GeneratorTask:在分区前调用SplitSharedDataForCubeAndVector完成输入分离,在PartitionByConnectivity后调用RestoreSplitDataNames恢复数据名称。 - 新增单元测试
Test_MatMul_Add_Shared_Data_Split:构造data0同时供MatMul(Cube 侧)和Add/Mul(Vector 侧)共享使用的场景,验证切分后产生两个 task,data0出现在两个子图中(Cube 图 1 个、Vector 图 1 个),且 Vector 图保留对data0的两个Load引用。


代码审查
Good — CountLoadsFromData correctly null-checks before use. The issue is confined to CountDataNodeByNameAndIndex. Now let me close out with the summary.
审查总结
各文件审查结果
| 文件 | 审查结果 |
|---|---|
autofuse/v35/optimize/task_generator/cube_schedule_case_generator.h |
✅ 无问题 — 仅新增 #include <utility> 和成员变量 split_data_names_,类型正确,与现有代码一致 |
autofuse/v35/optimize/task_generator/cube_schedule_case_generator.cpp |
✅ 无问题 — 新增的 4 个函数(IsReachableToCube、GetUniqueSplitDataName、CopyDataNodeForSharedSplit、SplitSharedDataForCubeAndVector、RestoreSplitDataNames)错误处理完备,宏返回值检查正确,BFS 避免了死循环,图修改时通过预捕获节点列表避免了迭代器失效。GE_ASSERT_TRUE/GE_ASSERT_SUCCESS 宏展开为 return ErrorResult() 而非崩溃,错误传播路径完整 |
autofuse/tests/v35/ut/optimize/test_cube_schedule_case_generator.cpp |
⚠️ 1 个 P2 问题 — CountDataNodeByNameAndIndex 空指针解引用 |
发现统计
- P0: 0
- P1: 0
- P2: 1 — 测试辅助函数
CountDataNodeByNameAndIndex中ir_attr空指针解引用风险 - P3: 0
整体风险评估
低风险。生产代码(.h、.cpp)的实现质量良好,算法逻辑正确(BFS 方向、分类条件、边替换、名称恢复),错误处理路径完整。唯一的缺陷位于测试辅助函数中,不影响生产运行时行为,但可能在测试复用或边界场景下导致测试崩溃。
| 类型 | 数量 |
|---|---|
| 🔴 阻塞 | 0 |
| 🟡 建议 | 1 |
💬 仅评论


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 | ✅ zhanj, zhang_shengjie, xchu42 (3/2) | ✅ zhanj (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
ling-DT, thanks for your pull request. All authors of the commits have signed the CLA. 👍


流水线任务触发成功
任务链接 [4594ae47df344574bca93260b7e1ad48][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| 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 | >>>>> |
[2026-07-23 04:11:03] CI执行结束


🟡 Medium Priority
在 CountDataNodeByNameAndIndex 函数(测试辅助函数)的第 206 行,代码直接对 node->attr.ir_attr 调用 ->DownCastTo<>() 而不先检查 ir_attr 是否为 null。
ir_attr 的类型是 std::unique_ptr<AscIrAttrDefBase>(定义于 ascendc_ir_def.h:370),默认初始化为 nullptr。对 null unique_ptr 调用 operator->() 属于未定义行为(通常会导致崩溃)。
虽然当前测试图中所有 Data 节点都通过 dataX.ir_attr.SetIndex(...) 设置了 ir_attr,但该函数作为通用辅助函数可能被复用于其他图场景。函数内部的第 207 行 if (ir_attr == nullptr) 空值检查也表明作者预期了可能为 null 的情况,但空指针解引用已经在第 206 行发生了。
证据链:node->attr.ir_attr(unique_ptr,可为 null)→ 第 206 行无保护地调用 ->DownCastTo<>() → 若 ir_attr 为空则 UB/崩溃 → 第 207 行的空值检查永远不会被触发。
修复方案:在解引用前先检查 ir_attr 是否为 null。


流水线任务触发成功
任务链接 [f95cebe9028a4954873dcc4182a68a69][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| 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 | >>>>> |
[2026-07-23 04:40:59] CI执行结束


流水线任务触发成功
任务链接 [400815494ec34ffcbdc2b872076dabdb][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| 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 | >>>>> |
[2026-07-23 05:14:35] CI执行结束


流水线任务触发成功
任务链接 [8dd89c07cc0245aeaca7c4ee841c4cd5][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| codecheck | ✅ SUCCESS | >>>>> | |
| SCA | ✅ SUCCESS | >>>>> | |
| antipoison | ✅ SUCCESS | >>>>> | |
| codecheck_checkpr | ✅ SUCCESS | ||
| pre_comment | ✅ SUCCESS | >>>>> | |
| codecheck_codestyle | ⚠️ WARNING | >>>>> | |
| codecheck_precommit | ✅ SUCCESS | >>>>> |
[2026-07-23 05:07:57] CI执行结束


/lgtm


/lgtm


/approve


Pull Request
描述
修复 ASCGraph 中同一个 Data 通过多个 Load 同时喂给 MatMul/Cube 与 Vector 后处理时,cube schedule case generator 因 shared input 无法把 MatMul 与 Vector 切成独立图的问题。
本次变更在切图前复制非 Cube/MatMul 侧共享 Data,并在切图后恢复复制 Data 的原始输入名,保持外部输入语义不变。
变更类型
请选择本次引入的变更类型:
关联的Issue
无。
如何测试
描述测试此变更的步骤和前提条件:
source /workspace/lingxing/Ascend0713/ascend-toolkit/set_env.sh && cmake --build build --target aihac_codegen pyautofuse -j 8tc_af_tf_ks_net_0018静态/动态 runtime 验证通过,并生成autofused_mm_mul_*;compare 脚本已跑通并生成 profiling CSV。核对清单
其他信息
本地未执行 llt。
optimize_ut在当前本地环境因 gmock/gtest 依赖缺失无法运行,待 PR CI 验证。