From: Tianqi Chen Date: Mon, 28 Oct 2019 18:28:00 +0000 (-0400) Subject: [TOPI] Fix flaky testcase for check round (#4211) X-Git-Tag: upstream/0.7.0~1725 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2e07447e4bd4ba648222ffc00bef3ea041265979;p=platform%2Fupstream%2Ftvm.git [TOPI] Fix flaky testcase for check round (#4211) --- diff --git a/topi/tests/python/test_topi_math.py b/topi/tests/python/test_topi_math.py index ebbf6f7..bb67436 100644 --- a/topi/tests/python/test_topi_math.py +++ b/topi/tests/python/test_topi_math.py @@ -52,7 +52,7 @@ def test_ewise(): a_np = np.random.uniform(low=low, high=high, size=shape).astype(A.dtype) * 10 # avoid round check too close to boundary if check_round: - a_np += ((np.fmod(a_np, 1) - 0.5) < 1e-6) * 1e-5 + a_np += ((np.abs(np.fmod(a_np, 1)) - 0.5) < 1e-6) * 1e-5 b_np = f_numpy(a_np) def check_device(device): @@ -100,7 +100,7 @@ def test_ewise(): a_np.ravel()[np.random.choice(a_np.size, int(a_np.size * 0.5), replace=False)] = np.nan # avoid round check too close to boundary if check_round: - a_np += ((np.fmod(a_np, 1) - 0.5) < 1e-6) * 1e-5 + a_np += ((np.abs(np.fmod(a_np, 1)) - 0.5) < 1e-6) * 1e-5 b_np = np.isnan(a_np) def check_device(device):