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

[Dy2Stat]Enhance Python if-else by pruning usless no_return variable #43880

Merged
merged 1 commit into from
Jun 28, 2022

Conversation

Aurelius84
Copy link
Contributor

@Aurelius84 Aurelius84 commented Jun 28, 2022

PR types

Bug fixes

PR changes

APIs

Describe

What's New?

优化了在执行 Python if-else后未正确移除框架中的 NO_RETURN_VAR 的逻辑。

后续优化

长期来看,我们不应该支持变长的提前return。虽然Python是支持控制流中可以分别返回不同长度的变量,但是在深度学习框架中,是要求每个true_branch 和 false_branch 返回相同的structure。

从普适性和鲁棒性上来看,在代码转写时不需要对变长的return语句做padding处理的。在执行期间,如果是不依赖控制流的非控制流IF,只需要保持和Python一致的执行即可。如果是依赖控制流的控制流IF,则执行期间需要添加强检查,并抛出详尽的报错信息。

@paddle-bot-old
Copy link

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

@paddle-bot-old
Copy link

paddle-bot-old bot commented Jun 28, 2022

✅ This PR's description meets the template requirements!
Please wait for other CI results.

Copy link
Contributor

@2742195759 2742195759 left a comment

Choose a reason for hiding this comment

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

LGTM

@Aurelius84 Aurelius84 merged commit 6e0aa77 into PaddlePaddle:develop Jun 28, 2022
@2742195759 2742195759 deleted the fix_return branch June 28, 2022 12:44
@2742195759 2742195759 restored the fix_return branch June 28, 2022 12:44
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