pub fn quantize_weights(
weight: &Tensor,
config: &BitNetConfig,
) -> Result<TernaryWeight>Expand description
Quantize a weight tensor to ternary using AbsMean quantization.
§Algorithm
For each group of weights:
- Compute
scale = mean(|W|) - Compute
W_q = round(W / scale)clamped to {-1, 0, +1}
§Arguments
weight- Input weight tensor [out_features, in_features]config- BitNet configuration
§Errors
Returns error if weight has wrong shape or quantization fails.