Skip to main content

Backend

Enum Backend 

Source
#[non_exhaustive]
pub enum Backend { Accelerate, Metal, Cuda, Simd, Fused, StableHlo, }
Expand description

The implementers of named formulas: everything that can serve work faster than the reference paths, in LLVM’s sense of the word — hardware kernel providers, the crate’s own fused kernels, and the translation library alike.

Variants name concrete implementations, so a future implementer arrives as a new variant, never as a broadening of an existing one. The enum is the public axis; every answer delegates to the variant’s manifest — a unit struct implementing the crate-internal Manifest contract in the backend’s own module, always compiled, while its kernels sit behind the feature cfg. The enum exists in every build: every question is an answer, not a compile error, so interrogating the stack never needs a cfg.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Accelerate

Apple’s Accelerate framework: cblas_sgemm/cblas_dgemm, executing on the AMX/SME matrix units on Apple Silicon and AVX kernels on Intel Macs, plus vForce for whole-buffer transcendentals. Behind the accelerate feature, macOS only. Leads the gemm chains: it measured ahead of the Metal kernel at every size.

§

Metal

Hand-written simdgroup-matrix GPU kernels for large f32 products and maps (Metal has no f64), compiled from source at first use. Behind the metal feature, macOS only; serves what BLAS declines, and everything large in metal-only builds.

§

Cuda

cuBLAS on an NVIDIA GPU for large f32/f64 products, its libraries bound at run time by dlopen so a machine without them declines instead of failing to build. Behind the cuda feature, Linux only; PCIe copies bound every task, so the threshold is high and residency stays future work.

§

Simd

The matrixmultiply crate’s tuned CPU microkernels with runtime instruction-set dispatch (AVX-512F, AVX2+FMA, AVX, NEON), single-threaded. Behind the simd feature, every platform — the portable rung for Linux and everyone else, and mop-up behind the Apple backends on macOS.

§

Fused

The crate’s own fused kernels for composed formulas, elected onto plans at compile time and executing in-process through the payload seam — windowed_product today. Always compiled, always resident; the only implementer that can meet bit-identity fidelity, because the oracle’s bits live in this process.

§

StableHlo

The StableHLO translation library: elected groups and leaf operations lower into a module a foreign runtime (XLA today) executes. Always compiled, always able to emit; running the module is that runtime’s business, and its kernels answer under the envelope fidelity only.

Implementations§

Source§

impl Backend

Source

pub const ALL: &'static [Backend]

Every implementer this crate version defines.

Source

pub fn coverage(self, formula: Formula) -> Coverage

The coverage matrix: whether this implementer has a kernel for the formula, at what fidelity, for which precisions.

Each row lives in its implementer’s module and answers here through the Manifest contract; offer chains agree with the matrix by test, the plan’s election reads Backend::Fused’s column, and emission reads Backend::StableHlo’s.

Source

pub fn serves(self, formula: Formula, precision: Precision) -> bool

Whether this implementer has a kernel for the formula that accepts tasks at this precision — designed coverage, the same answer in every build; status answers the orthogonal availability question.

Source

pub fn dispatch(self) -> Dispatch

How this implementer’s kernels are reached.

Source

pub fn compiled(self) -> bool

Reports whether this implementer is in this build at all: the build-time half of status, with no lazy setup and no device probe.

Plans key elections on this answer, never on status, so a plan’s shape depends only on the binary, not on which device happens to be plugged in.

Source

pub fn status(self) -> Result<(), BackendUnavailable>

Reports whether this implementer would accept work in this build on this machine, forcing its lazy setup if it has one.

NotCompiled is an ordinary answer, which is what lets a build without the feature ask the question; a loud program asserts readiness at startup with Backend::Accelerate.status().expect(..).

Trait Implementations§

Source§

impl Clone for Backend

Source§

fn clone(&self) -> Backend

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Backend

Source§

impl Debug for Backend

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Backend

Source§

impl PartialEq for Backend

Source§

fn eq(&self, other: &Backend) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Backend

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.