pub struct Checkpoint<R: Recomputable> { /* private fields */ }Expand description
A single checkpointed computation segment.
Stores the segment implementation and its saved input so that the output can
be recomputed at any time. The output itself is not stored; calling
recompute always re-runs the forward pass.
Implementations§
Source§impl<R: Recomputable> Checkpoint<R>
impl<R: Recomputable> Checkpoint<R>
Sourcepub fn new(recomputable: R, input: R::Input) -> Self
pub fn new(recomputable: R, input: R::Input) -> Self
Create a new checkpoint, saving input for later recomputation.
The recomputable segment is stored alongside the input so that
recompute can call recomputable.forward(&saved_input).
Sourcepub fn recompute(&self) -> R::Output
pub fn recompute(&self) -> R::Output
Recompute and return the output from the saved input.
This is the key operation: instead of loading a cached output tensor, we replay the forward pass from the checkpointed input.
Sourcepub fn memory_bytes(&self) -> usize
pub fn memory_bytes(&self) -> usize
Bytes consumed by the saved checkpoint (input only, not the output).
Auto Trait Implementations§
impl<R> Freeze for Checkpoint<R>
impl<R> RefUnwindSafe for Checkpoint<R>
impl<R> Send for Checkpoint<R>
impl<R> Sync for Checkpoint<R>
impl<R> Unpin for Checkpoint<R>
impl<R> UnsafeUnpin for Checkpoint<R>
impl<R> UnwindSafe for Checkpoint<R>
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> 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