Closed
[Bug-Report|缺陷反馈]: IndexPutWithSortV2 非连续索引轴判断错误,导致模板选择及 values 步长异常 #6881
surezzAdd on  23 days agoClosed at  22 days ago
surezz
surezzCollaborators
23 days ago Create

Describe the current behavior / 问题描述 (Mandatory / 必填)

IndexPutWithSortV2 的 IsIndexedContinuous() 函数在每次循环中更新 prevIndex,包括当前轴为非索引轴的情况。因此,prevIndex 实际记录的是前一个遍历位置,无法正确检测两个索引轴之间是否存在间隔。
例如,indexed_sizes=[1,0,1]、[0,1,0,1] 均会被错误判断为索引轴连续,影响后续处理:

  • 首轴为索引轴、索引元素数量大于 1,且非索引轴元素总数乘以数据类型字节数大于 256 时,可能误入 SIMD 模板。
  • 进入 SIMT 模板后,部分非连续布局会按连续布局计算 values 的维度顺序和步长,导致读写结果错误。

Environment Information / 环境信息 (Mandatory / 必填)

Ascend950

Steps to reproduce the issue / 重现步骤 (Mandatory / 必填)

使用修复前的 IsIndexedContinuous() 实现。
传入 indexed_sizes=[1,0,1]、size=3。
遍历至 i=1 时,虽然当前元素为 0,仍将 prevIndex 更新为 1。
遍历至 i=2 时,计算得到 i-prevIndex=1,未识别出索引轴之间的间隔,最终错误返回 true。
使用 [0,1,0,1] 同样可以复现。

Describe the expected behavior / 预期结果 (Mandatory / 必填)

仅当所有索引轴组成一个连续区间时返回 true。存在非索引轴间隔时应返回 false,使后续模板选择和 values 步长计算采用正确的布局信息。

从 PR 修复前后源码提取函数进行宿主侧验证,实际输出如下:
[1,0,1] before=true after=false
[0,1,0,1] before=true after=false
[0,1,1] before=true after=true
[0,1,0] before=true after=true
[1,0,0] before=true after=true

Special notes for this issue/备注 (Optional / 选填)

likedislike
surezzsurezzCollaborators
23 days ago Added label: bug-report
surezz
surezzCollaborators
23 days ago Comments:

/assign

likedislike
CANN-robotCANN-robotCollaborators
23 days ago Assign surezz as responsible person
CANN-robotCANN-robotCollaborators
22 days ago Close issue
CANN-robotCANN-robotCollaborators
22 days ago Added label: resolved