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

Method defun

tensorflow/python/framework/ops_test.py:2040–2058  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2038
2039 @eager_function.defun
2040 def defun():
2041 ops.add_to_collection("int", 1)
2042 ops.add_to_collection("tensor", constant_op.constant(2))
2043
2044 @eager_function.defun
2045 def inner_defun():
2046 self.assertEqual(ops.get_collection("int"), [1])
2047 three = ops.get_collection("tensor")[0] + ops.get_collection("int")[0]
2048 ops.add_to_collection("int", 2)
2049 self.assertEqual(ops.get_collection("int"), [1, 2])
2050 ops.add_to_collection("foo", "bar")
2051 self.assertEqual(ops.get_collection("foo"), ["bar"])
2052 return three
2053
2054 self.assertEqual(ops.get_collection("int"), [1])
2055 three = inner_defun()
2056 self.assertEqual(ops.get_collection("int"), [1])
2057 self.assertEqual(ops.get_collection("foo"), [])
2058 return three
2059
2060 three = defun()
2061 self.assertEqual(three.numpy(), 3)

Callers 15

__init__Method · 0.45
all_metric_resultsMethod · 0.45
__init__Method · 0.45
testDefunMatmulMethod · 0.45
test_call_defunMethod · 0.45
mainFunction · 0.45
_benchmark_eagerMethod · 0.45

Calls 3

add_to_collectionMethod · 0.80
constantMethod · 0.45
get_collectionMethod · 0.45

Tested by

no test coverage detected