#[repr(transparent)]pub struct e3m2(pub u8);Expand description
6-bit E3M2 micro-float (padded to 8-bit storage).
Layout: sign(1) + exponent(3) + mantissa(2), bias=3. Range: ±28, supports infinities. Only 64 total codes; 26 (40.6%) fall in [−1, +1]. Exact integer dot products via exponent-sum binning (15 bins).
§Examples
use numkong::e3m2;
let fp6 = e3m2::from_f32(2.5);
let float = fp6.to_f32();Tuple Fields§
§0: u8Implementations§
Trait Implementations§
Source§impl Angulars for e3m2
impl Angulars for e3m2
Source§type SpatialResult = f32
type SpatialResult = f32
Result type for angular distances.
Source§impl Dots for e3m2
impl Dots for e3m2
Source§type Accumulator = f32
type Accumulator = f32
Accumulator type for the multiplication.
Source§fn dots_packed_size(width: usize, depth: usize) -> usize
fn dots_packed_size(width: usize, depth: usize) -> usize
Returns the size in bytes needed for the packed B matrix buffer.
Source§unsafe fn dots_pack(
b: *const Self,
width: usize,
depth: usize,
b_stride: usize,
packed: *mut u8,
)
unsafe fn dots_pack( b: *const Self, width: usize, depth: usize, b_stride: usize, packed: *mut u8, )
Packs the B matrix into an optimized backend-specific layout. Read more
Source§impl Euclidean for e3m2
impl Euclidean for e3m2
type SqEuclideanOutput = f32
type EuclideanOutput = f32
Source§fn sqeuclidean(a: &[Self], b: &[Self]) -> Option<Self::SqEuclideanOutput>
fn sqeuclidean(a: &[Self], b: &[Self]) -> Option<Self::SqEuclideanOutput>
Squared Euclidean distance (L2²). Faster than
euclidean for comparisons.Source§fn euclidean(a: &[Self], b: &[Self]) -> Option<Self::EuclideanOutput>
fn euclidean(a: &[Self], b: &[Self]) -> Option<Self::EuclideanOutput>
Euclidean distance (L2). True metric distance.
Source§impl Euclideans for e3m2
impl Euclideans for e3m2
Source§type SpatialResult = f32
type SpatialResult = f32
Result type for euclidean distances.
Source§impl FloatConvertible for e3m2
impl FloatConvertible for e3m2
Source§impl NumberLike for e3m2
impl NumberLike for e3m2
Source§impl PartialOrd for e3m2
impl PartialOrd for e3m2
Source§impl ReduceMinMax for e3m2
impl ReduceMinMax for e3m2
Source§const NONE_ON_SENTINEL: bool = false
const NONE_ON_SENTINEL: bool = false
Whether
NK_SIZE_MAX indicates that the reduction produced no value.Source§impl ReduceMoments for e3m2
impl ReduceMoments for e3m2
Source§type SumSqOutput = f32
type SumSqOutput = f32
Type for the sum-of-squares output.
Source§unsafe fn reduce_moments_raw(
data: *const Self,
count: usize,
stride_bytes: usize,
) -> (Self::SumOutput, Self::SumSqOutput)
unsafe fn reduce_moments_raw( data: *const Self, count: usize, stride_bytes: usize, ) -> (Self::SumOutput, Self::SumSqOutput)
Compute
(sum, sum_of_squares) for raw pointer input with the given stride in bytes. Read moreSource§fn reduce_moments(
data: &[Self],
stride_bytes: usize,
) -> (Self::SumOutput, Self::SumSqOutput)
fn reduce_moments( data: &[Self], stride_bytes: usize, ) -> (Self::SumOutput, Self::SumSqOutput)
Compute
(sum, sum_of_squares) for data with the given stride (in bytes).
Use stride_bytes = size_of::<Self>() for contiguous data.Source§impl StorageElement for e3m2
impl StorageElement for e3m2
impl CastDtype for e3m2
impl Copy for e3m2
impl Eq for e3m2
impl StructuralPartialEq for e3m2
Auto Trait Implementations§
impl Freeze for e3m2
impl RefUnwindSafe for e3m2
impl Send for e3m2
impl Sync for e3m2
impl Unpin for e3m2
impl UnsafeUnpin for e3m2
impl UnwindSafe for e3m2
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