pub struct CheckpointSegment {
pub name: String,
pub weights: Vec<f32>,
pub in_dim: usize,
pub out_dim: usize,
}Expand description
A recomputable segment: stores weights and dimensions so the forward
pass (matrix-vector product y = W * x) can be re-executed cheaply.
Unlike the generic LinearSegment + Recomputable approach, this is
a self-contained struct that carries everything needed for recomputation.
Fields§
§name: StringHuman-readable name for this segment (e.g. "layer_3").
weights: Vec<f32>Row-major weight matrix of shape [out_dim, in_dim].
in_dim: usizeInput dimension.
out_dim: usizeOutput dimension.
Implementations§
Source§impl CheckpointSegment
impl CheckpointSegment
Sourcepub fn new(
name: impl Into<String>,
weights: Vec<f32>,
in_dim: usize,
out_dim: usize,
) -> Self
pub fn new( name: impl Into<String>, weights: Vec<f32>, in_dim: usize, out_dim: usize, ) -> Self
Create a segment with explicitly provided weights.
Sourcepub fn init_lcg(
name: impl Into<String>,
in_dim: usize,
out_dim: usize,
seed: u64,
) -> Self
pub fn init_lcg( name: impl Into<String>, in_dim: usize, out_dim: usize, seed: u64, ) -> Self
Create a segment with LCG-initialised weights (no rand crate).
Uses the Knuth MMIX LCG constants. Weights are mapped to [-1, 1].
Sourcepub fn forward(&self, input: &[f32]) -> Result<Vec<f32>, CheckpointError>
pub fn forward(&self, input: &[f32]) -> Result<Vec<f32>, CheckpointError>
Forward pass: compute y = W * x (matrix-vector product).
input must have exactly in_dim elements.
Returns a vector of out_dim elements.
Sourcepub fn activation_memory(&self) -> usize
pub fn activation_memory(&self) -> usize
Memory (in bytes) required to store one full activation (output).
Auto Trait Implementations§
impl Freeze for CheckpointSegment
impl RefUnwindSafe for CheckpointSegment
impl Send for CheckpointSegment
impl Sync for CheckpointSegment
impl Unpin for CheckpointSegment
impl UnsafeUnpin for CheckpointSegment
impl UnwindSafe for CheckpointSegment
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
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>
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>
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