Pull Request has been successfully merged by CANN-robot.
(Thank you for 高前程's contribution.)变更摘要
本 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 消费。


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
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)


compile


流水线任务触发成功
任务链接 [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执行结束


流水线任务触发成功
任务链接 [5fc14083897a4e15a33d16877aeade33][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| get_pr_file | ✅ SUCCESS | ||
| static-check | ✅ SUCCESS | ||
| compile | ✅ SUCCESS |
[2026-08-28 12:13:42] CI执行结束


/approve


/approve


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


/lgtm


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