MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / trace_export

Function trace_export

tensorflow/python/ops/summary_ops_v2.py:1174–1220  ·  view source on GitHub ↗

Stops and exports the active trace as a Summary and/or profile file. Stops the trace and exports all metadata collected during the trace to the default SummaryWriter, if one has been set. Args: name: A name for the summary to be written. step: Explicit `int64`-castable monotonic step

(name, step=None, profiler_outdir=None)

Source from the content-addressed store, hash-verified

1172
1173@tf_export("summary.trace_export", v1=[])
1174def trace_export(name, step=None, profiler_outdir=None):
1175 """Stops and exports the active trace as a Summary and/or profile file.
1176
1177 Stops the trace and exports all metadata collected during the trace to the
1178 default SummaryWriter, if one has been set.
1179
1180 Args:
1181 name: A name for the summary to be written.
1182 step: Explicit `int64`-castable monotonic step value for this summary. If
1183 omitted, this defaults to `tf.summary.experimental.get_step()`, which must
1184 not be None.
1185 profiler_outdir: Output directory for profiler. It is required when profiler
1186 is enabled when trace was started. Otherwise, it is ignored.
1187
1188 Raises:
1189 ValueError: if a default writer exists, but no step was provided and
1190 `tf.summary.experimental.get_step()` is None.
1191 """
1192 # TODO(stephanlee): See if we can remove profiler_outdir and infer it from
1193 # the SummaryWriter's logdir.
1194 global _current_trace_context
1195
1196 if ops.inside_function():
1197 logging.warn("Cannot export trace inside a tf.function.")
1198 return
1199 if not context.context().executing_eagerly():
1200 logging.warn("Can only export trace while executing eagerly.")
1201 return
1202
1203 with _current_trace_context_lock:
1204 if _current_trace_context is None:
1205 raise ValueError("Must enable trace before export.")
1206 graph, profiler = _current_trace_context # pylint: disable=redefined-outer-name
1207 if profiler and profiler_outdir is None:
1208 raise ValueError("Required profiler_outdir is not specified")
1209
1210 run_meta = context.context().export_run_metadata()
1211
1212 if graph and not profiler:
1213 run_metadata_graphs(name, run_meta, step)
1214 else:
1215 run_metadata(name, run_meta, step)
1216
1217 if profiler:
1218 _profiler.save(profiler_outdir, _profiler.stop())
1219
1220 trace_off()
1221
1222
1223@tf_export("summary.trace_off", v1=[])

Callers

nothing calls this directly

Calls 8

run_metadata_graphsFunction · 0.85
run_metadataFunction · 0.85
trace_offFunction · 0.85
executing_eagerlyMethod · 0.80
export_run_metadataMethod · 0.80
contextMethod · 0.45
saveMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected