Skip to content

[Dy2St]Refine AnnAssign in static_analysis #39572

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

Merged
merged 1 commit into from
Feb 16, 2022

Conversation

0x45f
Copy link
Contributor

@0x45f 0x45f commented Feb 15, 2022

PR types

Others

PR changes

Others

Describe

之前在动转静中使用a: int = b类似的type hint语句时,如果static analysis模块分析出a的标注类型和b的类型不同,则会将a分析为b的类型,而不会使用标注的类型int。但是static analysis模块有时后会将b分析为unknow类型,导致a的类型也被分析为unknow,使得type hint失效。

@paddle.jit.to_static
def func(x):
    a = []
    import pdb; pdb.set_trace()
    x = paddle.to_tensor(x)
    tmp: paddle.Tensor = len(x)
    for i in range(tmp):
        a.append(i)

@paddle-bot-old
Copy link

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

@Aurelius84 Aurelius84 merged commit eb3c7d0 into PaddlePaddle:develop Feb 16, 2022
@0x45f 0x45f deleted the dy2st_refine_annassign branch February 16, 2022 06:47
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