pub struct MlxClosureValueAndGrad(/* private fields */);Expand description
Owned MLX value-and-gradient closure, released exactly once.
Implementations§
Source§impl MlxClosureValueAndGrad
impl MlxClosureValueAndGrad
Sourcepub fn from_fn<F>(callback: F) -> Result<Self, MlxCError>
pub fn from_fn<F>(callback: F) -> Result<Self, MlxCError>
Builds an owned value-and-gradient closure from a Rust callable returning both outputs and gradients.
Sourcepub fn set(&mut self, source: &Self) -> Result<(), MlxCError>
pub fn set(&mut self, source: &Self) -> Result<(), MlxCError>
Copies the source closure handle into this handle.
Sourcepub fn apply(
&self,
input: &MlxArrayVector,
) -> Result<(MlxArrayVector, MlxArrayVector), MlxCError>
pub fn apply( &self, input: &MlxArrayVector, ) -> Result<(MlxArrayVector, MlxArrayVector), MlxCError>
Applies the closure, producing both the outputs and the gradients.
§Errors
Returns the captured MLX-C description when application fails.
Trait Implementations§
Source§impl Debug for MlxClosureValueAndGrad
impl Debug for MlxClosureValueAndGrad
Source§impl Drop for MlxClosureValueAndGrad
impl Drop for MlxClosureValueAndGrad
Auto Trait Implementations§
impl !Send for MlxClosureValueAndGrad
impl !Sync for MlxClosureValueAndGrad
impl Freeze for MlxClosureValueAndGrad
impl RefUnwindSafe for MlxClosureValueAndGrad
impl Unpin for MlxClosureValueAndGrad
impl UnsafeUnpin for MlxClosureValueAndGrad
impl UnwindSafe for MlxClosureValueAndGrad
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