message: Optimize FusedBatchNorm with DepthwiseConv2dNative for inference.
diff: @@ -238,9 +238,9 @@ def fold_batch_norms(input_graph_def):
  conv_op = node_from_map(input_node_map,
  node.input[INPUT_ORDER[node.op].index("conv_op")])
  - if conv_op.op != "Conv2D":
  + if conv_op.op != "Conv2D" and conv_op.op != "DepthwiseConv2dNative":
  tf_logging.warning(
  - "Didn't find expected Conv2D input to '%s'" % node.name)
  + "Didn't find expected Conv2D or DepthwiseConv2dNative input to '%s'" % node.name)
  continue
  weights_op = node_from_map(input_node_map, conv_op.input[1])
  @@ -250,7 +250,10 @@ def fold_batch_norms(input_graph_def):
  " run first?" % (conv_op.name, weights_op))
  continue
  weights = values_from_const(weights_op)
  + if conv_op.op == "Conv2D":
  channel_count = weights.shape[3]
  + elif conv_op.op == "DepthwiseConv2dNative":
  + channel_count = weights.shape[2] * weights.shape[3]
  mean_op = node_from_map(input_node_map,
  node.input[INPUT_ORDER[node.op].index("mean_op")])
  @@ -328,10 +331,17 @@ def fold_batch_norms(input_graph_def):
  scaled_weights = np.copy(weights)
  it = np.nditer(
  scaled_weights, flags=["multi_index"], op_flags=["readwrite"])
  + if conv_op.op == "Conv2D":
  while not it.finished:
  current_scale = scale_value[it.multi_index[3]]
  it[0] *= current_scale
  it.iternext()
  + elif conv_op.op == "DepthwiseConv2dNative":
  + channel_multiplier = weights.shape[3]
  + while not it.finished:
  + current_scale = scale_value[it.multi_index[2] * channel_multiplier + it.multi_index[3]]
  + it[0] *= current_scale
  + it.iternext()
  scaled_weights_op = node_def_pb2.NodeDef()
  scaled_weights_op.op = "Const"
  scaled_weights_op.name = weights_op.name
  