Pull Request已成功合入, 合并人@CANN-robot
(感谢 Jett_Woo 的贡献)变更摘要
该 PR 修复 Optimizer::AutoScheduler 重建 size var 表时漏收集 scalar-like 节点 IR 属性动态符号的问题:此前 AppendOriginalSizeVar 的扫描清单只覆盖轴的 size 与 Load/Store/Gather/Nddma 的视图表达式,导致仅被 IndexExpr.expr 引用的"孤儿" size var(如 ks1)在 ClearAllSizeVar + AppendOriginalSizeVar 重建后丢失,进而造成 tiling data 缺字段、设备代码符号替换表缺映射,编译报 use of undeclared identifier。本次在 AscGraphInfoComplete::AppendOriginalSizeVar 中补扫 IndexExpr.expr 与 Arange.base/step 属性表达式,并新增 UT 验证收集结果。
主要改动
- 新增
InsertIrAttrFreeSymbols辅助函数:在autofuse/common/ascgraph_info_complete.cpp中读取AscNode的ir_attr中指定属性名对应的af::Expression,通过InsertFreeSymbolsIntoVarSet将其中自由符号插入SizeVarSet。 - 扩展
AppendOriginalSizeVar的节点扫描:遍历graph.GetAllNodes()时,对IndexExpr节点补扫expr属性、对Arange节点补扫base/step属性;常量表达式收集不到自由符号,对既有场景无行为变化。 - 新增 UT
FrontendShapeVarsTest.CollectsSymbolsReferencedByScalarLikeIrAttrs:在test_frontend_shape_vars.cpp中构造挂轴的ks0、仅被IndexExpr.expr引用的ks1、仅被Arange.step引用的ks2,执行ClearAllSizeVar+AppendOriginalSizeVar后断言三者均被重新收集。


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


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


/lgtm


/lgtm


/approve


Pull Request
描述
inductor mean(dim=1) 分解图中,除数是动态 shape 符号(如 s44),经
index_expr(s44)进入图后成为只被IndexExpr.expr引用、不挂任何轴的"孤儿" size var(ks1)。根因:
Optimizer::AutoScheduler对每个 grouped graph 执行"清空后重建" size var 表(ClearAllSizeVar+AppendOriginalSizeVar),重建的扫描清单只覆盖"轴的 size"与"Load/Store/Gather/Nddma 的视图表达式",不含 IndexExpr/Arange 这类 scalar-like 节点(输出视图为空)的 IR 属性。孤儿符号在重建后丢失 → tiling data 结构体缺ks1字段、设备代码符号替换表缺ks1映射 →Tiler::Size原样输出裸符号 → 设备编译报use of undeclared identifier 'ks1'(两处:const int64_t scalar_2 = (ks1)/(1);与Duplicate(local_blk_tensor_of_scalar_2[0], static_cast<int64_t>((ks1)/(1)), ...))。修复:
AppendOriginalSizeVar补扫 scalar-like 节点的 IR 属性表达式——IndexExpr.expr与Arange.base/step(同一根因的同类隐患一并覆盖)。该函数是公共上游:AutoScheduler重建(设备 tiling 字段 + 替换表)与CollectFrontendShapeVars(host tiling 签名)两处调用方同时受益。对既有场景零行为变化:常量表达式收集不到自由符号,登记表内容不变。变更:
autofuse/common/ascgraph_info_complete.cpp+23 行;autofuse/tests/ut/optimize/test_frontend_shape_vars.cpp新增 UT(忠实复刻 Clear+Append 触发序列)。变更类型
关联的Issue
#315 (合并后可关闭)
如何测试
FrontendShapeVarsTest.CollectsSymbolsReferencedByScalarLikeIrAttrs:构造 ks0(挂轴)/ks1(仅 IndexExpr.expr 引用)/ks2(仅 Arange step 引用),执行ClearAllSizeVar+AppendOriginalSizeVar,断言三者均被重新收集。修复前失败(仅收到 ks0),修复后通过。sh build.sh -u --module=autofuse_framework -j 8:optimize_ut 全量 713 用例全绿(含新增);codegen 模块(C++ test_main + Python 267 用例)全绿。uint32_t ks1字段、host 签名含 ks1 参数、设备代码为scalar_2 = (t->ks1)/(1),裸符号 0 处(修复前 2 处)。核对清单
其他信息
同构问题参照:调度器轴表只收 cube 输出视图引用轴导致的轴缺失(已合入的同类修复),本次为 size var 收集范围的对应缺口。