Skip to main content

ScalarDType

Enum ScalarDType 

Source
pub enum ScalarDType {
Show 17 variants Bool = 0, Int8 = 1, UInt8 = 2, Int16 = 3, UInt16 = 4, Int32 = 5, UInt32 = 6, Int64 = 7, UInt64 = 8, FP8E4M3 = 9, FP8E5M2 = 10, Float16 = 11, BFloat16 = 12, Float32 = 13, Float64 = 14, Void = 15, Index = 16,
}
Expand description

Scalar data types (base numeric types).

Variants§

§

Bool = 0

§

Int8 = 1

§

UInt8 = 2

§

Int16 = 3

§

UInt16 = 4

§

Int32 = 5

§

UInt32 = 6

§

Int64 = 7

§

UInt64 = 8

§

FP8E4M3 = 9

§

FP8E5M2 = 10

§

Float16 = 11

§

BFloat16 = 12

§

Float32 = 13

§

Float64 = 14

§

Void = 15

Void type for metadata operations (no data).

§

Index = 16

Index type for array indexing and loop iteration.

Implementations§

Source§

impl ScalarDType

Source

pub fn can_safe_cast(self, to: Self) -> bool

Check if casting from from to to is safe (preserves value).

Source§

impl ScalarDType

Source

pub const fn from_repr(discriminant: usize) -> Option<ScalarDType>

Try to create Self from the raw representation

Source§

impl ScalarDType

Source

pub const fn bytes(&self) -> usize

Source

pub const fn is_bool(&self) -> bool

Source

pub const fn is_signed(&self) -> bool

Source

pub const fn is_unsigned(&self) -> bool

Source

pub const fn is_int(&self) -> bool

Source

pub const fn is_float(&self) -> bool

Source

pub const fn is_fp8(&self) -> bool

Source

pub const fn min_value(&self) -> f64

Source

pub const fn max_value(&self) -> f64

Source

pub const fn c_style(&self) -> &'static str

Source

pub const fn min_positive(&self) -> f64

Source

pub const fn finfo(&self) -> (u32, u32)

(exponent_bits, mantissa_bits) for float types. Matches Tinygrad’s dtypes.finfo().

Source

pub const fn exponent_bias(&self) -> i32

Exponent bias: (1 << (exp_bits - 1)) - 1.

Source

pub const fn float_to_uint(&self) -> ScalarDType

Map float dtype to uint storage equivalent of the same bit width.

Source

pub const fn bitsize(&self) -> u32

Bit size of this scalar type.

Source

pub const fn vec(self, count: usize) -> DType

Create a vector DType from this scalar type.

Trait Implementations§

Source§

impl Arbitrary for ScalarDType

Source§

type Parameters = ()

The type of parameters that arbitrary_with accepts for configuration of the generated Strategy. Parameters must implement Default.
Source§

type Strategy = TupleUnion<((u32, Arc<fn() -> ScalarDType>), (u32, Arc<fn() -> ScalarDType>), (u32, Arc<fn() -> ScalarDType>), (u32, Arc<fn() -> ScalarDType>), (u32, Arc<fn() -> ScalarDType>), (u32, Arc<fn() -> ScalarDType>), (u32, Arc<fn() -> ScalarDType>), (u32, Arc<fn() -> ScalarDType>), (u32, Arc<fn() -> ScalarDType>), (u32, Arc<TupleUnion<((u32, Arc<fn() -> ScalarDType>), (u32, Arc<fn() -> ScalarDType>), (u32, Arc<fn() -> ScalarDType>), (u32, Arc<fn() -> ScalarDType>), (u32, Arc<fn() -> ScalarDType>), (u32, Arc<fn() -> ScalarDType>), (u32, Arc<fn() -> ScalarDType>), (u32, Arc<fn() -> ScalarDType>))>>))>

The type of Strategy used to generate values of type Self.
Source§

fn arbitrary_with(_top: Self::Parameters) -> Self::Strategy

Generates a Strategy for producing arbitrary values of type the implementing type (Self). The strategy is passed the arguments given in args. Read more
Source§

fn arbitrary() -> Self::Strategy

Generates a Strategy for producing arbitrary values of type the implementing type (Self). Read more
Source§

impl<O: Into<EnumSet<ScalarDType>>> BitAnd<O> for ScalarDType

Source§

type Output = EnumSet<ScalarDType>

The resulting type after applying the & operator.
Source§

fn bitand(self, other: O) -> Self::Output

Performs the & operation. Read more
Source§

impl<O: Into<EnumSet<ScalarDType>>> BitOr<O> for ScalarDType

Source§

type Output = EnumSet<ScalarDType>

The resulting type after applying the | operator.
Source§

fn bitor(self, other: O) -> Self::Output

Performs the | operation. Read more
Source§

impl<O: Into<EnumSet<ScalarDType>>> BitXor<O> for ScalarDType

Source§

type Output = EnumSet<ScalarDType>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, other: O) -> Self::Output

Performs the ^ operation. Read more
Source§

impl Clone for ScalarDType

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ScalarDType

Source§

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

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

impl<'de> Deserialize<'de> for ScalarDType

Source§

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

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

impl EnumCount for ScalarDType

Source§

const COUNT: usize = 17usize

Source§

impl EnumSetConstHelper for ScalarDType

Source§

const CONST_INIT_HELPER: __EnumSetInitHelper = __EnumSetInitHelper

The instance of the ConstInitHelper.
Source§

const CONST_OP_HELPER: __EnumSetOpHelper = __EnumSetOpHelper

The instance of the ConstOpHelper.
Source§

type ConstInitHelper = __EnumSetInitHelper

A helper type used to convert values to EnumSets at compile-time.
Source§

type ConstOpHelper = __EnumSetOpHelper

A helper type used to implement compile-time operations on enums.
Source§

impl EnumSetTypePrivate for ScalarDType

Source§

const ALL_BITS: Self::Repr = 131071

A mask of bits that are valid in the bitset.
Source§

const BIT_WIDTH: u32 = 17u32

The largest bit used in the bitset.
Source§

const VARIANT_COUNT: u32 = 17u32

The number of variants in the bitset.
Source§

type Repr = u32

The underlying type used to store the bitset.
Source§

fn enum_into_u32(self) -> u32

Converts an enum of this type into its bit position.
Source§

unsafe fn enum_from_u32(val: u32) -> Self

Converts a bit position into an enum value.
Source§

unsafe fn enum_from_u32_checked(val: u32) -> Self

Converts a bit position into an enum value, with a debug_assert.
Source§

impl EnumSetTypeWithRepr for ScalarDType

Source§

type Repr = u32

The guaranteed representation.
Source§

impl From<ScalarDType> for DType

Source§

fn from(scalar: ScalarDType) -> Self

Converts to this type from the input type.
Source§

impl Hash for ScalarDType

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl IntoEnumIterator for ScalarDType

Source§

impl Not for ScalarDType

Source§

type Output = EnumSet<ScalarDType>

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl Ord for ScalarDType

Source§

fn cmp(&self, other: &ScalarDType) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq<EnumSet<ScalarDType>> for ScalarDType

Source§

fn eq(&self, other: &EnumSet<ScalarDType>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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 PartialEq for ScalarDType

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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 ScalarDType

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

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

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 (const: unstable) · Source§

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

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

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 ScalarDType

Source§

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

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

impl<O: Into<EnumSet<ScalarDType>>> Sub<O> for ScalarDType

Source§

type Output = EnumSet<ScalarDType>

The resulting type after applying the - operator.
Source§

fn sub(self, other: O) -> Self::Output

Performs the - operation. Read more
Source§

impl VariantArray for ScalarDType

Source§

const VARIANTS: &'static [Self]

Source§

impl Copy for ScalarDType

Source§

impl EnumSetType for ScalarDType

Source§

impl Eq for ScalarDType

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

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

Source§

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

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<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

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

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

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,