Add a feature flag for Metal acceleration support
This commit is contained in:
parent
7dac364460
commit
253ac1bb6f
3 changed files with 17 additions and 0 deletions
|
|
@ -27,6 +27,7 @@ coreml = ["whisper-rs-sys/coreml"]
|
||||||
cuda = ["whisper-rs-sys/cuda"]
|
cuda = ["whisper-rs-sys/cuda"]
|
||||||
opencl = ["whisper-rs-sys/opencl"]
|
opencl = ["whisper-rs-sys/opencl"]
|
||||||
openblas = ["whisper-rs-sys/openblas"]
|
openblas = ["whisper-rs-sys/openblas"]
|
||||||
|
metal = ["whisper-rs-sys/metal"]
|
||||||
test-with-tiny-model = []
|
test-with-tiny-model = []
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ coreml = []
|
||||||
cuda = []
|
cuda = []
|
||||||
opencl = []
|
opencl = []
|
||||||
openblas = []
|
openblas = []
|
||||||
|
metal = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
||||||
|
|
|
||||||
15
sys/build.rs
15
sys/build.rs
|
|
@ -20,6 +20,12 @@ fn main() {
|
||||||
println!("cargo:rustc-link-lib=framework=Foundation");
|
println!("cargo:rustc-link-lib=framework=Foundation");
|
||||||
println!("cargo:rustc-link-lib=framework=CoreML");
|
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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("cargo:rustc-link-search={}", env::var("OUT_DIR").unwrap());
|
println!("cargo:rustc-link-search={}", env::var("OUT_DIR").unwrap());
|
||||||
|
|
@ -119,6 +125,15 @@ fn main() {
|
||||||
#[cfg(feature = "opencl")]
|
#[cfg(feature = "opencl")]
|
||||||
cmd.arg("-DWHISPER_CLBLAST=ON");
|
cmd.arg("-DWHISPER_CLBLAST=ON");
|
||||||
|
|
||||||
|
cfg_if! {
|
||||||
|
if #[cfg(feature = "metal")] {
|
||||||
|
cmd.arg("-DWHISPER_METAL=ON");
|
||||||
|
} else {
|
||||||
|
// Metal is enabled by default so we need to explicitly disable it
|
||||||
|
cmd.arg("-DWHISPER_METAL=OFF");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
cmd.arg("-DCMAKE_POSITION_INDEPENDENT_CODE=ON");
|
cmd.arg("-DCMAKE_POSITION_INDEPENDENT_CODE=ON");
|
||||||
|
|
||||||
let code = cmd
|
let code = cmd
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue