pub fn vjp<F>(f: F) -> VjpFn<F>Expand description
Returns a function that computes f(primals) and the cotangents of the
inputs for given cotangents of the outputs (reverse mode), like calling
the function that jax.vjp returns.
Cotangents of non-float outputs are ignored; cotangents of non-float inputs are zeros.
ยงExamples
use ruxla_core::{F32, Trace, vjp};
let f = vjp(|(x, y): (F32<Trace>, F32<Trace>)| x * y);
let (out, (cx, cy)) = f.call(&(F32::new(3.0), F32::new(2.0)), &F32::new(1.0));
assert_eq!((out.value(), cx.value(), cy.value()), (6.0, 2.0, 3.0));