From 48b5d1535e4834a51c958ba1b03ccd86634c7b28 Mon Sep 17 00:00:00 2001 From: kongroo Date: Fri, 28 Aug 2020 12:57:44 +0800 Subject: [PATCH] test(topi): add topi.erf test of cuda half --- tests/python/topi/python/test_topi_math.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/python/topi/python/test_topi_math.py b/tests/python/topi/python/test_topi_math.py index 8a9754ed6f969..53c36dc2e0fd8 100644 --- a/tests/python/topi/python/test_topi_math.py +++ b/tests/python/topi/python/test_topi_math.py @@ -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") @@ -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) @@ -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( @@ -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')