Skip to main content

Fp16

Struct Fp16 

Source
pub struct Fp16;
Expand description

IEEE-754 binary16 (“half”): 1 sign, 5 exponent, 10 mantissa, bias 15. Has inf and NaN.

For a faster, inf/NaN-unchecked variant of the same layout see Fp16Fast.

Trait Implementations§

Source§

impl Clone for Fp16

Source§

fn clone(&self) -> Fp16

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 Copy for Fp16

Source§

impl Debug for Fp16

Source§

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

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

impl Eq for Fp16

Source§

impl FloatSpec for Fp16

Source§

const BITS: u32 = 16

Total number of significant bits (e.g. 16 for fp16/bf16, 8 for fp8).
Source§

const EXP_BITS: u32 = 5

Width of the exponent field in bits.
Source§

const MANTISSA_BITS: u32 = 10

Width of the (stored, fractional) mantissa field in bits.
Source§

const EXP_BIAS: i32 = 15

Exponent bias (subtracted from the stored exponent to get the true exponent).
Source§

const SPECIAL: SpecialEncoding = SpecialEncoding::Ieee

How the maximum-exponent code points encode inf / NaN.
Source§

const HAS_SIGN: bool = true

Whether the format has a sign bit. Almost always true.
Source§

const SIGN_SHIFT: u32 = _

Bit position of the sign (and of the field block: exp occupies MANTISSA_BITS .. SIGN_SHIFT).
Source§

const STORAGE_MASK: u32 = _

Mask of the significant bits within the u32 working register ((1 << BITS) - 1).
Source§

const SIGN_MASK: u32 = _

Mask isolating the sign bit (0 when HAS_SIGN is false).
Source§

const EXP_FIELD_MAX: u32 = _

All-ones exponent field value ((1 << EXP_BITS) - 1).
Source§

const EXP_MASK: u32 = _

Mask isolating the exponent field (already shifted into place).
Source§

const MANTISSA_MASK: u32 = _

Mask isolating the mantissa field.
Source§

const MANTISSA_SHIFT: u32 = _

Bits the mantissa shifts when aligning to / from f32’s 23-bit field (F32_MANTISSA_BITS - MANTISSA_BITS). Requires MANTISSA_BITS <= 23 (true for every sub-f32 format).
Source§

const EXP_REBIAS: i32 = _

Added to the stored exponent going packed -> f32 (subtracted the other way): F32_EXP_BIAS - EXP_BIAS.
Source§

const MAX_FINITE_EXP_FIELD: u32 = _

Largest exponent field that still denotes a finite number on the pack (encode) side. For SpecialEncoding::Ieee and Unchecked the all-ones field is the reserved inf/NaN code point, so this is EXP_FIELD_MAX - 1; for the no-reserved-code-point schemes it is EXP_FIELD_MAX. (Note Unchecked unpack still decodes the all-ones exponent as a large normal - it only matters here that an input which would round up onto that reserved code point overflows, and so flushes to zero, matching the hardware vcvtps2ph + flush path.)
Source§

const MAX_FINITE_BITS: u32 = _

Bit pattern (sign clear) of the largest finite magnitude - the saturation target.
Source§

const INFINITY_BITS: u32 = Self::EXP_MASK

Bit pattern (sign clear) of +inf. Only meaningful when SPECIAL is Ieee.
Source§

const NAN_BITS: u32 = _

Canonical quiet-NaN bit pattern (sign clear). Meaningful unless the format has no NaN (SpecialEncoding::Finite).
Source§

const OVERFLOW_BITS: u32 = _

Result (sign clear) when a magnitude exceeds the finite range: ±inf for IEEE formats, saturation to the largest finite for the no-inf schemes, and signed zero for Unchecked (which flushes overflow). Used for both overflow of a finite input and for an f32 infinity input.
Source§

const NAN_OUT_BITS: u32 = _

Result (sign clear) for an f32 NaN input: the canonical NaN for formats that have one, saturation for SpecialEncoding::Finite (no NaN code point), and signed zero for Unchecked (which flushes NaN).
Source§

fn unpack(packed: u32) -> f32

Decode the low BITS bits of packed (one value of this format) into the f32 it represents. Exact: every value of these sub-f32 formats is representable in f32.
Source§

fn pack(value: f32) -> u32

Encode value (an f32) into the low BITS bits of the returned u32, rounding the mantissa to nearest, ties to even. Overflow becomes ±inf (or saturates, for the non-IEEE schemes); tiny values become subnormals or signed zero. Read more
Source§

impl Hash for Fp16

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 PackedFloatRegister<Fp16, ArrayRegister<F32x4V1, 2>> for U16x8V1

Available on x86 or x86-64 only.
Source§

fn pack(values: Storage<F>) -> Storage<Self>
where Self: CastRegister<F::Bits>,

Source§

fn unpack(values: Storage<Self>) -> Storage<F>

Source§

impl PackedFloatRegister<Fp16, ArrayRegister<F32x4V1, 4>> for ArrayRegister<U16x8V1, 2>

Available on x86 or x86-64 only.
Source§

fn pack(values: Storage<F>) -> Storage<Self>
where Self: CastRegister<F::Bits>,

Source§

fn unpack(values: Storage<Self>) -> Storage<F>

Source§

impl PackedFloatRegister<Fp16, ArrayRegister<F32x4V2, 2>> for U16x8V2

Available on x86 or x86-64 only.
Source§

fn pack(values: Storage<F>) -> Storage<Self>
where Self: CastRegister<F::Bits>,

Source§

fn unpack(values: Storage<Self>) -> Storage<F>

Source§

impl PackedFloatRegister<Fp16, ArrayRegister<F32x4V2, 4>> for ArrayRegister<U16x8V2, 2>

Available on x86 or x86-64 only.
Source§

fn pack(values: Storage<F>) -> Storage<Self>
where Self: CastRegister<F::Bits>,

Source§

fn unpack(values: Storage<Self>) -> Storage<F>

Source§

impl PackedFloatRegister<Fp16, ArrayRegister<F32x8V3, 2>> for U16x16V3

Available on crate feature avx2-f16c and (x86 or x86-64) only.
Source§

impl PackedFloatRegister<Fp16, F32x4V1> for U16x4V1

Available on x86 or x86-64 only.
Source§

fn pack(values: Storage<F>) -> Storage<Self>
where Self: CastRegister<F::Bits>,

Source§

fn unpack(values: Storage<Self>) -> Storage<F>

Source§

impl PackedFloatRegister<Fp16, F32x4V2> for U16x4V2

Available on x86 or x86-64 only.
Source§

fn pack(values: Storage<F>) -> Storage<Self>
where Self: CastRegister<F::Bits>,

Source§

fn unpack(values: Storage<Self>) -> Storage<F>

Source§

impl PackedFloatRegister<Fp16, F32x4V3> for U16x4V3

Available on crate feature avx2-f16c and (x86 or x86-64) only.
Source§

fn unpack(values: Storage<Self>) -> Storage<F32x4V3>

Source§

fn pack(values: Storage<F32x4V3>) -> Storage<Self>

Source§

impl PackedFloatRegister<Fp16, F32x8V3> for U16x8V3

Available on crate feature avx2-f16c and (x86 or x86-64) only.
Source§

fn unpack(values: Storage<Self>) -> Storage<F32x8V3>

Source§

fn pack(values: Storage<F32x8V3>) -> Storage<Self>

Source§

impl PartialEq for Fp16

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Fp16

Auto Trait Implementations§

§

impl Freeze for Fp16

§

impl RefUnwindSafe for Fp16

§

impl Send for Fp16

§

impl Sync for Fp16

§

impl Unpin for Fp16

§

impl UnsafeUnpin for Fp16

§

impl UnwindSafe for Fp16

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

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> FmtForward for T

Source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. 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> Pipe for T
where T: ?Sized,

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
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> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. 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.