Skip to main content

Backend

Trait Backend 

Source
pub trait Backend<T>
where T: ScalarBase,
{ const MATERIALIZES_CONJ: bool; const REQUIRES_UNIT_STRIDE: bool; // Required method fn bgemm_contiguous_into( c: &mut ContiguousOperandMut<T>, a: &ContiguousOperand<T>, b: &ContiguousOperand<T>, batch_dims: &[usize], m: usize, n: usize, k: usize, alpha: T, beta: T, ) -> Result<(), StridedError>; }
Expand description

Trait for backends that can execute batched GEMM on contiguous operands.

Each backend declares its configuration (conjugation materialization, stride requirements) and provides a GEMM implementation.

Implementations are provided by each backend module (faer, blas). External crates can implement this trait for custom scalar types (e.g., tropical semiring) and pass the backend to einsum2_with_backend_into.

Required Associated Constants§

Source

const MATERIALIZES_CONJ: bool

Whether the backend needs conjugation materialized into the data before GEMM (e.g., CBLAS has no conjugation flag for ?gemm).

Source

const REQUIRES_UNIT_STRIDE: bool

Whether the backend requires at least one unit stride per matrix dimension (row or column stride must be 1). CBLAS ?gemm requires this; faer does not.

Required Methods§

Source

fn bgemm_contiguous_into( c: &mut ContiguousOperandMut<T>, a: &ContiguousOperand<T>, b: &ContiguousOperand<T>, batch_dims: &[usize], m: usize, n: usize, k: usize, alpha: T, beta: T, ) -> Result<(), StridedError>

Execute batched GEMM: C = alpha * A * B + beta * C for each batch.

  • c: mutable output operand (batch x m x n)
  • a: input operand (batch x m x k)
  • b: input operand (batch x k x n)
  • batch_dims: sizes of the batch dimensions
  • m, n, k: fused matrix dimensions
  • alpha, beta: scaling factors

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§