pub struct InferenceSession { /* private fields */ }Expand description
An inference session for running a model
Implementations§
Source§impl InferenceSession
impl InferenceSession
Sourcepub fn run(
&self,
inputs: HashMap<&str, Tensor>,
) -> Result<HashMap<String, Tensor>>
pub fn run( &self, inputs: HashMap<&str, Tensor>, ) -> Result<HashMap<String, Tensor>>
Run inference synchronously
§Example
use ronn_api::{Model, Tensor};
use ronn_core::{DataType, TensorLayout};
use std::collections::HashMap;
let model = Model::load("model.onnx")?;
let session = model.create_session_default()?;
let mut inputs = HashMap::new();
inputs.insert("input", Tensor::zeros(
vec![1, 3, 224, 224],
DataType::F32,
TensorLayout::RowMajor
)?);
let outputs = session.run(inputs)?;Sourcepub async fn run_async(
&self,
inputs: HashMap<&str, Tensor>,
) -> Result<HashMap<String, Tensor>>
pub async fn run_async( &self, inputs: HashMap<&str, Tensor>, ) -> Result<HashMap<String, Tensor>>
Run inference asynchronously
Sourcepub fn run_batch(
&self,
batch: Vec<HashMap<&str, Tensor>>,
) -> Result<Vec<HashMap<String, Tensor>>>
pub fn run_batch( &self, batch: Vec<HashMap<&str, Tensor>>, ) -> Result<Vec<HashMap<String, Tensor>>>
Run inference on a batch of inputs
Sourcepub fn options(&self) -> &SessionOptions
pub fn options(&self) -> &SessionOptions
Get session options
Sourcepub fn graph(&self) -> &ModelGraph
pub fn graph(&self) -> &ModelGraph
Get the model graph
Auto Trait Implementations§
impl !Freeze for InferenceSession
impl !RefUnwindSafe for InferenceSession
impl Send for InferenceSession
impl Sync for InferenceSession
impl Unpin for InferenceSession
impl !UnwindSafe for InferenceSession
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
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>
Converts
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>
Converts
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