C+
Packages · View as Markdown
v0.0.27 is a macOS / AppKit release. That is the supported path. Other platforms are not recommended; wait for a later version.

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 (cblas_sdot, cblas_ddot, cblas_saxpy, cblas_daxpy, cblas_sscal, cblas_sgemv, cblas_dgemv, cblas_sgemm, cblas_dgemm, and more). Layout and transpose are passed as i32 flags read from the CblasRowMajor() / CblasColMajor() and CblasNoTrans() / CblasTrans() / CblasConjTrans() helpers.
  • accelerate/v_dsp — element-wise operations and reductions: vDSP_vadd, vDSP_vmul, vDSP_vsmul, vDSP_dotpr, vDSP_meanv, vDSP_maxv, and their D-suffixed (f64) variants (vDSP_vaddD, and so on).
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::cblas_sdot(
    3 as i32,
    #addr_of(x) as *f32, 1 as i32,
    #addr_of(y) as *f32, 1 as i32,
);   // 32.0