JitExecutor

Struct JitExecutor 

Source
pub struct JitExecutor<B: Backend> { /* private fields */ }
Expand description

A JIT-compiled executor that runs pre-compiled graph execution plans.

Unlike the interpreter (Executor), the JIT executor:

  • Pre-compiles each graph into a flat instruction tape
  • Pre-resolves all buffer slot assignments
  • Inserts dead-value-free instructions for memory efficiency
  • Dispatches operations without HashMap lookups or string matching

§Usage

let jit = JitExecutor::<CpuBackend>::compile(program, device, config)?;
let result = jit.run("Forward", &inputs)?;
let output = result.get("output").unwrap();

Implementations§

Source§

impl<B: Backend> JitExecutor<B>

Source

pub fn compile( program: IrProgram, device: B::Device, config: RuntimeConfig, ) -> Result<Self>

Compile all graphs in a program and create a JIT executor.

Source

pub fn stats(&self, graph_name: &str) -> Option<&CompileStats>

Get compilation statistics for a graph.

Source

pub fn all_stats(&self) -> Vec<(&str, &CompileStats)>

Get all compilation statistics.

Source

pub fn run( &self, graph_name: &str, inputs: &HashMap<String, Tensor<B>>, ) -> Result<JitResult<B>>

Run a compiled graph with the given inputs.

Source

pub fn program(&self) -> &IrProgram

Get the underlying program.

Source

pub fn config(&self) -> &RuntimeConfig

Get runtime config.

Source

pub fn params(&self) -> &HashMap<(String, String), Tensor<B>>

Get all parameters.

Source

pub fn graph_params(&self, graph_name: &str) -> Vec<Tensor<B>>

Get parameters for a specific graph.

Source

pub fn update_params(&mut self, graph_name: &str, new_params: &[Tensor<B>])

Update parameters after an optimizer step.

Source

pub fn recompile(&mut self, graph_name: &str) -> Result<()>

Recompile a single graph (e.g., after optimizer changes shapes).

Source

pub fn dump(&self, graph_name: &str) -> Option<String>

Dump the compiled instruction tape for a graph (debugging).

Auto Trait Implementations§

§

impl<B> Freeze for JitExecutor<B>
where <B as Backend>::Device: Freeze,

§

impl<B> RefUnwindSafe for JitExecutor<B>
where <B as Backend>::Device: RefUnwindSafe,

§

impl<B> Send for JitExecutor<B>

§

impl<B> Sync for JitExecutor<B>

§

impl<B> Unpin for JitExecutor<B>
where <B as Backend>::Device: Unpin,

§

impl<B> UnwindSafe for JitExecutor<B>

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
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.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V