Skip to content

Conversation

@zhengshengning
Copy link
Contributor

@zhengshengning zhengshengning commented Aug 13, 2025

PR Category

Operator Mechanism

PR Types

Improvements

Description

paddle.Tensor.view
paddle.zeros

API Name Param Alias details
paddle.Tensor.view *shape shape_or_dtype 指定的维度。 PyTorch 参数 shape 既可以是可变参数,也可以是 list/tuple/torch.Size/dtype 的形式, Paddle 参数 shape_or_dtype 为 list/tuple/dtype 的形式。对于可变参数的用法,需要进行转写。
paddle.zeros x,axis input,dim 表示输出形状大小,PyTorch 以可变参数方式传入,Paddle 以 list 或 tuple 的方式传入,需要转写。

用法:

paddle.view(x=tensor_x, shape_or_dtype=[-1, 1, 3], name=None)
tensor_x.view(paddle.float32) -> paddle.view(tensor_x, paddle.float32)
tensor_x.view(dtype=paddle.float32) -> paddle.view(tensor_x, dtype=paddle.float32)
tensor_x.view([-1, 1, 3]) -> paddle.view(tensor_x, [-1, 1, 3])
tensor_x.view(-1, 1, 3) -> paddle.view(tensor_x, -1, 1, 3)
tensor_x.view(size=[-1, 1, 3]) -> paddle.view(tensor_x, size=[-1, 1, 3])

Other
增加了单测

pcard-67164

@paddle-bot
Copy link

paddle-bot bot commented Aug 13, 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.

@zhengshengning
Copy link
Contributor Author

/re-run all-failed

1 similar comment
@zhengshengning
Copy link
Contributor Author

/re-run all-failed

)


@SizeArgsDecorator()
Copy link
Contributor

Choose a reason for hiding this comment

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

注意后续补充中英文文档



@dygraph_only
@view_decorator()
Copy link
Contributor

Choose a reason for hiding this comment

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

同上,注意后续补充api 的中英文文档

@zhangbo9674 zhangbo9674 merged commit e55d20b into PaddlePaddle:develop Aug 14, 2025
79 of 87 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants