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>
impl<B: Backend> JitExecutor<B>
Sourcepub fn compile(
program: IrProgram,
device: B::Device,
config: RuntimeConfig,
) -> Result<Self>
pub fn compile( program: IrProgram, device: B::Device, config: RuntimeConfig, ) -> Result<Self>
Compile all graphs in a program and create a JIT executor.
Sourcepub fn stats(&self, graph_name: &str) -> Option<&CompileStats>
pub fn stats(&self, graph_name: &str) -> Option<&CompileStats>
Get compilation statistics for a graph.
Sourcepub fn all_stats(&self) -> Vec<(&str, &CompileStats)>
pub fn all_stats(&self) -> Vec<(&str, &CompileStats)>
Get all compilation statistics.
Sourcepub fn run(
&self,
graph_name: &str,
inputs: &HashMap<String, Tensor<B>>,
) -> Result<JitResult<B>>
pub fn run( &self, graph_name: &str, inputs: &HashMap<String, Tensor<B>>, ) -> Result<JitResult<B>>
Run a compiled graph with the given inputs.
Sourcepub fn config(&self) -> &RuntimeConfig
pub fn config(&self) -> &RuntimeConfig
Get runtime config.
Sourcepub fn graph_params(&self, graph_name: &str) -> Vec<Tensor<B>>
pub fn graph_params(&self, graph_name: &str) -> Vec<Tensor<B>>
Get parameters for a specific graph.
Sourcepub fn update_params(&mut self, graph_name: &str, new_params: &[Tensor<B>])
pub fn update_params(&mut self, graph_name: &str, new_params: &[Tensor<B>])
Update parameters after an optimizer step.
Auto Trait Implementations§
impl<B> Freeze for JitExecutor<B>
impl<B> RefUnwindSafe for JitExecutor<B>
impl<B> Send for JitExecutor<B>
impl<B> Sync for JitExecutor<B>
impl<B> Unpin for JitExecutor<B>
impl<B> UnwindSafe for JitExecutor<B>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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