Closed
[Bug-Report|缺陷反馈]: 负的具体 SymbolicScalar Tensor 索引未归一化 #3455
KaranocaVeAdd on  Sep 26Closed at  Oct 19
KaranocaVe
KaranocaVe
Sep 26 Create

[Bug-Report|缺陷反馈]: 负的具体 SymbolicScalar Tensor 索引未归一化

问题

Tensor.__getitem__ 支持 int 和 SymbolicScalar 索引,并声明支持 Python 风格负索引。对于长度为 4 的 Tensor,Host lowering 将 x[-1] 转为偏移 3,但 x[pypto.SymbolicScalar(-1)] 保留偏移 -1。

复现

构造长度为 4 的 Tensor,分别访问 x[-1] 与 x[pypto.SymbolicScalar(-1)],比较 Host lowering 生成的 GetTensorData 偏移。

预期 / 实际

  • 预期:两种写法都归一化为偏移 3。
  • 实际:Python 整数索引的偏移为 3,具体负 SymbolicScalar 索引的偏移为 -1。

影响与修复

等价索引被降低为不同 Tensor 坐标,可能读取错误元素。修复将编译期已知的负 SymbolicScalar 按轴长归一化,并保留动态符号索引原有行为。设备运行时结果未在本次验证中确认。

Validation

验证记录

长度为 4 的 DT_INT32 Tensor 上,修复前的 Host lowering 为 x[-1] 生成偏移 3,为 x[SymbolicScalar(-1)] 生成偏移 -1。应用修复后,两种索引都生成偏移 3;3 项归一化断言通过,动态符号索引仍保留原对象。

提交前将补丁应用到目标 master 基线并通过 git diff --check。修改的 Python 文件通过 PyPTO 适用的 pre-commit 检查(Ruff、切片冒号格式、空白与文件完整性检查)及 py_compile。

PyTest 与设备运行时对照未执行。本次结论限于 Host lowering 和索引归一化结果,没有声称观察到设备输出。

关联 PR: https://gitcode.com/cann/pypto/merge_requests/6724

likedislike
KaranocaVeKaranocaVe
Sep 26 Associated pull request
KaranocaVeKaranocaVe
Sep 26 Modify description of issue
liuyu205liuyu205
Sep 28 Associated pull request
liuyu205liuyu205
Sep 28 Associated pull request
lidongsheng
lidongshengCollaborators
Sep 28 Comments:

谢谢反馈,请及时完成相关PR合入

likedislike
lidongshenglidongshengCollaborators
Oct 8 Assign seu_chang as responsible person
lidongshenglidongshengCollaborators
Oct 8 Added label: Frontend
lidongsheng
lidongshengCollaborators
Oct 8 Comments:

seems some not related PR link to current issue, it's not a best practice, please avoid it

likedislike
KaranocaVe
KaranocaVe
Oct 11 Comments:

I checked the links. !6724 is the fix for this issue: it normalizes concrete negative SymbolicScalar indices, and the Issue and PR bodies link to each other. GitCode also lists !6699 (“Upload for Tile Check”) and !6726 (“Upload for load_unalign”) as associated with #3455, although their PR bodies do not reference this issue. I did not add those links; could you remove those associations if they were added by mistake?

!6724 is still open. Its current head 6898955eba31a78e3292fec8f9345492046118f8 has ci-pipeline-passed; all reported merge gates pass except this account lacks PUSH permission. Could a maintainer with push permission merge it when convenient?

likedislike
liuyu205liuyu205
Oct 14 Deleted associated pull request: fix(pypto_pro): Upload for Tile Check
liuyu205liuyu205
Oct 14 Deleted associated pull request: fix(pypto_pro): Upload for load_unalign
LiuChang
LiuChangCollaborators
Oct 19 Comments:

The associated PR has been merged. This issue is scheduled to be closed. Feel free to reach out if you have any further questions.

likedislike
LiuChangLiuChangCollaborators
Oct 19 changed custom state from 进行中 to 已完成
LiuChangLiuChangCollaborators
Oct 19 Close issue
CANN-robotCANN-robotCollaborators
Oct 19 Added label: resolved
KaranocaVe
KaranocaVe
Oct 22 Comments:

@tsungl4 @seu_chang 您好,这个 Issue 对应的修复已经合入:https://gitcode.com/cann/pypto/merge_requests/6724

开发者计划反馈,Issue 需要有 Accepted 标签才能计入积分,仅关闭或标记 resolved 还不够。目前这条 Issue 尚未标记 Accepted,麻烦您结合问题和已合入的修复复核一下;确认符合受理条件后,帮忙补上 Accepted 标签。

感谢您的支持!

likedislike