修复 put_along_axis 空 index 转换 - #723
Merged
feixi139 merged 1 commit intoSep 7, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
put_along_axis在indices.shape包含零维度时,Paddle 会直接返回输入结果,不执行索引广播,也不会校验values。原有 Torch 转换逻辑仍会先执行
torch.broadcast_to。当索引为空且形状无法扩展时,例如:arr = [8192, 32]indices = [0, 10]会触发广播错误,导致本应通过的测试用例失败。
修改内容
paddle.put_along_axis和paddle.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_axisAPI 入口。影响范围
本次修改仅针对 空索引(
indices.shape包含零维度) 的场景:put_along_axis转换逻辑不变。因此修改范围较小,不影响正常的非空索引场景。