MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / test_tensor_detach

Function test_tensor_detach

imperative/python/test/unit/jit/test_tracing.py:98–107  ·  view source on GitHub ↗
(trace_mode)

Source from the content-addressed store, hash-verified

96
97@pytest.mark.parametrize("trace_mode", [False, True])
98def test_tensor_detach(trace_mode):
99 @trace(symbolic=True)
100 def f(x):
101 y = x.detach() ** 2
102 z = y.detach() + 1
103 return z.detach()
104
105 x = tensor([1, 2, 3, 4])
106 for _ in range(3):
107 f(x).numpy()
108
109
110@pytest.mark.parametrize("trace_mode", [False, True])

Callers

nothing calls this directly

Calls 2

fFunction · 0.70
numpyMethod · 0.45

Tested by

no test coverage detected