cubecl_core::frontend

Trait Numeric

Source
pub trait Numeric:
    Copy
    + Abs
    + Max
    + Min
    + Clamp
    + Remainder
    + Vectorized
    + CubePrimitive
    + LaunchArgExpand<CompilationArg = ()>
    + ScalarArgSettings
    + ExpandElementBaseInit
    + Into<ExpandElementTyped<Self>>
    + CubeIndexMut<u32, Output = Self>
    + CubeIndexMut<ExpandElementTyped<u32>, Output = Self>
    + NumCast
    + AddAssign
    + SubAssign
    + MulAssign
    + DivAssign
    + Add<Output = Self>
    + Sub<Output = Self>
    + Mul<Output = Self>
    + Div<Output = Self>
    + PartialOrd
    + PartialEq {
    const MAX: Self;
    const MIN: Self;

    // Provided methods
    fn from_int(val: i64) -> Self { ... }
    fn from_vec<const D: usize>(_vec: [u32; D]) -> Self { ... }
    fn __expand_from_int(
        _context: &mut CubeContext,
        val: ExpandElementTyped<i64>,
    ) -> <Self as CubeType>::ExpandType { ... }
    fn __expand_from_vec<const D: usize>(
        context: &mut CubeContext,
        vec: [u32; D],
    ) -> <Self as CubeType>::ExpandType { ... }
}
Expand description

Type that encompasses both (unsigned or signed) integers and floats Used in kernels that should work for both.

Required Associated Constants§

Source

const MAX: Self

Source

const MIN: Self

Provided Methods§

Source

fn from_int(val: i64) -> Self

Create a new constant numeric.

Note: since this must work for both integer and float only the less expressive of both can be created (int) If a number with decimals is needed, use Float::new.

This method panics when unexpanded. For creating an element with a val, use the new method of the sub type.

Source

fn from_vec<const D: usize>(_vec: [u32; D]) -> Self

Source

fn __expand_from_int( _context: &mut CubeContext, val: ExpandElementTyped<i64>, ) -> <Self as CubeType>::ExpandType

Source

fn __expand_from_vec<const D: usize>( context: &mut CubeContext, vec: [u32; D], ) -> <Self as CubeType>::ExpandType

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Numeric for f32

Source§

const MAX: Self = 3.40282347E+38f32

Source§

const MIN: Self = -3.40282347E+38f32

Source§

impl Numeric for f64

Source§

const MAX: Self = 1.7976931348623157E+308f64

Source§

const MIN: Self = -1.7976931348623157E+308f64

Source§

impl Numeric for i32

Source§

const MAX: Self = 2_147_483_647i32

Source§

const MIN: Self = -2_147_483_648i32

Source§

impl Numeric for i64

Source§

const MAX: Self = 9_223_372_036_854_775_807i64

Source§

const MIN: Self = -9_223_372_036_854_775_808i64

Source§

impl Numeric for u32

Source§

const MAX: Self = 4_294_967_295u32

Source§

const MIN: Self = 0u32

Source§

impl Numeric for bf16

Source§

const MAX: Self = bf16::MAX

Source§

const MIN: Self = bf16::MIN

Source§

impl Numeric for f16

Source§

const MAX: Self = f16::MAX

Source§

const MIN: Self = f16::MIN

Implementors§