-
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
[AMP] Support amp for Intermediate_dygraph #40623
[AMP] Support amp for Intermediate_dygraph #40623
Conversation
Thanks for your contribution! |
# def func(): | ||
# with fluid.dygraph.guard(): | ||
# model = fluid.dygraph.Conv2D(3, 2, 3, bias_attr=False, act=None) | ||
# opt = paddle.optimizer.SGD(parameters=model.parameters()) |
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 commment
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.
已开启全部amp单测
" auto amp_dst_dtype = " | ||
"egr::GetAmpDestDtype(egr::Controller::Instance().GetCurrentTracer()-" | ||
">GetAmpDtype(), " | ||
"egr::Controller::Instance().GetAMPLevel(), \"%s\", " |
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.
u can reuse egr::Controller::Instance()
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.
Done.
… dev/amp_intermediate
… dev/amp_intermediate
… dev/amp_intermediate
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.
little problem, fix it in next PR
paddle/fluid/eager/amp_utils.h
Outdated
inputs_casted.push_back( | ||
std::move(cast_dygraph_function(input, cast_attrs))); | ||
} else { | ||
inputs_casted.push_back(input); |
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.
emplace_back is better
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.
Done, tks!
… dev/amp_intermediate
fd69d72
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 changing parallel_UT_rule.py
PR types
New features
PR changes
Others
Describe
AMP适配动态图中间态
** 1 实现要点:**
(1)动态图 api 中添加 amp 逻辑分支:
cast_dygraph_function
得到 casted_inputs(2)实现 amp 公共组件:
GetAmpDestDtype
:依据amp参数,获取需要cast的数据类型AmpAutoCast
/AmpAutoCasts
:将输入数据cast为指定数据类型2 实现效果:
eager_generator.cc中加入amp代码生成逻辑:
** 3 注:**