[Zero-Dim] Support input 0D Tensor for masked_select by ZzSean · Pull Request #49803 · PaddlePaddle/Paddle

@ZzSean

PR types

New features

PR changes

APIs

Describe

masked_select支持0D tensor

@ZzSean

@paddle-bot

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

@ZzSean

@ZzSean

zhwesky2010


y.backward()

self.assertEqual(y.shape, [1])

Choose a reason for hiding this comment

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

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

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, [])

Choose a reason for hiding this comment

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

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

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()

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

done,thx

@ZzSean

@ZzSean

zhwesky2010


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

@prog_scope()

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())

Choose a reason for hiding this comment

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

done, thx

@ZzSean

@ZzSean

zhwesky2010

Choose a reason for hiding this comment

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

LGTM