
Last chance! 50% off unlimited learning
Sale ends in
Quantize_per_tensor
torch_quantize_per_tensor(self, scale, zero_point, dtype)
(Tensor) float tensor to quantize
(float) scale to apply in quantization formula
(int) offset in integer value that maps to float zero
(torch.dtype
) the desired data type of returned tensor. Has to be one of the quantized dtypes: torch_quint8
, torch.qint8
, torch.qint32
Converts a float tensor to quantized tensor with given scale and zero point.
# NOT RUN {
if (torch_is_installed()) {
torch_quantize_per_tensor(torch_tensor(c(-1.0, 0.0, 1.0, 2.0)), 0.1, 10, torch_quint8())
torch_quantize_per_tensor(torch_tensor(c(-1.0, 0.0, 1.0, 2.0)), 0.1, 10, torch_quint8())$int_repr()
}
# }
Run the code above in your browser using DataLab