Expand description
Injectable CPU linear-algebra kernels.
A CpuLinalgKernels implementation replaces tenferro-linalg’s built-in
faer/LAPACK kernels op by op on one CPU backend. Install it with
install_linalg_kernels on a CpuProviderBundleBuilder; the CPU
session then asks it first for every primitive it dispatches (Cholesky,
triangular solve, LU and full-pivot LU, solve, SVD, QR and rank-revealing
QR, eigh, eig, and their value-only forms, including the _read
variants). A method returns CpuLinalgOutcome::Unsupported, its default,
before producing anything, and the built-in kernel runs instead. The
Householder family, lu_factor and prepared LU solves, and _into
outputs always use the built-in kernels. Composites (det, slogdet, inv, lstsq, pinv,
norms) are built from the primitives and follow them.
A kernel runs inside the session’s entered CpuExecutionContext on host
operands and must return exactly what the built-in kernel returns for the
same input: the same outputs in the same order, shapes, dtypes, pivot and
ordering conventions, and batch handling (trailing batch axes). It may run
in parallel only in tenferro_cpu::ParallelMode::Inner, within
thread_budget(), on the context’s pool
(CpuExecutionContext::rayon_pool).
§Examples
use std::sync::Arc;
use tenferro_cpu::{CpuBackendKind, CpuProviderBundle};
use tenferro_linalg::cpu_kernels::{install_linalg_kernels, CpuLinalgKernels, CpuLinalgKernelsSlot};
/// Declines everything, so the built-in kernels run.
#[derive(Debug)]
struct Nothing;
impl CpuLinalgKernels for Nothing {}
let builder = CpuProviderBundle::builder(CpuBackendKind::default_compiled());
let bundle = install_linalg_kernels(builder, Arc::new(Nothing)).build()?;
// Install with `CpuBackend::with_provider_bundle` (a faer backend; explicit
// bundles on the BLAS kind are rejected because BLAS threading is not
// enforceable).
assert!(bundle.extension::<CpuLinalgKernelsSlot>().is_some());Structs§
- CpuLinalg
Kernels Slot - The provider-bundle extension that carries a
CpuLinalgKernels. - Triangular
Solve Options - Flags of a triangular solve (
op(A) X = BorX op(A) = B).
Enums§
- CpuLinalg
Outcome - Result of a
CpuLinalgKernelscall.
Traits§
- CpuLinalg
Kernels - Replacement CPU linear-algebra kernels. Every method defaults to
CpuLinalgOutcome::Unsupported; implement the ones the provider handles. See the module documentation for the contract.
Functions§
- install_
linalg_ kernels - Install
kernelson a provider bundle under construction.