Merged
fix(tensor): clarify view rank mismatch assert message #6606
HuYiShengAdd on Sep 22
fix(tensor): clarify view rank mismatch assert message #6606
Merged
HuYiShengAdd on Sep 22
HuYiSheng
HuYiShengCollaborators
Sep 22

背景

PyPTO 编译期/运行时报错信息缺少源码定位与修复建议(11 算子批次共性问题的最高成本项)。其中报错点 1:pypto.view 做 rank 变化(4D→5D、2D→3D)时,F21003 断言仅输出裸数字:

ASSERT FAILED: ErrCode: F21003! Enum: FeError::INVALID_VAL
Their sizes actually are 4 and 5

不说明"谁的 4、谁的 5"、不说 view 不支持改 rank、无修复建议,agent/用户单次定位耗时 5–20 分钟。

改动概览

1 file changed, 2 insertions(+), 1 deletion(-)
文件 位置 改动
framework/src/interface/tensor/logical_tensor.cpp GetViewValidShape() :558 重写 FE_ASSERT 消息体(旧文案 "Their sizes actually are N and M" 为全仓唯一触发点)

断言条件、错误码(F21003)、抛异常机制、控制流均未改动,纯诊断信息增强,行为零变化。

修改后消息:

View rank mismatch: input tensor rank is 4, view shape rank is 5. pypto.view cannot
change tensor rank; use pypto.unsqueeze to add a dimension.
likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for HuYiSheng's contribution.)
HuYiShengHuYiShengCollaborators
Sep 22 Created pull request, commit d393b19b
HuYiShengHuYiShengCollaborators
Sep 22 Associated issue: [Bug-Report|缺陷反馈]:【易用性】PyPTO 框架的编译期/运行时报错信息缺少源码定位与修复建议
atomgit-bot
atomgit-bot
Sep 22 Comments:

变更摘要

本 PR 针对 pypto.view 在 rank 变化(如 4D→5D、2D→3D)时报错信息不明确的问题,对 framework/src/interface/tensor/logical_tensor.cpp 中 GetViewValidShape() 的 FE_ASSERT 诊断文案进行重写。改动仅在 FeError::INVALID_VAL(错误码 F21003)断言的输出消息层面,断言条件、错误码、抛异常机制与控制流均保持不变,属于纯诊断信息增强,运行时行为无变化。

主要改动

  • 重写 GetViewValidShape() 的断言消息体:将原先仅输出裸数字的 "Their sizes actually are N and M" 替换为带语义的 "View rank mismatch: ..." 文案,明确提示 rank 不匹配。
  • 标注两个 rank 的具体归属:新消息分别以 input tensor rank 与 view shape rank 区分 validShape.size() 和 viewShape.size(),避免用户无法判断哪个数字对应哪一方。
  • 补充修复建议:新消息说明 pypto.view 不能改变张量 rank,并提示改用 pypto.unsqueeze 增加维度,帮助用户/agent 快速定位与修复。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Sep 22 Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Sep 22 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Sep 22 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, DCGDDD (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

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

likedislike
CANN-robotCANN-robotCollaborators
Sep 22 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 22 Set TianXL,jiangtao_rts,gitcode-chenjiao,hanxiaolong,gcw_kUomxQ2l,Andy-lb as approver
杨旭
杨旭Collaborators
Sep 22 Comments:

/lgtm

likedislike
HuYiSheng
HuYiShengCollaborators
Sep 22 Comments:

/compile

likedislike
HuYiShengHuYiShengCollaborators
Sep 22 Pre merge succeeded (commit_id: 0b55282479710a4e11a777e1de585a1405a15c69)
CANN-robot
CANN-robotCollaborators
Sep 22 Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
Sep 22 Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 22 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 22 Added label: ci-pipeline-failed
HuYiSheng
HuYiShengCollaborators
Sep 22 Comments:

/compile

likedislike
CANN-robot
CANN-robotCollaborators
Sep 22 Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
Sep 22 Removed label: ci-pipeline-failed
CANN-robotCANN-robotCollaborators
Sep 22 Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 22 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 22 Added label: ci-pipeline-passed
liulun0308
liulun0308Collaborators
Sep 22 Comments:

/approve

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