Home Knowledge Base Per-tensor quantization

Per-tensor quantization uses a single set of quantization parameters (scale and zero-point) for an entire tensor, regardless of its shape or the variance across its dimensions. This is the simplest and most common quantization granularity.

How It Works

For a tensor $T$ with arbitrary shape:

$$q = ext{round}(T / s + z)$$

Where:

Scale Calculation

For 8-bit quantization:

$$s = frac{max(T) - min(T)}{255}$$

(For symmetric quantization, use $max(|T|)$ instead.)

Advantages

Disadvantages

When to Use Per-Tensor

Comparison to Per-Channel

AspectPer-TensorPer-Channel
Parameters1 scale + 1 zero-pointN scales + N zero-points (N = channels)
AccuracyLower (for heterogeneous data)Higher
SpeedFastestSlightly slower
StorageMinimalSmall overhead
Use CaseActivations, uniform dataWeights, heterogeneous data

Example

For a weight tensor with shape [64, 128, 3, 3] (64 output channels):

Per-tensor quantization is the default choice for activations and a reasonable baseline for weights, though per-channel quantization typically provides better accuracy for weights.

per-tensor quantizationmodel optimization

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.