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

Function trace_on

tensorflow/python/ops/summary_ops_v2.py:1129–1170  ·  view source on GitHub ↗

Starts a trace to record computation graphs and profiling information. Must be invoked in eager mode. When enabled, TensorFlow runtime will collection information that can later be exported and consumed by TensorBoard. The trace is activated across the entire TensorFlow runtime and affects

(graph=True, profiler=False)

Source from the content-addressed store, hash-verified

1127
1128@tf_export("summary.trace_on", v1=[])
1129def trace_on(graph=True, profiler=False): # pylint: disable=redefined-outer-name
1130 """Starts a trace to record computation graphs and profiling information.
1131
1132 Must be invoked in eager mode.
1133
1134 When enabled, TensorFlow runtime will collection information that can later be
1135 exported and consumed by TensorBoard. The trace is activated across the entire
1136 TensorFlow runtime and affects all threads of execution.
1137
1138 To stop the trace and export the collected information, use
1139 `tf.summary.trace_export`. To stop the trace without exporting, use
1140 `tf.summary.trace_off`.
1141
1142 Args:
1143 graph: If True, enables collection of executed graphs. It includes ones from
1144 tf.function invocation and ones from the legacy graph mode. The default
1145 is True.
1146 profiler: If True, enables the advanced profiler. Enabling profiler
1147 implicitly enables the graph collection. The profiler may incur a high
1148 memory overhead. The default is False.
1149
1150 """
1151 if ops.inside_function():
1152 logging.warn("Cannot enable trace inside a tf.function.")
1153 return
1154 if not context.context().executing_eagerly():
1155 logging.warn("Must enable trace in eager mode.")
1156 return
1157
1158 global _current_trace_context
1159 with _current_trace_context_lock:
1160 if _current_trace_context:
1161 logging.warn("Trace already enabled")
1162 return
1163
1164 if graph and not profiler:
1165 context.context().enable_graph_collection()
1166 if profiler:
1167 context.context().enable_run_metadata()
1168 _profiler.start()
1169
1170 _current_trace_context = _TraceContext(graph=graph, profiler=profiler)
1171
1172
1173@tf_export("summary.trace_export", v1=[])

Callers

nothing calls this directly

Calls 5

executing_eagerlyMethod · 0.80
enable_run_metadataMethod · 0.80
contextMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected