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

[Dy2Static] Add non-local for while and for. #43864

Merged
merged 12 commits into from
Jun 30, 2022

Conversation

2742195759
Copy link
Contributor

PR types

Others

PR changes

Others

Describe

Pass the test_loop.py

@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.


return loop_vars


def _run_paddle_while_loop(cond, body, loop_vars):
def _run_paddle_while_loop(cond, body, getter, setter):
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
def _run_paddle_while_loop(cond, body, getter, setter):
def _run_paddle_while(cond, body, getter, setter):

def _run_py_while(cond, body, getter, setter):
loop_vars = getter()
while cond():
loop_vars = body()
Copy link
Contributor

Choose a reason for hiding this comment

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

这里不需要调用setter来同步body里的修改么?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这个是不需要调用setter的。因为我们的body中的修改是non local的,那么他的修改就是原来的变量。只有的paddle的时候才需要修改。

body_new_vars = set([
var for var in _vars_with_store(if_vars_dict)
if var not in parent_vars_dict
if var not in parent_vars_dict and var != "__args"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if var not in parent_vars_dict and var != "__args"
if var not in parent_vars_dict and var != ARGS_NAME

])
orelse_new_vars = set([
var for var in _vars_with_store(else_vars_dict)
if var not in parent_vars_dict
if var not in parent_vars_dict and var != "__args"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if var not in parent_vars_dict and var != "__args"
if var not in parent_vars_dict and var != ARGS_NAME

@@ -39,10 +41,11 @@
FOR_BODY_PREFIX = 'for_loop_body'
GENERATE_VARIABLE_PREFIX = 'generate_variable'

ATTRIBUTE_VARIABLE_PREFIX = '__attribute_variable'
ARGS_NAME = '__args'
Copy link
Contributor

Choose a reason for hiding this comment

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

ifelse_transformer.py 里有一个ARGS_NAME,可以考虑复用下

@2742195759 2742195759 closed this Jun 29, 2022
@2742195759 2742195759 reopened this Jun 29, 2022
@2742195759 2742195759 marked this pull request as draft June 29, 2022 17:28
@2742195759 2742195759 marked this pull request as ready for review June 29, 2022 17:30
@2742195759 2742195759 merged commit 8279dfe into PaddlePaddle:develop Jun 30, 2022
@2742195759 2742195759 deleted the dy2static-non-local branch June 30, 2022 07:11
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