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

[Cherry-pick][Dy2stat]Support for i in [x, y, z] statements in dy2stat (#37259) #37356

Merged
merged 1 commit into from
Nov 19, 2021

Conversation

0x45f
Copy link
Contributor

@0x45f 0x45f commented Nov 19, 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

…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 (#37259) [Cherry-pick][Dy2stat]Support for i in [1,2,3] statements in dy2stat (#37259) Nov 19, 2021
@Aurelius84 Aurelius84 changed the title [Cherry-pick][Dy2stat]Support for i in [1,2,3] statements in dy2stat (#37259) [Cherry-pick][Dy2stat]Support for i in [x, y, z] statements in dy2stat (#37259) Nov 19, 2021
@lanxianghit lanxianghit merged commit 44db219 into PaddlePaddle:release/2.2 Nov 19, 2021
@0x45f 0x45f deleted the pick_dy2stat_for_list branch December 24, 2021 04:49
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.

3 participants