@@ -482,7 +482,7 @@ fn convert_chunked_slice_4<S: Copy + Default, D: Copy>(
482
482
pub ( crate ) const fn f32_to_f16_fallback ( value : f32 ) -> u16 {
483
483
// TODO: Replace mem::transmute with to_bits() once to_bits is const-stabilized
484
484
// Convert to raw bytes
485
- let x: u32 = unsafe { mem:: transmute ( value) } ;
485
+ let x: u32 = unsafe { mem:: transmute :: < f32 , u32 > ( value) } ;
486
486
487
487
// Extract IEEE754 components
488
488
let sign = x & 0x8000_0000u32 ;
@@ -544,7 +544,7 @@ pub(crate) const fn f64_to_f16_fallback(value: f64) -> u16 {
544
544
// Convert to raw bytes, truncating the last 32-bits of mantissa; that precision will always
545
545
// be lost on half-precision.
546
546
// TODO: Replace mem::transmute with to_bits() once to_bits is const-stabilized
547
- let val: u64 = unsafe { mem:: transmute ( value) } ;
547
+ let val: u64 = unsafe { mem:: transmute :: < f64 , u64 > ( value) } ;
548
548
let x = ( val >> 32 ) as u32 ;
549
549
550
550
// Extract IEEE754 components
@@ -612,7 +612,7 @@ pub(crate) const fn f16_to_f32_fallback(i: u16) -> f32 {
612
612
// Check for signed zero
613
613
// TODO: Replace mem::transmute with from_bits() once from_bits is const-stabilized
614
614
if i & 0x7FFFu16 == 0 {
615
- return unsafe { mem:: transmute ( ( i as u32 ) << 16 ) } ;
615
+ return unsafe { mem:: transmute :: < u32 , f32 > ( ( i as u32 ) << 16 ) } ;
616
616
}
617
617
618
618
let half_sign = ( i & 0x8000u16 ) as u32 ;
@@ -623,11 +623,11 @@ pub(crate) const fn f16_to_f32_fallback(i: u16) -> f32 {
623
623
if half_exp == 0x7C00u32 {
624
624
// Check for signed infinity if mantissa is zero
625
625
if half_man == 0 {
626
- return unsafe { mem:: transmute ( ( half_sign << 16 ) | 0x7F80_0000u32 ) } ;
626
+ return unsafe { mem:: transmute :: < u32 , f32 > ( ( half_sign << 16 ) | 0x7F80_0000u32 ) } ;
627
627
} else {
628
628
// NaN, keep current mantissa but also set most significiant mantissa bit
629
629
return unsafe {
630
- mem:: transmute ( ( half_sign << 16 ) | 0x7FC0_0000u32 | ( half_man << 13 ) )
630
+ mem:: transmute :: < u32 , f32 > ( ( half_sign << 16 ) | 0x7FC0_0000u32 | ( half_man << 13 ) )
631
631
} ;
632
632
}
633
633
}
@@ -645,21 +645,21 @@ pub(crate) const fn f16_to_f32_fallback(i: u16) -> f32 {
645
645
// Rebias and adjust exponent
646
646
let exp = ( 127 - 15 - e) << 23 ;
647
647
let man = ( half_man << ( 14 + e) ) & 0x7F_FF_FFu32 ;
648
- return unsafe { mem:: transmute ( sign | exp | man) } ;
648
+ return unsafe { mem:: transmute :: < u32 , f32 > ( sign | exp | man) } ;
649
649
}
650
650
651
651
// Rebias exponent for a normalized normal
652
652
let exp = ( ( unbiased_exp + 127 ) as u32 ) << 23 ;
653
653
let man = ( half_man & 0x03FFu32 ) << 13 ;
654
- unsafe { mem:: transmute ( sign | exp | man) }
654
+ unsafe { mem:: transmute :: < u32 , f32 > ( sign | exp | man) }
655
655
}
656
656
657
657
#[ inline]
658
658
pub ( crate ) const fn f16_to_f64_fallback ( i : u16 ) -> f64 {
659
659
// Check for signed zero
660
660
// TODO: Replace mem::transmute with from_bits() once from_bits is const-stabilized
661
661
if i & 0x7FFFu16 == 0 {
662
- return unsafe { mem:: transmute ( ( i as u64 ) << 48 ) } ;
662
+ return unsafe { mem:: transmute :: < u64 , f64 > ( ( i as u64 ) << 48 ) } ;
663
663
}
664
664
665
665
let half_sign = ( i & 0x8000u16 ) as u64 ;
@@ -670,11 +670,15 @@ pub(crate) const fn f16_to_f64_fallback(i: u16) -> f64 {
670
670
if half_exp == 0x7C00u64 {
671
671
// Check for signed infinity if mantissa is zero
672
672
if half_man == 0 {
673
- return unsafe { mem:: transmute ( ( half_sign << 48 ) | 0x7FF0_0000_0000_0000u64 ) } ;
673
+ return unsafe {
674
+ mem:: transmute :: < u64 , f64 > ( ( half_sign << 48 ) | 0x7FF0_0000_0000_0000u64 )
675
+ } ;
674
676
} else {
675
677
// NaN, keep current mantissa but also set most significiant mantissa bit
676
678
return unsafe {
677
- mem:: transmute ( ( half_sign << 48 ) | 0x7FF8_0000_0000_0000u64 | ( half_man << 42 ) )
679
+ mem:: transmute :: < u64 , f64 > (
680
+ ( half_sign << 48 ) | 0x7FF8_0000_0000_0000u64 | ( half_man << 42 ) ,
681
+ )
678
682
} ;
679
683
}
680
684
}
@@ -692,13 +696,13 @@ pub(crate) const fn f16_to_f64_fallback(i: u16) -> f64 {
692
696
// Rebias and adjust exponent
693
697
let exp = ( ( 1023 - 15 - e) as u64 ) << 52 ;
694
698
let man = ( half_man << ( 43 + e) ) & 0xF_FFFF_FFFF_FFFFu64 ;
695
- return unsafe { mem:: transmute ( sign | exp | man) } ;
699
+ return unsafe { mem:: transmute :: < u64 , f64 > ( sign | exp | man) } ;
696
700
}
697
701
698
702
// Rebias exponent for a normalized normal
699
703
let exp = ( ( unbiased_exp + 1023 ) as u64 ) << 52 ;
700
704
let man = ( half_man & 0x03FFu64 ) << 42 ;
701
- unsafe { mem:: transmute ( sign | exp | man) }
705
+ unsafe { mem:: transmute :: < u64 , f64 > ( sign | exp | man) }
702
706
}
703
707
704
708
#[ inline]
0 commit comments