pub struct TensorCheckpointer { /* private fields */ }Expand description
Manages a bounded, rolling window of tensor computation checkpoints with rollback support.
Implementations§
Source§impl TensorCheckpointer
impl TensorCheckpointer
Sourcepub fn new(config: CheckpointConfig) -> Self
pub fn new(config: CheckpointConfig) -> Self
Create a new checkpointer with the given configuration.
Sourcepub fn create_checkpoint(
&mut self,
label: &str,
tensor_data: Vec<Vec<f64>>,
metadata: HashMap<String, String>,
) -> u64
pub fn create_checkpoint( &mut self, label: &str, tensor_data: Vec<Vec<f64>>, metadata: HashMap<String, String>, ) -> u64
Create a checkpoint with the given label, tensor data, and metadata.
If the number of stored checkpoints exceeds max_checkpoints, the
oldest checkpoint is evicted (FIFO).
Returns the unique id of the newly created checkpoint.
Sourcepub fn rollback(&mut self, checkpoint_id: u64) -> Result<Checkpoint, String>
pub fn rollback(&mut self, checkpoint_id: u64) -> Result<Checkpoint, String>
Roll back to the checkpoint with the given checkpoint_id.
Returns the checkpoint data and removes all checkpoints that were created after the target checkpoint. The target checkpoint itself is also consumed (removed) so callers can restore from the returned data.
Increments rollbacks_performed.
Sourcepub fn latest_checkpoint(&self) -> Option<&Checkpoint>
pub fn latest_checkpoint(&self) -> Option<&Checkpoint>
Return a reference to the most recent checkpoint, if any.
Sourcepub fn get_checkpoint(&self, id: u64) -> Option<&Checkpoint>
pub fn get_checkpoint(&self, id: u64) -> Option<&Checkpoint>
Look up a checkpoint by its id.
Sourcepub fn checkpoint_count(&self) -> usize
pub fn checkpoint_count(&self) -> usize
Number of checkpoints currently stored.
Sourcepub fn should_auto_checkpoint(&self) -> bool
pub fn should_auto_checkpoint(&self) -> bool
Returns true if the number of ticks since the last checkpoint is
greater than or equal to auto_checkpoint_interval.
Sourcepub fn list_checkpoints(&self) -> Vec<(u64, String, u64)>
pub fn list_checkpoints(&self) -> Vec<(u64, String, u64)>
List all checkpoints as (id, label, tick) triples, ordered oldest to
newest.
Sourcepub fn stats(&self) -> CheckpointerStats
pub fn stats(&self) -> CheckpointerStats
Compute aggregate statistics.
Auto Trait Implementations§
impl Freeze for TensorCheckpointer
impl RefUnwindSafe for TensorCheckpointer
impl Send for TensorCheckpointer
impl Sync for TensorCheckpointer
impl Unpin for TensorCheckpointer
impl UnsafeUnpin for TensorCheckpointer
impl UnwindSafe for TensorCheckpointer
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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