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

Support 0d Tensor in ConditionalBlockOp #49842

Merged
merged 13 commits into from
Jan 17, 2023

Conversation

zhhsplendid
Copy link
Member

@zhhsplendid zhhsplendid commented Jan 15, 2023

PR types

New features

PR changes

APIs

Describe

Support 0d Tensor in ConditionalBlockOp

  1. Add dygraph 0d tensor support for ConditionalBlockOp
  2. Set scalar loss shape when append_backward

@paddle-bot
Copy link

paddle-bot bot commented Jan 15, 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.

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.

test_zero_dim_tensor里加下shape的检查吧

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.

文档就先改Paddle repo里的英文文档吧

@@ -384,8 +384,10 @@ class ConditionalBlockGradOp : public ConditionalOp {
if (!input_tensor.IsInitialized() || input_tensor.numel() == 0) {
return;
}
if (!input_tensor.meta().is_scalar) {
Copy link
Contributor

Choose a reason for hiding this comment

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

这个is_scalar可能用不上。这个判断0D方法用 input_tensor.dims().size()吧

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@zhhsplendid zhhsplendid changed the title Support 0d Tensor in ConditionalBlockOp, Memcpy, and AddNKernel Support 0d Tensor in ConditionalBlockOp and AddNKernel Jan 16, 2023
@zhhsplendid
Copy link
Member Author

文档就先改Paddle repo里的英文文档吧

我后续单独提PR修改文档吧,这样容易用test=document_fix, 跳过一些CI

@zhhsplendid
Copy link
Member Author

test_zero_dim_tensor里加下shape的检查吧

经讨论,控制流api不像计算api,直接在test_cond.py单测里检测shape

@zhhsplendid zhhsplendid changed the title Support 0d Tensor in ConditionalBlockOp and AddNKernel Support 0d Tensor in ConditionalBlockOp Jan 16, 2023
Copy link
Contributor

@Aurelius84 Aurelius84 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@zhiqiu zhiqiu left a comment

Choose a reason for hiding this comment

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

LGTM

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

@zhhsplendid zhhsplendid merged commit 791637c into PaddlePaddle:develop Jan 17, 2023
zhhsplendid added a commit that referenced this pull request Jan 18, 2023
…ase` (#49889)

Followed PR #49842 , added Digraph and Shape unit test for `case` and `switch_case`. This PR only contained test changes because `case` and `switch_case` call `cond`. The PR #49842 has already solved the 0d tensor support.
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

4 participants