Merged
fix(ir): Support get_tensor_data #5466
lidongshengAdd on Aug 15
fix(ir): Support get_tensor_data #5466
Merged
lidongshengAdd on Aug 15
lidongsheng
lidongshengCollaborators
Aug 15

Related Issue: #2559

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for lidongsheng's contribution.)
lidongshenglidongshengCollaborators
Aug 15 Created pull request, commit cb54b18d
lidongshenglidongshengCollaborators
Aug 15 Associated issue: [Task|任务跟踪]: 新IR适配
atomgit-bot
atomgit-bot
Aug 15 Comments:

变更摘要

本 PR 主要聚焦于 IR 层对 get_tensor_data 的支持:在 ComputeOutcast 中保留被标记为 IsGetTensorDataOutcast 的 operand,并在 hiddenFunc 构建阶段新增 CreateTensorDataImportOp,同时通过临时切换 CurrentFunction 保证该 op 生成在正确的函数上下文中。此外,IRContext 与 IRBuilder 新增了面向 Operation 的 GetDependToken 重载,在发射 tensor op 时填充 tokens_ 依赖 token,并补充了对应的 SSA 校验测试与 get_tensor_data 用例。

主要改动

  • ComputeOutcast 的 outcast 判定扩展: 在 framework/src/interface/tensor/ir_func_builder.cpp 中,原 neededByConsumer || isFuncOutput 条件新增 oOperand->IsGetTensorDataOutcast(),使与 get_tensor_data 相关的 operand 也能被加入 origin outcast,避免被误裁剪。
  • hiddenFunc 中创建 tensor data import op: 在 FinalizeHiddenFunc 中新增 hiddenFunc->CreateTensorDataImportOp();同时在 FinalizePathFunc 中临时将 CurrentFunction 切换为 hiddenFunc 并在 CreateAndFinalizePathFunc 后恢复,保证 import op 在正确的函数上下文内创建。
  • 新增面向 Operation 的依赖 token 获取: 在 IRContext 中新增 GetDependToken(Operation& op),遍历 op.GetDynamicAttributeList() 收集依赖 token、去重并按名称排序;IRBuilder::EmitTensorStmts 在发射 tensor op 语句时写入 stmt->tokens_,并在 irbuilder.h 中暴露对应接口。
  • 补充 SSA 校验辅助函数: python/tests/ut/ir/test_common.py 新增 ssa_verify(func, desc=""),用于将函数包装为 program 并用 IRVerifier 校验 SSA 形式。
  • 新增 get_tensor_data 测试用例: 新增 python/tests/ut/ir/test_tensor_data.py,覆盖动态 shape 下的 grouped_matmul、view、matmul 及结果写回场景,并对编译结果执行 SSA 校验。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Aug 15 Comments:

代码审查

✅ 未发现问题

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

CLA Signature Pass

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

likedislike
CANN-robot
CANN-robotCollaborators
Aug 15 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
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/pypto ✅ 尹杰, DCGDDD (2/2) ✅ 尹杰 (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

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

likedislike
CANN-robotCANN-robotCollaborators
Aug 15 Set xinweiliu,cam_bxh,dai-zhentao,gguuaanngg,codehjp423,gaoxiang618,wangzheng97,DCGDDD,syfeng,jason_yuan_ye,foundea,ym-HW,yinjie27_,congqiannan,zhangyuebing,gaoxingwang,zhiweiyuan,caodongdong,make_pto,zhoubotcam,linjiashu,wangbing110,WenboCodes as approver
CANN-robotCANN-robotCollaborators
Aug 15 Set xinweiliu,cam_bxh,dai-zhentao,gguuaanngg,codehjp423,gaoxiang618,wangzheng97,DCGDDD,syfeng,jason_yuan_ye,foundea,ym-HW,yinjie27_,congqiannan,zhangyuebing,gaoxingwang,zhiweiyuan,caodongdong,make_pto,zhoubotcam,linjiashu,wangbing110,WenboCodes as approver
lidongshenglidongshengCollaborators
Aug 15 Pre merge succeeded (commit_id: 8034f74e3bb98e66f559ca860c28d4981dcf675e)
lidongshenglidongshengCollaborators
Aug 15 Force-pushed 1 commits:5c44a0fd-fix(ir): Support get_tensor_data
lidongshenglidongshengCollaborators
Aug 15 Pre merge succeeded (commit_id: 4c9e30d051d4ed9edbccb4a2785619bae31ae17b)
CANN-robotCANN-robotCollaborators
Aug 15 Removed label: cann-cla/yes
lidongsheng
lidongshengCollaborators
Aug 15 Comments:

compile

likedislike
CANN-robotCANN-robotCollaborators
Aug 15 Added label: cann-cla/yes
lidongshenglidongshengCollaborators
Aug 15 Pre merge succeeded (commit_id: 6ace8a8bb262dbe2ebbf39ca04896d766d2b8fcd)
CANN-robotCANN-robotCollaborators
Aug 15 Added label: ci-pipeline-running
CANN-robot
CANN-robotCollaborators
Aug 15 Comments:

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

任务名称状态日志下载链接
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
PreSmoke_A900 ❌ FAILED >>>>>
likedislike
CANN-robot
CANN-robotCollaborators
Aug 15 Comments:

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

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

[2026-08-15 23:26:07]    CI执行结束

likedislike
CANN-robot
CANN-robotCollaborators
Aug 15 Comments:

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

任务名称状态日志下载链接
get_pr_file ✅ SUCCESS
static-check ✅ SUCCESS
compile ❌ FAILED
likedislike
CANN-robotCANN-robotCollaborators
Aug 15 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Aug 15 Added label: ci-pipeline-failed
lidongsheng
lidongshengCollaborators
Aug 16 Comments:

compile

likedislike
CANN-robotCANN-robotCollaborators
Aug 16 Removed label: ci-pipeline-failed
CANN-robotCANN-robotCollaborators
Aug 16 Added label: ci-pipeline-running
CANN-robot
CANN-robotCollaborators
Aug 16 Comments:

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

任务名称状态日志下载链接
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
PreSmoke_A900 ✅ SUCCESS >>>>>

[2026-08-16 07:51:40]    CI执行结束

likedislike
CANN-robot
CANN-robotCollaborators
Aug 16 Comments:

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

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

[2026-08-16 07:33:12]    CI执行结束

likedislike
CANN-robot
CANN-robotCollaborators
Aug 16 Comments:

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

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

[2026-08-16 07:52:13]    CI执行结束

likedislike
CANN-robotCANN-robotCollaborators
Aug 16 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Aug 16 Added label: ci-pipeline-passed
杨旭
杨旭Collaborators
Aug 17 Comments:

/lgtm

likedislike
Jie Yin
Jie YinCollaborators
Aug 17 Comments:

/approve

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