pub struct SessionBuilder<'a> { /* private fields */ }
Expand description
Type used to create a session using the builder pattern
A SessionBuilder
is created by calling the
Environment::new_session_builder()
method on the environment.
Once created, use the different methods to configure the session.
Once configured, use the SessionBuilder::with_model_from_file()
method to “commit” the builder configuration into a Session
.
§Example
let environment = Environment::builder()
.with_name("test")
.with_log_level(LoggingLevel::Verbose)
.build()?;
let mut session = environment
.new_session_builder()?
.with_optimization_level(GraphOptimizationLevel::Basic)?
.with_number_threads(1)?
.with_model_from_file("squeezenet.onnx")?;
Implementations§
Source§impl<'a> SessionBuilder<'a>
impl<'a> SessionBuilder<'a>
Sourcepub fn with_number_threads(self, num_threads: i16) -> Result<SessionBuilder<'a>>
pub fn with_number_threads(self, num_threads: i16) -> Result<SessionBuilder<'a>>
Configure the session to use a number of threads
Sourcepub fn with_optimization_level(
self,
opt_level: GraphOptimizationLevel,
) -> Result<SessionBuilder<'a>>
pub fn with_optimization_level( self, opt_level: GraphOptimizationLevel, ) -> Result<SessionBuilder<'a>>
Set the session’s optimization level
Sourcepub fn with_allocator(
self,
allocator: AllocatorType,
) -> Result<SessionBuilder<'a>>
pub fn with_allocator( self, allocator: AllocatorType, ) -> Result<SessionBuilder<'a>>
Set the session’s allocator
Defaults to AllocatorType::Arena
Sourcepub fn with_memory_type(
self,
memory_type: MemType,
) -> Result<SessionBuilder<'a>>
pub fn with_memory_type( self, memory_type: MemType, ) -> Result<SessionBuilder<'a>>
Set the session’s memory type
Defaults to MemType::Default
Sourcepub fn with_model_downloaded<M>(self, model: M) -> Result<Session<'a>>where
M: Into<AvailableOnnxModel>,
pub fn with_model_downloaded<M>(self, model: M) -> Result<Session<'a>>where
M: Into<AvailableOnnxModel>,
Download an ONNX pre-trained model from the ONNX Model Zoo and commit the session
Sourcepub fn with_model_from_file<P>(
self,
model_filepath_ref: P,
) -> Result<Session<'a>>
pub fn with_model_from_file<P>( self, model_filepath_ref: P, ) -> Result<Session<'a>>
Load an ONNX graph from a file and commit the session
Trait Implementations§
Source§impl<'a> Debug for SessionBuilder<'a>
impl<'a> Debug for SessionBuilder<'a>
Auto Trait Implementations§
impl<'a> Freeze for SessionBuilder<'a>
impl<'a> RefUnwindSafe for SessionBuilder<'a>
impl<'a> !Send for SessionBuilder<'a>
impl<'a> !Sync for SessionBuilder<'a>
impl<'a> Unpin for SessionBuilder<'a>
impl<'a> UnwindSafe for SessionBuilder<'a>
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