Merged
fix: 按字节数换算 Python group 属性元素数 #5682
fix: 按字节数换算 Python group 属性元素数 #5682
Merged
KaranocaVeAdd on Oct 20
KaranocaVe
Oct 20

fix: 按字节数换算 Python group 属性元素数

aclrtGetGroupInfoDetail 通过 paramRetSize 返回输出字节数。对于一个 int32_t 属性,返回值为 4;当前 Python 包装层把 4 当作列表元素数和循环上界,实际只写入一个元素,因此返回四项列表,后三项未初始化。预期结果是只返回一个属性值。
包装层应拒绝不能被元素大小整除的返回长度,并在创建列表和遍历前将字节数换算成元素数。用只写入值 42、并返回 4 字节的 fake C API 验证:基线返回四项,修复后返回 [42];非整除长度被拒绝。

关联 Issue: https://gitcode.com/cann/runtime/issues/1162

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for KaranocaVe's contribution.)
KaranocaVeKaranocaVe
Oct 20 Created pull request, commit f9c93c28
KaranocaVeKaranocaVe
Oct 20 Associated issue: Runtime Python group 属性返回长度单位错误
atomgit-bot
atomgit-bot
Oct 20 Comments:

变更摘要

本 PR 修正了 python/pyACL/rt/rt_group.cpp 中 WrapAclRtGetGroupInfoDetail 对 aclrtGetGroupInfoDetail 返回字节数的处理逻辑。该接口通过 paramRetRize 返回输出字节数,此前包装层将其直接当作列表元素数和遍历上界,导致按字节数申请长度、实际只写入少量元素,返回列表中出现未初始化的多余项。改动引入字节数到元素数的换算与整除校验,使返回结果与底层属性数量一致。

主要改动

  • 整除校验拒绝非法长度: 在换算前检查 paramRetRize % sizeof(attrValue[0]),无法被元素大小整除时设置 PyExc_RuntimeError 并返回 nullptr,避免对无效返回长度继续处理。
  • 字节数换算为元素数: 新增 attrCount = paramRetRize / sizeof(attrValue[0]),将接口返回的字节数转换为实际属性元素个数。
  • 修正列表长度与遍历上界: PyList_New 的入参由 paramRetRize 改为 attrCount,循环条件由 i < paramRetRize 改为 i < attrCount,使创建的元素与写入的元素数量一致。

🧩 本次 Review 已使用自定义 Skill:

likedislike
Incorrect?
atomgit-bot
atomgit-bot
Oct 20 Comments:

代码审查

✅ 未发现问题


🧩 本次 Review 已使用自定义 Skill:

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Oct 20 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Oct 20 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
repo-cann/runtime ✅ 卢煜坤, zhangpengpeng8 (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

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

likedislike
CANN-robotCANN-robotCollaborators
Oct 20 Set wangtao43,zhangpengpeng8,yanmingxiang,Reyn52166,ykl999,houyanbao,tingwood as approver
CANN-robotCANN-robotCollaborators
Oct 20 Set wangtao43,zhangpengpeng8,yanmingxiang,Reyn52166,ykl999,houyanbao,tingwood as approver
KaranocaVe
KaranocaVe
Oct 20 Comments:

/compile

likedislike
KaranocaVeKaranocaVe
Oct 20 Pre merge succeeded (commit_id: 8c30e5c4c4f51ea26476651ff1c5bcc64f6a0bac)
CANN-robot
CANN-robotCollaborators
Oct 20 Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
Oct 20 Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Oct 20 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Oct 20 Added label: ci-pipeline-passed
KaranocaVe
KaranocaVe
Oct 21 Comments:

按机器人当前审批进度,模块 repo-cann/runtime 还缺 approve。麻烦 @Reyn52166 @wangtao43 @tingwood @houyanbao @ykl999 抽空协助审批,并在条件满足后推进合并,谢谢!

likedislike
KaranocaVe
KaranocaVe
Oct 21 Comments:

再跟进一下:按机器人最新审批进度,模块 repo-cann/runtime 仍待 approve。麻烦 @Reyn52166 @wangtao43 @tingwood @houyanbao @ykl999 再次抽空协助审批,并在审批条件满足后推进合并,谢谢!

likedislike
KaranocaVe
KaranocaVe
Oct 23 Comments:

/compile

likedislike
KaranocaVeKaranocaVe
Oct 23 Pre merge succeeded (commit_id: 1bea12af3ac4b26cc858bc787b0c60bb26dfb73c)
CANN-robot
CANN-robotCollaborators
Oct 23 Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
Oct 23 Removed label: ci-pipeline-passed
CANN-robotCANN-robotCollaborators
Oct 23 Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Oct 23 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Oct 23 Added label: ci-pipeline-passed
KaranocaVe
KaranocaVe
28 days ago Comments:

再次提醒:根据 CANN-robot 当前审批进度,该 PR 仍缺少必要的代码检视或合入审批。麻烦 houyanbao yanmingxiang Reyn52166 wangtao43 tingwood ykl999 抽空协助审核;确认无误后请按仓库规则执行 /lgtm 和 /approve,谢谢!

likedislike
KaranocaVe
KaranocaVe
28 days ago Comments:

再次提醒:根据 CANN-robot 当前审批进度,该 PR 仍缺少必要的代码检视或合入审批。麻烦 @houyanbao @yanmingxiang @Reyn52166 @wangtao43 @tingwood @ykl999 抽空协助审核;确认无误后请按仓库规则执行 /lgtm 和 /approve,谢谢!

likedislike
KaranocaVe
KaranocaVe
25 days ago Comments:

当前 PR 已满足仓库自动合入条件:mergeable=true,冲突检查通过,CI/审批/讨论均通过,CLA 与 ci-pipeline-passed 标签存在。尝试执行合入时平台返回 HTTP 405:You do not have permissions to push into target branch。请有目标分支 PUSH 权限的维护者直接合入。

likedislike
ykl999
ykl999Collaborators
23 days ago Comments:

/compile

likedislike
KaranocaVeKaranocaVe
23 days ago Pre merge succeeded (commit_id: d103dec7cf93492f87bfb87915dcd934be29743c)
CANN-robot
CANN-robotCollaborators
23 days ago Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
23 days ago Removed label: ci-pipeline-passed
ykl999
ykl999Collaborators
23 days ago Comments:

/approve
/lgtm

likedislike
CANN-robotCANN-robotCollaborators
23 days ago Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
23 days ago Added label: approved
CANN-robotCANN-robotCollaborators
23 days ago Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
23 days ago Added label: ci-pipeline-passed
zhangpengpeng8
zhangpengpeng8Collaborators
23 days ago Comments:

/lgtm

likedislike
CANN-robotCANN-robotCollaborators
23 days ago Added label: lgtm
CANN-robotCANN-robotCollaborators
23 days ago Merged pull request