pub struct Linear { /* private fields */ }Expand description
A row-major y = x · Wᵀ projection.
Quantized projections stay in the existing mmap-backed Proj/QTensor
path, including Q8_2f and Q4TP. Native F32/F16/BF16 projections retain an
Arc to the CMF mapping and are decoded into a single bounded scratch row.
Implementations§
Source§impl Linear
impl Linear
Sourcepub fn load(model: &Arc<CmfModel>, name: &str) -> Result<Self, String>
pub fn load(model: &Arc<CmfModel>, name: &str) -> Result<Self, String>
Load a rank-2 projection without materializing a whole F16/BF16
matrix. The CMF shape is semantic [out_features, in_features].
pub fn rows(&self) -> usize
pub fn cols(&self) -> usize
pub fn dtype(&self) -> Option<TensorDtype>
Sourcepub fn forward(
&self,
x: &[f32],
batch: usize,
out: &mut [f32],
pool: Option<&Pool>,
) -> Result<(), String>
pub fn forward( &self, x: &[f32], batch: usize, out: &mut [f32], pool: Option<&Pool>, ) -> Result<(), String>
Compute out[b, rows] = x[b, cols] · Wᵀ.
The output and activation buffers are caller-owned. Mapped dense weights are decoded in bounded row tiles and sent through the existing GEMM path, so a 3,072×3,072 BF16 projection never becomes a 36 MiB temporary. Quantized projections use the existing pooled CPU/GPU dispatch and preserve Q8_2f/Q4TP semantics.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Linear
impl RefUnwindSafe for Linear
impl Send for Linear
impl Sync for Linear
impl Unpin for Linear
impl UnsafeUnpin for Linear
impl UnwindSafe for Linear
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