Skip to main content

cubecl_wgpu/
lib.rs

1#[macro_use]
2extern crate derive_new;
3
4extern crate alloc;
5
6mod backend;
7mod compiler;
8mod compute;
9mod device;
10mod element;
11mod graphics;
12mod runtime;
13
14pub use compiler::base::*;
15pub use compute::*;
16pub use device::*;
17pub use element::*;
18pub use graphics::*;
19pub use runtime::*;
20
21#[cfg(feature = "spirv")]
22pub use backend::vulkan;
23
24#[cfg(all(feature = "msl", target_os = "macos"))]
25pub use backend::metal;
26
27#[cfg(all(test, not(feature = "spirv"), not(feature = "msl")))]
28#[allow(unexpected_cfgs)]
29mod tests {
30    pub type TestRuntime = crate::WgpuRuntime;
31    use half::f16;
32
33    // Include 64-bit types (i64, u64) for WGSL as wgpu supports them. These don't exist on
34    // native WebGPU however.
35    //
36    // Also include f16, this is an extension but supported by wgpu and WebGPU.
37    cubecl_core::testgen_all!(f32: [f16, f32], i32: [i32, i64], u32: [u32, u64]);
38    cubecl_std::testgen!();
39    cubecl_std::testgen_tensor_identity!([flex32, f32, u32]);
40    cubecl_std::testgen_quantized_view!(f32);
41}
42
43#[cfg(all(test, feature = "spirv"))]
44#[allow(unexpected_cfgs)]
45mod tests_spirv {
46    pub type TestRuntime = crate::WgpuRuntime;
47    use cubecl_core::flex32;
48    use half::f16;
49
50    cubecl_core::testgen_all!(f32: [f16, flex32, f32], i32: [i8, i16, i32, i64], u32: [u8, u16, u32, u64]);
51    cubecl_std::testgen!();
52    cubecl_std::testgen_tensor_identity!([f16, flex32, f32, u32]);
53    cubecl_std::testgen_quantized_view!(f16);
54}
55
56#[cfg(all(test, feature = "msl"))]
57#[allow(unexpected_cfgs)]
58mod tests_msl {
59    pub type TestRuntime = crate::WgpuRuntime;
60    use half::f16;
61
62    cubecl_core::testgen_all!(f32: [f16, f32], i32: [i16, i32], u32: [u16, u32]);
63    cubecl_std::testgen!();
64    cubecl_std::testgen_tensor_identity!([f16, flex32, f32, u32]);
65    cubecl_std::testgen_quantized_view!(f16);
66}