pub struct OrtSessionConfig {
pub intra_threads: Option<usize>,
pub inter_threads: Option<usize>,
pub parallel_execution: Option<bool>,
pub optimization_level: Option<OrtGraphOptimizationLevel>,
pub execution_providers: Option<Vec<OrtExecutionProvider>>,
pub enable_mem_pattern: Option<bool>,
pub log_severity_level: Option<i32>,
pub log_verbosity_level: Option<i32>,
pub session_config_entries: Option<HashMap<String, String>>,
}Expand description
Configuration for ONNX Runtime sessions.
This struct contains various configuration options for ONNX Runtime sessions, including threading, memory management, and optimization settings.
Fields§
§intra_threads: Option<usize>Number of threads used to parallelize execution within nodes
inter_threads: Option<usize>Number of threads used to parallelize execution across nodes
parallel_execution: Option<bool>Enable parallel execution mode
optimization_level: Option<OrtGraphOptimizationLevel>Graph optimization level
execution_providers: Option<Vec<OrtExecutionProvider>>Execution providers in order of preference
enable_mem_pattern: Option<bool>Enable memory pattern optimization
log_severity_level: Option<i32>Log severity level (0=Verbose, 1=Info, 2=Warning, 3=Error, 4=Fatal)
log_verbosity_level: Option<i32>Log verbosity level
session_config_entries: Option<HashMap<String, String>>Session configuration entries (key-value pairs)
Implementations§
Source§impl OrtSessionConfig
impl OrtSessionConfig
Sourcepub fn new() -> OrtSessionConfig
pub fn new() -> OrtSessionConfig
Creates a new OrtSessionConfig with default values.
Sourcepub fn with_intra_threads(self, threads: usize) -> OrtSessionConfig
pub fn with_intra_threads(self, threads: usize) -> OrtSessionConfig
Sets the number of intra-op threads.
Sourcepub fn with_inter_threads(self, threads: usize) -> OrtSessionConfig
pub fn with_inter_threads(self, threads: usize) -> OrtSessionConfig
Sets the number of inter-op threads.
Sourcepub fn with_parallel_execution(self, enabled: bool) -> OrtSessionConfig
pub fn with_parallel_execution(self, enabled: bool) -> OrtSessionConfig
Enables or disables parallel execution.
Sourcepub fn with_optimization_level(
self,
level: OrtGraphOptimizationLevel,
) -> OrtSessionConfig
pub fn with_optimization_level( self, level: OrtGraphOptimizationLevel, ) -> OrtSessionConfig
Sets the graph optimization level.
Sourcepub fn with_execution_providers(
self,
providers: Vec<OrtExecutionProvider>,
) -> OrtSessionConfig
pub fn with_execution_providers( self, providers: Vec<OrtExecutionProvider>, ) -> OrtSessionConfig
Sets the execution providers, in order of preference.
Sourcepub fn add_execution_provider(
self,
provider: OrtExecutionProvider,
) -> OrtSessionConfig
pub fn add_execution_provider( self, provider: OrtExecutionProvider, ) -> OrtSessionConfig
Appends a single execution provider.
Sourcepub fn with_memory_pattern(self, enable: bool) -> OrtSessionConfig
pub fn with_memory_pattern(self, enable: bool) -> OrtSessionConfig
Enables or disables memory pattern optimization.
Sourcepub fn with_log_severity_level(self, level: i32) -> OrtSessionConfig
pub fn with_log_severity_level(self, level: i32) -> OrtSessionConfig
Sets the log severity level (0=Verbose, 1=Info, 2=Warning, 3=Error, 4=Fatal).
Sourcepub fn with_log_verbosity_level(self, level: i32) -> OrtSessionConfig
pub fn with_log_verbosity_level(self, level: i32) -> OrtSessionConfig
Sets the log verbosity level.
Sourcepub fn add_config_entry<K, V>(self, key: K, value: V) -> OrtSessionConfig
pub fn add_config_entry<K, V>(self, key: K, value: V) -> OrtSessionConfig
Adds a session configuration entry.
Sourcepub fn get_intra_threads(&self) -> usize
pub fn get_intra_threads(&self) -> usize
Effective intra-op thread count, defaulting to available parallelism.
Sourcepub fn get_inter_threads(&self) -> usize
pub fn get_inter_threads(&self) -> usize
Effective inter-op thread count, defaulting to 1.
Sourcepub fn get_optimization_level(&self) -> OrtGraphOptimizationLevel
pub fn get_optimization_level(&self) -> OrtGraphOptimizationLevel
Effective graph optimization level, defaulting to OrtGraphOptimizationLevel::default().
Sourcepub fn get_execution_providers(&self) -> Vec<OrtExecutionProvider>
pub fn get_execution_providers(&self) -> Vec<OrtExecutionProvider>
Configured execution providers, defaulting to CPU.
Trait Implementations§
Source§impl Clone for OrtSessionConfig
impl Clone for OrtSessionConfig
Source§fn clone(&self) -> OrtSessionConfig
fn clone(&self) -> OrtSessionConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for OrtSessionConfig
impl Debug for OrtSessionConfig
Source§impl Default for OrtSessionConfig
impl Default for OrtSessionConfig
Source§fn default() -> OrtSessionConfig
fn default() -> OrtSessionConfig
Source§impl<'de> Deserialize<'de> for OrtSessionConfig
impl<'de> Deserialize<'de> for OrtSessionConfig
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<OrtSessionConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<OrtSessionConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for OrtSessionConfig
impl Serialize for OrtSessionConfig
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for OrtSessionConfig
impl RefUnwindSafe for OrtSessionConfig
impl Send for OrtSessionConfig
impl Sync for OrtSessionConfig
impl Unpin for OrtSessionConfig
impl UnsafeUnpin for OrtSessionConfig
impl UnwindSafe for OrtSessionConfig
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.