pub struct GradientCheckpointManager<T: GpuDataType> { /* private fields */ }Expand description
Gradient checkpoint manager (GPU feature required)
Implementations§
Source§impl<T: GpuDataType> GradientCheckpointManager<T>
impl<T: GpuDataType> GradientCheckpointManager<T>
Sourcepub fn new(
gpu_context: Arc<GpuContext>,
memory_budget: u64,
policy: RecomputationPolicy,
) -> Self
pub fn new( gpu_context: Arc<GpuContext>, memory_budget: u64, policy: RecomputationPolicy, ) -> Self
Create a new gradient checkpoint manager
Sourcepub fn checkpoint_activation(
&self,
layer_id: usize,
activation: &GpuBuffer<T>,
recomputation_cost: u32,
) -> Result<()>
pub fn checkpoint_activation( &self, layer_id: usize, activation: &GpuBuffer<T>, recomputation_cost: u32, ) -> Result<()>
Save an activation checkpoint
Sourcepub fn get_checkpoint(&self, layer_id: usize) -> Result<Option<GpuBuffer<T>>>
pub fn get_checkpoint(&self, layer_id: usize) -> Result<Option<GpuBuffer<T>>>
Retrieve a checkpointed activation (removes it from the checkpoint manager)
Sourcepub fn has_checkpoint(&self, layer_id: usize) -> bool
pub fn has_checkpoint(&self, layer_id: usize) -> bool
Check if a layer has a checkpoint
Sourcepub fn remove_checkpoint(&self, layer_id: usize) -> Result<()>
pub fn remove_checkpoint(&self, layer_id: usize) -> Result<()>
Remove a checkpoint and free its memory
Sourcepub fn memory_usage(&self) -> u64
pub fn memory_usage(&self) -> u64
Get current memory usage in bytes
Sourcepub fn memory_budget(&self) -> u64
pub fn memory_budget(&self) -> u64
Get memory budget in bytes
Sourcepub fn num_checkpoints(&self) -> usize
pub fn num_checkpoints(&self) -> usize
Get number of active checkpoints
Sourcepub fn get_statistics(&self) -> CheckpointStatistics
pub fn get_statistics(&self) -> CheckpointStatistics
Get checkpoint statistics
Auto Trait Implementations§
impl<T> Freeze for GradientCheckpointManager<T>
impl<T> !RefUnwindSafe for GradientCheckpointManager<T>
impl<T> Send for GradientCheckpointManager<T>
impl<T> Sync for GradientCheckpointManager<T>
impl<T> Unpin for GradientCheckpointManager<T>
impl<T> UnsafeUnpin for GradientCheckpointManager<T>
impl<T> !UnwindSafe for GradientCheckpointManager<T>
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.