Skip to main content

cubecl_utils_rs/
traits.rs

1//! Shared trait bounds for element-generic kernels.
2
3use cubecl::frontend::{CubePrimitive, Float};
4use cubecl::CubeElement;
5
6/// Float bound for kernels and tensors generic over the element type.
7///
8/// Blanket-implemented, so it is a naming convenience rather than a
9/// restriction: any type CubeCL already accepts as a float element satisfies
10/// it.
11///
12/// ### Note
13///
14/// `f64` satisfies this bound but is not universally available. WGSL has no
15/// 64-bit float at all, so an `f64` kernel compiles here and then fails on the
16/// wgpu backend; only the CUDA and HIP runtimes support it. Code that is
17/// generic over the element type still needs to account for the element size
18/// when it budgets shared memory or a binding.
19pub trait CubeclFloat: Float + CubePrimitive + CubeElement {}
20
21impl<T> CubeclFloat for T where T: Float + CubePrimitive + CubeElement {}