pub trait Quantize<Q>: Send + Sync {
// Required method
fn quantize(&self, tensor: &Tensor, device: &Device) -> Result<Q>;
}Expand description
Tensor quantization trait.
Converts full-precision tensors to quantized representation. Implementations may use various quantization schemes (NF4, FP4, ternary, etc.).
§Type Parameters
Q: The quantized tensor type (e.g.,QuantizedTensor,TernaryVector)
§Example
ⓘ
use rust_ai_core::Quantize;
struct Nf4Quantizer;
impl Quantize<Nf4Tensor> for Nf4Quantizer {
fn quantize(&self, tensor: &Tensor, device: &Device) -> Result<Nf4Tensor> {
// Quantize to NF4 format
}
}