cubecl_wgpu/
element.rs

1use crate::compiler::wgsl;
2
3/// The base element trait for the wgpu backend.
4pub trait WgpuElement {
5    fn wgpu_elem() -> wgsl::Elem;
6}
7
8/// The float element type for the wgpu backend.
9pub trait FloatElement: WgpuElement {}
10
11/// The int element type for the wgpu backend.
12pub trait IntElement: WgpuElement {}
13
14impl WgpuElement for u32 {
15    fn wgpu_elem() -> wgsl::Elem {
16        wgsl::Elem::U32
17    }
18}
19
20impl WgpuElement for i32 {
21    fn wgpu_elem() -> wgsl::Elem {
22        wgsl::Elem::I32
23    }
24}
25
26impl WgpuElement for f32 {
27    fn wgpu_elem() -> wgsl::Elem {
28        wgsl::Elem::F32
29    }
30}
31
32impl FloatElement for f32 {}
33impl IntElement for i32 {}