neural_network/
backend.rs1use crate::{QuantizationEntry, TensorInfo};
3use file_system::Result;
4
5pub trait Backend: Send + Sync + 'static {
11 type Execution: Send + Sync + 'static;
12 type Input<'a>: AsMut<[u8]>
13 where
14 Self: 'a;
15 type Output<'a>: AsRef<[u8]>
16 where
17 Self: 'a;
18
19 fn create_execution(&self) -> Result<Self::Execution>;
20 fn owns_execution(&self, execution: &Self::Execution) -> bool;
21 fn input_count(&self) -> usize;
22 fn output_count(&self) -> usize;
23 fn input_info(&self, index: usize) -> Result<TensorInfo>;
24 fn output_info(&self, index: usize) -> Result<TensorInfo>;
25 fn input_quantization(&self, tensor: usize, entry: usize) -> Result<QuantizationEntry>;
26 fn output_quantization(&self, tensor: usize, entry: usize) -> Result<QuantizationEntry>;
27 fn input<'a>(
28 &self,
29 execution: &'a mut Self::Execution,
30 index: usize,
31 ) -> Result<Self::Input<'a>>;
32 fn output<'a>(&self, execution: &'a Self::Execution, index: usize) -> Result<Self::Output<'a>>;
33 fn compute(&self, execution: &mut Self::Execution) -> Result<()>;
34}