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>
impl<const ARENA_SIZE: usize> ModelStorage<ARENA_SIZE>
Sourcepub fn load(&mut self, model_data: &[u8]) -> Result<Model>
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> 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