RafLit commented on a change in pull request #20835:
URL: https://github.com/apache/incubator-mxnet/pull/20835#discussion_r795432242
##########
File path: tests/python/quantization/test_quantization.py
##########
@@ -945,6 +945,46 @@ def check_quantized_bn(data_shape, qdtype):
check_quantized_bn((32, 3, 224, 224), qdtype)
+def test_quantized_reshape():
+ test_cases = [((2, 3, 5, 5), (-2, -1), False, (2, 75)),
+ ((2, 3, 5, 5), (-2, -2, -1), False, (2, 3, 25)),
+ ((5, 3, 4, 5), (-2, -1, -2), False, (5, 15, 4)),
+ ((2, 3, 5, 4), (-1, -2, -2), False, (8, 3, 5)),
+ ((2, 3, 5, 5), (-2, -2, -2, -2), False, (2, 3, 5, 5)),
+ ((2, 1, 4, 5), (-2, -3, -2, -2), False, (2, 4, 5)),
+ ((1, 1, 4, 1), (-3, -3, -2, -2), False, (4, 1)),
+ ((1, 1, 1, 1), (-3, -3, -3, -3), False, ()),
+ ((2, 4, 5, 3), (-1, 2, 2, 1), False, (30, 2, 2, 1)),
+ ((2, 3, 5, 6), (-4,), False, (2, 3, 5, 6)),
+ ((2, 3, 5, 6), (6, 1, -4), False, (6, 1, 5, 6)),
+ ((2, 3, 5, 6), (-5, -5), False, (6, 30)),
+ ((2, 3, 5, 6), (-5, -1), False, (6, 30)),
+ ((64,), (-6, 16, 4), False, (16, 4)),
+ ((64,), (-6, 16, -1), False, (16, 4)),
+ ((64, 1, 2, 3), (-6, 16, -1, -4), False, (16, 4, 1, 2, 3)),
+ ((8, 5, 4, 6), (-4, -1, 3, -6), True, (8, 5, 4, 2, 3))]
+
+ def check_quantized_reshape(shape, qdtype, newshape, reverse,
expected_ret_shape):
+ if qdtype == 'uint8':
+ data_low = 0.0
+ data_high = 127.0
+ else:
+ data_low = -127.0
+ data_high = 127.0
+ qdata = mx.np.random.uniform(low=data_low, high=data_high,
size=shape).astype(qdtype)
+ min_data = mx.np.array([-1023.343], dtype='float32')
+ max_data = mx.np.array([2343.324275], dtype='float32')
+ qoutput, min_output, max_output = npx.quantized_reshape(qdata,
min_data, max_data, newshape=newshape, reverse=reverse)
+ assert qoutput.shape == expected_ret_shape
+ assert same(qdata.asnumpy().flatten(), qoutput.asnumpy().flatten())
Review comment:
is flatten necessary here?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]