pub trait BackendTestAdapter {
type Executor: TlExecutor<Tensor = Self::Tensor>;
type Tensor: Clone;
// Required methods
fn create_executor() -> Self::Executor;
fn create_tensor_from_data(data: &[f64], shape: &[usize]) -> Self::Tensor;
fn tensor_to_vec(tensor: &Self::Tensor) -> Vec<f64>;
fn tensor_shape(tensor: &Self::Tensor) -> Vec<usize>;
// Provided methods
fn create_scalar(value: f64) -> Self::Tensor { ... }
fn create_vector(data: &[f64]) -> Self::Tensor { ... }
fn create_matrix(data: &[f64], rows: usize, cols: usize) -> Self::Tensor { ... }
}Expand description
Adapter trait for backend testing.
Backend developers implement this trait to adapt their executor to the test framework.
Required Associated Types§
Sourcetype Executor: TlExecutor<Tensor = Self::Tensor>
type Executor: TlExecutor<Tensor = Self::Tensor>
The executor type being tested
Required Methods§
Sourcefn create_executor() -> Self::Executor
fn create_executor() -> Self::Executor
Create a new executor instance for testing
Sourcefn create_tensor_from_data(data: &[f64], shape: &[usize]) -> Self::Tensor
fn create_tensor_from_data(data: &[f64], shape: &[usize]) -> Self::Tensor
Create a tensor from raw data and shape
Sourcefn tensor_to_vec(tensor: &Self::Tensor) -> Vec<f64>
fn tensor_to_vec(tensor: &Self::Tensor) -> Vec<f64>
Convert tensor to a flat vector for comparison
Sourcefn tensor_shape(tensor: &Self::Tensor) -> Vec<usize>
fn tensor_shape(tensor: &Self::Tensor) -> Vec<usize>
Get the shape of a tensor
Provided Methods§
Sourcefn create_scalar(value: f64) -> Self::Tensor
fn create_scalar(value: f64) -> Self::Tensor
Create a scalar tensor
Sourcefn create_vector(data: &[f64]) -> Self::Tensor
fn create_vector(data: &[f64]) -> Self::Tensor
Create a 1D tensor (vector)
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.