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] Support input 0D Tensor for masked_select #49803

Merged
merged 11 commits into from
Jan 17, 2023

Conversation

ZzSean
Copy link
Contributor

@ZzSean ZzSean commented Jan 13, 2023

PR types

New features

PR changes

APIs

Describe

masked_select支持0D tensor

@paddle-bot
Copy link

paddle-bot bot commented Jan 13, 2023

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

@PaddlePaddle PaddlePaddle locked and limited conversation to collaborators Jan 16, 2023
@PaddlePaddle PaddlePaddle unlocked this conversation Jan 16, 2023
@PaddlePaddle PaddlePaddle locked and limited conversation to collaborators Jan 16, 2023
@PaddlePaddle PaddlePaddle unlocked this conversation Jan 16, 2023

y.backward()

self.assertEqual(y.shape, [1])
Copy link
Contributor

Choose a reason for hiding this comment

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

加下y的具体值的测试吧,与x相等

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

y.backward()

self.assertEqual(y.shape, [1])
self.assertEqual(x.grad.shape, [])
Copy link
Contributor

Choose a reason for hiding this comment

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

加下x.grad的具体值的测试吧

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

mask = paddle.full([], True, dtype='bool')
y = paddle.masked_select(x, mask)

y.backward()
Copy link
Contributor

Choose a reason for hiding this comment

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

拉下最新的,需要y.retain_grads()

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,thx

@@ -1968,6 +1982,16 @@ def test_atan2(self):

self.assertEqual(res[0].shape, ())

@prog_scope()
Copy link
Contributor

Choose a reason for hiding this comment

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

静态图也要测反向呢,paddle.static.append_backward(out.sum())

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, thx

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

@ZzSean ZzSean merged commit ce04589 into PaddlePaddle:develop Jan 17, 2023
@ZzSean ZzSean deleted the 0D-tensor branch July 13, 2023 07:47
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.

2 participants