You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2019/11/21 02:58:20 UTC

[GitHub] [incubator-tvm] tqchen commented on a change in pull request #4382: [TOPI] Fix flaky testcase for floor div

tqchen commented on a change in pull request #4382: [TOPI] Fix flaky testcase for floor div
URL: https://github.com/apache/incubator-tvm/pull/4382#discussion_r348876427
 
 

 ##########
 File path: topi/tests/python/test_topi_broadcast.py
 ##########
 @@ -71,27 +99,19 @@ def check_device(device):
         with tvm.target.create(device):
             s = topi.generic.schedule_broadcast(C)
         foo = tvm.build(s, [A, B, C], device, name="broadcast_binary" + "_" + ftopi.__name__)
-        if lhs_shape is None:
-            lhs_npy = float(np.random.uniform(low=lhs_min, high=lhs_max))
-            if dtype.startswith('int'):
-                lhs_npy = int(lhs_npy)
-            lhs_nd = lhs_npy
-        else:
-            lhs_npy = np.random.uniform(low=lhs_min, high=lhs_max,
-                                        size=lhs_shape).astype(A.dtype)
-            lhs_nd = tvm.nd.array(lhs_npy, ctx)
 
-        if rhs_shape is None:
-            rhs_npy = float(np.random.uniform(low=rhs_min, high=rhs_max))
-            if dtype.startswith('int'):
-                rhs_npy = int(rhs_npy)
-            rhs_nd = rhs_npy
-        else:
-            rhs_npy = np.random.uniform(low=rhs_min, high=rhs_max,
-                                        size=rhs_shape).astype(A.dtype)
-            rhs_nd = tvm.nd.array(rhs_npy, ctx)
+        lhs_npy, lhs_nd = gen_operand(lhs_shape, lhs_min, lhs_max, ctx)
+        rhs_npy, rhs_nd = gen_operand(rhs_shape, rhs_min, rhs_max, ctx)
 
         out_npy = fnumpy(lhs_npy, rhs_npy)
+        # avoid check too close to 0.5
+        unstable_points = np.abs(out_npy) - 0.5 < 1e-6
+        while adjust_unstable_points and unstable_points.any():
 
 Review comment:
   The the logic was a bit too complicated, likely you can do vectorize.
   ```
   mask = (np.abs(np.fmod(out, 1)) - 0.5) < 1e-6
   lhs_npy += mask * 1e-3  * rhs_npy
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services