Skip to content

[0-size Tensor Job2 No.11] Add 0-size Tensor support for paddle.expand_as - #72986

Merged
DanielSun11 merged 7 commits into
PaddlePaddle:developfrom
co63oc:b38
Jul 7, 2025
Merged

DanielSun11 merged 7 commits into
PaddlePaddle:developfrom
co63oc:b38

Conversation

@co63oc

@co63oc co63oc commented May 28, 2025 •

Copy link
Copy Markdown
Contributor

PR Category

Operator Mechanism

PR Types

Bug fixes

Description

[0-size Tensor No.302] Add 0-size Tensor support for paddle.Tensor.expand_as
[0-size Tensor Job2 No.11] Add 0-size Tensor support for paddle.expand_as [fluid_ops]

修改前向和反向,反向填充0
infermeta没有修改
kernel 修改cpu/gpu/xpu,xpu无反向

torch测试反向

import torch
x=torch.randn([3, 1])
y=torch.randn([3, 0])
x.requires_grad=True
result = x.expand_as(y)
result.sum().backward()
print(x.grad)

tensor([[0.],
        [0.],
        [0.]])

PaddleAPITest 测试通过
image

test/legacy_test/test_solve_op.py 运行时有调用data 启用static提示,增加 enable_static,static测试输入形状有误修改。
solve调用expand_as kernel时,会传入out没有初始化,所以在expand_as kernel中是判断x和y,然后再判断target_shape为0返回

@paddle-bot

paddle-bot Bot commented May 28, 2025

Copy link
Copy Markdown

你的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 May 28, 2025
@co63oc co63oc changed the title CI测试不review expand_as [0-size Tensor No.302] Add 0-size Tensor support for expand_as May 28, 2025
@co63oc co63oc changed the title [0-size Tensor No.302] Add 0-size Tensor support for expand_as CI测试不review expand_as May 28, 2025
@paddle-ci-bot

paddle-ci-bot Bot commented Jun 11, 2025

Copy link
Copy Markdown

Sorry to inform you that 34ae4c9's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually.

@co63oc co63oc changed the title CI测试不review expand_as [0-size Tensor No.302] Add 0-size Tensor support for expand_as Jun 30, 2025
@co63oc co63oc changed the title [0-size Tensor No.302] Add 0-size Tensor support for expand_as [0-size Tensor No.302] Add 0-size Tensor support for expand_as [fluid_ops] Jul 3, 2025
@co63oc

co63oc commented Jul 3, 2025

Copy link
Copy Markdown
Contributor Author

/re-run all-failed

@co63oc

co63oc commented Jul 5, 2025

Copy link
Copy Markdown
Contributor Author

/re-run all-failed

@co63oc

co63oc commented Jul 7, 2025

Copy link
Copy Markdown
Contributor Author

@DanielSun11 CI已完成需要review @luotao1

@DanielSun11 DanielSun11 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@DanielSun11
DanielSun11 merged commit 30c6715 into PaddlePaddle:develop Jul 7, 2025
@co63oc co63oc changed the title [0-size Tensor No.302] Add 0-size Tensor support for expand_as [fluid_ops] [0-size Tensor Job2 No.11] Add 0-size Tensor support for paddle.expand_as Jul 8, 2025
@co63oc
co63oc deleted the b38 branch July 16, 2025 04:57
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.

2 participants