ttnn.dequantize

ttnn.dequantize(input_tensor: ttnn.Tensor, scale: ttnn.Tensor or Number, zero_point: ttnn.Tensor or Number, *, axis: int = None, dtype: ttnn.DataType = None, memory_config: ttnn.MemoryConfig = None, output_tensor: ttnn.Tensor = None) → ttnn.Tensor

Converts a quantized integer tensor back to floating point: t = (input_tensor - zero_point) * scale, per tensor by default or per channel along axis.

Parameters:
  • input_tensor (ttnn.Tensor)the input tensor.

  • scale (ttnn.Tensor or Number)the quantization scale.

  • zero_point (ttnn.Tensor or Number)the quantization zero point.

Keyword Arguments:
  • axis (int, optional)the axis of the quantization dimension of the input tensor. Defaults to None.

  • dtype (ttnn.DataType, optional)data type for the output tensor. Defaults to None.

  • memory_config (ttnn.MemoryConfig, optional)memory configuration for the operation. Defaults to None.

  • output_tensor (ttnn.Tensor, optional)preallocated output tensor. Defaults to None.

Returns:

ttnn.Tensorthe output tensor.

Note

Supported dtypes and layouts:

Dtypes

Layouts

INT32

TILE

bfloat8_b/bfloat4_b supports only on TILE_LAYOUT

Input tensor dtype must be INT32. When scale and zero_point are tensors, they must be FLOAT32.

Example

# Create a quantized tensor to dequantize
input_tensor = ttnn.from_torch(
    torch.tensor([[-127, -42], [43, 127]], dtype=torch.int32),
    dtype=ttnn.int32,
    layout=ttnn.TILE_LAYOUT,
    device=device,
)

# Dequantize back to float, [-127, 127] -> approximately [0.1, 0.4]
scale = 0.001173
zero_point = -213
output = ttnn.dequantize(input_tensor, scale, zero_point)
logger.info(f"Dequantize result: {output}")