pub struct Session { /* private fields */ }Expand description
A session manages graph compilation and execution on a device.
Implementations§
Source§impl Session
impl Session
Sourcepub fn new(device: Device) -> Self
pub fn new(device: Device) -> Self
Create a session for the given device at default (F32) precision.
§Panics
Panics if the device is not available (missing feature flag).
Sourcepub fn new_with_precision(device: Device, precision: Precision) -> Self
pub fn new_with_precision(device: Device, precision: Precision) -> Self
Create a session targeting a specific numeric precision. Backends fall back to F32 if the requested precision isn’t supported.
Sourcepub fn with_policy(self, policy: PrecisionPolicy) -> Self
pub fn with_policy(self, policy: PrecisionPolicy) -> Self
Builder: set a per-op precision policy. Applied as a graph rewrite before backend compile. Same mechanism works for AOT compile, JIT tracing, and proc-macro AOT — it’s a graph pass, not a runtime mode.
pub fn device(&self) -> Device
pub fn precision(&self) -> Precision
pub fn policy(&self) -> Option<&PrecisionPolicy>
Sourcepub fn compile(&self, graph: Graph) -> CompiledGraph
pub fn compile(&self, graph: Graph) -> CompiledGraph
Compile a MIR graph through the fusion-first pipeline (GraphModule → LIR).
Prefer Self::compile_hir or Self::compile_module for new code.
This entry wraps the graph as a MIR-stage GraphModule.
Sourcepub fn compile_graph(&self, graph: Graph) -> CompiledGraph
pub fn compile_graph(&self, graph: Graph) -> CompiledGraph
Explicit legacy alias — same as Self::compile.
Sourcepub fn compile_with(
&self,
graph: Graph,
options: &CompileOptions,
) -> CompiledGraph
pub fn compile_with( &self, graph: Graph, options: &CompileOptions, ) -> CompiledGraph
Compile with explicit options (full control over the pipeline).
Most callers use compile() and configure the session via
new_with_precision / with_policy. This escape hatch is for
callers that need finer control (e.g., disable DCE for debugging).
Sourcepub fn compile_hir(&self, hir: HirModule) -> Result<CompiledGraph, LowerError>
pub fn compile_hir(&self, hir: HirModule) -> Result<CompiledGraph, LowerError>
Compile a fusion-first HIR module through HIR → MIR → LIR.
Sourcepub fn compile_hir_with(
&self,
hir: HirModule,
options: &CompileOptions,
) -> Result<CompiledGraph, LowerError>
pub fn compile_hir_with( &self, hir: HirModule, options: &CompileOptions, ) -> Result<CompiledGraph, LowerError>
Compile HIR with explicit compile options.
Sourcepub fn compile_module(
&self,
module: GraphModule,
) -> Result<CompiledGraph, LowerError>
pub fn compile_module( &self, module: GraphModule, ) -> Result<CompiledGraph, LowerError>
Compile a GraphModule (HIR/MIR/LIR stage) through the pipeline.
Sourcepub fn compile_module_with(
&self,
module: GraphModule,
options: &CompileOptions,
) -> Result<CompiledGraph, LowerError>
pub fn compile_module_with( &self, module: GraphModule, options: &CompileOptions, ) -> Result<CompiledGraph, LowerError>
Compile a GraphModule with explicit compile options.
Auto Trait Implementations§
impl Freeze for Session
impl RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl UnsafeUnpin for Session
impl UnwindSafe for Session
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
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>
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>
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