• H
    [Dy2stat] Fix Read-Only Attribute as while_loop Output (#31415) · 6bf02a12
    Huihuang Zheng 提交于
    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
    ```
    6bf02a12
control_flow.py 154.2 KB