-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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] Refactor param_guard logic of @to_static #32867
[Dy2Static] Refactor param_guard logic of @to_static #32867
Conversation
Thanks for your contribution! |
python/paddle/fluid/tests/unittests/dygraph_to_static/test_param_guard.py
Outdated
Show resolved
Hide resolved
python/paddle/fluid/tests/unittests/dygraph_to_static/test_param_guard.py
Show resolved
Hide resolved
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.
LGTM
inputs = kwargs.get("inputs", None) | ||
outputs = kwargs.get("outputs", None) | ||
with param_guard(inputs), param_guard(outputs): | ||
op = Operator( |
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.
This will not hurt performance of static graph, because it's only call once in static mode.
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.
LGTM for the modification of framework.py
PR types
Function optimization
PR changes
APIs
Describe
1.PR功能
2. 解决方案
无论上层VarBase如何被各种容器(Python的list、dict、ParameterList)包含,最终在转为静态图时,都是以OpDesc为单位的操作的,对应于framework.py中的append_op,因此只需要在append_op进行统一的转Variable处理即可。
为什么不对Attrs dict 处理?
答:因为在append_op处的Attrs是不支持Tensor类型的。前端Python API对于参数为Tensor类型的支持方案是:将Tensor类型的参数映射一个新的Input,如slice中starts对应StartTensor。
Attr支持的类型: