message: Reduce the number of warning messages for unsupported operations.
diff: @@ -52,6 +52,8 @@ _NOT_IMPLEMENTED_OPS = set([
  "TensorSummaryV2",
  ])
  +_MAX_WARNING_LINES = 5
  +
  _TPU_REPLICATE_ATTR = "_tpu_replicate"
  @@ -121,6 +123,17 @@ class TPUReplicateContext(control_flow_ops.ControlFlowContext):
  def __init__(self, name):
  control_flow_ops.ControlFlowContext.__init__(self)
  self._name = name
  + self._unsupported_ops = []
  +
  + def report_unsupported_operations(self):
  + if self._unsupported_ops:
  + op_str = "\n".join([" %s (%s)" % (op.type, op.name)
  + for op in self._unsupported_ops[:_MAX_WARNING_LINES]])
  + logging.warning("%d unsupported operations found: \n%s",
  + len(self._unsupported_ops), op_str)
  + if len(self._unsupported_ops) > _MAX_WARNING_LINES:
  + logging.warning("... and %d more" %
  + len(self._unsupported_ops) - _MAX_WARNING_LINES)
  def AddOp(self, op):
  self._AddOpInternal(op)
  @@ -132,8 +145,7 @@ class TPUReplicateContext(control_flow_ops.ControlFlowContext):
  (op.type, op.name))
  if op.type in _NOT_IMPLEMENTED_OPS:
  - logging.warning(
  - "Operation %s (%s) is not currently supported", op.type, op.name)
  + self._unsupported_ops.append(op)
  if any(x.dtype._is_ref_dtype for x in op.inputs):
  raise NotImplementedError(
  @@ -346,6 +358,7 @@ def replicate(computation,
  new_output_tensors.append(array_ops.identity(t))
  output_tensors = new_output_tensors
  finally:
  + context.report_unsupported_operations()
  context.Exit()
  # Fan-out: Builds a TPUReplicatedOutput node for each output.
  