Expand description
TensorQuantizer — Multi-precision tensor quantization for model compression.
Provides production-grade quantization for INT8 (symmetric and asymmetric), INT4, FP16, and BF16, with per-channel support, calibration-percentile outlier suppression, and comprehensive MSE error measurement.
§Examples
use ipfrs_tensorlogic::tensor_quantizer::{
TensorQuantizer, QuantizationMode, QuantizerConfig,
};
let config = QuantizerConfig {
mode: QuantizationMode::Int8Symmetric,
per_channel: false,
channel_dim: 0,
calibration_percentile: 99.9,
};
let quantizer = TensorQuantizer::new(config);
let values = vec![0.5_f64, -0.3, 0.8, -0.1, 1.0, -1.0];
let dims = vec![6];
let qt = quantizer.quantize(&values, &dims).expect("example: should succeed in docs");
let dq = quantizer.dequantize(&qt).expect("example: should succeed in docs");
assert_eq!(dq.values.len(), 6);Structs§
- Dequantized
Tensor - The result of dequantization — approximate reconstruction of the original values.
- Quantized
Tensor - A quantized representation of a tensor.
- Quantizer
Config - Configuration for
TensorQuantizer. - Quantizer
Stats - Accumulated statistics across multiple
TensorQuantizer::quantizecalls. - Tensor
Quantizer - Multi-precision tensor quantizer.
Enums§
- Quantization
Mode - Precision target for quantization.
- Quantizer
Error - Errors produced by
TensorQuantizer.
Functions§
- percentile
- Compute the
p-th percentile ofvaluesusing the nearest-rank method.