Skip to main content

per_channel_quantize

Function per_channel_quantize 

Source
pub fn per_channel_quantize(
    weights: &[f32],
    shape: &[usize],
    channel_axis: usize,
) -> PerChannelQuantParams
Expand description

Compute per-channel quantization parameters for a weight tensor.

For Conv2D weights in OIHW layout, quantizes along the output channel axis (axis 0). Each output channel gets its own scale/zero_point.

ยงArguments

  • weights - The flat weight tensor values.
  • shape - The shape of the weight tensor [O, I, H, W] or [O, I].
  • channel_axis - The axis along which to compute per-channel params (typically 0).