Skip to main content

ExecutionBackend

Trait ExecutionBackend 

Source
pub trait ExecutionBackend: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn allocate(&self, shape: &[usize], dtype: DType) -> Result<BufferHandle>;
    fn execute(
        &self,
        graph: &Graph,
        inputs: HashMap<String, Tensor>,
    ) -> Result<Vec<Tensor>>;
    fn supports_op(&self, op: &OpType) -> bool;

    // Provided method
    fn is_available() -> bool
       where Self: Sized { ... }
}
Expand description

The unified backend interface every hardware target must implement.

Backends may be selected at runtime via Box<dyn ExecutionBackend> or at compile time via generics.

Required Methods§

Source

fn name(&self) -> &str

Short name for logging / CLI display.

Source

fn allocate(&self, shape: &[usize], dtype: DType) -> Result<BufferHandle>

Allocate an uninitialised buffer for the given shape and dtype.

Source

fn execute( &self, graph: &Graph, inputs: HashMap<String, Tensor>, ) -> Result<Vec<Tensor>>

Execute the graph, returning output tensors in the order of graph.outputs.

Source

fn supports_op(&self, op: &OpType) -> bool

Whether this backend can execute the given op natively.

Provided Methods§

Source

fn is_available() -> bool
where Self: Sized,

True if this backend is available on the current system.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§