C+
Packages · v0.0.13

accelerate

Bindings to Apple's Accelerate.framework: pre-tuned CPU numerics that already ship in every macOS binary. This is the "no GPU available" fallback path for matmul, matvec, dot, and axpy, and the reference implementation when GPU results need checking.

Two sub-modules:

  • accelerate/cblas — BLAS Level 1 / 2 / 3 (sdot, ddot, saxpy, daxpy, sscal, sgemv, dgemv, sgemm, dgemm, and more), with typed Order (RowMajor / ColMajor) and Transpose (NoTrans / Trans / ConjTrans) enums.
  • accelerate/vdsp — element-wise operations and reductions: vadd, vmul, vsmul, dotpr, meanv, maxv, and their _d (f64) variants.
import "accelerate/cblas" as cblas;

let x: [f32; 3] = [1.0f32, 2.0f32, 3.0f32];
let y: [f32; 3] = [4.0f32, 5.0f32, 6.0f32];
let dot: f32 = cblas::sdot(
    3 as i32,
    unsafe { #addr_of(x) as *f32 }, 1 as i32,
    unsafe { #addr_of(y) as *f32 }, 1 as i32,
);   // 32.0