pub struct GradientCheckpointer<A: Float, D: Dimension> { /* private fields */ }Expand description
Gradient checkpointing manager
Implementations§
Source§impl<A: Float + ScalarOperand + Debug, D: Dimension + Send + Sync> GradientCheckpointer<A, D>
impl<A: Float + ScalarOperand + Debug, D: Dimension + Send + Sync> GradientCheckpointer<A, D>
Sourcepub fn new(strategy: CheckpointStrategy) -> Self
pub fn new(strategy: CheckpointStrategy) -> Self
Create a new gradient checkpointer
Sourcepub fn set_max_depth(&mut self, depth: usize)
pub fn set_max_depth(&mut self, depth: usize)
Set the maximum computation depth
Sourcepub fn set_enabled(&mut self, enabled: bool)
pub fn set_enabled(&mut self, enabled: bool)
Enable or disable checkpointing
Sourcepub fn should_checkpoint(&self, depth: usize) -> bool
pub fn should_checkpoint(&self, depth: usize) -> bool
Check if we should checkpoint at the current depth
Sourcepub fn store_checkpoint(&mut self, depth: usize, activation: Array<A, D>)
pub fn store_checkpoint(&mut self, depth: usize, activation: Array<A, D>)
Store a checkpoint
Sourcepub fn get_checkpoint(&self, depth: usize) -> Option<&Array<A, D>>
pub fn get_checkpoint(&self, depth: usize) -> Option<&Array<A, D>>
Retrieve a checkpoint
Sourcepub fn remove_checkpoint(&mut self, depth: usize) -> Option<Array<A, D>>
pub fn remove_checkpoint(&mut self, depth: usize) -> Option<Array<A, D>>
Remove a checkpoint to free memory
Sourcepub fn clear_checkpoints(&mut self)
pub fn clear_checkpoints(&mut self)
Clear all checkpoints
Sourcepub fn memory_usage(&self) -> MemoryUsage
pub fn memory_usage(&self) -> MemoryUsage
Get memory usage information
Sourcepub fn optimize_strategy(&mut self, target_memoryusage: f64)
pub fn optimize_strategy(&mut self, target_memoryusage: f64)
Optimize checkpointing strategy based on memory usage
Trait Implementations§
Auto Trait Implementations§
impl<A, D> Freeze for GradientCheckpointer<A, D>
impl<A, D> RefUnwindSafe for GradientCheckpointer<A, D>where
D: RefUnwindSafe,
A: RefUnwindSafe,
impl<A, D> Send for GradientCheckpointer<A, D>where
A: Send,
impl<A, D> Sync for GradientCheckpointer<A, D>where
A: Sync,
impl<A, D> Unpin for GradientCheckpointer<A, D>where
D: Unpin,
impl<A, D> UnwindSafe for GradientCheckpointer<A, D>where
D: UnwindSafe,
A: RefUnwindSafe,
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> 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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.