Expand description
Abstract compute backend for GPU-accelerated operations.
The ComputeBackend trait defines the interface for GPU computation,
allowing higher-level crates (SciRS2, oxionnx, ToRSh, TrustformeRS)
to use GPU acceleration without coupling to specific GPU APIs.
§Architecture
┌─────────────────────────────┐
│ SciRS2 / ToRSh / oxionnx │
│ (consumers) │
└─────────────┬───────────────┘
│ dyn ComputeBackend
┌─────────────▼───────────────┐
│ BackendRegistry (select) │
│ ComputeBackend │
│ (trait definition) │
└─────────────┬───────────────┘
│
┌─────────────▼───────────────┐
│ CudaBackend / MetalBackend │
│ CpuBackend / NullBackend │
│ (concrete impls) │
└─────────────────────────────┘§Beyond the trait
This crate also ships the host-side control plane that turns the bare trait into a usable multi-backend abstraction layer:
BackendKind— names every backend and ranks them by preference.BackendRegistry— registers backends, probes availability, and does capability-based selection plus GPU→CPUfallback chains.Capabilities/DeviceInfo— per-backend feature and device discovery.CpuBackend— a genuinely-working pure-Rust reference backend (the always-available fallback and the numerical reference for conformance).NullBackend— a scaffold that refuses every op, for testing dispatch.
None of the control-plane logic touches a GPU, so it is fully testable on a machine with no accelerator.
Structs§
- Backend
Entry - A backend known to the registry, plus the runtime facts needed to pick it.
- Backend
Registry - A registry of compute backends with capability-aware selection.
- Capabilities
- Per-backend capability report.
- CpuBackend
- Pure-Rust host backend. Always available; never touches a GPU.
- Device
Info - A single device exposed by a backend, in a backend-agnostic shape.
- Null
Backend - A no-op backend whose operations all return
BackendError::Unsupported. - Selection
Request - Required-feature predicate used to filter backends during selection.
- Tile
Shape - A GEMM tile-shape hint
(tile_m, tile_n, tile_k)returned byComputeBackend::recommended_tile_for.
Enums§
- Backend
Error - Error type for backend operations.
- Backend
Kind - One of the concrete compute backends OxiCUDA targets.
- Backend
Transpose - Transpose mode for matrix operations.
- Binary
Op - Element-wise binary operation.
- Memory
Kind - Memory-type classification, abstracting each backend’s notion of where
a buffer physically lives. Used by
DeviceInfoand cross-backend transfer planning. - Mixed
Precision - Reduced-precision input storage format for a mixed-precision GEMM.
- OpClass
- Routable operation classes used by
BackendRegistry::route. - Reduce
Op - Reduction operation applied along an axis.
- UnaryOp
- Element-wise unary operation.
Traits§
- Compute
Backend - Abstract compute backend trait.
Functions§
- default_
tile_ for - Default tile heuristic shared by the trait’s
recommended_tile_for: small problems get a small tile (less wasted compute on the fringe), large problems get the canonical 128×128×8 tile, mid-size gets 64×64×16. - round_
to_ bf16 - Round an
f32to bfloat16 storage and return the resultingf32. - round_
to_ f16 - Round an
f32to IEEE-754 binary16 storage and return the resultingf32.
Type Aliases§
- Backend
Result - Result type for backend operations.