Trait Loader
pub trait Loader:
Send
+ Sync
+ 'static {
type Backend: Backend;
// Required methods
fn load(
&self,
encoding: ModelEncoding,
model: ModelBuffer,
) -> Result<Self::Backend, Kind>;
fn maximum_model_size(&self) -> usize;
}Expand description
Lower-half interface for backends capable of dynamic model loading at runtime.
An implementation of Loader is mounted as a VFS device (e.g. /devices/nn/cpu).
Guest applications open the node, write the model bytes sequentially, and send
the LOAD control command to instantiate a Backend.
Required Associated Types§
Required Methods§
fn load(
&self,
encoding: ModelEncoding,
model: ModelBuffer,
) -> Result<Self::Backend, Kind>
fn load( &self, encoding: ModelEncoding, model: ModelBuffer, ) -> Result<Self::Backend, Kind>
Parse, verify, and instantiate an inference backend from an owned aligned model buffer.
fn maximum_model_size(&self) -> usize
fn maximum_model_size(&self) -> usize
Maximum model size in bytes accepted by this loader.
Writes beyond this bound return [file_system::IoErrorKind::FileTooLarge].