PyTorch torch.dequantize function
PyTorch torch reference manual
torch.dequantize is a PyTorch function for dequantizing a quantized tensor into a floating-point tensor.
Function definition
torch.dequantize(input)
Usage examples
Example
import
torch
Create an input tensor
input
=
torch.
tensor
(
[
[
1.0
,
0.0
]
,
[
1.0
,
2.0
]
]
)
Quantize the tensor
quantized
=
torch.
quantize_per_tensor
(
input
,
scale
=
0.1
,
zero_point
=
10
,
dtype
=
torch.
quint8
)
(
"Quantized tensor:"
)
(
quantized
)
Dequantize
x
=
torch.
dequantize
(
quantized
)
(
"Dequantized floating-point tensor:"
)
(
x
)