pub struct Session { /* private fields */ }Expand description
An inference session.
Sessions hold the runtime state for model inference, including allocated memory and intermediate tensors.
§Thread Safety
Sessions can be used from multiple threads, but run() must not be
called concurrently on the same session.
Implementations§
Source§impl Session
impl Session
Sourcepub fn run(&mut self) -> MnnResult<()>
pub fn run(&mut self) -> MnnResult<()>
Run inference.
This executes the model on the current input tensors and populates the output tensors.
§Returns
Ok(()) on success, or an error on failure.
Sourcepub fn memory_usage(&self) -> usize
pub fn memory_usage(&self) -> usize
Get the memory usage of this session in bytes.
Sourcepub fn inner(&self) -> *mut MNNSession
pub fn inner(&self) -> *mut MNNSession
Get the raw pointer to the underlying MNN session.
§Safety
The returned pointer is owned by this Session and must not be freed.
Sourcepub fn inner_mut(&mut self) -> *mut MNNSession
pub fn inner_mut(&mut self) -> *mut MNNSession
Get the mutable raw pointer to the underlying MNN session.
§Safety
The returned pointer is owned by this Session and must not be freed.
Sourcepub fn interpreter(&self) -> *mut MNNInterpreter
pub fn interpreter(&self) -> *mut MNNInterpreter
Sourcepub unsafe fn from_ptr(
inner: *mut MNNSession,
interpreter: *mut MNNInterpreter,
) -> Self
pub unsafe fn from_ptr( inner: *mut MNNSession, interpreter: *mut MNNInterpreter, ) -> Self
Create a new session from raw pointers.
§Safety
The pointers must be valid and the interpreter must outlive the session.