shoubhik commented on a change in pull request #14749: [Mxnet-1397] Support symbolic api for requantize and dequantize URL: https://github.com/apache/incubator-mxnet/pull/14749#discussion_r277123964
########## File path: tests/python/quantization/test_quantization.py ########## @@ -124,7 +150,40 @@ def check_requantize(shape, min_calib_range=None, max_calib_range=None): assert_almost_equal(qdata_int8.asnumpy(), qdata_int8_np, atol = 1) assert_almost_equal(min_output.asnumpy(), np.array([min_output_np])) assert_almost_equal(max_output.asnumpy(), np.array([max_output_np])) + + def check_requantize_with_symbol(shape, min_calib_range=None, max_calib_range=None): + qdata = mx.nd.random.uniform(low=-1000.0, high=1000.0, shape=shape).astype('int32') + min_range = mx.nd.array([-1010.0]) + max_range = mx.nd.array([1020.0]) + sym_data = mx.sym.Variable('data') + sym_min_range = mx.sym.Variable('min_range') + sym_max_range = mx.sym.Variable('max_range') + if min_calib_range is None or max_calib_range is None: + requant = mx.sym.contrib.requantize(sym_data, sym_min_range, sym_max_range) + out = requant.bind(ctx=mx.cpu(), args={'data':qdata, 'min_range':min_range, + 'max_range':max_range}) + qdata_int8, min_output, max_output = out.forward() + else: + requant = mx.sym.contrib.requantize(sym_data, sym_min_range, sym_max_range, + min_calib_range, max_calib_range) + out = requant.bind(ctx=mx.cpu(), args={'data':qdata, 'min_range':min_range, 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