Fix the values for test_fmod since it fails way too often otherwise (#5723)
authorabergeron <abergeron@gmail.com>
Fri, 5 Jun 2020 21:17:41 +0000 (17:17 -0400)
committerGitHub <noreply@github.com>
Fri, 5 Jun 2020 21:17:41 +0000 (14:17 -0700)
tests/python/integration/test_ewise.py

index a8f2db1..dfa247e 100644 (file)
@@ -80,8 +80,15 @@ def test_fmod():
 
             # launch the kernel.
             n = 1024
-            a = tvm.nd.array((np.random.uniform(size=n) * 256).astype(A.dtype), ctx)
-            b = tvm.nd.array((np.random.uniform(size=n) * 256).astype(B.dtype), ctx)
+            a_np = (np.random.uniform(size=n) * 256).astype(A.dtype)
+            b_np = (np.random.uniform(size=n) * 256).astype(B.dtype)
+
+            # "fix" the values in a and b to avoid the result being too small
+            b_np += ((b_np < 2.0) * 2)
+            a_np[np.abs(np.fmod(a_np, b_np)) < 1] += 1
+
+            a = tvm.nd.array(a_np, ctx)
+            b = tvm.nd.array(b_np, ctx)
             c = tvm.nd.array(np.zeros(n, dtype=C.dtype), ctx)
             ftimer = fmod.time_evaluator(fmod.entry_name, ctx, number=1)
             tcost = ftimer(a, b, c).mean