pub struct OnnxRuntime;Expand description
ONNX Runtime environment wrapper
Manages the global ONNX Runtime environment and provides helper methods for loading models.
Uses load-dynamic feature: the runtime library is loaded at runtime.
The library is resolved in this order:
ORT_DYLIB_PATHenvironment variable (if set)libs/onnxruntime/<LIB>relative to the executablelibs/onnxruntime/<LIB>relative to the current working directory
Implementations§
Source§impl OnnxRuntime
impl OnnxRuntime
Sourcepub fn init() -> Result<Self>
pub fn init() -> Result<Self>
Initialize the ONNX Runtime global environment.
Dynamically loads libonnxruntime.so at runtime. The library is searched
in the order described on OnnxRuntime.
This should be called once at application startup, before creating any sessions.
Sourcepub fn load_model_with_threads<P: AsRef<Path>>(
&self,
path: P,
intra_threads: usize,
) -> Result<Session>
pub fn load_model_with_threads<P: AsRef<Path>>( &self, path: P, intra_threads: usize, ) -> Result<Session>
Load an ONNX model with a specific number of intra-op threads.
Attempts to register GPU execution providers in platform-specific priority order, then falls back to CPU if none initialize. The CPU provider is always appended last so session creation never fails due to missing GPU drivers or runtime libraries.
Platform priority: Windows: DirectML (covers NVIDIA/AMD/Intel/Qualcomm via D3D12) Linux: CUDA (NVIDIA). ROCm could be added via a cargo flag later. macOS: CoreML (Apple Silicon + AMD on Intel Macs)
intra_threads applies to the CPU provider; GPU providers ignore it.
Auto Trait Implementations§
impl Freeze for OnnxRuntime
impl RefUnwindSafe for OnnxRuntime
impl Send for OnnxRuntime
impl Sync for OnnxRuntime
impl Unpin for OnnxRuntime
impl UnsafeUnpin for OnnxRuntime
impl UnwindSafe for OnnxRuntime
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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