Skip to content

Commit

Permalink
Dynamic amp support sync_batch_norm op (#32770)
Browse files Browse the repository at this point in the history
  • Loading branch information
sljlp authored May 10, 2021
1 parent beab956 commit 23ab01e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions paddle/fluid/imperative/amp_auto_cast.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ NameVarBaseMap AutoCastInputs(const std::string& op_type,
if (AmpOperators::Instance().GetMutableAllowOps()->count(op_type)) {
for (auto& pair : new_ins) {
// NOTE(zhiqiu): batch_norm and layer_norm support only input x is fp16.
if ((op_type == "batch_norm" || op_type == "layer_norm") &&
if ((op_type == "batch_norm" || op_type == "layer_norm" ||
op_type == "sync_batch_norm") &&
pair.first != "X") {
continue;
}
Expand Down Expand Up @@ -191,7 +192,8 @@ NameVarBaseMap AutoCastInputs(const std::string& op_type,
}
for (auto& pair : new_ins) {
// NOTE(zhiqiu): batch_norm and layer_norm support only input x is fp16.
if ((op_type == "batch_norm" || op_type == "layer_norm") &&
if ((op_type == "batch_norm" || op_type == "layer_norm" ||
op_type == "sync_batch_norm") &&
pair.first == "X" && dst_type == framework::proto::VarType::FP32) {
continue;
}
Expand Down

0 comments on commit 23ab01e

Please sign in to comment.