Merged
feat(ir): Make assemble mark_store controllable via runtime switch #5591
赵俊涵Add on Aug 21
feat(ir): Make assemble mark_store controllable via runtime switch #5591
Merged
赵俊涵Add on Aug 21
赵俊涵
赵俊涵Collaborators
Aug 21

背景

pil/ops.py 中 assemble 的 Block.mark_store 此前为全局无条件调用,无法按场景关闭,影响 LogicalTensor 版本生成的灵活性。

改动内容

  • 开关控制:ops.py 中 assemble 的 mark_store 改为仅在 assemble_new_logical_tensor() 返回 True 时执行,实现运行时开关
  • 新增接口:builder.cpp / ir.pyi 新增 assemble_new_logical_tensor() getter,与已有的 set_assemble_new_logical_tensor() 配套
  • UT 同步:run_merge_pass 默认 create_new_logical_tensor=True, 移除测试中冗余的显式传参,重新生成 8 个 merge_pass golden 文件
likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for 赵俊涵's contribution.)
赵俊涵赵俊涵Collaborators
Aug 21 Created pull request, commit 3493ca71
赵俊涵赵俊涵Collaborators
Aug 21 Associated issue: [Task|任务跟踪]: 前端插入token依赖,删除冗余token
atomgit-bot
atomgit-bot
Aug 21 Comments:

变更摘要

本 PR 回退了 assemble 对输出张量执行的 mark_store 逻辑(fix(ir): Revert mark_store of assemble)。核心改动是在 python/pypto/pil/ops.py 的 assemble 包装函数中,将无条件调用 Block.mark_store(args[2]) 改为仅在 pypto_impl.ir.assemble_new_logical_tensor() 返回真时才调用,即默认不再对 ASSEMBLE 做 store 标记。为此新增了查询 Assemble 是否创建新 LogicalTensor 版本的接口 assemble_new_logical_tensor()(含 .pyi 类型桩与 C++ Python 绑定),并同步更新了大量 .pypto IR 测试夹具及若干 Python 单测。

主要改动

  • 回退 mark_store 调用: 在 python/pypto/pil/ops.py 的 assemble 中,Block.mark_store(args[2]) 的执行增加前置条件 pypto_impl.ir.assemble_new_logical_tensor() and not isinstance(args[0], Sequence),使默认行为下不再对 ASSEMBLE 标记 store。
  • 新增查询接口: 在 python/pypto/pypto_impl/ir.pyi 中新增 assemble_new_logical_tensor() -> bool 桩函数,并在 python/src/bindings/ir/builder.cpp 中绑定为调用 IRContext::Get().AssembleNewLogicalTensor(),与已有的 set_assemble_new_logical_tensor 成对提供开关/查询能力。
  • 更新 IR 测试夹具: python/tests/ut/ir/test_merge_pass/ 下多个 .pypto 用例(如 test_merge_pass1.pypto 至 test_merge_pass8.pypto、test_oi_update1.pypto、test_yield_scalar.pypto)以及 python/tests/ut/ir/token/ 下的 test_infer_pass_test_*.pypto 用例中,ASSEMBLE 的结果不再作为循环 carry 变量,移除了相应 iter/yield/continue 中的 %z、%aux 等传递项,反映回退后的 IR 形态。
  • 删除与调整相关单测: 删除了 python/tests/ut/ir/test_canonicalize_nested_loop.py(原用于验证嵌套循环 carry 的 canonicalize 用例);python/tests/ut/ir/test_pass.py 中 test_tensor_move 与 test_tensor_move2 对 ADDS 结果名的断言由 b_4 调整为 b_0。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Aug 21 Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Aug 21 Added label: cann-cla/yes
44 messages are collapsed here。 See more
CANN-robotCANN-robotCollaborators
Aug 22 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Aug 22 Added label: ci-pipeline-passed
lidongsheng
lidongshengCollaborators
Aug 24 Comments:

/approve

likedislike
CANN-robotCANN-robotCollaborators
Aug 24 Added label: lgtmapproved
CANN-robotCANN-robotCollaborators
Aug 24 Merged pull request