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

Function test_binary_minmax

tests/python/relax/test_op_gradient_numeric.py:256–264  ·  view source on GitHub ↗
(target, dev, binary_minmax_op_func)

Source from the content-addressed store, hash-verified

254
255@tvm.testing.parametrize_targets("llvm")
256def test_binary_minmax(target, dev, binary_minmax_op_func):
257 # Checking numerical gradient of min and max requires data1_numpy[i] != data2_numpy[i]
258 # for all possible i.
259 # If data1_numpy[i] == data2_numpy[i], the operator is not differentiable w.r.t. place i
260 data1_numpy = np.random.uniform(1, 1.1, (3, 3)).astype(np.float32)
261 delta = np.random.uniform(1, 1.1, (3, 3)).astype(np.float32)
262 sign = np.random.randint(0, 2, (3, 3)).astype(np.float32) * 2 - 1
263 data2_numpy = data1_numpy + delta * sign
264 relax_check_gradients(binary_minmax_op_func, [data1_numpy, data2_numpy], target, dev)
265
266
267(binary_cmp_op_func,) = tvm.testing.parameters(

Callers

nothing calls this directly

Calls 3

relax_check_gradientsFunction · 0.85
uniformMethod · 0.80
astypeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…