Skip to content

[0-size Tensor No.37] Add 0-size Tensor support for index_put #73513

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

co63oc
Copy link
Contributor

@co63oc co63oc commented Jun 21, 2025

PR Category

Execute Infrastructure

PR Types

Improvements

Description

index_put 输出维度和输入维度相同,反向 value 参数填充0, x numel为0不填充
torch 测试反向

args = []
args.append(paddle.randn([10, 0]))
args.append([paddle.to_tensor([-4, -9, -7, -3, -8, -8,  0, -1, -6,  2], dtype=paddle.int64)])
args.append(paddle.randn([1, 1]))
args.append(False)
args[2].stop_gradient=False
args[0].stop_gradient=False
result = paddle.index_put(*args)
result.sum().backward()
print(args[2].grad)

Tensor(shape=[1, 1], dtype=float32, place=Place(gpu:0), stop_gradient=False,
       [[0.]])

PaddleAPITest 测试numpy error,其他通过
image

Copy link

paddle-bot bot commented Jun 21, 2025

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot bot added the contributor External developers label Jun 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant