#[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
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
impl Backend
Sourcepub fn coverage(self, formula: Formula) -> Coverage
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.
Sourcepub fn serves(self, formula: Formula, precision: Precision) -> bool
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.
Sourcepub fn compiled(self) -> bool
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.
Sourcepub fn status(self) -> Result<(), BackendUnavailable>
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(..).