pub struct ChunkedOptimizer<O, A>{ /* private fields */ }Expand description
Chunked optimizer for processing large parameter arrays in chunks
Enables optimization of very large models by processing parameters in manageable chunks, reducing peak memory usage.
Implementations§
Source§impl<O, A> ChunkedOptimizer<O, A>
impl<O, A> ChunkedOptimizer<O, A>
Sourcepub fn new(base_optimizer: O, chunk_size: Option<usize>) -> Self
pub fn new(base_optimizer: O, chunk_size: Option<usize>) -> Self
Creates a new chunked optimizer
§Arguments
base_optimizer- Base optimizer to use for each chunkchunk_size- Size of each chunk (default: 1M elements)
Sourcepub fn step_chunked(
&mut self,
params: &Array1<A>,
gradients: &Array1<A>,
) -> Result<Array1<A>>
pub fn step_chunked( &mut self, params: &Array1<A>, gradients: &Array1<A>, ) -> Result<Array1<A>>
Sourcepub fn chunk_size(&self) -> usize
pub fn chunk_size(&self) -> usize
Get the chunk size
Sourcepub fn num_chunks(&self, total_size: usize) -> usize
pub fn num_chunks(&self, total_size: usize) -> usize
Calculate number of chunks for given size
Auto Trait Implementations§
impl<O, A> Freeze for ChunkedOptimizer<O, A>where
O: Freeze,
impl<O, A> RefUnwindSafe for ChunkedOptimizer<O, A>where
O: RefUnwindSafe,
A: RefUnwindSafe,
impl<O, A> Send for ChunkedOptimizer<O, A>
impl<O, A> Sync for ChunkedOptimizer<O, A>
impl<O, A> Unpin for ChunkedOptimizer<O, A>
impl<O, A> UnwindSafe for ChunkedOptimizer<O, A>where
O: UnwindSafe,
A: UnwindSafe,
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.