Skip to main content

cubecl_core/frontend/element/float/
fp6.rs

1use cubecl_common::{e2m3, e3m2};
2use cubecl_ir::{ConstantValue, ElemType, FloatKind, Scope, Type};
3
4use crate::prelude::*;
5
6impl CubeType for e2m3 {
7    type ExpandType = NativeExpand<e2m3>;
8}
9
10impl Scalar for e2m3 {}
11impl CubePrimitive for e2m3 {
12    type Scalar = Self;
13    type Size = Const<1>;
14    type WithScalar<S: Scalar> = S;
15
16    /// Return the element type to use on GPU
17    fn as_type_native() -> Option<Type> {
18        Some(ElemType::Float(FloatKind::E2M3).into())
19    }
20
21    fn from_const_value(_value: ConstantValue) -> Self {
22        unimplemented!("e2m3 doesn't yet support conversion");
23    }
24}
25
26impl IntoRuntime for e2m3 {
27    fn __expand_runtime_method(self, _scope: &mut Scope) -> NativeExpand<Self> {
28        self.into()
29    }
30}
31
32impl NativeAssign for e2m3 {}
33
34impl CubeType for e3m2 {
35    type ExpandType = NativeExpand<e3m2>;
36}
37
38impl Scalar for e3m2 {}
39impl CubePrimitive for e3m2 {
40    type Scalar = Self;
41    type Size = Const<1>;
42    type WithScalar<S: Scalar> = S;
43
44    /// Return the element type to use on GPU
45    fn as_type_native() -> Option<Type> {
46        Some(ElemType::Float(FloatKind::E3M2).into())
47    }
48
49    fn from_const_value(_value: ConstantValue) -> Self {
50        unimplemented!("e3m2 doesn't yet support conversion");
51    }
52}
53
54impl IntoRuntime for e3m2 {
55    fn __expand_runtime_method(self, _scope: &mut Scope) -> NativeExpand<Self> {
56        self.into()
57    }
58}
59
60impl NativeAssign for e3m2 {}