Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
guizili0 committed Oct 25, 2019
1 parent 73b6692 commit 7e2b602
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions tensorflow/core/grappler/optimizers/remapper.cc
Expand Up @@ -573,6 +573,7 @@ bool FindContractionWithBiasInPort(const RemapperContext& ctx,
if (add_node_view.NumRegularFanins() < port_id + 1) return false;
const auto& bias_add_node_view =
add_node_view.GetRegularFanin(port_id).node_view();
if (bias_add_node_view == nullptr) return false;
const auto* bias_add_node_def = bias_add_node_view->node();

if (!FindContractionWithBias(ctx, bias_add_node_view->node_index(), base,
Expand Down Expand Up @@ -637,6 +638,7 @@ bool FindContractionWithBiasAndAddActivation(

// Root of the pattern must be an activation node.
const auto* node_def = node_view->node();
if (node_def == nullptr) return false;
if (!IsSupportedActivation(*node_def)) return false;

// MKL activation op only supports float data type.
Expand Down Expand Up @@ -1208,14 +1210,13 @@ Status AddFusedBatchNormExNode(RemapperContext* ctx,
const NodeDef& activation = graph->node(matched.activation);

VLOG(2) << "Fuse " << activation.op() << " with FusedBatchNorm:"
<< " activation=" << activation.name() << " side_input="
<< (matched.side_input != kMissingIndex
? graph->node(matched.side_input).name()
: "<none>")
<< " invalidated="
<< (matched.invalidated != kMissingIndex
? graph->node(matched.invalidated).name()
: "<none>")
<< " activation=" << activation.name()
<< " side_input=" << (matched.side_input != kMissingIndex
? graph->node(matched.side_input).name()
: "<none>")
<< " invalidated=" << (matched.invalidated != kMissingIndex
? graph->node(matched.invalidated).name()
: "<none>")
<< " fused_batch_norm=" << fused_batch_norm.name();

// Replace FusedBatchNorm with _FusedBatchNormEx + <SideInput> + <Activation>.
Expand Down

0 comments on commit 7e2b602

Please sign in to comment.