pub enum DType {
Float32,
Float16,
Float64,
Int8,
Int16,
Int32,
Int64,
Uint8,
Uint16,
Uint32,
Uint64,
Bool,
}Expand description
Numerical data type for array contents.
Corresponds to jax-js DType enum. Supports basic types that can be efficiently worked with on the web.
Variants§
Float32
32-bit floating point
Float16
16-bit floating point (stored as u16 bits)
Float64
64-bit floating point
Int8
8-bit signed integer
Int16
16-bit signed integer
Int32
32-bit signed integer
Int64
64-bit signed integer
Uint8
8-bit unsigned integer
Uint16
16-bit unsigned integer
Uint32
32-bit unsigned integer
Uint64
64-bit unsigned integer
Bool
Boolean (stored as 1-byte value)
Implementations§
Source§impl DType
impl DType
Sourcepub const fn byte_width(self) -> usize
pub const fn byte_width(self) -> usize
Returns the byte width of this dtype.
Sourcepub const fn is_unsigned(self) -> bool
pub const fn is_unsigned(self) -> bool
Returns true if this is an unsigned integer dtype.
Sourcepub fn promote(dtype1: DType, dtype2: DType) -> DType
pub fn promote(dtype1: DType, dtype2: DType) -> DType
Promotes two dtypes according to JAX’s type promotion rules.
Type lattice: bool -> uint8 -> uint16 -> uint32 -> int8 -> int16 -> int32 -> float16 -> float32 -> float64
§Examples
assert_eq!(DType::promote(DType::Bool, DType::Int32), DType::Int32);
assert_eq!(DType::promote(DType::Uint32, DType::Int32), DType::Int32);
assert_eq!(DType::promote(DType::Int32, DType::Float16), DType::Float16);
assert_eq!(DType::promote(DType::Float16, DType::Float32), DType::Float32);Sourcepub fn cast_from_f32(self, value: f32) -> f32
pub fn cast_from_f32(self, value: f32) -> f32
Cast a float32 value to this dtype (returns as f32 for storage).
Trait Implementations§
impl Copy for DType
impl Eq for DType
impl StructuralPartialEq for DType
Auto Trait Implementations§
impl Freeze for DType
impl RefUnwindSafe for DType
impl Send for DType
impl Sync for DType
impl Unpin for DType
impl UnwindSafe for DType
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.