Skip to content
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

[Zero-Dim] reshape/reshape_/reverse 0D support #49357

Merged
merged 7 commits into from
Jan 3, 2023

Conversation

zhaoyinglia
Copy link
Contributor

@zhaoyinglia zhaoyinglia commented Dec 27, 2022

PR types

Others

PR changes

Others

Describe

@paddle-bot
Copy link

paddle-bot bot commented Dec 27, 2022

你的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.

self.assertEqual(out.shape, [1])
self.assertEqual(out.grad.shape, [1])

new_shape = [paddle.to_tensor(-1), paddle.to_tensor(1)]
Copy link
Contributor

Choose a reason for hiding this comment

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

目前paddle.to_tensor还有些bug,会把0D强转为1D,可以把这个改成paddle.full([], -1) paddle.full([], 1)

然后API文档这里用 形状为[]的0D Tensor 比较好
infoflow 2022-12-27 14-44-38

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

The data type is ``int32`` . If ``shape`` is a list or tuple, the elements of it should be integers or Tensors with shape [1].
If ``shape`` is an Tensor, it should be an 1-D Tensor .
The data type is ``int32`` . If ``shape`` is a list or tuple, the elements of it should be integers or Tensors with shape [].
If ``shape`` is an Tensor, it should be an 0-D Tensor .
Copy link
Contributor

@zhwesky2010 zhwesky2010 Dec 28, 2022

Choose a reason for hiding this comment

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

就是如果是list(Tensor),其每个元素应该是一个标量,就应该支持0D Tensor的list。
如果是Tensor,其应该对应一个list,这个时候还是1D Tensor。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

zhwesky2010
zhwesky2010 previously approved these changes Dec 29, 2022
Copy link
Contributor

@zhwesky2010 zhwesky2010 left a comment

Choose a reason for hiding this comment

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

LGTM

@zhwesky2010
Copy link
Contributor

zhwesky2010 commented Dec 29, 2022

API文档这里,建议像目前这样写明白多少D对用户会更清楚些

zhwesky2010
zhwesky2010 previously approved these changes Dec 29, 2022
Copy link
Contributor

@zhwesky2010 zhwesky2010 left a comment

Choose a reason for hiding this comment

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

LGTM

@zhwesky2010 zhwesky2010 merged commit 347d212 into PaddlePaddle:develop Jan 3, 2023
wangxn12138 added a commit to wangxn12138/Paddle that referenced this pull request Jan 4, 2023
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.

None yet

3 participants