Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
zhoutianzi666 committed Sep 19, 2022
1 parent e92b177 commit c021a7f
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions paddle/fluid/framework/ir/preln_residual_bias_fuse_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,7 @@ void PrelnResidualBiasFusePass::ApplyImpl(ir::Graph *graph) const {
LOG(WARNING) << "The subgraph is empty.";
return;
}
if (!IsCompat(subgraph, graph)) {
LOG(WARNING) << "preln_residual_bias pass in op compat failed.";
return;
}

VLOG(4) << "handle PrelnResidualBias fuse";
GET_IR_NODE_FROM_SUBGRAPH(
elementwise_bias, elementwise_bias, fused_pattern);
Expand All @@ -168,11 +165,15 @@ void PrelnResidualBiasFusePass::ApplyImpl(ir::Graph *graph) const {
// We can not accept that two or more layer_norm is connected to
// elementwise1_out. This will lead to two or more PrelnResidualBias
// patterns is found near elementwise1_out, and these patterns will interact
// on each other.
int num_layer_norm = 0;
for (auto op : elementwise1_out->outputs) {
if (op->Name() == "layer_norm") num_layer_norm++;
if (num_layer_norm >= 2) return;
// on each other, so we make below check to ensure only one
// PrelnResidualBias pattern is delalted with.
for (auto op : elementwise1_out->inputs) {
if (op->Name() == "preln_residual_bias") return;
}

if (!IsCompat(subgraph, graph)) {
LOG(WARNING) << "preln_residual_bias pass in op compat failed.";
return;
}

std::unordered_set<const Node *> del_node_set;
Expand Down

0 comments on commit c021a7f

Please sign in to comment.