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

Method testCleanup

tensorflow/python/kernel_tests/py_func_test.py:465–488  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

463
464 # ----- Tests shared by py_func and eager_py_func -----
465 def testCleanup(self):
466 # Delete everything created by previous tests to avoid side effects.
467 ops.reset_default_graph()
468 gc.collect()
469 initial_size = script_ops._py_funcs.size()
470 # Encapsulate the graph generation, so locals can be deleted.
471 def make_graphs():
472 for _ in xrange(1000):
473 g = ops.Graph()
474 with g.as_default():
475 c = constant_op.constant([1.], dtypes.float32)
476 _ = script_ops.py_func(lambda x: x + 1, [c], [dtypes.float32])
477 _ = script_ops.eager_py_func(lambda x: x + 1, [c], [dtypes.float32])
478 # These ops have a reference to 'c' which has a reference to the graph.
479 # Checks if the functions are being deleted though the graph is referenced from them.
480 # (see #18292)
481 _ = script_ops.py_func(lambda x: x + c.shape[0], [c], [dtypes.float32])
482 _ = script_ops.eager_py_func(lambda x: x + c.shape[0], [c], [dtypes.float32])
483
484 # Call garbage collector to enforce deletion.
485 make_graphs()
486 ops.reset_default_graph()
487 gc.collect()
488 self.assertEqual(initial_size, script_ops._py_funcs.size())
489
490 # ----- Tests for eager_py_func -----
491 @test_util.run_in_graph_and_eager_modes

Callers

nothing calls this directly

Calls 2

collectMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected