Skip to main content

ruda_driver_wgpu/
lib.rs

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