Reputation: 867
What is the best way to run a qauntized model using int8 data types in Pytorch? I know in pytorch I can define tensors as int8, however, when I actually want to use int8, I get:
RuntimeError: _thnn_conv2d_forward is not implemented for type torch.CharTensor
So I am confused, how to run quantized model in pytorch that uses for instance int8 when the datatype is not supported for computational blocks such as convolutions? I am using pytorch version 1.0.1.post2.
Upvotes: 1
Views: 1588
Reputation: 1674
In recent Pytorch versions, there is native support for quantized tensor operations. That means you can do most of common operations (Conv, ReLU, Linear, etc.) on quantized tensor (currently CPU only unfortunately). See https://pytorch.org/docs/stable/quantization-support.html
Upvotes: 0
Reputation: 993
Depends what your goals are.
You may stick to existing float data type and only introduce truncation as needed, i.e.:
x = torch.floor(x * 2**8) / 2**8
assuming x is a float tensor.
Then, I am afraid PyTorch will be not very useful since the low-level convolutional operator is implemented only for float type.
Upvotes: 1