mlx_rs::optimizers

Type Alias State

Source
pub type State<T = Array> = HashMap<Rc<str>, T>;
Expand description

Type alias for common optimizer state.

Aliased Type§

struct State<T = Array> { /* private fields */ }

Trait Implementations§

Source§

impl OptimizerState for State<(Array, Array)>

Source§

type UnflattenError = UnflattenError

Error type for unflatten.
Source§

fn flatten(&self) -> impl Iterator<Item = (Rc<str>, &Array)>

Flatten the optimizer state.
Source§

fn flatten_mut(&mut self) -> impl Iterator<Item = (Rc<str>, &mut Array)>

Flatten the mutable optimizer state.
Source§

fn unflatten<I, K>(input: I) -> Result<Self, Self::UnflattenError>
where Self: Sized, I: IntoIterator<Item = (K, Array)>, K: Ord + AsRef<str> + Into<Rc<str>>,

Unflatten an iterator of key-value pairs into the optimizer state.
Source§

fn save_safetensors(&self, path: impl AsRef<Path>) -> Result<(), IoError>

Save the optimizer state to a safetensors file.
Source§

fn load_safetensors(&mut self, path: impl AsRef<Path>) -> Result<(), IoError>

Load the optimizer state from a safetensors file.
Source§

impl OptimizerState for State<AdafactorState>

Source§

type UnflattenError = UnflattenError

Error type for unflatten.
Source§

fn flatten(&self) -> impl Iterator<Item = (Rc<str>, &Array)>

Flatten the optimizer state.
Source§

fn flatten_mut(&mut self) -> impl Iterator<Item = (Rc<str>, &mut Array)>

Flatten the mutable optimizer state.
Source§

fn unflatten<I, K>(input: I) -> Result<Self, Self::UnflattenError>
where Self: Sized, I: IntoIterator<Item = (K, Array)>, K: Ord + AsRef<str> + Into<Rc<str>>,

Unflatten an iterator of key-value pairs into the optimizer state.
Source§

fn save_safetensors(&self, path: impl AsRef<Path>) -> Result<(), IoError>

Save the optimizer state to a safetensors file.
Source§

fn load_safetensors(&mut self, path: impl AsRef<Path>) -> Result<(), IoError>

Load the optimizer state from a safetensors file.
Source§

impl OptimizerState for State

Source§

type UnflattenError = Infallible

Error type for unflatten.
Source§

fn flatten(&self) -> impl Iterator<Item = (Rc<str>, &Array)>

Flatten the optimizer state.
Source§

fn flatten_mut(&mut self) -> impl Iterator<Item = (Rc<str>, &mut Array)>

Flatten the mutable optimizer state.
Source§

fn unflatten<I, K>(input: I) -> Result<Self, Self::UnflattenError>
where Self: Sized, I: IntoIterator<Item = (K, Array)>, K: Ord + AsRef<str> + Into<Rc<str>>,

Unflatten an iterator of key-value pairs into the optimizer state.
Source§

fn save_safetensors(&self, path: impl AsRef<Path>) -> Result<(), IoError>

Save the optimizer state to a safetensors file.
Source§

fn load_safetensors(&mut self, path: impl AsRef<Path>) -> Result<(), IoError>

Load the optimizer state from a safetensors file.