pub trait OptimizerState: Sized {
type UnflattenError: Error + Into<IoError>;
// Required methods
fn state_projection(
&mut self,
) -> Result<StateProjection<'_>, StateProjectionError>;
fn unflatten<I, K>(input: I) -> Result<Self, Self::UnflattenError>
where I: IntoIterator<Item = (K, Array)>,
K: Ord + AsRef<str> + Into<Rc<str>>;
// Provided methods
fn flatten(
&mut self,
) -> Result<Vec<(Rc<str>, &Array)>, StateProjectionError> { ... }
fn flatten_mut(
&mut self,
) -> Result<Vec<(Rc<str>, &mut Array)>, StateProjectionError> { ... }
fn save_safetensors(
&mut self,
path: impl AsRef<Path>,
) -> Result<(), IoError> { ... }
fn load_safetensors(
&mut self,
path: impl AsRef<Path>,
) -> Result<(), IoError> { ... }
}Expand description
Trait for optimizer states.
Required Associated Types§
Sourcetype UnflattenError: Error + Into<IoError>
type UnflattenError: Error + Into<IoError>
Error type for unflatten.
Required Methods§
Sourcefn state_projection(
&mut self,
) -> Result<StateProjection<'_>, StateProjectionError>
fn state_projection( &mut self, ) -> Result<StateProjection<'_>, StateProjectionError>
Declare all required and optional optimizer-state slots.
Provided Methods§
Sourcefn flatten(&mut self) -> Result<Vec<(Rc<str>, &Array)>, StateProjectionError>
fn flatten(&mut self) -> Result<Vec<(Rc<str>, &Array)>, StateProjectionError>
Flatten present state entries in stable key order.
Sourcefn flatten_mut(
&mut self,
) -> Result<Vec<(Rc<str>, &mut Array)>, StateProjectionError>
fn flatten_mut( &mut self, ) -> Result<Vec<(Rc<str>, &mut Array)>, StateProjectionError>
Flatten mutable present state entries in stable key order.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".