tingying2020 commented on a change in pull request #16016: [numpy] operator 
ravel, derive from reshape
URL: https://github.com/apache/incubator-mxnet/pull/16016#discussion_r323690459
 
 

 ##########
 File path: tests/python/unittest/test_numpy_op.py
 ##########
 @@ -1744,6 +1777,45 @@ def test_indexing_mode(sampler, set_size, samples_size, 
replace, weight=None):
             test_indexing_mode(test_choice_weighted, num_classes, num_classes 
// 2, replace, weight)
 
 
+@with_seed()
+@use_np
+def test_np_ravel():
+    class TestRavel(HybridBlock):
+        def __init__(self):
+            super(TestRavel, self).__init__()
+
+        def hybrid_forward(self, F, a):
+            return F.np.ravel(a)
+
+    types = ['float64', 'float32', 'float16', 'int64', 'int32', 'int8']
+    for oneType in types:
+        for hybridize in [True, False]:
+            for shape in [(),
+                          (2,),
+                          (2, 2),
+                          (1, 2, 3),
+                          (3, 0),
+                          (1, 0, 2)
+                          ]:
+                test_ravel = TestRavel()
+                if hybridize:
+                    test_ravel.hybridize()
+                x = rand_ndarray(shape, dtype=oneType).as_np_ndarray()
+                x.attach_grad()
+                np_out = _np.ravel(x.asnumpy())
+                with mx.autograd.record():
+                    mx_out = test_ravel(x)
+                assert mx_out.shape == np_out.shape
 
 Review comment:
   Done.

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