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

[Dy2St] allow write to container in control flow #51248

Merged

Conversation

SigureMo
Copy link
Member

@SigureMo SigureMo commented Mar 6, 2023

PR types

Function optimization

PR changes

Others

Describe

完善动转静支持,避免动转静目前的一个 Limitation( 2.1 给容器添加赋值语义

示例:

def func_loop_write_dict(x):
    res = {"a": 1}
    t = paddle.shape(x)[0]
    for i in range(t):
        res["a"] = i      # res["a"] 的 context 为 Store、而 res 为 Load
    return res

由于现有的 visit_Name 无法捕获 res["a"] 的 Store 语义,因此增加 visit_Subscript 来捕获

if-else 也有同样的问题,结果是错误的,修改后正常

@paddle-bot
Copy link

paddle-bot bot commented Mar 6, 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.

@SigureMo SigureMo changed the title [Don't review][Dy2St] fix a dy2st limitation [Dy2St] fix a dy2st limitation Mar 9, 2023
@SigureMo SigureMo changed the title [Dy2St] fix a dy2st limitation [Dy2St] allow write to container in control flow Mar 9, 2023
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

@SigureMo SigureMo merged commit 3086511 into PaddlePaddle:develop Mar 10, 2023
@SigureMo SigureMo deleted the dy2st/fix-limitation-container branch March 10, 2023 10:55
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