sxjscience commented on a change in pull request #16009: [Numpy] Numpy 
compatible bitwise_and operator
URL: https://github.com/apache/incubator-mxnet/pull/16009#discussion_r324475447
 
 

 ##########
 File path: tests/python/unittest/test_numpy_op.py
 ##########
 @@ -1080,6 +1080,53 @@ def hybrid_forward(self, F, a, *args):
                 assert same(mx_out.asnumpy(), np_out)
 
 
+@with_seed()
+@use_np
+def test_np_bitwise_and():
+    class TestBitwiseAnd(HybridBlock):
+        def __init__(self):
+            super(TestBitwiseAnd, self).__init__()
+
+        def hybrid_forward(self, F, x1, x2):
+            return F.np.bitwise_and(x1, x2)
+
+    shapes = [
+        ((3, 1), (3, 1)),
+        ((3, 1, 2), (3, 1, 2)),
+        ((1, ),(1, )),
+        ((3, 0), (3, 0)),  # zero-size shape
+        ((0, 1), (0, 1)),  # zero-size shape
+        ((2, 0, 2), (2, 0, 2)),  # zero-size shape
+        ((1, ), (3, )),  # broadcast
+        ((2, 3), (2, 1)),  # broadcast
+        ((1, 3), (2, 3)),  # broadcast
+        ((1, 3), (2, 0, 3)),  # broadcast to zero-size shape
+        ((1, 0, 1), (3, 0, 1)), # broadcast of zero-size shape
+        ((), ()),  # zero-dim shape
+    ]
+
+    for hybridize in [True, False]:
+        for shape in shapes:
+            x1_shape, x2_shape = shape
+
+            test_bitwise_and = TestBitwiseAnd()
+            if hybridize:
+                test_bitwise_and.hybridize()
+
+            x1 = rand_ndarray(x1_shape, dtype=_np.dtype(int)).as_np_ndarray()
+            x2 = rand_ndarray(x2_shape, dtype=_np.dtype(int)).as_np_ndarray()
 
 Review comment:
   Should we test for all the supported dtypes, I think we support uint8, int8, 
int32, int64.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to