-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
add backward inplace for dygraph #35412
add backward inplace for dygraph #35412
Conversation
Thanks for your contribution! |
paddle::framework::OpInfoMap::Instance().Get(op_type).infer_inplace_; | ||
|
||
if (infer_inplace) { | ||
auto in_to_outs = infer_inplace(true); |
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.
Why always be true
?
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.
Discussed offline, the parameter being true
and false
has no difference now.
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
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
* add backward inplace for dygraph * fix bug * support gradient accumulation
PR types
New features
PR changes
Others
Describe
add backward inplace for dygraph
how
In dygraph mode, the forward part is not determined, while the backward computation graph is determined after forward. So the graph optimization can be performed. And, the reference count used to guide inplace optimization can be easily get
shared_ptr
of input tensor.Two benefits: (1) reduce d2d copy and speed up training, (2) reduce memory usage
performance
GPT model, speed up +2.8%.