Merged
feat(pass): Attach tile-graph tokens from source op during ExpandFunction #5755
高前程Add on Aug 28
feat(pass): Attach tile-graph tokens from source op during ExpandFunction #5755
Merged
高前程Add on Aug 28
高前程
高前程Collaborators
Aug 28

token expandfunction代码重构,泛化实现方式

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for 高前程's contribution.)
高前程高前程Collaborators
Aug 28 Created pull request, commit dcaae241
atomgit-bot
atomgit-bot
Aug 28 Comments:

变更摘要

本 PR 重构了 ExpandFunction 展开过程中 tile 图 token 的挂载机制:将 READ/WRITE 语义 token 与 NORMAL token 的配对关系从 IRContext 迁移到 ExpandFunction(线程局部存储),并在展开时以当前被展开的源 op(ExpandFunction::GetCurrentTileOp())为上下文,把其 result_token_/tokens_ 对应的 NORMAL token 直接挂到生成的 SLICE/CONTRACT 操作上,替代原先基于 contract_write_token.h 属性传递的机制,同时删除相关旧接口与旧 UT。

主要改动

  • Token 配对逻辑迁移到 ExpandFunction:删除 IRContext::GetNormalToken 及 semantic_to_normal_ 映射,MakeSemanticToken 不再创建并登记配对 NORMAL token;ExpandFunction 新增线程局部 semanticToNormal_ 与静态方法 GetNormalToken(),在展开期间惰性生成配对 NORMAL token,并通过新增的 CurrentTileOpGuard/SemanticToNormalGuard 管理其生命周期。
  • 重写 Function::AddOperation 的 token 挂载:新增 CollectExpandTokenPlan、AttachReadToMatchingInputParents、AttachToOutputParents、AssignMappedTokens 等辅助函数,将 READ 的 NORMAL token 挂到 slice op 的 result_token_、将 WRITE/依赖 token 挂到 contract op 的 result_token_/tokens_,替换原有基于 IRBuilder 依赖收集的旧逻辑。
  • tile 展开路径改用新挂载接口:operation_impl.cpp 新增 AttachExpandResultTokens/AttachExpandInputTokens,在 TiledAssembleRecursive、TiledViewOperationRecursive 中调用,并移除 AttachContractWriteTokenAttrs/ApplyContractWriteNormalTokens 的调用;TiledAssemble、TiledAssembleRecursive、TiledInnerAssemble 删除 sourceOp 参数,TiledViewOperationRecursive 增加 VIEW 至多一个 READ result token 的断言。
  • 删除旧的属性化 token 传递机制:整体删除 contract_write_token.h(含 kContractWriteTokenOut/kContractWriteTokenIn/kContractReadTokenIn 常量及相关内联函数)及其对应 UT 文件 test_expandfunction_cascade_assemble_waw.cpp;ProcessForNotExpandOp 不再直接拷贝 result_token_/tokens_。
  • 新增 UT 覆盖新挂载行为:test_expandfunction.cpp 新增 ComputeOpReadGoesToSliceAndWriteGoesToContract 与 AssembleWriteGoesToContractAndConsumedOnNextAssemble 两个用例,验证 READ token 落到 slice、WRITE token 落到 contract,以及前序写 token 被后续 assemble 消费。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Aug 28 Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Aug 28 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Aug 28 Comments:

CLA Signature Pass

Immutable01, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
CANN-robot
CANN-robotCollaborators
Aug 28 Comments:

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
framework/src/interface/cache ✅ tsungl4, DCGDDD (2/2) ✅ tsungl4 (1/1)
framework/src/interface/function ✅ tsungl4, DCGDDD (2/2) ✅ tsungl4 (1/1)
framework/src/interface/operation ✅ tsungl4, DCGDDD (2/2) ✅ tsungl4 (1/1)
framework/src/interface/tensor ✅ tsungl4, DCGDDD (2/2) ✅ tsungl4 (1/1)
framework/src/passes ✅ zhangyuebing, DCGDDD (2/2) ✅ zhangyuebing (1/1)
repo-cann/pypto ✅ tsungl4, zhangyuebing, DCGDDD (3/2) ✅ tsungl4, zhangyuebing (2/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)
likedislike
CANN-robotCANN-robotCollaborators
Aug 28 Set xinweiliu,cam_bxh,dai-zhentao,lululu40888,shi-dingkun,gguuaanngg,codehjp423,gaoxiang618,wangzheng97,DCGDDD,syfeng,jason_yuan_ye,foundea,ym-HW,hw_zhangzhiqi,yinjie27_,congqiannan,zhangyuebing,tsungl4,gaoxingwang,zhiweiyuan,caodongdong,make_pto,zhoubotcam,linjiashu,wangbing110,WenboCodes as approver
CANN-robotCANN-robotCollaborators
Aug 28 Set xinweiliu,cam_bxh,dai-zhentao,lululu40888,shi-dingkun,gguuaanngg,codehjp423,gaoxiang618,wangzheng97,DCGDDD,syfeng,jason_yuan_ye,foundea,ym-HW,hw_zhangzhiqi,yinjie27_,congqiannan,zhangyuebing,tsungl4,gaoxingwang,zhiweiyuan,caodongdong,make_pto,zhoubotcam,linjiashu,wangbing110,WenboCodes as approver
高前程高前程Collaborators
Aug 28 Associated issue: [Task|任务跟踪]: 新IR适配
高前程高前程Collaborators
Aug 28 Modify description of pull request
高前程
高前程Collaborators
Aug 28 Comments:

compile

likedislike
高前程高前程Collaborators
Aug 28 Pre merge succeeded (commit_id: 21800633a12e06732560bd6c539defc5d07a1c38)
高前程高前程Collaborators
Aug 28 Modify description of pull request
CANN-robotCANN-robotCollaborators
Aug 28 Added label: ci-pipeline-running
CANN-robot
CANN-robotCollaborators
Aug 28 Comments:

流水线任务触发成功
任务链接 [8046c64c9d514727954349c562060d98][流水线指导]

任务名称状态日志下载链接
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_ubuntu24 ✅ SUCCESS >>>>> >>>>>
pre_comment ✅ SUCCESS >>>>>
UT_Test_Py3_ninja_simulation ✅ SUCCESS
UT_Test_Py3_ninja ✅ SUCCESS >>>>>
UT_Test_Cpp_make_gnu_part_1 ✅ SUCCESS
UT_Test_Cpp_make_gnu_part_2 ✅ SUCCESS
UT_Test_Cpp_make_gnu_part_3 ✅ SUCCESS
UT_Test_Cpp_make_clang_part1 ✅ SUCCESS
UT_Test_Cpp_make_clang_part2 ✅ SUCCESS
UT_Test_Cpp_make_clang_part3 ✅ SUCCESS
UT_Test_kirinx90 ✅ SUCCESS
UT_Test_kirin9030 ✅ SUCCESS
UT_Test_report ✅ SUCCESS >>>>>
PreSmoke_A900 ✅ SUCCESS >>>>>

[2026-08-28 12:12:59]    CI执行结束

likedislike
CANN-robot
CANN-robotCollaborators
Aug 28 Comments:

流水线任务触发成功
任务链接 [ef475a62f4214051bb82c24d60de96c6][流水线指导]

任务名称状态日志下载链接
SCA ✅ SUCCESS >>>>>
antipoison ✅ SUCCESS >>>>>
codecheck_Pr ✅ SUCCESS
codecheck_codestyle ✅ SUCCESS >>>>>
codecheck_precommit ✅ SUCCESS >>>>>
StaticCheck_md ✅ SUCCESS

[2026-08-28 11:49:25]    CI执行结束

likedislike
CANN-robot
CANN-robotCollaborators
Aug 28 Comments:

流水线任务触发成功
任务链接 [5fc14083897a4e15a33d16877aeade33][流水线指导]

任务名称状态日志下载链接
get_pr_file ✅ SUCCESS
static-check ✅ SUCCESS
compile ✅ SUCCESS

[2026-08-28 12:13:42]    CI执行结束

likedislike
CANN-robotCANN-robotCollaborators
Aug 28 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Aug 28 Added label: ci-pipeline-passed
lidongsheng
lidongshengCollaborators
Aug 29 Comments:

/approve

likedislike
zhangyuebing
zhangyuebingCollaborators
Aug 29 Comments:

/approve

likedislike
CANN-robotCANN-robotCollaborators
Aug 29 Added label: approved
zhangyuebing
zhangyuebingCollaborators
Aug 29 Comments:

✅ 已将本 PR 下你提交的未解决检视意见标记为已解决(无未解决的检视意见)。

likedislike
杨旭
杨旭Collaborators
Aug 29 Comments:

/lgtm

likedislike
CANN-robotCANN-robotCollaborators
Aug 29 Added label: lgtm
CANN-robotCANN-robotCollaborators
Aug 29 Merged pull request