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

Function _default_compare_fn

imperative/python/test/helpers/utils.py:13–19  ·  view source on GitHub ↗
(x, y)

Source from the content-addressed store, hash-verified

11
12
13def _default_compare_fn(x, y):
14 if isinstance(x, tensor) and not isinstance(x, VarNode):
15 x = x.numpy()
16 elif not isinstance(x, np.ndarray):
17 x = get_var_value(x)
18 assert isinstance(x, np.ndarray)
19 np.testing.assert_allclose(x, y, rtol=1e-6)
20
21
22def make_tensor(x, network=None, device=None):

Callers

nothing calls this directly

Calls 2

get_var_valueFunction · 0.85
numpyMethod · 0.45

Tested by

no test coverage detected