Skip to content

Commit

Permalink
test(topi): add topi.erf test of cuda half
Browse files Browse the repository at this point in the history
  • Loading branch information
kongroo committed Aug 28, 2020
1 parent 505421e commit 48b5d15
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tests/python/topi/python/test_topi_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def test_apply(
dtype="float32",
check_round=False,
skip_name_check=False,
targets=get_all_backend(),
):
m = te.var("m")
l = te.var("l")
Expand All @@ -55,7 +56,7 @@ def test_apply(
# avoid round check too close to boundary
if check_round:
a_np += ((np.abs(np.fmod(a_np, 1)) - 0.5) < 1e-6) * 1e-4
b_np = f_numpy(a_np)
b_np = f_numpy(a_np).astype(dtype)

def check_device(device):
ctx = tvm.context(device, 0)
Expand All @@ -71,7 +72,7 @@ def check_device(device):
foo(a, b)
tvm.testing.assert_allclose(b.asnumpy(), b_np, rtol=1e-5, atol=1e-5)

for target in get_all_backend():
for target in targets:
check_device(target)

def test_isnan(
Expand Down Expand Up @@ -162,6 +163,7 @@ def check_device(device):
test_apply(topi.tan, "tan", np.tan, -2.0*np.pi, 2.0*np.pi, dtype='float64')
test_apply(topi.sin, "sin", np.sin, -2.0*np.pi, 2.0*np.pi)
test_apply(topi.erf, "erf", scipy.special.erf, -.1, .1, dtype="float32")
test_apply(topi.erf, "erf", scipy.special.erf, -.1, .1, dtype="float16", targets=['cuda'])
test_isnan(-100, 100)
test_infiniteness_ops(topi.isfinite, np.isfinite, 'isifinite')
test_infiniteness_ops(topi.isinf, np.isinf, 'isinf')
Expand Down

0 comments on commit 48b5d15

Please sign in to comment.