Skip to content

Commit 2628a5f

Browse files
authored
Rename f8E4M3 to f8E4M3FN in mlir.extras.types py package (#97102)
Currently `f8E4M3` is mapped to `Float8E4M3FNType`. This PR renames `f8E4M3` to `f8E4M3FN` to accurately reflect the actual type. This PR is needed to avoid names conflict in upcoming PR which will add IEEE 754 `Float8E4M3Type`. #97118 Add f8E4M3 IEEE 754 type Maksim, can you review this PR? @makslevental ?
1 parent 5a8c4b5 commit 2628a5f

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

llvm/lib/Support/APFloat.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ enum class fltNanEncoding {
8383
// exponent is all 1s and the significand is non-zero.
8484
IEEE,
8585

86-
// Represents the behavior in the Float8E4M3 floating point type where NaN is
87-
// represented by having the exponent and mantissa set to all 1s.
86+
// Represents the behavior in the Float8E4M3FN floating point type where NaN
87+
// is represented by having the exponent and mantissa set to all 1s.
8888
// This behavior matches the FP8 E4M3 type described in
8989
// https://arxiv.org/abs/2209.05433. We treat both signed and unsigned NaNs
9090
// as non-signalling, although the paper does not state whether the NaN

llvm/unittests/ADT/APFloatTest.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5508,8 +5508,8 @@ TEST(APFloatTest, ConvertE4M3FNToE5M2) {
55085508
EXPECT_TRUE(losesInfo);
55095509
EXPECT_EQ(status, APFloat::opInexact);
55105510

5511-
// Convert E4M3 denormal to E5M2 normal. Should not be truncated, despite the
5512-
// destination format having one fewer significand bit
5511+
// Convert E4M3FN denormal to E5M2 normal. Should not be truncated, despite
5512+
// the destination format having one fewer significand bit
55135513
test = APFloat(APFloat::Float8E4M3FN(), "0x1.Cp-7");
55145514
status = test.convert(APFloat::Float8E5M2(), APFloat::rmNearestTiesToEven,
55155515
&losesInfo);
@@ -5647,8 +5647,8 @@ TEST(APFloatTest, Float8E4M3FNAdd) {
56475647
int category;
56485648
APFloat::roundingMode roundingMode = APFloat::rmNearestTiesToEven;
56495649
} AdditionTests[] = {
5650-
// Test addition operations involving NaN, overflow, and the max E4M3
5651-
// value (448) because E4M3 differs from IEEE-754 types in these regards
5650+
// Test addition operations involving NaN, overflow, and the max E4M3FN
5651+
// value (448) because E4M3FN differs from IEEE-754 types in these regards
56525652
{FromStr("448"), FromStr("16"), "448", APFloat::opInexact,
56535653
APFloat::fcNormal},
56545654
{FromStr("448"), FromStr("18"), "NaN",
@@ -6278,8 +6278,8 @@ TEST(APFloatTest, ConvertE4M3FNUZToE5M2FNUZ) {
62786278
EXPECT_TRUE(losesInfo);
62796279
EXPECT_EQ(status, APFloat::opInexact);
62806280

6281-
// Convert E4M3 denormal to E5M2 normal. Should not be truncated, despite the
6282-
// destination format having one fewer significand bit
6281+
// Convert E4M3FNUZ denormal to E5M2 normal. Should not be truncated, despite
6282+
// the destination format having one fewer significand bit
62836283
losesInfo = true;
62846284
test = APFloat(APFloat::Float8E4M3FNUZ(), "0x1.Cp-8");
62856285
status = test.convert(APFloat::Float8E5M2FNUZ(), APFloat::rmNearestTiesToEven,

mlir/python/mlir/extras/types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def ui(width):
6868
bf16 = lambda: BF16Type.get()
6969

7070
f8E5M2 = lambda: Float8E5M2Type.get()
71-
f8E4M3 = lambda: Float8E4M3FNType.get()
71+
f8E4M3FN = lambda: Float8E4M3FNType.get()
7272
f8E4M3B11FNUZ = lambda: Float8E4M3B11FNUZType.get()
7373

7474
none = lambda: NoneType.get()

0 commit comments

Comments
 (0)