Skip to content

Commit

Permalink
fix: place ug dep behind not wasm32 flag (#2760)
Browse files Browse the repository at this point in the history
* place `ug` behind not wasm32 attr

so that wasm32 can compile

* mv `ug` to conditional target dep

assuming every non-wasm32 user wants this
  • Loading branch information
DougAnderson444 authored Feb 1, 2025
1 parent 4301753 commit 0af3e42
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
7 changes: 4 additions & 3 deletions candle-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ accelerate-src = { workspace = true, optional = true }
byteorder = { workspace = true }
candle-kernels = { workspace = true, optional = true }
candle-metal-kernels = { workspace = true, optional = true }
metal = { workspace = true, optional = true}
metal = { workspace = true, optional = true }
cudarc = { workspace = true, optional = true }
gemm = { workspace = true }
half = { workspace = true }
Expand All @@ -28,18 +28,19 @@ rand_distr = { workspace = true }
rayon = { workspace = true }
safetensors = { workspace = true }
thiserror = { workspace = true }
ug = { workspace = true }
ug-cuda = { workspace = true, optional = true }
ug-metal = { workspace = true, optional = true }
yoke = { workspace = true }
zip = { workspace = true }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
ug = { workspace = true }

[dev-dependencies]
anyhow = { workspace = true }
clap = { workspace = true }
criterion = { workspace = true }


[features]
default = []
cuda = ["cudarc", "dep:candle-kernels", "dep:ug-cuda"]
Expand Down
1 change: 1 addition & 0 deletions candle-core/src/cuda_backend/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ impl CudaDevice {
self.device.clone()
}

#[cfg(not(target_arch = "wasm32"))]
pub fn compile(
&self,
func_name: &'static str,
Expand Down
1 change: 1 addition & 0 deletions candle-core/src/custom_op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ pub struct UgIOp1 {

impl UgIOp1 {
#[allow(unused)]
#[cfg(not(target_arch = "wasm32"))]
pub fn new(
name: &'static str,
kernel: ug::lang::ssa::Kernel,
Expand Down
1 change: 1 addition & 0 deletions candle-core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ pub enum Error {
#[error("Metal error {0}")]
Metal(#[from] MetalError),

#[cfg(not(target_arch = "wasm32"))]
#[error(transparent)]
Ug(#[from] ug::Error),

Expand Down
1 change: 1 addition & 0 deletions candle-core/src/metal_backend/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ impl std::ops::Deref for MetalDevice {
}

impl MetalDevice {
#[cfg(not(target_arch = "wasm32"))]
pub fn compile(
&self,
func_name: &'static str,
Expand Down

0 comments on commit 0af3e42

Please sign in to comment.