Skip to content

Latest commit

 

History

348 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AppleAccelerate.jl

CI Coverage Docs JuliaHub License: MIT Julia compat

A Julia interface to Apple's Accelerate framework, providing:

  • Vectorized array operations via vDSP and vForce — element-wise math, reductions, compound arithmetic, clipping, interpolation — 2–19× faster than Base Julia for transcendentals (sin, cos, exp, log)
  • Dense linear algebra — all of LinearAlgebra (lu, qr, svd, cholesky, eigen, …) accelerated transparently via libblastrampoline6–13× faster single-threaded GEMM than OpenBLAS on Apple Silicon (SME/AMX co-processor), plus 2–4× faster factorizations and solves
  • Sparse linear algebra via libSparse — direct (Cholesky / LDLᵀ / LU / QR) and iterative (CG / GMRES / LSMR) solvers, real and complex
  • Signal processing — 1D/2D real & complex FFT (batched, mixed-radix), DCT, convolution, biquad filtering, window functions; cached setups make no-plan fft(x) competitive with FFTW and drop the FFTW dependency
  • Neural-network primitives via BNNS — Float32 matrix multiply and pointwise activations
  • Image processing via vImage — geometry (scale, rotate, affine warp), convolution, morphology, histogram, alpha compositing, and format/colorspace conversion (incl. Y′CbCr)

See the benchmarks for full performance comparisons and methodology.

Installation

Requires macOS 13.4+ and Julia 1.10+.

using Pkg
Pkg.add("AppleAccelerate")

Quick start

One self-contained, copy-pasteable example per subsystem. Every function lives under the AppleAccelerate. prefix — the package intentionally exports nothing, so it never shadows Base/LinearAlgebra.

Dense linear algebra — all of LinearAlgebra accelerated transparently via LBT

using AppleAccelerate, LinearAlgebra
A = randn(1000, 1000)
F = lu(A)                                       # BLAS/LAPACK routed to Accelerate

Vectorized elementwise math (vForce / vDSP)

using AppleAccelerate
X = randn(10_000)
Y = AppleAccelerate.exp(X)                      # also sin, cos, log, sqrt, tanh, …
AppleAccelerate.sincos(X)                       # fused, both results in one pass

Signal processing — FFT / DCT / convolution / biquad filtering

using AppleAccelerate
x = randn(ComplexF64, 1024)
X = AppleAccelerate.fft(x)                      # cached setup; also rfft, fft2d, dct

Complex vector operations (split-complex vDSP)

using AppleAccelerate
z = randn(ComplexF64, 1000)
mags = AppleAccelerate.vmags(z)                 # squared magnitudes (abs2)
ang  = AppleAccelerate.vphase(z)                # phase angles

Sparse solvers (libSparse) — direct Cholesky / LDLᵀ / LU / QR and iterative CG / GMRES / LSMR

using AppleAccelerate, LinearAlgebra, SparseArrays
S = sprandn(500, 500, 0.01); S = S*S' + 500I    # symmetric positive-definite
As = AppleAccelerate.AASparseMatrix(SparseMatrixCSC{Float64,Int64}(S))
xs = AppleAccelerate.solve(AppleAccelerate.cholesky(As), randn(500))

Neural-network primitives (BNNS) — reductions & top-k

using AppleAccelerate
logits = randn(Float32, 4, 6)                                 # 4 classes × 6 samples
sums      = AppleAccelerate.bnns_reduce(:sum, logits; dim = 1)  # column-wise reduction
vals, idx = AppleAccelerate.bnns_topk(logits, 2; dim = 1)       # top-2 classes per sample

Image processing (vImage)

using AppleAccelerate
img   = rand(Float32, 64, 48)                        # a 64×48 planar (grayscale) image
small = AppleAccelerate.scale_PlanarF(img, 32, 24)   # resize to 32×24
flip  = AppleAccelerate.horizontalReflect_PlanarF(img)

Documentation

See the full documentation for the complete API reference.

About

Julia interface to the macOS Accelerate framework

Topics

Resources

Stars

123 stars

Watchers

8 watching

Forks

Releases

Used by

Contributors

Languages