pub struct CustomFunction<I, O> { /* private fields */ }Expand description
A function of a tree with custom transform rules; see custom_function.
Implementations§
Source§impl<I, O> CustomFunction<I, O>
impl<I, O> CustomFunction<I, O>
Sourcepub fn with_vjp(
self,
rule: impl Fn(&I, &O, &O) -> Result<I> + Send + Sync + 'static,
) -> Self
pub fn with_vjp( self, rule: impl Fn(&I, &O, &O) -> Result<I> + Send + Sync + 'static, ) -> Self
Sets the reverse-mode rule: (primals, outputs, cotangents) → the cotangent of the
primals (a tree like them).
Sourcepub fn with_jvp(
self,
rule: impl Fn(&I, &I) -> Result<O> + Send + Sync + 'static,
) -> Self
pub fn with_jvp( self, rule: impl Fn(&I, &I) -> Result<O> + Send + Sync + 'static, ) -> Self
Sets the forward-mode rule: (primals, tangents) → the outputs’ tangents (missing
input tangents are passed as zeros).
Trait Implementations§
Auto Trait Implementations§
impl<I, O> !RefUnwindSafe for CustomFunction<I, O>
impl<I, O> !UnwindSafe for CustomFunction<I, O>
impl<I, O> Freeze for CustomFunction<I, O>where
Arc<dyn Fn(&I) -> Result<O, Error> + Send + Sync>: Freeze,
Option<Arc<dyn Fn(&I, &O, &O) -> Result<I, Error> + Send + Sync>>: Freeze,
Option<Arc<dyn Fn(&I, &I) -> Result<O, Error> + Send + Sync>>: Freeze,
Option<Arc<dyn Fn(&I, &[Option<i32>]) -> Result<(O, i32), Error> + Send + Sync>>: Freeze,
impl<I, O> Send for CustomFunction<I, O>
impl<I, O> Sync for CustomFunction<I, O>
impl<I, O> Unpin for CustomFunction<I, O>
impl<I, O> UnsafeUnpin for CustomFunction<I, O>where
Arc<dyn Fn(&I) -> Result<O, Error> + Send + Sync>: UnsafeUnpin,
Option<Arc<dyn Fn(&I, &O, &O) -> Result<I, Error> + Send + Sync>>: UnsafeUnpin,
Option<Arc<dyn Fn(&I, &I) -> Result<O, Error> + Send + Sync>>: UnsafeUnpin,
Option<Arc<dyn Fn(&I, &[Option<i32>]) -> Result<(O, i32), Error> + Send + Sync>>: UnsafeUnpin,
Blanket Implementations§
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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