Pull Request has been successfully merged by CANN-robot.
(Thank you for LiuChang's contribution.)变更摘要
本 PR 从 master cherry-pick 4 笔提交到 9.2.0 分支,核心修复 IR 中符号标量表达式(如 if 条件、标量 yield/continue 值)的操作数变量对基本访问器不可见、导致循环携带标量被误判失效的问题。改动包括:在变量收集器中新增对 ScalarExprPtr 的下钻处理(stmt_utils.cpp),在 host 后端为标量迭代参数生成初始化、逐迭代 phi 更新与循环退出绑定(ir_backend.cpp),重构 merge_stmts_pass 中分支克隆的 raw tensor 共享逻辑,并将 IR 文本 dump/load 的 memoryId 字段更名为 rawmagic,同时配套更新 LogicalTensor::Clone、EraseOperations 以及大量 golden 测试与示例。
主要改动
-
符号标量操作数下钻收集(
stmt_utils.cpp): 新增VisitExpr_(const ScalarExprPtr&)重载,通过SymbolicScalar::FromExpr(op).GetVarRefs(var_uses)收集隐藏在RawSymbolicExpression中的操作数变量,使循环携带的标量保持存活,对应 PR 标题所述核心修复。 -
标量迭代参数的代码生成(
ir_backend.cpp):FindExprFromForStmt将标量iterArgs_的迭代变量符号注册到Linker;VisitForStmtForControlFlow为标量iterArg输出初始化赋值(VALUE_<name> = ...)、从循环体尾部ContinueStmt提取新值做逐迭代 phi 更新,并在循环退出时把最终携带值绑定到returnVars_。 -
分支克隆的 raw tensor 共享重建(
merge_stmts_pass.cpp): 新增RawDefCollector区分 raw 定义与 view 定义(ASSEMBLE/ASSEMBLE_SSA/ATOMIC_RMW),克隆改为统一v->Clone()后按rawmagic重建克隆变量与分支内 raw tensor 的映射,避免分支间 raw tensor 串扰。 -
IR 文本读写字段更名(
io_text_dumper.cpp/io_text_loader.cpp): 逻辑张量引用的打印与解析从memoryId改为rawmagic,ParseLogicalTensorVar同步改用rawmagic >= 0判断回填。 -
配套调整与测试(
logical_tensor.cpp、function.cpp及测试):LogicalTensor::Clone提前复制actualRawmagic/memoryId;Function::EraseOperations在擦除后调用RefreshVarDependency();新增test_c2v2.py、test_yield_scalar1.pypto、test_assemble.py等用例并批量更新 golden 文件,activation.py示例将 GELU 由 sigmoid 近似改为基于pypto.erf的精确公式。


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 |
|---|---|---|
| examples | ✅ DCGDDD, tsungl4 (2/2) | ✅ DCGDDD (1/1) |
| framework/src/interface/function | ✅ DCGDDD, tsungl4 (2/2) | ✅ tsungl4, DCGDDD (2/1) |
| framework/src/interface/ir/transforms | ✅ DCGDDD, tsungl4 (2/2) | ✅ DCGDDD, tsungl4 (2/1) |
| framework/src/interface/tensor | ✅ DCGDDD, tsungl4 (2/2) | ✅ DCGDDD, tsungl4 (2/1) |
| framework/src/machine | ✅ tsungl4, DCGDDD (2/2) | ✅ tsungl4 (1/1) |
| repo-cann/pypto | ✅ DCGDDD, tsungl4 (2/2) | ✅ DCGDDD, tsungl4 (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
seu_chang, thanks for your pull request. All authors of the commits have signed the CLA. 👍


compile


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


/lgtm
/approve


/approve


/check-pr


The following label is not ready.
lgtm: Please wait for committers to review the code.


/lgtm


bf599774e
dd89fd6af
f14a6b6a
e2e62919e
同步主线4笔提交,从master cherry-pick到9.2.0分支