ModelStorage

Struct ModelStorage 

Source
pub struct ModelStorage<const ARENA_SIZE: usize> { /* private fields */ }
Expand description

Reusable model storage and arena pair for sequential inference.

Owns both the C ove_model_storage_t and a 16-byte aligned arena buffer. Call load() to create a Model session; the borrow checker ensures the storage is not shared.

§Example

let mut storage = ModelStorage::<32768>::new();
let model = storage.load(&cfg)?;
let input = model.input_slice_mut::<i16>(0)?;
input[0] = 42;
model.invoke()?;
let output = model.output_slice::<i8>(0)?;

Implementations§

Source§

impl<const ARENA_SIZE: usize> ModelStorage<ARENA_SIZE>

Source

pub fn new() -> Self

Create a zeroed storage + arena pair.

Source

pub fn load(&mut self, model_data: &[u8]) -> Result<Model>

Load a model into this storage, returning a session handle.

The arena size is supplied by the const generic ARENA_SIZE — no need to repeat it. The returned Model borrows self mutably, so the compiler prevents concurrent use or re-loading until the model is dropped.

Auto Trait Implementations§

§

impl<const ARENA_SIZE: usize> Freeze for ModelStorage<ARENA_SIZE>

§

impl<const ARENA_SIZE: usize> RefUnwindSafe for ModelStorage<ARENA_SIZE>

§

impl<const ARENA_SIZE: usize> Send for ModelStorage<ARENA_SIZE>

§

impl<const ARENA_SIZE: usize> Sync for ModelStorage<ARENA_SIZE>

§

impl<const ARENA_SIZE: usize> Unpin for ModelStorage<ARENA_SIZE>

§

impl<const ARENA_SIZE: usize> UnwindSafe for ModelStorage<ARENA_SIZE>

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.