Skip to content

Commit

Permalink
Add accelerate framework support for burn-ndarray (#183) (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
antimora authored Feb 28, 2023
1 parent 9df3b6a commit c510e8b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions burn-ndarray/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ std = [
"ndarray/matrixmultiply-threading",
]

blas-accelerate = ["ndarray/blas", "blas-src/accelerate"] # Accelerate framework (macOS only)
blas-netlib = ["ndarray/blas", "blas-src/netlib"]
blas-openblas = ["ndarray/blas", "blas-src/openblas", "openblas-src"]
blas-openblas-system = [
Expand Down
6 changes: 6 additions & 0 deletions burn-ndarray/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fn main() {
// https://github.com/rust-ndarray/ndarray/issues/1197
if cfg!(feature = "blas-accelerate") {
println!("cargo:rustc-link-lib=framework=Accelerate");
}
}
1 change: 1 addition & 0 deletions examples/mnist/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ default = []
tch-cpu = ["dep:burn-tch"]
tch-gpu = ["dep:burn-tch"]
ndarray = ["burn-ndarray"]
ndarray-blas-accelerate = ["burn-ndarray/blas-accelerate"]
ndarray-blas-netlib = ["burn-ndarray/blas-netlib"]
ndarray-blas-openblas = ["burn-ndarray/blas-openblas"]

Expand Down
2 changes: 2 additions & 0 deletions examples/mnist/examples/mnist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
feature = "ndarray",
feature = "ndarray-blas-netlib",
feature = "ndarray-blas-openblas",
feature = "ndarray-blas-accelerate",
))]
mod ndarray {
use burn_autodiff::ADBackendDecorator;
Expand Down Expand Up @@ -46,6 +47,7 @@ fn main() {
feature = "ndarray",
feature = "ndarray-blas-netlib",
feature = "ndarray-blas-openblas",
feature = "ndarray-blas-accelerate",
))]
ndarray::run();
#[cfg(feature = "tch-gpu")]
Expand Down

0 comments on commit c510e8b

Please sign in to comment.