Skip to main content

Backend

Trait Backend 

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, Kind>;
    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, Kind>;
    fn output_info(&self, index: usize) -> Result<TensorInfo, Kind>;
    fn input_quantization(
        &self,
        tensor: usize,
        entry: usize,
    ) -> Result<QuantizationEntry, Kind>;
    fn output_quantization(
        &self,
        tensor: usize,
        entry: usize,
    ) -> Result<QuantizationEntry, Kind>;
    fn input<'a>(
        &self,
        execution: &'a mut Self::Execution,
        index: usize,
    ) -> Result<Self::Input<'a>, Kind>;
    fn output<'a>(
        &self,
        execution: &'a Self::Execution,
        index: usize,
    ) -> Result<Self::Output<'a>, Kind>;
    fn compute(&self, execution: &mut Self::Execution) -> Result<(), Kind>;
}
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§

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, Kind>

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, Kind>

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

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

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

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

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

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

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§