Skip to content

修复 put_along_axis 空 index 转换 - #723

Merged
feixi139 merged 1 commit into
PFCCLab:mainfrom
feixi139:fix/put-along-axis-empty-index-convert
Sep 7, 2026
Merged

feixi139 merged 1 commit into
PFCCLab:mainfrom
feixi139:fix/put-along-axis-empty-index-convert

Conversation

@feixi139

@feixi139 feixi139 commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

背景

put_along_axisindices.shape 包含零维度时,Paddle 会直接返回输入结果,不执行索引广播,也不会校验 values

原有 Torch 转换逻辑仍会先执行 torch.broadcast_to。当索引为空且形状无法扩展时,例如:

  • arr = [8192, 32]
  • indices = [0, 10]

会触发广播错误,导致本应通过的测试用例失败。

修改内容

  • 修复 paddle.put_along_axispaddle.Tensor.put_along_axis 的空索引处理。
  • 当索引包含零维度时,跳过广播预处理,直接返回输入副本。
  • 修复 paddle._C_ops.put_along_axis_paddle.Tensor.put_along_axis_ 的空索引处理。
  • 原地版本在空索引时跳过广播以及 scatter_ / scatter_reduce_,保持 Paddle 的 no-op 语义。
  • 修改范围仅限 tester/paddle_to_torch/rules.py 中的 4 个 put_along_axis API 入口。
  • 非空索引场景保持原有转换逻辑不变。

影响范围

本次修改仅针对 空索引(indices.shape 包含零维度) 的场景:

  • 空索引:跳过 Torch 侧的广播预处理,保持 Paddle 原有 no-op 语义。
  • 非空索引:保持原有 put_along_axis 转换逻辑不变。

因此修改范围较小,不影响正常的非空索引场景。

@feixi139
feixi139 merged commit f4972a4 into PFCCLab:main Sep 7, 2026
1 check passed
@feixi139
feixi139 deleted the fix/put-along-axis-empty-index-convert branch September 7, 2026 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant