Skip to main content

jvp

Function jvp 

Source
pub fn jvp<F>(f: F) -> Jvp<F>
Expand description

Returns a function that computes f(primals) and its derivative in the direction of tangents (forward mode), like jax.jvp.

Tangents of non-float inputs are ignored; tangents of non-float outputs are zeros.

ยงExamples

use ruxla_core::{F32, Trace, jvp};

let f = jvp(|(x, y): (F32<Trace>, F32<Trace>)| x * y);
let (out, t) = f.call(&(F32::new(3.0), F32::new(2.0)), &(F32::new(1.0), F32::new(0.0)));
assert_eq!((out.value(), t.value()), (6.0, 2.0));