cubecl_core/frontend/element/float/
fp4.rs

1use cubecl_common::e2m1;
2use cubecl_ir::{Elem, ExpandElement, FloatKind, Scope};
3
4use crate::prelude::{
5    CubePrimitive, CubeType, ExpandElementIntoMut, ExpandElementTyped, IntoRuntime,
6    into_mut_expand_element, into_runtime_expand_element,
7};
8
9impl CubeType for e2m1 {
10    type ExpandType = ExpandElementTyped<e2m1>;
11}
12
13impl CubePrimitive for e2m1 {
14    /// Return the element type to use on GPU
15    fn as_elem_native() -> Option<Elem> {
16        Some(Elem::Float(FloatKind::E2M1))
17    }
18}
19
20impl IntoRuntime for e2m1 {
21    fn __expand_runtime_method(self, scope: &mut Scope) -> ExpandElementTyped<Self> {
22        let elem: ExpandElementTyped<Self> = self.into();
23        into_runtime_expand_element(scope, elem).into()
24    }
25}
26
27impl ExpandElementIntoMut for e2m1 {
28    fn elem_into_mut(scope: &mut Scope, elem: ExpandElement) -> ExpandElement {
29        into_mut_expand_element(scope, elem)
30    }
31}