haojin2 commented on a change in pull request #11587: [MXNET-378] Adding
depth_to_space and space_to_depth operator(Updated)
URL: https://github.com/apache/incubator-mxnet/pull/11587#discussion_r200794066
##########
File path: tests/python/unittest/test_operator.py
##########
@@ -6967,6 +6967,42 @@ def test_roi_align_autograd(sampling_ratio=0):
test_roi_align_value(2)
test_roi_align_autograd()
+@with_seed()
+def test_depthtospace():
+ def f(x, blocksize):
+ b, c, h, w = x.shape[0], x.shape[1], x.shape[2], x.shape[3]
+ tmp = np.reshape(x, [b, blocksize, blocksize, c // (blocksize**2), h,
w])
+ tmp = np.transpose(tmp, [0, 3, 4, 1, 5, 2])
+ y = np.reshape(tmp, [b, c // (blocksize**2), h * blocksize, w *
blocksize])
+ return y
+
+
+ shape = (1,4,2,3)
+ block = 2
+ data = rand_ndarray(shape, 'default')
+ data_np = data.asnumpy()
+ expected = f(data_np, block)
+ output = mx.nd.depth_to_space(data, block)
+ assert_almost_equal(output.asnumpy(), expected)
Review comment:
Please use check_numeric_gradient, check_symbolic_forward and
check_symbolic_backward helper functions to check your op, for example usage
please consult other tests within this file. For the code of these 3 functions
please see
https://github.com/apache/incubator-mxnet/blob/master/python/mxnet/test_utils.py
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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