yzhliu 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_r348897950
 
 

 ##########
 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:
   but it's broadcast, mask, lhs, rhs can have different shape.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to