Skip to content

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
@ZzSean ZzSean requested a review from zhwesky2010 January 17, 2023 07:12

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


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

2 participants