MCPcopy Create free account
hub / github.com/apache/tvm / assert_allclose

Function assert_allclose

python/tvm/testing/utils.py:101–112  ·  view source on GitHub ↗

Version of np.testing.assert_allclose with `atol` and `rtol` fields set in reasonable defaults. Arguments `actual` and `desired` are not interchangeable, since the function compares the `abs(actual-desired)` with `atol+rtol*abs(desired)`. Since we often allow `desired` to be close

(actual, desired, rtol=1e-7, atol=1e-7, verbose=True)

Source from the content-addressed store, hash-verified

99
100
101def assert_allclose(actual, desired, rtol=1e-7, atol=1e-7, verbose=True):
102 """Version of np.testing.assert_allclose with `atol` and `rtol` fields set
103 in reasonable defaults.
104
105 Arguments `actual` and `desired` are not interchangeable, since the function
106 compares the `abs(actual-desired)` with `atol+rtol*abs(desired)`. Since we
107 often allow `desired` to be close to zero, we generally want non-zero `atol`.
108 """
109 actual = np.asanyarray(actual)
110 desired = np.asanyarray(desired)
111 np.testing.assert_allclose(actual.shape, desired.shape)
112 np.testing.assert_allclose(actual, desired, rtol=rtol, atol=atol, verbose=verbose)
113
114
115def check_numerical_grads(

Callers 5

test_manual_gradientFunction · 0.90
_assert_allclose_nestedFunction · 0.90
test_cpu_matmulFunction · 0.90
test_cpu_fusionFunction · 0.90
test_gpuFunction · 0.90

Calls

no outgoing calls

Tested by 5

test_manual_gradientFunction · 0.72
_assert_allclose_nestedFunction · 0.72
test_cpu_matmulFunction · 0.72
test_cpu_fusionFunction · 0.72
test_gpuFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…