message: [convergence_tools]: Adding a tensor tracer flag to disable tracing of the scalar ops.
diff: @@ -58,6 +58,7 @@ _REASON_OUTSIDE_OP_RANGE = 'not-traced-outside-op-range'
  _REASON_UNSAFE_OP = 'not-traced-unsafe-op'
  _REASON_WHILELOOP_OP = 'not-traced-special-whileloop-op'
  _REASON_UNSAFE_SCALAR = 'not-traced-unsafe-scalar'
  +_REASON_SKIP_SCALAR = 'not-traced-scalar'
  _REASON_LESS_INTERESTING_OP = 'not-traced-less-interesting-op'
  _REASON_DEVICE_MISMATCH = 'not-traced-device-mismatch'
  _REASON_DYNAMIC_SHAPE = 'not-traced-dynamic-shape'
  @@ -95,6 +96,7 @@ _FLAG_NO_EQUAL_PAT = re.compile(r'\s*--([^=]+)\s*')
  _FLAG_NAME_ENABLE = 'enable'
  _FLAG_NAME_TRACE_MODE = 'trace_mode'
  _FLAG_NAME_USE_COMPACT_TRACE = 'compact_trace'
  +_FLAG_NAME_TRACE_SCALAR_OPS = 'trace_scalar'
  _FLAG_NAME_SUBMODE = 'submode'
  _FLAG_NAME_INCLUDE_LESS_INTERESTING_OPS = 'include_less_interesting_ops'
  _FLAG_NAME_EXCLUDED_OPNAMES = 'excluded_opnames'
  @@ -239,6 +241,7 @@ class TensorTracer(object):
  """
  # The set of graphs that are rewritten by tensor tracer.
  _traced_graphs = set()
  +
  @staticmethod
  def _match_next_flag(flags, pos):
  """Returns the match for the next TensorTracer flag.
  @@ -274,6 +277,7 @@ class TensorTracer(object):
  """Validates if the TensorTrace flags passed are valid."""
  valid_flag_names = [_FLAG_NAME_ENABLE, _FLAG_NAME_TRACE_MODE,
  _FLAG_NAME_USE_COMPACT_TRACE,
  + _FLAG_NAME_TRACE_SCALAR_OPS,
  _FLAG_NAME_SUBMODE,
  _FLAG_NAME_EXCLUDED_OPNAMES,
  _FLAG_NAME_EXCLUDED_OPTYPES,
  @@ -648,6 +652,8 @@ class TensorTracer(object):
  self._num_replicas_per_host = None
  self._num_hosts = None
  self._replica_id = None
  + self._trace_scalar_ops = TensorTracer._is_flag_on(
  + _FLAG_NAME_TRACE_SCALAR_OPS)
  _, self._graph_dump_path = TensorTracer.get_flag_value(
  _FLAG_DUMP_BEFORE_AFTER_GRAPHS)
  @@ -1078,6 +1084,7 @@ class TensorTracer(object):
  rank = len(out_tensor.shape)
  if rank < 1:
  # scalar
  + if self._trace_scalar_ops:
  if TensorTracer.unsafe_scalar_trace(out_tensor.op):
  self._instrument_records[out_tensor.name] = TensorTracer.reason(
  op_id, _REASON_UNSAFE_SCALAR)
  @@ -1086,6 +1093,10 @@ class TensorTracer(object):
  self._instrument_records[out_tensor.name] = TensorTracer.reason(
  op_id, _REASON_SCALAR_GET_TRACED)
  return False
  + else:
  + self._instrument_records[out_tensor.name] = TensorTracer.reason(
  + op_id, _REASON_SKIP_SCALAR)
  + return True
  else:
  # tensor
  self._instrument_records[out_tensor.name] = TensorTracer.reason(
  