DequantizeLinear#

  • Domain: ai.onnx

  • Since version: 28

The linear dequantization operator. It consumes a quantized tensor, a scale, and a zero point to compute the full-precision tensor. The dequantization formula is y = (x - x_zero_point) * x_scale. x_scale and x_zero_point must have the same shape, determining the quantization’s granularity: a scalar for per-tensor/per-layer quantization, a 1-D tensor for per-axis quantization, or have a rank identical to the input for blocked quantization. See QuantizeLinear for details on quantization granularity.

x_zero_point and x must have the same type. x and y must have the same shape. In the case of dequantizing int32, there’s no zero point (zero point is supposed to be 0). zero-point is usually not used in the case of float8 and 4-bit types quantization, but the dequantization formula remains the same for consistency. The output type is determined by the attribute output_dtype. If output_dtype is not supplied then the output type is the same as x_scale. The output type also determines the precision of the multiplication operation.

Inputs

  • x (T1): N-D quantized input tensor to be de-quantized.

  • x_scale (T2): Scale for input x. For per-tensor/layer dequantization the scale is a scalar, for per per-axis dequantization it is a 1-D Tensor and for blocked dequantization it has the same shape as the input, except for one dimension in which blocking is performed.

  • x_zero_point (T1): Zero point for input x. Shape must match x_scale. It’s optional. Zero point is 0 when it’s not specified.

Outputs

  • y (T3): N-D full precision output tensor. It has the same shape as input x. The data type is specified by the output_dtype attribute or, in its absence, the type of x_scale.

Type Constraints

  • T1: The type of the inputs ‘x_zero_point’ and ‘x’. Allowed types: tensor(float4e2m1), tensor(float6e2m3), tensor(float6e3m2), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(int16), tensor(int2), tensor(int32), tensor(int4), tensor(int8), tensor(uint16), tensor(uint2), tensor(uint4), tensor(uint8).

  • T2: The type of the input ‘x_scale’. Allowed types: tensor(bfloat16), tensor(float), tensor(float16), tensor(float8e8m0).

  • T3: The type of the output ‘y’. Allowed types: tensor(bfloat16), tensor(float), tensor(float16).

Examples#

test_dequantizelinear_float6e2m3

Node:
  DequantizeLinear(x, x_scale) -> (y)
  Attributes:
    output_dtype = 1
Inputs:
  x: shape=(6,), dtype=float6_e2m3fn
    [0, -0, 0.125, 1, 7.5, 7.5]
  x_scale: shape=(), dtype=float32
    1.

Outputs:
  y: shape=(6,), dtype=float32
    [ 0.   , -0.   ,  0.125,  1.   ,  7.5  ,  7.5  ]

test_dequantizelinear_float6e3m2

Node:
  DequantizeLinear(x, x_scale) -> (y)
  Attributes:
    output_dtype = 1
Inputs:
  x: shape=(6,), dtype=float6_e3m2fn
    [0, -0, 0.125, 1, 8, 28]
  x_scale: shape=(), dtype=float32
    1.

Outputs:
  y: shape=(6,), dtype=float32
    [ 0.   , -0.   ,  0.125,  1.   ,  8.   , 28.   ]

Differences with previous version (25)#

SchemaDiff: DequantizeLinear (domain 'ai.onnx')

  • old version: 25

  • new version: 28

  • breaking: no

Type constraints:

  • changed ‘T1’: added types: [‘tensor(float6e2m3)’, ‘tensor(float6e3m2)’]

Version History#