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] Fix Read-Only Attribute as while_loop Output #31415

Merged
merged 4 commits into from
Mar 4, 2021

Conversation

zhhsplendid
Copy link
Member

@zhhsplendid zhhsplendid commented Mar 3, 2021

PR types

Bug fixes

PR changes

APIs

Describe

Fix Read-Only Attribute as while_loop Output:

Usually, our convert_while_loop will be like:

    [a, b, c] = paddle.jit.dy2static.convert_while_loop(
            condition_name, body_name, [a, b, c])

where a, b, c are in loop_var_names.

However, if loop_var_names contains property such as foo.x, we cannot
assign the attribute as output of convert_while_loop because Python
property is a kind of read-only attribute. To handle the case, we replace
the attributes which are output of convert_while_loop with generated
variables, then if we know the attribute is not read-only at runtime, we
assign the attribute. The created statements are like:

    [a, b, __attribute_variable_1] = paddle.jit.dy2static.convert_while_loop(
            condition_name, body_name, [a, b, foo.x])
    if not isinstance(getattr(type(foo), x, None), property): foo.x = __attribute_variable_1

@paddle-bot-old
Copy link

paddle-bot-old bot commented Mar 3, 2021

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


where a, b, c are in loop_var_names.

However, if loop_var_names contains attribute such as foo.x, we cannot
Copy link
Member Author

@zhhsplendid zhhsplendid Mar 4, 2021

Choose a reason for hiding this comment

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

Here I had a comment error: "attribute" -> "property"

I will change it in the near future (for example, after reviewer reviews it, or make it as test=document_fix in the next PR) because current commit passes CI tests.

Copy link
Contributor

@liym27 liym27 left a comment

Choose a reason for hiding this comment

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

LGTM

@zhhsplendid zhhsplendid merged commit 6bf02a1 into PaddlePaddle:develop Mar 4, 2021
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