Merged
修复 PyACL get_aipp_data_size 返回值截断 #5753
修复 PyACL get_aipp_data_size 返回值截断 #5753
Merged
KaranocaVeAdd on Oct 21
KaranocaVe
Oct 21

修复 PyACL get_aipp_data_size 返回值截断

WrapAclMdlGetAippDataSize 使用 Py_BuildValue("Ii", memSize, ret) 返回 size_t memSize。在 64 位 CPython 中,I 按 unsigned int 读取,例如 0x100000060 会变成 0x60,导致大尺寸 AIPP 数据的缓冲区长度错误。
将格式串改为 "ki",在 CANN 的 64 位 Linux 平台上完整返回 size_t 大小,并保持错误码为 int。

验证

  • CPython C API 探针确认:64 位 CPython 下,"Ii" 将 0x100000060 返回为 0x60,"ki" 保留完整值。
  • 变更检查通过:补丁仅将尺寸格式符改为 "ki",错误码格式 i 保持。
  • 真实 ACL Runtime API 和 NPU 行为未验证。

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

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for KaranocaVe's contribution.)
KaranocaVeKaranocaVe
Oct 21 Created pull request, commit 1c75079b
KaranocaVeKaranocaVe
Oct 21 Associated issue: PyACL `get_aipp_data_size` 返回值宽度截断
atomgit-bot
atomgit-bot
Oct 21 Comments:

变更摘要

本 PR 修复 python/pyACL/mdl/mdl_wrap.cpp 中 WrapAclMdlGetAippDataSize 返回值被截断的问题。该函数使用 Py_BuildValue("Ii", memSize, ret) 打包 size_t memSize 与 aclError ret,在 64 位 CPython 下 I 按 unsigned int 读取,导致超过 UINT32_MAX 的内存大小丢失高位。改为 "ki" 后按平台 size_t 完整返回 memSize,同时保持错误码仍为 int,使调用方获取到的 AIPP 数据大小不再被截断。

主要改动

  • 修复 size_t 返回值截断: 将 WrapAclMdlGetAippDataSize 中的 Py_BuildValue 格式串由 "Ii" 改为 "ki",避免 memSize 高位在 64 位平台被截断。
  • 保持错误码类型不变: 格式串中 i 未变,aclError ret 仍按 int 返回,仅调整 memSize 的打包方式。
  • 影响 acl.mdl.get_aipp_data_size 接口数值语义: 该 Python 接口现在返回完整的 64 位内存大小,而非仅低 32 位。

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

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

代码审查

✅ 未发现问题


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

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

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)
likedislike
CANN-robot
CANN-robotCollaborators
Oct 21 Comments:

CLA Signature Pass

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

likedislike
CANN-robotCANN-robotCollaborators
Oct 21 Set wangtao43,zhangpengpeng8,yanmingxiang,Reyn52166,ykl999,houyanbao,tingwood as approver
CANN-robotCANN-robotCollaborators
Oct 21 Set wangtao43,zhangpengpeng8,yanmingxiang,Reyn52166,ykl999,houyanbao,tingwood as approver
KaranocaVeKaranocaVe
Oct 21 Modify description of pull request
KaranocaVe
KaranocaVe
Oct 21 Comments:

/compile

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

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

likedislike
KaranocaVe
KaranocaVe
28 days ago Comments:

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

likedislike
KaranocaVe
KaranocaVe
25 days ago Comments:

当前 PR 状态核对:代码审查/审批、CI、依赖、冲突和讨论项均已通过;唯一未通过条件是 merged_by_user_passed,当前账号没有目标仓库 PUSH 权限。请具备合入权限的维护者直接执行合入。

likedislike
ykl999
ykl999Collaborators
24 days ago Comments:

/approve
/lgtm

likedislike
ykl999
ykl999Collaborators
24 days ago Comments:

/compile

likedislike
KaranocaVeKaranocaVe
24 days ago Pre merge succeeded (commit_id: 6a854a36eb25bdfbe1682a30b726652269f9cf27)
CANN-robotCANN-robotCollaborators
24 days ago Added label: approved
CANN-robot
CANN-robotCollaborators
24 days ago Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
24 days ago Removed label: ci-pipeline-passed
CANN-robotCANN-robotCollaborators
24 days ago Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
24 days ago Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
24 days ago Added label: ci-pipeline-passed
yanmingxiang
yanmingxiangCollaborators
24 days ago Comments:

/lgtm

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