Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ rand_distr = { version = "0.5.0", default-features = false, optional = true }
rkyv = { version = "0.8.0", optional = true }
arbitrary = { version = "1.4.1", features = ["derive"], optional = true }

[target.'cfg(target_arch = "spirv")'.dependencies]
crunchy = "0.2.2"

[dev-dependencies]
criterion = "0.5"
quickcheck = "1.0"
Expand Down
10 changes: 0 additions & 10 deletions src/bfloat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use core::{
num::FpCategory,
ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, RemAssign, Sub, SubAssign},
};
#[cfg(not(target_arch = "spirv"))]
use core::{
fmt::{
Binary, Debug, Display, Error, Formatter, LowerExp, LowerHex, Octal, UpperExp, UpperHex,
Expand Down Expand Up @@ -918,64 +917,55 @@ impl PartialOrd for bf16 {
}
}

#[cfg(not(target_arch = "spirv"))]
impl FromStr for bf16 {
type Err = ParseFloatError;
fn from_str(src: &str) -> Result<bf16, ParseFloatError> {
f32::from_str(src).map(bf16::from_f32)
}
}

#[cfg(not(target_arch = "spirv"))]
impl Debug for bf16 {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
Debug::fmt(&self.to_f32(), f)
}
}

#[cfg(not(target_arch = "spirv"))]
impl Display for bf16 {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
Display::fmt(&self.to_f32(), f)
}
}

#[cfg(not(target_arch = "spirv"))]
impl LowerExp for bf16 {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
write!(f, "{:e}", self.to_f32())
}
}

#[cfg(not(target_arch = "spirv"))]
impl UpperExp for bf16 {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
write!(f, "{:E}", self.to_f32())
}
}

#[cfg(not(target_arch = "spirv"))]
impl Binary for bf16 {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
write!(f, "{:b}", self.0)
}
}

#[cfg(not(target_arch = "spirv"))]
impl Octal for bf16 {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
write!(f, "{:o}", self.0)
}
}

#[cfg(not(target_arch = "spirv"))]
impl LowerHex for bf16 {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
write!(f, "{:x}", self.0)
}
}

#[cfg(not(target_arch = "spirv"))]
impl UpperHex for bf16 {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
write!(f, "{:X}", self.0)
Expand Down
3 changes: 1 addition & 2 deletions src/bfloat/convert.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::leading_zeros::leading_zeros_u16;
use core::mem;

#[inline]
Expand Down Expand Up @@ -138,7 +137,7 @@ pub(crate) const fn bf16_to_f64(i: u16) -> f64 {
// Check for subnormals, which will be normalized by adjusting exponent
if half_exp == 0 {
// Calculate how much to adjust the exponent by
let e = leading_zeros_u16(half_man as u16) - 9;
let e = u16::leading_zeros(half_man as u16) - 9;

// Rebias and adjust exponent
let exp = ((1023 - 127 - e) as u64) << 52;
Expand Down
10 changes: 0 additions & 10 deletions src/binary16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use core::{
num::FpCategory,
ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, RemAssign, Sub, SubAssign},
};
#[cfg(not(target_arch = "spirv"))]
use core::{
fmt::{
Binary, Debug, Display, Error, Formatter, LowerExp, LowerHex, Octal, UpperExp, UpperHex,
Expand Down Expand Up @@ -929,64 +928,55 @@ impl PartialOrd for f16 {
}
}

#[cfg(not(target_arch = "spirv"))]
impl FromStr for f16 {
type Err = ParseFloatError;
fn from_str(src: &str) -> Result<f16, ParseFloatError> {
f32::from_str(src).map(f16::from_f32)
}
}

#[cfg(not(target_arch = "spirv"))]
impl Debug for f16 {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
Debug::fmt(&self.to_f32(), f)
}
}

#[cfg(not(target_arch = "spirv"))]
impl Display for f16 {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
Display::fmt(&self.to_f32(), f)
}
}

#[cfg(not(target_arch = "spirv"))]
impl LowerExp for f16 {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
write!(f, "{:e}", self.to_f32())
}
}

#[cfg(not(target_arch = "spirv"))]
impl UpperExp for f16 {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
write!(f, "{:E}", self.to_f32())
}
}

#[cfg(not(target_arch = "spirv"))]
impl Binary for f16 {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
write!(f, "{:b}", self.0)
}
}

#[cfg(not(target_arch = "spirv"))]
impl Octal for f16 {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
write!(f, "{:o}", self.0)
}
}

#[cfg(not(target_arch = "spirv"))]
impl LowerHex for f16 {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
write!(f, "{:x}", self.0)
}
}

#[cfg(not(target_arch = "spirv"))]
impl UpperHex for f16 {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
write!(f, "{:X}", self.0)
Expand Down
6 changes: 3 additions & 3 deletions src/binary16/arch.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![allow(dead_code, unused_imports)]
use crate::leading_zeros::leading_zeros_u16;

use core::mem;

#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
Expand Down Expand Up @@ -640,7 +640,7 @@ pub(crate) const fn f16_to_f32_fallback(i: u16) -> f32 {
// Check for subnormals, which will be normalized by adjusting exponent
if half_exp == 0 {
// Calculate how much to adjust the exponent by
let e = leading_zeros_u16(half_man as u16) - 6;
let e = u16::leading_zeros(half_man as u16) - 6;

// Rebias and adjust exponent
let exp = (127 - 15 - e) << 23;
Expand Down Expand Up @@ -691,7 +691,7 @@ pub(crate) const fn f16_to_f64_fallback(i: u16) -> f64 {
// Check for subnormals, which will be normalized by adjusting exponent
if half_exp == 0 {
// Calculate how much to adjust the exponent by
let e = leading_zeros_u16(half_man as u16) - 6;
let e = u16::leading_zeros(half_man as u16) - 6;

// Rebias and adjust exponent
let exp = ((1023 - 15 - e) as u64) << 52;
Expand Down
65 changes: 0 additions & 65 deletions src/leading_zeros.rs

This file was deleted.

2 changes: 0 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@
trivial_numeric_casts,
future_incompatible
)]
#![cfg_attr(not(target_arch = "spirv"), warn(missing_debug_implementations))]
#![allow(clippy::verbose_bit_mask, clippy::cast_lossless, unexpected_cfgs)]
#![cfg_attr(not(feature = "std"), no_std)]
#![doc(html_root_url = "https://docs.rs/half/2.6.0")]
Expand All @@ -228,7 +227,6 @@ extern crate alloc;

mod bfloat;
mod binary16;
mod leading_zeros;
#[cfg(feature = "num-traits")]
mod num_traits;

Expand Down