Skip to main content

Loader

Trait Loader 

Source
pub trait Loader:
    Send
    + Sync
    + 'static {
    type Backend: Backend;

    // Required methods
    fn load(
        &self,
        encoding: ModelEncoding,
        model: ModelBuffer,
    ) -> Result<Self::Backend>;
    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§

Source

type Backend: Backend

The concrete backend produced by this loader.

Required Methods§

Source

fn load( &self, encoding: ModelEncoding, model: ModelBuffer, ) -> Result<Self::Backend>

Parse, verify, and instantiate an inference backend from an owned aligned model buffer.

Source

fn maximum_model_size(&self) -> usize

Maximum model size in bytes accepted by this loader.

Writes beyond this bound return [file_system::IoErrorKind::FileTooLarge].

Implementors§