pub struct Bf16(pub bf16);Expand description
Tuple Fields§
§0: bf16Implementations§
Source§impl Bf16
impl Bf16
Sourcepub const fn of(value: bf16) -> Self
pub const fn of(value: bf16) -> Self
Wrap a bfloat16 value.
§Examples
use tenferro_bf16_proof::Bf16;
assert_eq!(Bf16::of(half::bf16::from_f32(2.0)).to_f32(), 2.0);Sourcepub const fn narrow(self) -> bf16
pub const fn narrow(self) -> bf16
The stored bfloat16 value.
§Examples
use tenferro_bf16_proof::Bf16;
assert_eq!(Bf16::from_f32(1.0).narrow(), half::bf16::from_f32(1.0));Sourcepub fn from_f64(value: f64) -> Self
pub fn from_f64(value: f64) -> Self
Round an f64 to bfloat16, which is the only way a stored value is produced.
§Examples
use tenferro_bf16_proof::Bf16;
// The spacing of bfloat16 on [1, 2) is 2^-8, so 1.001 is nearer to 1.0 than to the next
// representable value above it.
let stored = Bf16::from_f64(1.001);
assert_eq!(stored.to_f32(), 1.0);Sourcepub fn from_f32(value: f32) -> Self
pub fn from_f32(value: f32) -> Self
Round an f32 to bfloat16.
§Examples
use tenferro_bf16_proof::Bf16;
assert_eq!(Bf16::from_f32(0.5).to_f32(), 0.5);Sourcepub fn to_f32(self) -> f32
pub fn to_f32(self) -> f32
Widen the stored value to f32, which is exact.
§Examples
use tenferro_bf16_proof::Bf16;
let stored = Bf16::from_f64(1.0 + 2f64.powi(-10));
assert_eq!(stored.to_f32(), 1.0);Sourcepub fn to_f64(self) -> f64
pub fn to_f64(self) -> f64
Widen the stored value to f64, which is exact.
§Examples
use tenferro_bf16_proof::Bf16;
assert_eq!(Bf16::from_f32(2.5).to_f64(), 2.5);Trait Implementations§
Source§impl BinaryScalarOp<Bf16> for Bf16Add
impl BinaryScalarOp<Bf16> for Bf16Add
Source§impl BinaryScalarOp<Bf16> for Bf16Sub
impl BinaryScalarOp<Bf16> for Bf16Sub
Source§impl BinaryScalarOp<Bf16> for Bf16Mul
impl BinaryScalarOp<Bf16> for Bf16Mul
impl Copy for Bf16
Source§impl Scalar for Bf16
impl Scalar for Bf16
Source§const DOMAIN: ScalarDomain = tenferro_tensor_core::ScalarDomain::Field
const DOMAIN: ScalarDomain = tenferro_tensor_core::ScalarDomain::Field
Algebra of this scalar’s ordinary arithmetic.
Source§impl ScalarArithmetic for Bf16
impl ScalarArithmetic for Bf16
Source§fn scalar_zero() -> Self
fn scalar_zero() -> Self
Additive identity. Read more
Source§fn scalar_one() -> Self
fn scalar_one() -> Self
Multiplicative identity. Read more
Source§fn scalar_add(self, rhs: Self) -> Self
fn scalar_add(self, rhs: Self) -> Self
Sum under this scalar’s own semantics. Read more
Source§fn scalar_sub(self, rhs: Self) -> Self
fn scalar_sub(self, rhs: Self) -> Self
Difference under this scalar’s own semantics. Read more
Source§fn scalar_mul(self, rhs: Self) -> Self
fn scalar_mul(self, rhs: Self) -> Self
Product under this scalar’s own semantics. Read more
impl StructuralPartialEq for Bf16
Auto Trait Implementations§
impl Freeze for Bf16
impl RefUnwindSafe for Bf16
impl Send for Bf16
impl Sync for Bf16
impl Unpin for Bf16
impl UnsafeUnpin for Bf16
impl UnwindSafe for Bf16
Blanket Implementations§
impl<T> Boilerplate for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T, U> Imply<T> for U
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> ⓘ
Converts
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> ⓘ
Converts
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