pub fn jit<F>(f: F) -> Jit<F>Expand description
Returns f compiled with XLA, like jax.jit.
f takes and returns pytrees of Trace values. The result is called
- with
Nativevalues (Jit::call):fis traced for the input types (once per combination of types and structure), compiled with XLA (cached), and run; inputs and outputs are copied to and from the device; - with values on the device (
Jit::call_on_device), which stay there; - with
Tracevalues inside another trace (Jit::call_traced): the traced body becomes ajitequation of the outer IR.
ยงExamples
use ruxla_core::{Array, F32, Trace, jit, jnp};
let f = jit(|(x, y): (Array<Trace, f32>, F32<Trace>)| jnp::sin(&(x * y)));
let out = f.call(&(Array::from_vec(vec![1.0f32, 2.0], [2]), F32::new(3.0)));
assert_eq!(out.shape().to_vec(), [2]);