pub struct CacheFriendlyAdam { /* private fields */ }Expand description
Cache-friendly Adam optimizer implementation.
This optimizer uses blocked processing and optimized memory layouts to minimize cache misses and improve performance.
Implementations§
Source§impl CacheFriendlyAdam
impl CacheFriendlyAdam
Sourcepub fn new(lr: f32, betas: (f32, f32), eps: f32, weight_decay: f32) -> Self
pub fn new(lr: f32, betas: (f32, f32), eps: f32, weight_decay: f32) -> Self
Creates a new cache-friendly Adam optimizer.
Sourcepub fn with_cache_config(
lr: f32,
betas: (f32, f32),
eps: f32,
weight_decay: f32,
cache_config: CacheConfig,
) -> Self
pub fn with_cache_config( lr: f32, betas: (f32, f32), eps: f32, weight_decay: f32, cache_config: CacheConfig, ) -> Self
Creates a cache-friendly Adam optimizer with custom cache configuration.
Sourcepub fn cache_stats(&self) -> CacheStats
pub fn cache_stats(&self) -> CacheStats
Gets cache utilization statistics.
Sourcepub fn cleanup_unused_params(&mut self, steps_threshold: usize)
pub fn cleanup_unused_params(&mut self, steps_threshold: usize)
Performs garbage collection on unused parameters.
Trait Implementations§
Source§impl Debug for CacheFriendlyAdam
impl Debug for CacheFriendlyAdam
Source§impl Optimizer for CacheFriendlyAdam
impl Optimizer for CacheFriendlyAdam
Source§fn update(&mut self, parameter: &mut Tensor, grad: &Tensor) -> Result<()>
fn update(&mut self, parameter: &mut Tensor, grad: &Tensor) -> Result<()>
Updates a parameter based on its gradient. Read more
Source§fn accumulate_grad(
&mut self,
parameter: &mut Tensor,
grad: &Tensor,
) -> Result<(), TrustformersError>
fn accumulate_grad( &mut self, parameter: &mut Tensor, grad: &Tensor, ) -> Result<(), TrustformersError>
Accumulates gradients for gradient accumulation. Read more
Source§fn apply_accumulated_grads(
&mut self,
accumulation_steps: usize,
) -> Result<(), TrustformersError>
fn apply_accumulated_grads( &mut self, accumulation_steps: usize, ) -> Result<(), TrustformersError>
Applies accumulated gradients after gradient accumulation. Read more
Auto Trait Implementations§
impl Freeze for CacheFriendlyAdam
impl RefUnwindSafe for CacheFriendlyAdam
impl Send for CacheFriendlyAdam
impl Sync for CacheFriendlyAdam
impl Unpin for CacheFriendlyAdam
impl UnwindSafe for CacheFriendlyAdam
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