cubecl_core/frontend/element/
uint.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use crate::frontend::{CubeContext, CubePrimitive, CubeType, ExpandElement, Numeric};
use crate::ir::Elem;
use crate::prelude::{KernelBuilder, KernelLauncher};
use crate::Runtime;

use super::{
    init_expand_element, ExpandElementBaseInit, ExpandElementTyped, Init, IntoRuntime,
    LaunchArgExpand, ScalarArgSettings,
};

impl CubeType for u32 {
    type ExpandType = ExpandElementTyped<Self>;
}

impl ExpandElementBaseInit for u32 {
    fn init_elem(context: &mut CubeContext, elem: ExpandElement) -> ExpandElement {
        init_expand_element(context, elem)
    }
}

impl CubePrimitive for u32 {
    fn as_elem() -> Elem {
        Elem::UInt
    }
}

impl IntoRuntime for u32 {
    fn __expand_runtime_method(self, context: &mut CubeContext) -> ExpandElementTyped<Self> {
        let expand: ExpandElementTyped<Self> = self.into();
        Init::init(expand, context)
    }
}

impl LaunchArgExpand for u32 {
    type CompilationArg = ();

    fn expand(_: &Self::CompilationArg, builder: &mut KernelBuilder) -> ExpandElementTyped<Self> {
        builder.scalar(u32::as_elem()).into()
    }
}

impl ScalarArgSettings for u32 {
    fn register<R: Runtime>(&self, settings: &mut KernelLauncher<R>) {
        settings.register_u32(*self);
    }
}

impl Numeric for u32 {
    const MAX: Self = u32::MAX;
    const MIN: Self = u32::MIN;
}