Merged
fix(function): Fix copy attr of inner copyin/out not normalized #6587
fix(function): Fix copy attr of inner copyin/out not normalized #6587
Merged
赵俊涵Add on Sep 21
赵俊涵
赵俊涵Collaborators
Sep 21

问题背景

子图中的内部 COPY_IN/COPY_OUT 属性未正确进行 COA Normalize,导致无法子图同构。
补充 Normalize 后,又暴露出 operand COA 索引和 shape 参数化引起的精度问题。

修改内容

本 PR 包含以下三部分修改:

  1. 支持内部 Copy Normalize
    在 NormalizeCoaForNormalOperands 中处理内部 COPY_IN/COPY_OUT 及 L1 Copy,将动态属性加入 COA 参数列表。

  2. 修正内部 Copy 的 operand 属性索引
    普通内部 Copy 的 COA 仅用于 Copy 属性,不再设置 IOpAtt/OOpAtt,避免 InferParamIndex 将其错误解释为
    Tensor COA;仅保留 outcast raw 场景的索引设置。

  3. 保持 Copy shape 为编译期常量
    Normalize 时不再将 shape 回写为 COA Parameter,只对 offset 等动态属性进行参数化。避免 codegen 通过
    GetSpecifiedShape(1) 读取参数化 shape 时回退成 1×1,导致内部 GM spill 搬运数据不完整。

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for 赵俊涵's contribution.)
赵俊涵赵俊涵Collaborators
Sep 21 Created pull request, commit c8c8f229
atomgit-bot
atomgit-bot
Sep 21 Comments:

变更摘要

本 PR 重构了 Function::NormalizeCoa 系列中 COA 规范化(参数化)的处理逻辑。核心是移除用于去重的 normalizedOps 集合、将 processedOperands 重命名为 normTensors,并抽出通用的 MaybeNormalizeValue 重载来统一处理 OpImmediate 列表到 SymbolicScalar 的归一化,从而让入口/出口 cast、普通操作数以及特殊算子的规范化路径共享同一套逻辑。同时将散落在 function.cpp 中的长串 opcode 判断收敛为 OpcodeManager 上的新判定接口。

主要改动

  • 新增算子类别判定接口: 在 OpcodeManager 中新增 IsTransData、IsReshapeCopyIn、IsReshapeCopyOut 三个内联方法,把原先逐条列举的 opcode 比较封装为语义化判定。
  • 抽取并复用 MaybeNormalizeValue 重载: 新增接收 std::vector<OpImmediate> 并返回 std::vector<SymbolicScalar> 的 MaybeNormalizeValue,替换并删除了 NormalizeReshapeCopyDynValidShape,同时被 NormalizeCopyIn、NormalizeCopyOut、NormalizeCoaForSpecialInfo 复用。
  • 移除 normalizedOps 去重集合: 删除 std::unordered_set<Operation*> 的 normalizedOps 及其在各 NormalizeCoaFor* 函数中的插入与判断,processedOperands 统一重命名为 normTensors,相关函数签名同步调整。
  • 调整 NormalizeCoaForNormalOperands 的规范化条件: 由依赖 normalizedOps 改为依据 IOpAttrOffset(0) == -1、GetOpAttribute() != nullptr 及 IsCopyIn/IsCopyFromL1/IsCopyOut 判定,内层 copy attr 仍进入 coaLists,仅 outcast-raw 的 copy 才占用 IOpAtt。
  • 特殊信息处理改用新判定并区分 reshape copy: NormalizeCoaForSpecialInfo 用 IsTransData 替代原 opcode 枚举,并分别为 IsReshapeCopyIn/IsReshapeCopyOut 归一化 fromDynValidShape/toDynValidShape 后写回 CopyOpAttribute。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Sep 21 Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Sep 21 Added label: stat/needs-squash
CANN-robotCANN-robotCollaborators
Sep 21 Added label: cann-cla/yes
赵俊涵赵俊涵Collaborators
Sep 21 Associated issue: [Task|任务跟踪]: 新IR适配
CANN-robot
CANN-robotCollaborators
Sep 21 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
9.2.0 ✅ DCGDDD, gcw_kUomxQ2l (2/2) ✅ gcw_kUomxQ2l (1/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
CANN-robotCANN-robotCollaborators
Sep 21 Set xinweiliu,cam_bxh,dai-zhentao,TianXL,lululu40888,shi-dingkun,gguuaanngg,codehjp423,jiangtao_rts,gitcode-chenjiao,hanxiaolong,gaoxiang618,wangzheng97,DCGDDD,syfeng,jason_yuan_ye,foundea,ym-HW,hw_zhangzhiqi,yinjie27_,congqiannan,zhangyuebing,tsungl4,gaoxingwang,zhiweiyuan,caodongdong,make_pto,zhoubotcam,linjiashu,wangbing110,gcw_kUomxQ2l,Andy-lb,WenboCodes as approver
CANN-robotCANN-robotCollaborators
Sep 21 Set TianXL,jiangtao_rts,gitcode-chenjiao,hanxiaolong,gcw_kUomxQ2l,Andy-lb as approver
赵俊涵
赵俊涵Collaborators
Sep 21 Comments:

/compile

likedislike
赵俊涵赵俊涵Collaborators
Sep 21 Pre merge succeeded (commit_id: 086e01a1176b0aeffe03d6954e12b133e729193f)
CANN-robot
CANN-robotCollaborators
Sep 21 Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
Sep 21 Added label: ci-pipeline-running
6 event messages are collapsed here。 See more
CANN-robotCANN-robotCollaborators
Sep 22 Removed label: ci-pipeline-passed
CANN-robot
CANN-robotCollaborators
Sep 22 Comments:

Notification

This pull request has been changed(code update) or closed, so removes the following label(s): ci-pipeline-passed.

likedislike
CANN-robotCANN-robotCollaborators
Sep 22 Added label: cann-cla/yes
赵俊涵
赵俊涵Collaborators
Sep 22 Comments:

/compile

likedislike
赵俊涵赵俊涵Collaborators
Sep 22 Pre merge succeeded (commit_id: 24f205ca4ac3ed296b2a6b5d14c3c06462cf7d11)
CANN-robot
CANN-robotCollaborators
Sep 22 Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
Sep 22 Added label: ci-pipeline-running
赵俊涵赵俊涵Collaborators
Sep 22 Change title to "fix(function): Fix copy attr of inner copyin/out not normalized", originally titled "fix_distribution".
CANN-robotCANN-robotCollaborators
Sep 22 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 22 Added label: ci-pipeline-passed
赵俊涵赵俊涵Collaborators
Sep 22 Modify description of pull request
CANN-robotCANN-robotCollaborators
Sep 22 Added label: AscendC-SUCC
杨旭
杨旭Collaborators
Sep 22 Comments:

/lgtm

likedislike
liulun0308
liulun0308Collaborators
Sep 22 Comments:

/approve

likedislike
CANN-robotCANN-robotCollaborators
Sep 22 Added label: lgtmapproved
CANN-robotCANN-robotCollaborators
Sep 22 Merged pull request