e2m1x2

Struct e2m1x2 

Source
pub struct e2m1x2(/* private fields */);
Expand description

A 4-bit floating point type with 2 exponent bits and 1 mantissa bit. Packed with two elements per value, to allow for conversion to/from bytes. Care must be taken to ensure the shape is adjusted appropriately.

Implementations§

Source§

impl e2m1x2

Source

pub fn from_bits(bits: u8) -> e2m1x2

Create a new e2m1x2 from bits

Source

pub fn from_f32_slice(f32s: &[f32]) -> Vec<e2m1x2>

Create a slice of packed fp4 values from a slice of f32s

Trait Implementations§

Source§

impl Clone for e2m1x2

Source§

fn clone(&self) -> e2m1x2

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl CubeElement for e2m1x2

Source§

fn type_name() -> &'static str

Returns the name of the type.
Source§

fn as_bytes(slice: &[Self]) -> &[u8]

Convert a slice of elements to a slice of bytes.
Source§

fn from_bytes(bytes: &[u8]) -> &[Self]

Convert a slice of bytes to a slice of elements.
Source§

fn cube_type() -> StorageType

Element representation for cubecl.
Source§

fn maximum_value() -> Self

Highest possible value
Source§

fn minimum_value() -> Self

Lowest possible value
Source§

impl CubePrimitive for e2m1x2

Source§

fn as_type_native() -> Option<StorageType>

Return the element type to use on GPU

Source§

fn from_const_value(value: ConstantScalarValue) -> Self

Source§

fn as_type(_scope: &Scope) -> StorageType

Return the element type to use on GPU.
Source§

fn as_type_native_unchecked() -> StorageType

Native or static element type.
Source§

fn size() -> Option<usize>

Only native element types have a size.
Source§

fn size_bits() -> Option<usize>

Only native element types have a size.
Source§

fn size_bits_unchecked() -> usize

Only native element types have a size.
Source§

fn from_expand_elem(elem: ExpandElement) -> Self::ExpandType

Source§

fn into_lit_unchecked(self) -> Self

Source§

fn supported_uses<R: Runtime>(client: &ComputeClient<R>) -> EnumSet<TypeUsage>

Source§

fn type_size() -> u32

Source§

fn type_size_bits() -> u32

Source§

fn packing_factor() -> u32

Source§

fn __expand_type_size(scope: &Scope) -> u32

Source§

fn __expand_type_size_bits(scope: &Scope) -> u32

Source§

fn __expand_packing_factor(scope: &Scope) -> u32

Source§

impl CubeType for e2m1x2

Source§

type ExpandType = ExpandElementTyped<e2m1x2>

Source§

fn into_mut(scope: &mut Scope, expand: Self::ExpandType) -> Self::ExpandType

Wrapper around the init method, necessary to type inference.
Source§

impl Debug for e2m1x2

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for e2m1x2

Source§

fn default() -> e2m1x2

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for e2m1x2

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<e2m1x2, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl ExpandElementIntoMut for e2m1x2

Source§

impl From<e2m1x2> for ExpandElementTyped<e2m1x2>

Source§

fn from(value: e2m1x2) -> Self

Converts to this type from the input type.
Source§

impl From<e2m1x2> for Variable

Source§

fn from(_value: e2m1x2) -> Variable

Converts to this type from the input type.
Source§

impl IntoRuntime for e2m1x2

Source§

fn __expand_runtime_method(self, scope: &mut Scope) -> ExpandElementTyped<Self>

Source§

fn runtime(self) -> Self

Source§

impl PartialEq for e2m1x2

Source§

fn eq(&self, other: &e2m1x2) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for e2m1x2

Source§

fn partial_cmp(&self, other: &e2m1x2) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for e2m1x2

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Zeroable for e2m1x2

Source§

fn zeroed() -> Self

Source§

impl Copy for e2m1x2

Source§

impl Pod for e2m1x2

Source§

impl StructuralPartialEq for e2m1x2

Auto Trait Implementations§

§

impl Freeze for e2m1x2

§

impl RefUnwindSafe for e2m1x2

§

impl Send for e2m1x2

§

impl Sync for e2m1x2

§

impl Unpin for e2m1x2

§

impl UnwindSafe for e2m1x2

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<P> Cast for P
where P: CubePrimitive,

Source§

fn cast_from<From>(_value: From) -> P
where From: CubePrimitive,

Source§

fn __expand_cast_from<From: CubePrimitive>( scope: &mut Scope, value: ExpandElementTyped<From>, ) -> <Self as CubeType>::ExpandType

Source§

impl<T> CheckedBitPattern for T
where T: AnyBitPattern,

Source§

type Bits = T

Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern.
Source§

fn is_valid_bit_pattern(_bits: &T) -> bool

If this function returns true, then it must be valid to reinterpret bits as &Self.
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<P> CubeDebug for P
where P: CubePrimitive,

Source§

fn set_debug_name(&self, scope: &mut Scope, name: &'static str)

Set the debug name of this type’s expansion. Should do nothing for types that don’t appear at runtime
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P> Reinterpret for P
where P: CubePrimitive,

Source§

fn reinterpret<From: CubePrimitive>(value: From) -> Self

Reinterpret the bits of another primitive as this primitive without conversion.
Source§

fn __expand_reinterpret<From: CubePrimitive>( scope: &mut Scope, value: ExpandElementTyped<From>, ) -> <Self as CubeType>::ExpandType

§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> AnyBitPattern for T
where T: Pod,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> NoUninit for T
where T: Pod,