Skip to main content

Jit

Struct Jit 

Source
pub struct Jit<F> { /* private fields */ }
Expand description

A function compiled with XLA; see jit.

Implementations§

Source§

impl<F> Jit<F>

Source

pub fn with_name(self, name: impl Into<String>) -> Self

Sets the name shown in the IR (the default is jit).

Source

pub fn call<I, O>(&self, input: &I) -> O::On<Native>
where I: Tree<Native>, O: Tree<Trace> + Send + Sync + 'static, F: Fn(I::On<Trace>) -> O,

Runs the function on Native values with XLA.

§Panics

Panics if the runtime fails (see Jit::try_call), or if f uses traced values of another trace.

Source

pub fn try_call<I, O>(&self, input: &I) -> Result<O::On<Native>, Error>
where I: Tree<Native>, O: Tree<Trace> + Send + Sync + 'static, F: Fn(I::On<Trace>) -> O,

Runs the function on Native values with XLA.

§Errors

Returns an error if no PJRT plugin is configured (see runtime), or if compiling or running fails.

Source

pub fn call_on_device<I, O>( &self, input: &OnDevice<I>, ) -> OnDevice<O::On<Native>>
where I: Tree<Native>, O: Tree<Trace> + Send + Sync + 'static, O::On<Native>: Send + Sync + 'static, F: Fn(I::On<Trace>) -> O,

Runs the function with XLA on values on the device, and returns the results on the device.

§Panics

Panics if the runtime fails, or if the values are on another platform.

Source

pub fn call_on_device_donating<I, O>( &self, input: OnDevice<I>, ) -> OnDevice<O::On<Native>>
where I: Tree<Native>, O: Tree<Trace> + Send + Sync + 'static, O::On<Native>: Send + Sync + 'static, F: Fn(I::On<Trace>) -> O,

Jit::call_on_device taking the input, whose buffers the program may reuse for the results (donation, as with JAX’s donate_argnums), which saves memory and copies in loops such as state = step.call_on_device_donating(state). Leaves whose buffers are shared with another OnDevice (a clone) are not donated.

§Panics

Panics if the runtime fails, or if the values are on another platform.

Source

pub fn call_traced<I, O>(&self, input: I) -> O
where I: Tree<Trace>, O: Tree<Trace>, F: Fn(I) -> O,

Calls the function on Trace values inside another trace, which adds a jit equation with the traced body to the outer IR.

Trait Implementations§

Source§

impl<F> Debug for Jit<F>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<F> !Freeze for Jit<F>

§

impl<F> RefUnwindSafe for Jit<F>
where F: RefUnwindSafe,

§

impl<F> Send for Jit<F>
where F: Send,

§

impl<F> Sync for Jit<F>
where F: Sync,

§

impl<F> Unpin for Jit<F>
where F: Unpin,

§

impl<F> UnsafeUnpin for Jit<F>
where F: UnsafeUnpin,

§

impl<F> UnwindSafe for Jit<F>
where F: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.