Merged
refactor(operation): Replace GatherInUB magic numbers with named constants #6590
refactor(operation): Replace GatherInUB magic numbers with named constants #6590
Merged
bynshardAdd on Sep 21
bynshard
bynshardCollaborators
Sep 21

gatherinub 代码中魔鬼数字整改

Related Issue:
https://gitcode.com/cann/pypto/issues/3413

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for bynshard's contribution.)
bynshardbynshardCollaborators
Sep 21 Created pull request, commit 7071182b
atomgit-bot
atomgit-bot
Sep 21 Comments:

变更摘要

本 PR 在 framework/src/interface/operation/operation_impl.cpp 中对 GatherInUB 相关实现进行了可读性重构,将原先散落在 TiledGatherInUB 和 experimental::GatherInUB 中的魔法数字替换为具名常量,不改变原有逻辑与行为。新增了 GATHER_IN_UB_INDICES_LEADING_DIM 与 GATHER_IN_UB_SUPPORTED_AXIS 两个常量,分别表示 indices 前导维度长度和仅支持的 axis 取值。

主要改动

  • 新增具名常量: 在 TiledGatherInUB 前定义 constexpr int64_t GATHER_IN_UB_INDICES_LEADING_DIM = 1 与 constexpr int GATHER_IN_UB_SUPPORTED_AXIS = -2,用于表达 indices 前导维度与受支持的 axis 值。
  • 替换分块视图中的魔法数字: 在 TiledGatherInUB 内将 indices->View 的形状参数由字面量 1 改为 GATHER_IN_UB_INDICES_LEADING_DIM,语义保持一致。
  • 替换维度校验中的魔法数字: 在 experimental::GatherInUB 中将 indices.GetShape()[0] == 1 的判断改为与 GATHER_IN_UB_INDICES_LEADING_DIM 比较。
  • 替换 axis 校验并调整报错信息: 将 axis == -2 的判断改为与 GATHER_IN_UB_SUPPORTED_AXIS 比较,并在 CHECK 的提示信息中改为输出该常量,使提示与常量定义保持同步。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Sep 21 Comments:

代码审查

✅ 未发现问题

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

CLA Signature Pass

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

likedislike
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 ✅ 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)
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
bynshardbynshardCollaborators
Sep 21 Associated issue: [Bug-Report|缺陷反馈]:gatherinub 代码中魔鬼数字整改
bynshard
bynshardCollaborators
Sep 21 Comments:

compile

likedislike
bynshardbynshardCollaborators
Sep 21 Pre merge succeeded (commit_id: d8c2788b523eb3688ca92f9416dea1623b7f447b)
CANN-robot
CANN-robotCollaborators
Sep 21 Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
Sep 21 Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 21 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 21 Added label: ci-pipeline-passed
liulun0308
liulun0308Collaborators
Sep 22 Comments:

/approve

likedislike
CANN-robotCANN-robotCollaborators
Sep 22 Added label: approved
bynshardbynshardCollaborators
Sep 22 Modify description of pull request
Jie Yin
Jie YinCollaborators
Sep 22 Comments:

/approve

likedislike
Jie Yin
Jie YinCollaborators
Sep 22 Comments:

/lgtm

likedislike
CANN-robot
CANN-robotCollaborators
Sep 22 Comments:

The following users do not have permission to comment /lgtm or /approve on any module in this PR:
/approve: 尹杰

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