You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2019/06/21 08:28:22 UTC

[GitHub] [incubator-mxnet] zoeygxy commented on a change in pull request #15306: Numpy bitwise_and operation added

zoeygxy commented on a change in pull request #15306: Numpy bitwise_and operation added
URL: https://github.com/apache/incubator-mxnet/pull/15306#discussion_r296142502
 
 

 ##########
 File path: tests/python/unittest/test_numpy_op.py
 ##########
 @@ -1018,6 +1018,56 @@ def hybrid_forward(self, F, x):
             assert same(ret_mx.asnumpy(), ret_np)
 
 
+@with_seed()
+@npx.use_np_shape
+def test_np_bitwise_and():
+    @npx.use_np_shape
+    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-dim shape
+        ((1, 0, 1), (3, 0, 1)), # broadcast of zero-dim 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()
+            x1.attach_grad()
 
 Review comment:
   Fixed.

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