Skip to content

armgit / uzu

Public Imported from GitHub
0

A high-performance inference engine for AI models

start unmetaling (#84)

uuuvn648fbf099e6e
diff --git a/crates/uzu/Cargo.toml b/crates/uzu/Cargo.toml
index e68a2ee77..30294356c 100644
--- a/crates/uzu/Cargo.toml
+++ b/crates/uzu/Cargo.toml
@@ -13,10 +13,6 @@ serde_json.workspace = true
thiserror.workspace = true
tokenizers.workspace = true
mpsgraph.workspace = true
-objc2.workspace = true
-objc2-foundation.workspace = true
-metal.workspace = true
-block.workspace = true
bytemuck.workspace = true
num-traits.workspace = true
regex.workspace = true
@@ -30,6 +26,17 @@ sysinfo.workspace = true
itertools.workspace = true
schemars.workspace = true
+# metal feature requires objc2, block (for callbacks) and metal
+objc2 = { workspace = true, optional = true}
+objc2-foundation = { workspace = true, optional = true}
+block = { workspace = true, optional = true }
+metal = { workspace = true, optional = true }
+
+# macos requires objc2 even on non-metal (but shouldn't)
+[target.'cfg(target_os = "macos")'.dependencies]
+objc2.workspace = true
+objc2-foundation.workspace = true
+
[dev-dependencies]
is_close.workspace = true
serde_json5.workspace = true
@@ -45,7 +52,6 @@ depfile.workspace = true
tempfile.workspace = true
serde.workspace = true
serde_json.workspace = true
-clang-ast.workspace = true
futures.workspace = true
tokio.workspace = true
blake3.workspace = true
@@ -55,10 +61,13 @@ syn.workspace = true
prettyplease.workspace = true
itertools.workspace = true
+# metal feature requires clang-ast
+clang-ast = { workspace = true, optional = true }
+
[features]
default = ["metal"]
-metal = []
+metal = ["dep:clang-ast", "dep:objc2", "dep:objc2-foundation", "dep:block", "dep:metal"]
metal-nax = []
tracing = []
diff --git a/crates/uzu/build/main.rs b/crates/uzu/build/main.rs
index 918d1228e..ffd77191c 100644
--- a/crates/uzu/build/main.rs
+++ b/crates/uzu/build/main.rs
@@ -3,9 +3,11 @@ use std::{env, fs, path::PathBuf};
use anyhow::Context;
mod common;
-mod metal;
mod shared_types;
+#[cfg(feature = "metal")]
+mod metal;
+
use common::compiler::Compiler;
use common::envs;
use futures::future::try_join_all;
@@ -38,10 +40,10 @@ async fn main() -> anyhow::Result<()> {
let mut compilers: Vec<Box<dyn Compiler>> = Vec::new();
- if cfg!(feature = "metal") {
- compilers.push(Box::new(metal::MetalCompiler::new()?));
- compilers.push(Box::new(shared_types::SharedTypesCompiler::new()?));
- }
+ compilers.push(Box::new(shared_types::SharedTypesCompiler::new()?));
+
+ #[cfg(feature = "metal")]
+ compilers.push(Box::new(metal::MetalCompiler::new()?));
try_join_all(compilers.iter().map(|c| c.build())).await?;