pub struct QuantizedWeight {
pub data: Vec<u8>,
pub scales: Vec<f32>,
pub in_feat: usize,
pub out_feat: usize,
pub num_groups: usize,
}Expand description
Packed INT4 weight tensor with per-group f32 scales.
data: row-major packed nibbles [pair * out_feat + o],
total (in_padded / 2) * out_feat bytes.
scales: [num_groups * out_feat] f32, row-major [g * out_feat + o].
in_feat: original (unpadded) input dimension.
out_feat: output dimension.
Fields§
§data: Vec<u8>§scales: Vec<f32>§in_feat: usize§out_feat: usize§num_groups: usizeImplementations§
Source§impl QuantizedWeight
impl QuantizedWeight
Sourcepub fn quantize(w: &[f32], in_feat: usize, out_feat: usize) -> Self
pub fn quantize(w: &[f32], in_feat: usize, out_feat: usize) -> Self
Quantize an f32 weight matrix w of shape [in_feat, out_feat].
Matches Python _fake_quantize_int4 exactly.
Sourcepub fn dequantize_to(&self, out: &mut [f32])
pub fn dequantize_to(&self, out: &mut [f32])
Dequantize to f32 into out buffer of shape [in_feat, out_feat].
Auto Trait Implementations§
impl Freeze for QuantizedWeight
impl RefUnwindSafe for QuantizedWeight
impl Send for QuantizedWeight
impl Sync for QuantizedWeight
impl Unpin for QuantizedWeight
impl UnsafeUnpin for QuantizedWeight
impl UnwindSafe for QuantizedWeight
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more