pub struct TernaryWeight {
pub data: Vec<PackedTritVec>,
pub scales: Vec<f32>,
pub shape: (usize, usize),
pub group_size: usize,
}Expand description
Ternary weight representation with per-group scales.
Weights are quantized to {-1, 0, +1} using AbsMean quantization, with a scale factor stored per group.
Fields§
§data: Vec<PackedTritVec>Packed ternary values (bitsliced storage). Shape: [out_features, in_features] flattened.
scales: Vec<f32>Scale factors per group. For a weight matrix [out, in], scales has shape [out, in/group_size].
shape: (usize, usize)Original shape [out_features, in_features].
group_size: usizeGroup size used for quantization.
Implementations§
Source§impl TernaryWeight
impl TernaryWeight
Sourcepub const fn out_features(&self) -> usize
pub const fn out_features(&self) -> usize
Get the output features dimension.
Sourcepub const fn in_features(&self) -> usize
pub const fn in_features(&self) -> usize
Get the input features dimension.
Sourcepub fn memory_bytes(&self) -> usize
pub fn memory_bytes(&self) -> usize
Memory size in bytes.
Sourcepub fn compression_ratio(&self) -> f32
pub fn compression_ratio(&self) -> f32
Compression ratio vs FP32.
Trait Implementations§
Source§impl Clone for TernaryWeight
impl Clone for TernaryWeight
Source§fn clone(&self) -> TernaryWeight
fn clone(&self) -> TernaryWeight
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TernaryWeight
impl Debug for TernaryWeight
Source§impl<'de> Deserialize<'de> for TernaryWeight
impl<'de> Deserialize<'de> for TernaryWeight
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for TernaryWeight
impl RefUnwindSafe for TernaryWeight
impl Send for TernaryWeight
impl Sync for TernaryWeight
impl Unpin for TernaryWeight
impl UnwindSafe for TernaryWeight
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more