Model

Struct Model 

Source
pub struct Model { /* private fields */ }
Expand description

An ML inference model session.

Wraps a TFLM MicroInterpreter with automatic cleanup.

Implementations§

Source§

impl Model

Source

pub fn new(config: &ModelConfig<'_>) -> Result<Self>

Create a new model via heap allocation.

Source

pub unsafe fn from_static( storage: *mut ove_model_storage_t, arena: *mut u8, config: &ModelConfig<'_>, ) -> Result<Self>

Create from caller-provided storage and arena.

Available in both heap and zero-heap modes. Useful when the same storage/arena must be reused for different models (e.g. two-stage inference pipelines).

§Safety

Caller must ensure storage and arena outlive the Model and are not shared with another primitive.

Source

pub fn invoke(&self) -> Result<()>

Run the model forward pass.

Source

pub fn input(&self, index: u32) -> Result<TensorInfo>

Get tensor info for an input tensor.

Source

pub fn output(&self, index: u32) -> Result<TensorInfo>

Get tensor info for an output tensor.

Source

pub fn last_inference_us(&self) -> u64

Return last inference duration in microseconds.

Source§

impl Model

Source

pub fn input_slice_mut<T>(&self, index: u32) -> Result<&mut [T]>

Get input tensor data as a mutable typed slice.

The slice length is tensor_info.size / size_of::<T>().

§Errors

Returns an error if the tensor index is invalid.

Source

pub fn output_slice<T>(&self, index: u32) -> Result<&[T]>

Get output tensor data as a typed slice.

The slice length is tensor_info.size / size_of::<T>().

§Errors

Returns an error if the tensor index is invalid.

Trait Implementations§

Source§

impl Drop for Model

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for Model

Source§

impl Sync for Model

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.