pub enum DType {
F64,
F32,
I64,
I32,
U8,
Bool,
Bf16,
F16,
Complex,
}Expand description
Element type for typed tensor storage.
Each variant determines how the raw byte buffer is interpreted. Byte widths are fixed and platform-independent (little-endian canonical).
Variants§
F64
64-bit IEEE 754 float (8 bytes per element)
F32
32-bit IEEE 754 float (4 bytes per element)
I64
64-bit signed integer (8 bytes per element)
I32
32-bit signed integer (4 bytes per element)
U8
8-bit unsigned integer (1 byte per element)
Bool
Boolean (1 byte per element; 0x00 = false, 0x01 = true) Note: NOT packed bits — 1 byte per bool for simplicity and alignment. Packed-bit BoolTensor can be a future optimization.
Bf16
Brain float 16-bit (2 bytes per element)
F16
IEEE 754 half-precision float (2 bytes per element)
Complex
Complex f64 pair (16 bytes per element: 8 re + 8 im)
Implementations§
Source§impl DType
impl DType
Sourcepub fn byte_width(&self) -> usize
pub fn byte_width(&self) -> usize
Bytes per element for this dtype.
Sourcepub fn is_numeric(&self) -> bool
pub fn is_numeric(&self) -> bool
Whether this dtype supports arithmetic operations.
Sourcepub fn from_snap_tag(tag: u8) -> Result<Self, String>
pub fn from_snap_tag(tag: u8) -> Result<Self, String>
Reconstruct DType from a snap tag byte.
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 UnsafeUnpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more