Merge pull request #91 from tazz4843/metal-feature-flag
Add a feature flag for Metal acceleration support
This commit is contained in:
commit
73e33a182c
3 changed files with 15 additions and 0 deletions
|
|
@ -27,6 +27,7 @@ coreml = ["whisper-rs-sys/coreml"]
|
|||
cuda = ["whisper-rs-sys/cuda"]
|
||||
opencl = ["whisper-rs-sys/opencl"]
|
||||
openblas = ["whisper-rs-sys/openblas"]
|
||||
metal = ["whisper-rs-sys/metal"]
|
||||
test-with-tiny-model = []
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ coreml = []
|
|||
cuda = []
|
||||
opencl = []
|
||||
openblas = []
|
||||
metal = []
|
||||
|
||||
[build-dependencies]
|
||||
cmake = "0.1"
|
||||
|
|
|
|||
13
sys/build.rs
13
sys/build.rs
|
|
@ -20,6 +20,12 @@ fn main() {
|
|||
println!("cargo:rustc-link-lib=framework=Foundation");
|
||||
println!("cargo:rustc-link-lib=framework=CoreML");
|
||||
}
|
||||
#[cfg(feature = "metal")]
|
||||
{
|
||||
println!("cargo:rustc-link-lib=framework=Foundation");
|
||||
println!("cargo:rustc-link-lib=framework=Metal");
|
||||
println!("cargo:rustc-link-lib=framework=MetalKit");
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "coreml")]
|
||||
|
|
@ -125,6 +131,13 @@ fn main() {
|
|||
config.define("WHISPER_CLBLAST", "ON");
|
||||
}
|
||||
|
||||
if cfg!(feature = "metal") {
|
||||
config.define("WHISPER_METAL", "ON");
|
||||
} else {
|
||||
// Metal is enabled by default, so we need to explicitly disable it
|
||||
config.define("WHISPER_METAL", "OFF");
|
||||
}
|
||||
|
||||
let destination = config.build();
|
||||
|
||||
if env::var("TARGET").unwrap().contains("window") {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue