Pull Request已成功合入, 合并人@CANN-robot
(感谢 xiebangrui2025 的贡献)变更摘要
本 PR 主要完善 IndirectLoad 在 SIMD/SIMT 场景下的 Broadcast 重写、前置算子融合与后融合 Reduce 支持。核心是修复 SIMT 双输入前置算子 + 后融合 Reduce 的 codegen 失败:为 TemplateBehavior 新增 skips_input_lifecycle 开关,SIMT IndirectLoad 的 input0/input1 跳过通用 WaitInputs/FreeInputs,输出生命周期仍由 skips_ub_lifecycle 单独控制,避免 post-reduce SIMT 输出 Alloc/Sync/Free 缺失导致 GetTensor not found。同时调整 SIMD 广播重写策略(不再折叠/拒绝直连 outer Broadcast,SK 跳过 input-pre 搬移),修正 zero-stride-compact 窗口 stride 派生,并新增 IL_ADD_IL_REDUCE 最小回归用例、IL_INPUT_ABS_BEFORE_BROADCAST Abs 前置支持及 embedding 用例改造。
主要改动
-
SIMT 输入/输出生命周期拆分修复:在
codegen_kernel_loop.cpp的GenerateBody中,SIMTIndirectLoad的 input0/input1 不再进入通用WaitInputs/FreeInputs,输出侧仍按skips_ub_lifecycle保留 Alloc/Sync/Free,修复 post-reduce SIMT codegen 的 GetTensor not found / WaitInputs tensor_ptr nullptr 问题;对应在indirect_load_utils.h/.cpp新增TemplateBehavior::skips_input_lifecycle字段与IsSimtIndirectLoad()判定函数。 -
SIMD/SIMT/SK 广播重写路径拆分:
indirect_load_schedule_case_generator.cpp删除HasDirectOuterBroadcast/IsSupportedDirectOuterBroadcast等对直连 outer Broadcast 的折叠与拒绝逻辑,SIMD candidate 保留直连 Broadcast 节点;RewriteInputPreNodes对kIndirectLoadSK直接跳过,并拆分出RewriteSkInputPaths/RewriteBroadcastPaths分别处理 SK 与 SIMT/SIMD 的改写入口。 -
zero-stride-compact 窗口 stride 派生修正:
reg_indirect_load_api_call.cpp的BuildTensorWindowInfo中仅kDense布局保留逻辑 row-major strides,kZeroStrideCompact视图保留零 stride 轴、非零窗口 stride 改由物理向量视图派生,以规避 bitwidth 变化的 producer 在逻辑元素间引入 padding 的问题。 -
新增回归用例与生成器扩展:新增
indirect_load_add_il_reduce_test(index 区双输入 Add 前置 + 后融合ReduceSum的 SIMT 最小场景,复用 where 生成器/E2E 文件,以IL_ADD_IL_REDUCE宏门控);indirect_load_broadcast_backend_generator.cpp与对应 E2E kernel 新增IL_INPUT_ABS_BEFORE_BROADCAST,支持 Broadcast 前插入 Abs 前置算子并补齐 oracle 计算。 -
embedding 用例改造与测试矩阵精简:
indirect_load_embedding_backend_generator.cpp将索引改为 INT32 +Cast到 INT64 链路,并在IndirectLoad后拼接 Add/Mul/ReduceSum后融合;E2E 断言从EXPECT_FLOAT_EQ改为EXPECT_NEAR(..., 0.0625F)以对齐 IL 家族容差约定;indirect_load_backend_generator_common.h的BackendGraph构造新增index_type参数,同时精简 rank3 int64 gather exact、strided gap-kind 笛卡尔积等冗余用例并同步更新run_autofuse_test.shCI 清单。


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


描述
本 PR 完善 IndirectLoad 在 SIMD/SIMT 模板下的广播、前置融合与后融合 Reduce,并补充 embedding 相关场景覆盖。
GetTensor not found或空指针。变更类型
请选择本次引入的变更类型:
关联的Issue
无。
如何测试
pre-commit与 OAT 增量检查,检查通过。核对清单
其他信息
无。
本次提交补充
index_offset,普通 output 分支 GM Load 使用output_index,并同时向Outputevaluator 传递两类偏移,避免IndirectLoad → index-dependent Mul → Reduce场景的 GM 越界。pre-commit与 OAT 增量检查。