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/08/03 00:17:43 UTC

[GitHub] [incubator-mxnet] ChaiBapchya commented on a change in pull request #15126: [MXNET-1407] Added test to verify Large Tensor Support for pad operator

ChaiBapchya commented on a change in pull request #15126: [MXNET-1407] Added test to verify Large Tensor Support for pad operator
URL: https://github.com/apache/incubator-mxnet/pull/15126#discussion_r310329521
 
 

 ##########
 File path: tests/nightly/test_large_array.py
 ##########
 @@ -319,6 +319,39 @@ def test_flip():
     assert np.sum(t[-1, :].asnumpy() == 0) == b.shape[1]
 
 
+def check_pad_with_shape(shape, pad_width, mode, dtype="float64"):
+    # bind with label
+    X = mx.symbol.Variable('X', dtype=dtype)
+    Y = mx.symbol.Pad(data=X, mode=mode, pad_width=pad_width)
+    x = mx.random.uniform(-1, 1, shape, dtype=dtype)
+    # numpy result
+    pad_grouped = list(zip(*[iter(list(pad_width))] * 2))
+    np_out = np.pad(x.asnumpy(), pad_grouped, mode)
+    # mxnet result
+    grad = mx.nd.empty(shape, dtype=dtype)
+    exec1 = Y.bind(args=[x], ctx=mx.cpu(), args_grad={'X': grad})
+    exec1.forward(is_train=True)
+    out = exec1.outputs[0].asnumpy()
+    # compare numpy + mxnet
+    assert_almost_equal(out, np_out)
+
+def test_pad():
+    shape1 = (LARGE_X, 2, 2, 2)
+    pad1 = (0, 0, 0, 0, 1, 1, 1, 1)
+    shape2 = (LARGE_X, 2, 2, 1, 1)
+    pad2 = (0, 0, 0, 0, 1, 1, 0, 0, 0, 0)
+    # note: this op doesn't support ints yet. Add tests when supported
+    dtypes = ["float16", "float32", "float64"]
+    dtypes = ["float16"]
 
 Review comment:
   which of the above 2 is correct?

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