fix an exception when profiler is stopped twice.
PiperOrigin-RevId: 343582616 Change-Id: I37fd9e677d2a3912d51c9f5f42b3ad2bdb481ec8
This commit is contained in:
parent
c75297bb18
commit
4f301f5997
@ -1216,6 +1216,26 @@ class SummaryOpsTest(test_util.TensorFlowTestCase):
|
||||
# Reset to default state for other tests.
|
||||
summary_ops.set_step(None)
|
||||
|
||||
@test_util.run_v2_only
|
||||
def testTrace_withProfiler(self):
|
||||
|
||||
@def_function.function
|
||||
def f():
|
||||
x = constant_op.constant(2)
|
||||
y = constant_op.constant(3)
|
||||
return x**y
|
||||
|
||||
assert context.executing_eagerly()
|
||||
logdir = self.get_temp_dir()
|
||||
writer = summary_ops.create_file_writer(logdir)
|
||||
summary_ops.trace_on(graph=True, profiler=True)
|
||||
profiler_outdir = self.get_temp_dir()
|
||||
with writer.as_default():
|
||||
f()
|
||||
summary_ops.trace_export(
|
||||
name='foo', step=1, profiler_outdir=profiler_outdir)
|
||||
writer.close()
|
||||
|
||||
@test_util.run_v2_only
|
||||
def testGraph_graph(self):
|
||||
|
||||
|
@ -1385,4 +1385,7 @@ def trace_off():
|
||||
context.context().disable_run_metadata()
|
||||
|
||||
if profiler:
|
||||
_profiler.stop()
|
||||
try:
|
||||
_profiler.stop()
|
||||
except _profiler.ProfilerNotRunningError:
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user