pub struct PackedLittleBitLinear { /* private fields */ }Expand description
Memory-compact 1-bit inference representation keeping U, V packed as i32 bitfields.
Implementations§
Source§impl PackedLittleBitLinear
impl PackedLittleBitLinear
Sourcepub fn from_packed_tensors(
prefix: &str,
tensors: &HashMap<String, Tensor>,
shape: LayerShape,
config: &LittleBitConfig,
ratio_factor: f64,
) -> Result<Self>
pub fn from_packed_tensors( prefix: &str, tensors: &HashMap<String, Tensor>, shape: LayerShape, config: &LittleBitConfig, ratio_factor: f64, ) -> Result<Self>
Construct directly from packed checkpoint tensors without allocating dense float matrices.
§Errors
Returns LittleBitError::MissingTensor or shape mismatch errors if packed entries
are missing or invalid.
Sourcepub fn forward(&self, x: &Tensor) -> Result<Tensor>
pub fn forward(&self, x: &Tensor) -> Result<Tensor>
Execute direct 1-bit packed forward pass and return result on x’s device and dtype.
§Errors
Returns an error if input dimensions do not match in_features or tensor transfer fails.
Sourcepub fn pack_state_dict(
&self,
prefix: &str,
device: &Device,
) -> Result<HashMap<String, Tensor>>
pub fn pack_state_dict( &self, prefix: &str, device: &Device, ) -> Result<HashMap<String, Tensor>>
Export packed tensors for checkpoint serialization.
§Errors
Returns an error if tensor creation fails.
Sourcepub fn memory_bytes(&self) -> usize
pub fn memory_bytes(&self) -> usize
Total heap memory footprint in bytes for the 1-bit packed layer.
Trait Implementations§
Source§impl Clone for PackedLittleBitLinear
impl Clone for PackedLittleBitLinear
Auto Trait Implementations§
impl Freeze for PackedLittleBitLinear
impl RefUnwindSafe for PackedLittleBitLinear
impl Send for PackedLittleBitLinear
impl Sync for PackedLittleBitLinear
impl Unpin for PackedLittleBitLinear
impl UnsafeUnpin for PackedLittleBitLinear
impl UnwindSafe for PackedLittleBitLinear
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T, U> Imply<T> for U
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