QuantizedArrary Error

I am using the below command to create a quantized array for input data. The shape of my input data is - torch.Size([1, 2048]), and input is floating point numbers.

n_bits = 6, is_signed = True
q_test_data = QuantizedArray(n_bits = n_bits, values=t_ip, is_signed=is_signed)

The error I am getting is


TypeError Traceback (most recent call last)
in <cell line: 4>()
2 pt_quant = PostTrainingAffineQuantization(n_bits = n_bits, numpy_model = numpy_fc_model, is_signed = is_signed)
3 # Quantize input
----> 4 q_mnist_test_data = QuantizedArray(n_bits = n_bits, values=t_ip, is_signed=is_signed)
5 # Calibrate layers and activations
6 quant_module = pt_quant.quantize_module(t_ip)

5 frames
/usr/local/lib/python3.9/dist-packages/numpy/core/fromnumeric.py in _wrapreduction(obj, ufunc, method, axis, dtype, out, **kwargs)
82 return reduction(axis=axis, dtype=dtype, out=out, **passkwargs)
83 else:
—> 84 return reduction(axis=axis, out=out, **passkwargs)
85
86 return ufunc.reduce(obj, axis, dtype, out, **passkwargs)

TypeError: min() received an invalid combination of arguments - got (out=NoneType, axis=NoneType, ), but expected one of:

  • ()
  • (Tensor other)
  • (int dim, bool keepdim)
    didn’t match because some of the keywords were incorrect: out, axis
  • (name dim, bool keepdim)
    didn’t match because some of the keywords were incorrect: out, axis

Can I know the issue?

Thanks in advance

QuantizedArray does not support torch input yet so that might be the reason of you error. You will have to convert the input data to numpy.

Note that quant_module = pt_quant.quantize_module(t_ip) will do the input quantization for you. Then you can just call quant_modulde.quantize_input(t_ip) to get the quantized input.

1 Like