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]Support for i in [x,y,z] statements in dy2stat #37259

Merged
merged 4 commits into from
Nov 19, 2021

Conversation

0x45f
Copy link
Contributor

@0x45f 0x45f commented Nov 16, 2021

PR types

Others

PR changes

Others

Describe

该PR使得动转静模块能够正确转换如下的for i in [1, 2, 3]语句。

import paddle
class Net(paddle.nn.Layer):
    @paddle.jit.to_static
    def forward(self):
        # import pdb; pdb.set_trace()
        for i in [1, 2, 3]:
            print(i)
net = Net()
net()

PR中对List和Tuple进行了支持;对于Dict,由于动转静会改写生成类似Dict[index]的语句,比如
{'a': 1, 'b': 2}[__for_loop_var_index_0]这样的语句是错误,所以如果要支持Dict,还需要进行其他的修改。
image

@paddle-bot-old
Copy link

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@0x45f 0x45f closed this Nov 17, 2021
@0x45f 0x45f reopened this Nov 17, 2021
Aurelius84
Aurelius84 previously approved these changes Nov 17, 2021
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

@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

@Aurelius84 Aurelius84 merged commit d772a9a into PaddlePaddle:develop Nov 19, 2021
0x45f added a commit to 0x45f/Paddle that referenced this pull request Nov 19, 2021
…le#37259)

* support `for i in [1,2,3]` statements in dy2stat

* add test case

* fix ci

* remove wrong code
@0x45f 0x45f changed the title [Dy2stat]Support for i in [1,2,3] statements in dy2stat [Dy2stat]Support for i in [x,y,z] statements in dy2stat Nov 19, 2021
@0x45f 0x45f deleted the dy2stat_for_list branch November 19, 2021 08:44
lanxianghit pushed a commit that referenced this pull request Nov 19, 2021
…37356)

该PR使得动转静模块能够正确转换如下的for i in [1, 2, 3]语句。
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