Skip to content

Commit c20cc93

Browse files
committed
Add IEEE aliases
1 parent 3abb5f6 commit c20cc93

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

src/Microfloat.jl

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
11
abstract type Variant end
2+
3+
primitive type Microfloat{S,E,M,V<:Variant} <: AbstractFloat 8 end
4+
25
abstract type IEEE <: Variant end
36

4-
primitive type Microfloat{S,E,M,V} <: AbstractFloat 8 end
7+
const IEEEMicrofloat{S,E,M} = Microfloat{S,E,M,IEEE}
8+
9+
"""
10+
Float8_E3M4
11+
12+
8-bit Microfloat with 1 sign bit, 3 exponent bits, and 4 mantissa bits.
13+
Follows the pattern of the IEEE 754 standard.
14+
"""
15+
const Float8_E3M4 = IEEEMicrofloat{1,3,4}
16+
17+
const Float8_E4M3 = IEEEMicrofloat{1,4,3}
18+
const Float8_E5M2 = IEEEMicrofloat{1,5,2}
19+
const Float6_E2M3 = IEEEMicrofloat{1,2,3}
20+
const Float6_E3M2 = IEEEMicrofloat{1,3,2}
21+
const Float4_E2M1 = IEEEMicrofloat{1,2,1}
522

623
"""
724
Microfloat(S, E, M, V=IEEE)

src/Microfloats.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ include("float-bits.jl")
55
include("Microfloat.jl")
66
export Microfloat
77
export IEEE
8+
export Float8_E3M4, Float8_E4M3, Float8_E5M2, Float6_E2M3, Float6_E3M2, Float4_E2M1
89

910
include("microscaled/microscaled.jl")
1011
export MX, NV

src/conversion/to_microfloat.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ end
4545

4646
(::Type{T})(x::Float32) where {S,E,M,T<:Microfloat{S,E,M}} = T{IEEE}(x)
4747

48-
@generated function (::Type{T})(x::Float32) where {S,E,M,V,T<:Microfloat{S,E,M,V}}
48+
@generated function (::Type{T})(x::Float32) where {S,E,M,V<:Variant,T<:Microfloat{S,E,M,V}}
4949
basetable, shifttable = create_base_shifttable(T)
5050

5151
quote

test/Float8s/runtests.jl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
using Float8s: Float8, Float8_4
44

5-
const FP8_E3M4 = Microfloat(1, 3, 4)
6-
const FP8_E4M3 = Microfloat(1, 4, 3)
7-
85
@testset "Float8s.jl parity" begin
96

107
@testset "E3M4" begin

0 commit comments

Comments
 (0)