[ https://issues.apache.org/jira/browse/MXNET-1397?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
shoubhik bhattacharya updated MXNET-1397: ----------------------------------------- Description: Reproducible code {code:java} from mxnet.ndarray.contrib import quantize, requantize, dequantize from mxnet import nd import numpy as np import mxnet as mx {code} {code:java} # requantize and dequantize work with ndarry data = nd.array(np.random.uniform(size=(5,5))) min_ = data_.min() max_ = data_.max() a,b,c = quantize(data_, min_, max_) requantize(a.astype('int32'),b,c) #output [ [[ 94 120 32 92 73] [ 32 105 110 112 100] [ 13 72 57 111 127] [ 20 2 118 37 119] [ 40 70 26 77 56]] <NDArray 5x5 @cpu(0)>, [-1.1555843e-07] <NDArray 1 @cpu(0)>, [1.1555843e-07] <NDArray 1 @cpu(0)>] {code} {code:java} # requantize and dequantize do not work with symbolic api data__ = nd.array(np.random.uniform(size=(5,5))) min__ = data__.min() max__ = data__.max() data_ = mx.sym.Variable('data_') min_ = mx.sym.Variable('min_') max_ = mx.sym.Variable('max_') quant, q_min, q_max = mx.sym.contrib.quantize(data_, min_, max_) requant, requant_min, requant_max = mx.sym.contrib.requantize(quant.astype('int32'), q_min, q_max, min_calib_range=None,max_calib_range=None) dequant = mx.sym.contrib.dequantize(requant, requant_min, requant_max) ex = dequant.bind(ctx=mx.cpu(), args={'data_':data__, 'min_':min__, 'max_':max__}) out = ex.forward() ex.outputs[0].asnumpy() #output --------------------------------------------------------------------------- MXNetError Traceback (most recent call last) <ipython-input-38-01aee958ded9> in <module> 8 9 quant, q_min, q_max = mx.sym.contrib.quantize(data_, min_, max_) ---> 10 requant = mx.sym.contrib.requantize(quant.astype('int32'), q_min, q_max) 11 12 ~/anaconda/anaconda3/envs/mxnet_1_4_p36/lib/python3.6/site-packages/mxnet/symbol/register.py in requantize(data, min_range, max_range, min_calib_range, max_calib_range, name, attr, out, **kwargs) ~/anaconda/anaconda3/envs/mxnet_1_4_p36/lib/python3.6/site-packages/mxnet/_ctypes/symbol.py in _symbol_creator(handle, args, kwargs, keys, vals, name) 133 s._compose(*args, name=name) 134 elif kwargs: --> 135 s._compose(name=name, **kwargs) 136 else: 137 s._compose(name=name) ~/anaconda/anaconda3/envs/mxnet_1_4_p36/lib/python3.6/site-packages/mxnet/symbol/symbol.py in _compose(self, *args, **kwargs) 480 args = c_handle_array(args) 481 check_call(_LIB.MXSymbolCompose( --> 482 self.handle, name, num_args, keys, args)) 483 484 def __getitem__(self, index): ~/anaconda/anaconda3/envs/mxnet_1_4_p36/lib/python3.6/site-packages/mxnet/base.py in check_call(ret) 250 """ 251 if ret != 0: --> 252 raise MXNetError(py_str(_LIB.MXGetLastError())) 253 254 MXNetError: [10:38:07] src/core/symbolic.cc:351: Not enough argument to call operator _contrib_requantize{code} was: Reproducable code {code:java} from mxnet.ndarray.contrib import quantize, requantize, dequantize from mxnet import nd import numpy as np import mxnet as mx {code} {code:java} # requantize and dequantize work with ndarry data = nd.array(np.random.uniform(size=(5,5))) min_ = data_.min() max_ = data_.max() a,b,c = quantize(data_, min_, max_) requantize(a.astype('int32'),b,c) #output [ [[ 94 120 32 92 73] [ 32 105 110 112 100] [ 13 72 57 111 127] [ 20 2 118 37 119] [ 40 70 26 77 56]] <NDArray 5x5 @cpu(0)>, [-1.1555843e-07] <NDArray 1 @cpu(0)>, [1.1555843e-07] <NDArray 1 @cpu(0)>] {code} {code:java} # requantize and dequantize do not work with symbolic api data__ = nd.array(np.random.uniform(size=(5,5))) min__ = data__.min() max__ = data__.max() data_ = mx.sym.Variable('data_') min_ = mx.sym.Variable('min_') max_ = mx.sym.Variable('max_') quant, q_min, q_max = mx.sym.contrib.quantize(data_, min_, max_) requant, requant_min, requant_max = mx.sym.contrib.requantize(quant.astype('int32'), q_min, q_max, min_calib_range=None,max_calib_range=None) dequant = mx.sym.contrib.dequantize(requant, requant_min, requant_max) ex = dequant.bind(ctx=mx.cpu(), args={'data_':data__, 'min_':min__, 'max_':max__}) out = ex.forward() ex.outputs[0].asnumpy() #output --------------------------------------------------------------------------- MXNetError Traceback (most recent call last) <ipython-input-38-01aee958ded9> in <module> 8 9 quant, q_min, q_max = mx.sym.contrib.quantize(data_, min_, max_) ---> 10 requant = mx.sym.contrib.requantize(quant.astype('int32'), q_min, q_max) 11 12 ~/anaconda/anaconda3/envs/mxnet_1_4_p36/lib/python3.6/site-packages/mxnet/symbol/register.py in requantize(data, min_range, max_range, min_calib_range, max_calib_range, name, attr, out, **kwargs) ~/anaconda/anaconda3/envs/mxnet_1_4_p36/lib/python3.6/site-packages/mxnet/_ctypes/symbol.py in _symbol_creator(handle, args, kwargs, keys, vals, name) 133 s._compose(*args, name=name) 134 elif kwargs: --> 135 s._compose(name=name, **kwargs) 136 else: 137 s._compose(name=name) ~/anaconda/anaconda3/envs/mxnet_1_4_p36/lib/python3.6/site-packages/mxnet/symbol/symbol.py in _compose(self, *args, **kwargs) 480 args = c_handle_array(args) 481 check_call(_LIB.MXSymbolCompose( --> 482 self.handle, name, num_args, keys, args)) 483 484 def __getitem__(self, index): ~/anaconda/anaconda3/envs/mxnet_1_4_p36/lib/python3.6/site-packages/mxnet/base.py in check_call(ret) 250 """ 251 if ret != 0: --> 252 raise MXNetError(py_str(_LIB.MXGetLastError())) 253 254 MXNetError: [10:38:07] src/core/symbolic.cc:351: Not enough argument to call operator _contrib_requantize{code} > mxnet.ndarray.contrib requantize and dequantize not working with symbolic api > ----------------------------------------------------------------------------- > > Key: MXNET-1397 > URL: https://issues.apache.org/jira/browse/MXNET-1397 > Project: Apache MXNet > Issue Type: Bug > Components: Apache MXNet C/C++ API > Reporter: shoubhik bhattacharya > Assignee: Amol Lele > Priority: Major > > Reproducible code > > {code:java} > from mxnet.ndarray.contrib import quantize, requantize, dequantize > from mxnet import nd > import numpy as np > import mxnet as mx > {code} > {code:java} > # requantize and dequantize work with ndarry > data = nd.array(np.random.uniform(size=(5,5))) min_ = data_.min() max_ = > data_.max() > a,b,c = quantize(data_, min_, max_) > requantize(a.astype('int32'),b,c) > #output > [ [[ 94 120 32 92 73] [ 32 105 110 112 100] [ 13 72 57 111 127] [ 20 2 118 37 > 119] [ 40 70 26 77 56]] <NDArray 5x5 @cpu(0)>, [-1.1555843e-07] <NDArray 1 > @cpu(0)>, [1.1555843e-07] <NDArray 1 @cpu(0)>] > {code} > {code:java} > # requantize and dequantize do not work with symbolic api > data__ = nd.array(np.random.uniform(size=(5,5))) > min__ = data__.min() > max__ = data__.max() > data_ = mx.sym.Variable('data_') > min_ = mx.sym.Variable('min_') > max_ = mx.sym.Variable('max_') > quant, q_min, q_max = mx.sym.contrib.quantize(data_, min_, max_) > requant, requant_min, requant_max = > mx.sym.contrib.requantize(quant.astype('int32'), q_min, q_max, > min_calib_range=None,max_calib_range=None) > dequant = mx.sym.contrib.dequantize(requant, requant_min, requant_max) > ex = dequant.bind(ctx=mx.cpu(), args={'data_':data__, 'min_':min__, > 'max_':max__}) > out = ex.forward() > ex.outputs[0].asnumpy() > #output > --------------------------------------------------------------------------- > MXNetError Traceback (most recent call last) > <ipython-input-38-01aee958ded9> in <module> > 8 > 9 quant, q_min, q_max = mx.sym.contrib.quantize(data_, min_, max_) > ---> 10 requant = mx.sym.contrib.requantize(quant.astype('int32'), q_min, > q_max) > 11 > 12 > ~/anaconda/anaconda3/envs/mxnet_1_4_p36/lib/python3.6/site-packages/mxnet/symbol/register.py > in requantize(data, min_range, max_range, min_calib_range, max_calib_range, > name, attr, out, **kwargs) > ~/anaconda/anaconda3/envs/mxnet_1_4_p36/lib/python3.6/site-packages/mxnet/_ctypes/symbol.py > in _symbol_creator(handle, args, kwargs, keys, vals, name) > 133 s._compose(*args, name=name) > 134 elif kwargs: > --> 135 s._compose(name=name, **kwargs) > 136 else: > 137 s._compose(name=name) > ~/anaconda/anaconda3/envs/mxnet_1_4_p36/lib/python3.6/site-packages/mxnet/symbol/symbol.py > in _compose(self, *args, **kwargs) > 480 args = c_handle_array(args) > 481 check_call(_LIB.MXSymbolCompose( > --> 482 self.handle, name, num_args, keys, args)) > 483 > 484 def __getitem__(self, index): > ~/anaconda/anaconda3/envs/mxnet_1_4_p36/lib/python3.6/site-packages/mxnet/base.py > in check_call(ret) > 250 """ > 251 if ret != 0: > --> 252 raise MXNetError(py_str(_LIB.MXGetLastError())) > 253 > 254 > MXNetError: [10:38:07] src/core/symbolic.cc:351: Not enough argument to call > operator _contrib_requantize{code} > > > -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@mxnet.apache.org For additional commands, e-mail: issues-h...@mxnet.apache.org