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§
Sourcefn allocate(&self, shape: &[usize], dtype: DType) -> Result<BufferHandle>
fn allocate(&self, shape: &[usize], dtype: DType) -> Result<BufferHandle>
Allocate an uninitialised buffer for the given shape and dtype.
Sourcefn execute(
&self,
graph: &Graph,
inputs: HashMap<String, Tensor>,
) -> Result<Vec<Tensor>>
fn execute( &self, graph: &Graph, inputs: HashMap<String, Tensor>, ) -> Result<Vec<Tensor>>
Execute the graph, returning output tensors in the order of
graph.outputs.
Sourcefn supports_op(&self, op: &OpType) -> bool
fn supports_op(&self, op: &OpType) -> bool
Whether this backend can execute the given op natively.
Provided Methods§
Sourcefn is_available() -> boolwhere
Self: Sized,
fn is_available() -> boolwhere
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".