PyTorch torch.dequantize Function


Pytorch torch 参考手册PyTorch torch Reference Manual

torch.dequantizeIt is a function in PyTorch used to dequantize a quantized tensor into a floating-point tensor.

Function Definition

torch.dequantize(input)

Usage Example

Example

import torch

# Create the input tensor
input = torch.tensor([[-1.0, 0.0], [1.0, 2.0]])

# Quantized tensor
quantized = torch.quantize_per_tensor(input, scale=0.1, zero_point=10, dtype=torch.quint8)

print("Quantized tensor:")
print(quantized)

# Dequantize
x = torch.dequantize(quantized)

print("Dequantized floating-point tensor:")
print(x)

Pytorch torch 参考手册PyTorch torch Reference Manual

Other Extensions