-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
[dy2static] support fallback for whole graph. (stage 1) #50111
Merged
2742195759
merged 5 commits into
PaddlePaddle:develop
from
2742195759:dy2static-fallback
Feb 3, 2023
Merged
[dy2static] support fallback for whole graph. (stage 1) #50111
2742195759
merged 5 commits into
PaddlePaddle:develop
from
2742195759:dy2static-fallback
Feb 3, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
你的PR提交成功,感谢你对开源项目的贡献! |
Aurelius84
reviewed
Jan 31, 2023
Aurelius84
approved these changes
Feb 3, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
后续我们在to_static里加一个参数:fallback=True的开关是不是好一些?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR types
New features
PR changes
Others
Describe
动转静整图Fallback机制:
给动转静添加了整图Fallback机制。如果在动转静过程中出现了语法错误、用户无法识别语法会进行fallback到动态图下执行。整个过程不修改任何的用户用法,除了会报 warning 之外,不会有任何的影响。
开启方法:
build_strategy 中传入 build_strategy.build_cinn_pass=True 就会默认开启。(TODO:后续会添加一个独立的开关进行启动)
运行截图:报warning
如果出现了动转静失败,同时开启了上述的pass,那么就会抛出一个warning,如下:
错误日志
如果报错,那么warning中会提示在 dy2static.error 文件中可以查看不支持的语法:例如:
可以看到上述的错误是因为调用了numpy函数,用户可以通过修改代码,或者是反馈来解决模型问题,当模型问题修复之后,就不会出现warning了。
设计架构:
局限性
当前只是支持整图fallback,所以整个模型都会到动态图下执行。因此无法进行 jit.save、jit.load 等用法,同时也不支持获取 program。如果使用了上述的不支持方法,会有 Exception 抛出,并拦截提示。(用户友好)
比如调用了如下代码:
如果 u_net 不支持动转静,那么会报如下错误: