pub struct ValueAndGrad<F> { /* private fields */ }Expand description
See value_and_grad.
Implementations§
Source§impl<F> ValueAndGrad<F>
impl<F> ValueAndGrad<F>
Sourcepub fn call<P, A, O>(
&self,
params: &P,
args: &A,
) -> (<O as Tree<Trace>>::On<Native>, P)
pub fn call<P, A, O>( &self, params: &P, args: &A, ) -> (<O as Tree<Trace>>::On<Native>, P)
Computes the value and the gradient with the interpreter.
§Panics
Panics if a parameter is not a float, if the first output is not a float scalar, or if a primitive has no differentiation rule.
Sourcepub fn call_xla<P, A, O>(
&self,
params: &P,
args: &A,
) -> Result<(<O as Tree<Trace>>::On<Native>, P), Error>
pub fn call_xla<P, A, O>( &self, params: &P, args: &A, ) -> Result<(<O as Tree<Trace>>::On<Native>, P), Error>
Computes the value and the gradient with XLA.
§Errors
Returns an error if no PJRT plugin is configured, or if compiling or running fails.
§Panics
See ValueAndGrad::call.
Sourcepub fn call_traced<P, A, O>(&self, params: P, args: A) -> (O, P)
pub fn call_traced<P, A, O>(&self, params: P, args: A) -> (O, P)
Computes the value and the gradient inside another trace: the
derivative becomes a jit equation of the outer IR. Values that f
captures from the outer trace are not differentiated.
§Panics
See ValueAndGrad::call.
Trait Implementations§
Auto Trait Implementations§
impl<F> Forget for ValueAndGrad<F>
impl<F> Freeze for ValueAndGrad<F>where
F: Freeze,
impl<F> Move for ValueAndGrad<F>
impl<F> RefUnwindSafe for ValueAndGrad<F>where
F: RefUnwindSafe,
impl<F> Send for ValueAndGrad<F>where
F: Send,
impl<F> Sync for ValueAndGrad<F>where
F: Sync,
impl<F> Unpin for ValueAndGrad<F>where
F: Unpin,
impl<F> UnsafeUnpin for ValueAndGrad<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for ValueAndGrad<F>where
F: 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