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
impl ScalarDType
Sourcepub fn can_safe_cast(self, to: Self) -> bool
pub fn can_safe_cast(self, to: Self) -> bool
Check if casting from from to to is safe (preserves value).
Source§impl ScalarDType
impl ScalarDType
Source§impl ScalarDType
impl ScalarDType
pub const fn bytes(&self) -> usize
pub const fn is_bool(&self) -> bool
pub const fn is_signed(&self) -> bool
pub const fn is_unsigned(&self) -> bool
pub const fn is_int(&self) -> bool
pub const fn is_float(&self) -> bool
pub const fn is_fp8(&self) -> bool
pub const fn min_value(&self) -> f64
pub const fn max_value(&self) -> f64
pub const fn c_style(&self) -> &'static str
pub const fn min_positive(&self) -> f64
Sourcepub const fn finfo(&self) -> (u32, u32)
pub const fn finfo(&self) -> (u32, u32)
(exponent_bits, mantissa_bits) for float types.
Matches Tinygrad’s dtypes.finfo().
Sourcepub const fn exponent_bias(&self) -> i32
pub const fn exponent_bias(&self) -> i32
Exponent bias: (1 << (exp_bits - 1)) - 1.
Sourcepub const fn float_to_uint(&self) -> ScalarDType
pub const fn float_to_uint(&self) -> ScalarDType
Map float dtype to uint storage equivalent of the same bit width.
Trait Implementations§
Source§impl Arbitrary for ScalarDType
impl Arbitrary for ScalarDType
Source§type Parameters = ()
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>))>>))>
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
fn arbitrary_with(_top: Self::Parameters) -> Self::Strategy
Source§impl<O: Into<EnumSet<ScalarDType>>> BitAnd<O> for ScalarDType
impl<O: Into<EnumSet<ScalarDType>>> BitAnd<O> for ScalarDType
Source§impl<O: Into<EnumSet<ScalarDType>>> BitOr<O> for ScalarDType
impl<O: Into<EnumSet<ScalarDType>>> BitOr<O> for ScalarDType
Source§impl<O: Into<EnumSet<ScalarDType>>> BitXor<O> for ScalarDType
impl<O: Into<EnumSet<ScalarDType>>> BitXor<O> for ScalarDType
Source§impl Clone for ScalarDType
impl Clone for ScalarDType
Source§impl Debug for ScalarDType
impl Debug for ScalarDType
Source§impl<'de> Deserialize<'de> for ScalarDType
impl<'de> Deserialize<'de> for ScalarDType
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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 EnumSetConstHelper for ScalarDType
impl EnumSetConstHelper for ScalarDType
Source§const CONST_INIT_HELPER: __EnumSetInitHelper = __EnumSetInitHelper
const CONST_INIT_HELPER: __EnumSetInitHelper = __EnumSetInitHelper
The instance of the
ConstInitHelper.Source§const CONST_OP_HELPER: __EnumSetOpHelper = __EnumSetOpHelper
const CONST_OP_HELPER: __EnumSetOpHelper = __EnumSetOpHelper
The instance of the
ConstOpHelper.Source§type ConstInitHelper = __EnumSetInitHelper
type ConstInitHelper = __EnumSetInitHelper
A helper type used to convert values to EnumSets at compile-time.
Source§type ConstOpHelper = __EnumSetOpHelper
type ConstOpHelper = __EnumSetOpHelper
A helper type used to implement compile-time operations on enums.
Source§impl EnumSetTypePrivate for ScalarDType
impl EnumSetTypePrivate for ScalarDType
Source§const VARIANT_COUNT: u32 = 17u32
const VARIANT_COUNT: u32 = 17u32
The number of variants in the bitset.
Source§fn enum_into_u32(self) -> u32
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
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
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
impl EnumSetTypeWithRepr for ScalarDType
Source§impl From<ScalarDType> for DType
impl From<ScalarDType> for DType
Source§fn from(scalar: ScalarDType) -> Self
fn from(scalar: ScalarDType) -> Self
Converts to this type from the input type.
Source§impl Hash for ScalarDType
impl Hash for ScalarDType
Source§impl IntoEnumIterator for ScalarDType
impl IntoEnumIterator for ScalarDType
type Iterator = ScalarDTypeIter
fn iter() -> ScalarDTypeIter ⓘ
Source§impl Not for ScalarDType
impl Not for ScalarDType
Source§impl Ord for ScalarDType
impl Ord for ScalarDType
Source§fn cmp(&self, other: &ScalarDType) -> Ordering
fn cmp(&self, other: &ScalarDType) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq<EnumSet<ScalarDType>> for ScalarDType
impl PartialEq<EnumSet<ScalarDType>> for ScalarDType
Source§impl PartialEq for ScalarDType
impl PartialEq for ScalarDType
Source§impl PartialOrd for ScalarDType
impl PartialOrd for ScalarDType
Source§impl Serialize for ScalarDType
impl Serialize for ScalarDType
Source§impl<O: Into<EnumSet<ScalarDType>>> Sub<O> for ScalarDType
impl<O: Into<EnumSet<ScalarDType>>> Sub<O> for ScalarDType
Source§impl VariantArray for ScalarDType
impl VariantArray for ScalarDType
impl Copy for ScalarDType
impl EnumSetType for ScalarDType
impl Eq for ScalarDType
Auto Trait Implementations§
impl Freeze for ScalarDType
impl RefUnwindSafe for ScalarDType
impl Send for ScalarDType
impl Sync for ScalarDType
impl Unpin for ScalarDType
impl UnsafeUnpin for ScalarDType
impl UnwindSafe for ScalarDType
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more