Skip to main content

Backend

Trait Backend 

Source
pub trait Backend:
    Send
    + Sync
    + 'static {
    type Execution: Send + Sync + 'static;
    type Input<'a>: AsMut<[u8]>
       where Self: 'a;
    type Output<'a>: AsRef<[u8]>
       where Self: 'a;

    // Required methods
    fn create_execution(&self) -> Result<Self::Execution>;
    fn owns_execution(&self, execution: &Self::Execution) -> bool;
    fn input_count(&self) -> usize;
    fn output_count(&self) -> usize;
    fn input_info(&self, index: usize) -> Result<TensorInfo>;
    fn output_info(&self, index: usize) -> Result<TensorInfo>;
    fn input_quantization(
        &self,
        tensor: usize,
        entry: usize,
    ) -> Result<QuantizationEntry>;
    fn output_quantization(
        &self,
        tensor: usize,
        entry: usize,
    ) -> Result<QuantizationEntry>;
    fn input<'a>(
        &self,
        execution: &'a mut Self::Execution,
        index: usize,
    ) -> Result<Self::Input<'a>>;
    fn output<'a>(
        &self,
        execution: &'a Self::Execution,
        index: usize,
    ) -> Result<Self::Output<'a>>;
    fn compute(&self, execution: &mut Self::Execution) -> Result<()>;
}
Expand description

An immutable prepared model, with independent mutable execution storage per open.

Implementations own model lifetimes, arena allocation and error translation. Input and output views must refer directly to execution/model storage; the adapter never stages tensors. Backend selection and model loading belong to the runtime assembly.

Required Associated Types§

Source

type Execution: Send + Sync + 'static

Source

type Input<'a>: AsMut<[u8]> where Self: 'a

Source

type Output<'a>: AsRef<[u8]> where Self: 'a

Required Methods§

Source

fn create_execution(&self) -> Result<Self::Execution>

Source

fn owns_execution(&self, execution: &Self::Execution) -> bool

Source

fn input_count(&self) -> usize

Source

fn output_count(&self) -> usize

Source

fn input_info(&self, index: usize) -> Result<TensorInfo>

Source

fn output_info(&self, index: usize) -> Result<TensorInfo>

Source

fn input_quantization( &self, tensor: usize, entry: usize, ) -> Result<QuantizationEntry>

Source

fn output_quantization( &self, tensor: usize, entry: usize, ) -> Result<QuantizationEntry>

Source

fn input<'a>( &self, execution: &'a mut Self::Execution, index: usize, ) -> Result<Self::Input<'a>>

Source

fn output<'a>( &self, execution: &'a Self::Execution, index: usize, ) -> Result<Self::Output<'a>>

Source

fn compute(&self, execution: &mut Self::Execution) -> Result<()>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§