message: infer summary writer logdir
diff: @@ -1205,14 +1205,13 @@ def trace_export(name, step=None, profiler_outdir=None):
  omitted, this defaults to `tf.summary.experimental.get_step()`, which must
  not be None.
  profiler_outdir: Output directory for profiler. It is required when profiler
  - is enabled when trace was started. Otherwise, it is ignored.
  + is enabled when trace was started. Otherwise, it is ignored. If you never
  + set it, the logdir set to the current SummaryWriter will be set.
  Raises:
  ValueError: if a default writer exists, but no step was provided and
  `tf.summary.experimental.get_step()` is None.
  """
  - # TODO(stephanlee): See if we can remove profiler_outdir and infer it from
  - # the SummaryWriter's logdir.
  global _current_trace_context
  if ops.inside_function():
  @@ -1226,8 +1225,12 @@ def trace_export(name, step=None, profiler_outdir=None):
  if _current_trace_context is None:
  raise ValueError("Must enable trace before export.")
  graph, profiler = _current_trace_context # pylint: disable=redefined-outer-name
  + if profiler_outdir is None \
  + and isinstance(_summary_state.writer, ResourceSummaryWriter):
  + profiler_outdir = _summary_state.writer._init_op_fn.keywords.get('logdir') # pylint: disable=protected-access
  if profiler and profiler_outdir is None:
  - raise ValueError("Required profiler_outdir is not specified")
  + raise ValueError("Must set profiler_outdir or "
  + "enable summary writer with logdir.")
  run_meta = context.context().export_run_metadata()
  