Skip to content

Commit 3f9caba

Browse files
authored
[MLIR] Add f8E8M0FNU type (#111028)
This PR adds `f8E8M0FNU` type to MLIR. `f8E8M0FNU` type is proposed in [OpenCompute MX Specification](https://www.opencompute.org/documents/ocp-microscaling-formats-mx-v1-0-spec-final-pdf). It defines a 8-bit floating point number with bit layout S0E8M0. Unlike IEEE-754 types, there are no infinity, denormals, zeros or negative values. ```c f8E8M0FNU - Exponent bias: 127 - Maximum stored exponent value: 254 (binary 1111'1110) - Maximum unbiased exponent value: 254 - 127 = 127 - Minimum stored exponent value: 0 (binary 0000'0000) - Minimum unbiased exponent value: 0 − 127 = -127 - Doesn't have zero - Doesn't have infinity - NaN is encoded as binary 1111'1111 Additional details: - Zeros cannot be represented - Negative values cannot be represented - Mantissa is always 1 ``` Related PRs: - [PR-107127](#107127) [APFloat] Add APFloat support for E8M0 type - [PR-105573](#105573) [MLIR] Add f6E3M2FN type - was used as a template for this PR - [PR-107999](#107999) [MLIR] Add f6E2M3FN type - [PR-108877](#108877) [MLIR] Add f4E2M1FN type
1 parent ccca3c6 commit 3f9caba

File tree

24 files changed

+140
-7
lines changed

24 files changed

+140
-7
lines changed

mlir/include/mlir-c/BuiltinTypes.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,16 @@ MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat8E3M4(MlirType type);
179179
/// context.
180180
MLIR_CAPI_EXPORTED MlirType mlirFloat8E3M4TypeGet(MlirContext ctx);
181181

182+
/// Returns the typeID of an Float8E8M0FNU type.
183+
MLIR_CAPI_EXPORTED MlirTypeID mlirFloat8E8M0FNUTypeGetTypeID(void);
184+
185+
/// Checks whether the given type is an f8E8M0FNU type.
186+
MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat8E8M0FNU(MlirType type);
187+
188+
/// Creates an f8E8M0FNU type in the given context. The type is owned by the
189+
/// context.
190+
MLIR_CAPI_EXPORTED MlirType mlirFloat8E8M0FNUTypeGet(MlirContext ctx);
191+
182192
/// Returns the typeID of an BFloat16 type.
183193
MLIR_CAPI_EXPORTED MlirTypeID mlirBFloat16TypeGetTypeID(void);
184194

mlir/include/mlir/IR/Builders.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class Builder {
7070
FloatType getFloat8E4M3FNUZType();
7171
FloatType getFloat8E4M3B11FNUZType();
7272
FloatType getFloat8E3M4Type();
73+
FloatType getFloat8E8M0FNUType();
7374
FloatType getBF16Type();
7475
FloatType getF16Type();
7576
FloatType getTF32Type();

mlir/include/mlir/IR/BuiltinTypes.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class FloatType : public Type {
7070
static FloatType getFloat4E2M1FN(MLIRContext *ctx);
7171
static FloatType getFloat6E2M3FN(MLIRContext *ctx);
7272
static FloatType getFloat6E3M2FN(MLIRContext *ctx);
73+
static FloatType getFloat8E8M0FNU(MLIRContext *ctx);
7374

7475
/// Methods for support type inquiry through isa, cast, and dyn_cast.
7576
static bool classof(Type type);
@@ -416,11 +417,12 @@ inline bool BaseMemRefType::isValidElementType(Type type) {
416417
}
417418

418419
inline bool FloatType::classof(Type type) {
419-
return llvm::isa<
420-
Float4E2M1FNType, Float6E2M3FNType, Float6E3M2FNType, Float8E5M2Type,
421-
Float8E4M3Type, Float8E4M3FNType, Float8E5M2FNUZType, Float8E4M3FNUZType,
422-
Float8E4M3B11FNUZType, Float8E3M4Type, BFloat16Type, Float16Type,
423-
FloatTF32Type, Float32Type, Float64Type, Float80Type, Float128Type>(type);
420+
return llvm::isa<Float4E2M1FNType, Float6E2M3FNType, Float6E3M2FNType,
421+
Float8E5M2Type, Float8E4M3Type, Float8E4M3FNType,
422+
Float8E5M2FNUZType, Float8E4M3FNUZType,
423+
Float8E4M3B11FNUZType, Float8E3M4Type, Float8E8M0FNUType,
424+
BFloat16Type, Float16Type, FloatTF32Type, Float32Type,
425+
Float64Type, Float80Type, Float128Type>(type);
424426
}
425427

426428
inline FloatType FloatType::getFloat4E2M1FN(MLIRContext *ctx) {
@@ -463,6 +465,10 @@ inline FloatType FloatType::getFloat8E3M4(MLIRContext *ctx) {
463465
return Float8E3M4Type::get(ctx);
464466
}
465467

468+
inline FloatType FloatType::getFloat8E8M0FNU(MLIRContext *ctx) {
469+
return Float8E8M0FNUType::get(ctx);
470+
}
471+
466472
inline FloatType FloatType::getBF16(MLIRContext *ctx) {
467473
return BFloat16Type::get(ctx);
468474
}

mlir/include/mlir/IR/BuiltinTypes.td

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,29 @@ def Builtin_Float6E3M2FN : Builtin_FloatType<"Float6E3M2FN", "f6E3M2FN"> {
296296
}];
297297
}
298298

299+
//===----------------------------------------------------------------------===//
300+
// Float8E8M0FNUType
301+
302+
def Builtin_Float8E8M0FNU : Builtin_FloatType<"Float8E8M0FNU", "f8E8M0FNU"> {
303+
let summary = "8-bit floating point with 8-bit exponent, no mantissa or sign";
304+
let description = [{
305+
An 8-bit floating point type with no sign bit, 8 bits exponent and no
306+
mantissa. This is not a standard type as defined by IEEE-754; it is intended
307+
to be used for representing scaling factors, so it cannot represent zeros
308+
and negative numbers. The values it can represent are powers of two in the
309+
range [-127,127] and NaN.
310+
311+
* bit encoding: S0E8M0
312+
* exponent bias: 127
313+
* infinities: Not supported
314+
* NaNs: Supported with all bits set to 1
315+
* denormals: Not supported
316+
317+
Open Compute Project (OCP) microscaling formats (MX) specification:
318+
https://www.opencompute.org/documents/ocp-microscaling-formats-mx-v1-0-spec-final-pdf
319+
}];
320+
}
321+
299322
//===----------------------------------------------------------------------===//
300323
// BFloat16Type
301324

mlir/include/mlir/IR/CommonTypeConstraints.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,8 @@ def F6E2M3FN : Type<CPred<"$_self.isFloat6E2M3FN()">, "f6E2M3FN type">,
353353
BuildableType<"$_builder.getFloat6E2M3FNType()">;
354354
def F6E3M2FN : Type<CPred<"$_self.isFloat6E3M2FN()">, "f6E3M2FN type">,
355355
BuildableType<"$_builder.getFloat6E3M2FNType()">;
356+
def F8E8M0FNU : Type<CPred<"$_self.isFloat8E8M0FNU()">, "f8E8M0FNU type">,
357+
BuildableType<"$_builder.getFloat8E8M0FNUType()">;
356358

357359
def AnyComplex : Type<CPred<"::llvm::isa<::mlir::ComplexType>($_self)">,
358360
"complex-type", "::mlir::ComplexType">;

mlir/include/mlir/IR/Types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ class Type {
135135
bool isFloat8E4M3FNUZ() const;
136136
bool isFloat8E4M3B11FNUZ() const;
137137
bool isFloat8E3M4() const;
138+
bool isFloat8E8M0FNU() const;
138139
bool isBF16() const;
139140
bool isF16() const;
140141
bool isTF32() const;

mlir/lib/AsmParser/TokenKinds.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ TOK_KEYWORD(f8E3M4)
104104
TOK_KEYWORD(f4E2M1FN)
105105
TOK_KEYWORD(f6E2M3FN)
106106
TOK_KEYWORD(f6E3M2FN)
107+
TOK_KEYWORD(f8E8M0FNU)
107108
TOK_KEYWORD(f128)
108109
TOK_KEYWORD(false)
109110
TOK_KEYWORD(floordiv)

mlir/lib/AsmParser/TypeParser.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ OptionalParseResult Parser::parseOptionalType(Type &type) {
4949
case Token::kw_f8E4M3FNUZ:
5050
case Token::kw_f8E4M3B11FNUZ:
5151
case Token::kw_f8E3M4:
52+
case Token::kw_f8E8M0FNU:
5253
case Token::kw_bf16:
5354
case Token::kw_f16:
5455
case Token::kw_tf32:
@@ -336,6 +337,9 @@ Type Parser::parseNonFunctionType() {
336337
case Token::kw_f8E3M4:
337338
consumeToken(Token::kw_f8E3M4);
338339
return builder.getFloat8E3M4Type();
340+
case Token::kw_f8E8M0FNU:
341+
consumeToken(Token::kw_f8E8M0FNU);
342+
return builder.getFloat8E8M0FNUType();
339343
case Token::kw_bf16:
340344
consumeToken(Token::kw_bf16);
341345
return builder.getBF16Type();

mlir/lib/Bindings/Python/IRTypes.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,27 @@ class PyFloat8E3M4Type : public PyConcreteType<PyFloat8E3M4Type, PyFloatType> {
331331
}
332332
};
333333

334+
/// Floating Point Type subclass - Float8E8M0FNUType.
335+
class PyFloat8E8M0FNUType
336+
: public PyConcreteType<PyFloat8E8M0FNUType, PyFloatType> {
337+
public:
338+
static constexpr IsAFunctionTy isaFunction = mlirTypeIsAFloat8E8M0FNU;
339+
static constexpr GetTypeIDFunctionTy getTypeIdFunction =
340+
mlirFloat8E8M0FNUTypeGetTypeID;
341+
static constexpr const char *pyClassName = "Float8E8M0FNUType";
342+
using PyConcreteType::PyConcreteType;
343+
344+
static void bindDerived(ClassTy &c) {
345+
c.def_static(
346+
"get",
347+
[](DefaultingPyMlirContext context) {
348+
MlirType t = mlirFloat8E8M0FNUTypeGet(context->get());
349+
return PyFloat8E8M0FNUType(context->getRef(), t);
350+
},
351+
py::arg("context") = py::none(), "Create a float8_e8m0fnu type.");
352+
}
353+
};
354+
334355
/// Floating Point Type subclass - BF16Type.
335356
class PyBF16Type : public PyConcreteType<PyBF16Type, PyFloatType> {
336357
public:
@@ -953,6 +974,7 @@ void mlir::python::populateIRTypes(py::module &m) {
953974
PyFloat8E4M3B11FNUZType::bind(m);
954975
PyFloat8E5M2FNUZType::bind(m);
955976
PyFloat8E3M4Type::bind(m);
977+
PyFloat8E8M0FNUType::bind(m);
956978
PyBF16Type::bind(m);
957979
PyF16Type::bind(m);
958980
PyTF32Type::bind(m);

mlir/lib/CAPI/IR/BuiltinTypes.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,18 @@ MlirType mlirFloat8E3M4TypeGet(MlirContext ctx) {
205205
return wrap(FloatType::getFloat8E3M4(unwrap(ctx)));
206206
}
207207

208+
MlirTypeID mlirFloat8E8M0FNUTypeGetTypeID() {
209+
return wrap(Float8E8M0FNUType::getTypeID());
210+
}
211+
212+
bool mlirTypeIsAFloat8E8M0FNU(MlirType type) {
213+
return unwrap(type).isFloat8E8M0FNU();
214+
}
215+
216+
MlirType mlirFloat8E8M0FNUTypeGet(MlirContext ctx) {
217+
return wrap(FloatType::getFloat8E8M0FNU(unwrap(ctx)));
218+
}
219+
208220
MlirTypeID mlirBFloat16TypeGetTypeID() {
209221
return wrap(BFloat16Type::getTypeID());
210222
}

mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ Type LLVMTypeConverter::convertFloatType(FloatType type) const {
250250
if (type.isFloat8E5M2() || type.isFloat8E4M3() || type.isFloat8E4M3FN() ||
251251
type.isFloat8E5M2FNUZ() || type.isFloat8E4M3FNUZ() ||
252252
type.isFloat8E4M3B11FNUZ() || type.isFloat8E3M4() ||
253-
type.isFloat4E2M1FN() || type.isFloat6E2M3FN() || type.isFloat6E3M2FN())
253+
type.isFloat4E2M1FN() || type.isFloat6E2M3FN() || type.isFloat6E3M2FN() ||
254+
type.isFloat8E8M0FNU())
254255
return IntegerType::get(&getContext(), type.getWidth());
255256
return type;
256257
}

mlir/lib/Dialect/Arith/Utils/Utils.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ std::optional<FloatType> parseFloatType(MLIRContext *ctx, StringRef name) {
370370
.Case("f8E5M2FNUZ", b.getFloat8E5M2FNUZType())
371371
.Case("f8E4M3FNUZ", b.getFloat8E4M3FNUZType())
372372
.Case("f8E3M4", b.getFloat8E3M4Type())
373+
.Case("f8E8M0FNU", b.getFloat8E8M0FNUType())
373374
.Case("bf16", b.getBF16Type())
374375
.Case("f16", b.getF16Type())
375376
.Case("f32", b.getF32Type())

mlir/lib/IR/AsmPrinter.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2593,6 +2593,7 @@ void AsmPrinter::Impl::printTypeImpl(Type type) {
25932593
.Case<Float8E4M3FNUZType>([&](Type) { os << "f8E4M3FNUZ"; })
25942594
.Case<Float8E4M3B11FNUZType>([&](Type) { os << "f8E4M3B11FNUZ"; })
25952595
.Case<Float8E3M4Type>([&](Type) { os << "f8E3M4"; })
2596+
.Case<Float8E8M0FNUType>([&](Type) { os << "f8E8M0FNU"; })
25962597
.Case<BFloat16Type>([&](Type) { os << "bf16"; })
25972598
.Case<Float16Type>([&](Type) { os << "f16"; })
25982599
.Case<FloatTF32Type>([&](Type) { os << "tf32"; })

mlir/lib/IR/Builders.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ FloatType Builder::getFloat8E3M4Type() {
7474
return FloatType::getFloat8E3M4(context);
7575
}
7676

77+
FloatType Builder::getFloat8E8M0FNUType() {
78+
return FloatType::getFloat8E8M0FNU(context);
79+
}
80+
7781
FloatType Builder::getBF16Type() { return FloatType::getBF16(context); }
7882

7983
FloatType Builder::getF16Type() { return FloatType::getF16(context); }

mlir/lib/IR/BuiltinTypes.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ const llvm::fltSemantics &FloatType::getFloatSemantics() {
121121
return APFloat::Float8E4M3B11FNUZ();
122122
if (llvm::isa<Float8E3M4Type>(*this))
123123
return APFloat::Float8E3M4();
124+
if (llvm::isa<Float8E8M0FNUType>(*this))
125+
return APFloat::Float8E8M0FNU();
124126
if (llvm::isa<BFloat16Type>(*this))
125127
return APFloat::BFloat();
126128
if (llvm::isa<Float16Type>(*this))

mlir/lib/IR/MLIRContext.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ class MLIRContextImpl {
231231
Float8E4M3FNUZType f8E4M3FNUZTy;
232232
Float8E4M3B11FNUZType f8E4M3B11FNUZTy;
233233
Float8E3M4Type f8E3M4Ty;
234+
Float8E8M0FNUType f8E8M0FNUTy;
234235
BFloat16Type bf16Ty;
235236
Float16Type f16Ty;
236237
FloatTF32Type tf32Ty;
@@ -326,6 +327,7 @@ MLIRContext::MLIRContext(const DialectRegistry &registry, Threading setting)
326327
impl->f8E4M3FNUZTy = TypeUniquer::get<Float8E4M3FNUZType>(this);
327328
impl->f8E4M3B11FNUZTy = TypeUniquer::get<Float8E4M3B11FNUZType>(this);
328329
impl->f8E3M4Ty = TypeUniquer::get<Float8E3M4Type>(this);
330+
impl->f8E8M0FNUTy = TypeUniquer::get<Float8E8M0FNUType>(this);
329331
impl->bf16Ty = TypeUniquer::get<BFloat16Type>(this);
330332
impl->f16Ty = TypeUniquer::get<Float16Type>(this);
331333
impl->tf32Ty = TypeUniquer::get<FloatTF32Type>(this);
@@ -1049,6 +1051,9 @@ Float8E4M3B11FNUZType Float8E4M3B11FNUZType::get(MLIRContext *context) {
10491051
Float8E3M4Type Float8E3M4Type::get(MLIRContext *context) {
10501052
return context->getImpl().f8E3M4Ty;
10511053
}
1054+
Float8E8M0FNUType Float8E8M0FNUType::get(MLIRContext *context) {
1055+
return context->getImpl().f8E8M0FNUTy;
1056+
}
10521057
BFloat16Type BFloat16Type::get(MLIRContext *context) {
10531058
return context->getImpl().bf16Ty;
10541059
}

mlir/lib/IR/Types.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ bool Type::isFloat8E4M3FNUZ() const {
4949
bool Type::isFloat8E4M3B11FNUZ() const {
5050
return llvm::isa<Float8E4M3B11FNUZType>(*this);
5151
}
52+
bool Type::isFloat8E8M0FNU() const {
53+
return llvm::isa<Float8E8M0FNUType>(*this);
54+
}
5255
bool Type::isFloat8E3M4() const { return llvm::isa<Float8E3M4Type>(*this); }
5356
bool Type::isBF16() const { return llvm::isa<BFloat16Type>(*this); }
5457
bool Type::isF16() const { return llvm::isa<Float16Type>(*this); }

mlir/python/mlir/_mlir_libs/_mlir/ir.pyi

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ __all__ = [
117117
"Float8E4M3Type",
118118
"Float8E5M2FNUZType",
119119
"Float8E5M2Type",
120+
"Float8E8M0FNUType",
120121
"FloatAttr",
121122
"FloatTF32Type",
122123
"FloatType",
@@ -1660,6 +1661,19 @@ class Float8E5M2Type(FloatType):
16601661
@property
16611662
def typeid(self) -> TypeID: ...
16621663

1664+
class Float8E8M0FNUType(FloatType):
1665+
static_typeid: ClassVar[TypeID]
1666+
@staticmethod
1667+
def get(context: Context | None = None) -> Float8E8M0FNUType:
1668+
"""
1669+
Create a float8_e8m0fnu type.
1670+
"""
1671+
@staticmethod
1672+
def isinstance(other: Type) -> bool: ...
1673+
def __init__(self, cast_from_type: Type) -> None: ...
1674+
@property
1675+
def typeid(self) -> TypeID: ...
1676+
16631677
class FloatAttr(Attribute):
16641678
static_typeid: ClassVar[TypeID]
16651679
@staticmethod

mlir/python/mlir/extras/types.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
Float8E4M3FNType,
2121
Float8E4M3Type,
2222
Float8E5M2Type,
23+
Float8E8M0FNUType,
2324
FunctionType,
2425
IndexType,
2526
IntegerType,
@@ -80,6 +81,7 @@ def ui(width):
8081
f4E2M1FN = lambda: Float4E2M1FNType.get()
8182
f6E2M3FN = lambda: Float6E2M3FNType.get()
8283
f6E3M2FN = lambda: Float6E3M2FNType.get()
84+
f8E8M0FNU = lambda: Float8E8M0FNUType.get()
8385

8486
none = lambda: NoneType.get()
8587

mlir/test/IR/attribute.mlir

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ func.func @float_attrs_pass() {
7676
// CHECK: float_attr = 2.000000e+00 : f8E3M4
7777
float_attr = 2. : f8E3M4
7878
} : () -> ()
79+
"test.float_attrs"() {
80+
// CHECK: float_attr = 2.000000e+00 : f8E8M0FNU
81+
float_attr = 2. : f8E8M0FNU
82+
} : () -> ()
7983
"test.float_attrs"() {
8084
// CHECK: float_attr = 2.000000e+00 : f16
8185
float_attr = 2. : f16

mlir/test/Target/LLVMIR/llvmir.mlir

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ llvm.mlir.global internal @f8E5M2FNUZ_global_as_i8(1.5 : f8E5M2FNUZ) : i8
7272
// CHECK: @f8E4M3B11FNUZ_global_as_i8 = internal global i8 92
7373
llvm.mlir.global internal @f8E4M3B11FNUZ_global_as_i8(1.5 : f8E4M3B11FNUZ) : i8
7474

75+
// CHECK: @f8E8M0FNU_global_as_i8 = internal global i8 127
76+
llvm.mlir.global internal @f8E8M0FNU_global_as_i8(1.0 : f8E8M0FNU) : i8
77+
7578
// CHECK: @bf16_global_as_i16 = internal global i16 16320
7679
llvm.mlir.global internal @bf16_global_as_i16(1.5 : bf16) : i16
7780

mlir/test/python/ir/builtin_types.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ def testFloatTypeSubclasses():
133133
# CHECK: True
134134
print(isinstance(Type.parse("f8E5M2FNUZ", ctx), FloatType))
135135
# CHECK: True
136+
print(isinstance(Type.parse("f8E8M0FNU", ctx), FloatType))
137+
# CHECK: True
136138
print(isinstance(Type.parse("f16", ctx), FloatType))
137139
# CHECK: True
138140
print(isinstance(Type.parse("bf16", ctx), FloatType))
@@ -259,6 +261,8 @@ def testFloatType():
259261
print("float:", Float8E4M3FNUZType.get())
260262
# CHECK: float: f8E4M3B11FNUZ
261263
print("float:", Float8E4M3B11FNUZType.get())
264+
# CHECK: float: f8E8M0FNU
265+
print("float:", Float8E8M0FNUType.get())
262266
# CHECK: float: bf16
263267
print("float:", BF16Type.get())
264268
# CHECK: float: f16
@@ -631,6 +635,7 @@ def testTypeIDs():
631635
(Float8E4M3FNUZType, Float8E4M3FNUZType.get()),
632636
(Float8E4M3B11FNUZType, Float8E4M3B11FNUZType.get()),
633637
(Float8E5M2FNUZType, Float8E5M2FNUZType.get()),
638+
(Float8E8M0FNUType, Float8E8M0FNUType.get()),
634639
(BF16Type, BF16Type.get()),
635640
(F16Type, F16Type.get()),
636641
(F32Type, F32Type.get()),
@@ -659,6 +664,7 @@ def testTypeIDs():
659664
# CHECK: Float8E4M3FNUZType(f8E4M3FNUZ)
660665
# CHECK: Float8E4M3B11FNUZType(f8E4M3B11FNUZ)
661666
# CHECK: Float8E5M2FNUZType(f8E5M2FNUZ)
667+
# CHECK: Float8E8M0FNUType(f8E8M0FNU)
662668
# CHECK: BF16Type(bf16)
663669
# CHECK: F16Type(f16)
664670
# CHECK: F32Type(f32)
@@ -761,6 +767,9 @@ def print_downcasted(typ):
761767
# CHECK: Float8E5M2FNUZType
762768
# CHECK: Float8E5M2FNUZType(f8E5M2FNUZ)
763769
print_downcasted(Float8E5M2FNUZType.get())
770+
# CHECK: Float8E8M0FNUType
771+
# CHECK: Float8E8M0FNUType(f8E8M0FNU)
772+
print_downcasted(Float8E8M0FNUType.get())
764773
# CHECK: BF16Type
765774
# CHECK: BF16Type(bf16)
766775
print_downcasted(BF16Type.get())

mlir/utils/lldb-scripts/mlirDataFormatters.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def build_ptr_str_from_addr(addrValue: lldb.SBValue, type: lldb.SBType):
6060
"mlir::Float8E4M3FNUZType": '"f8E4M3FNUZ"',
6161
"mlir::Float8E4M3B11FNUZType": '"f8E4M3B11FNUZ"',
6262
"mlir::Float8E3M4Type": '"f8E3M4"',
63+
"mlir::Float8E8M0FNUType": '"f8E8M0FNU"',
6364
"mlir::BFloat16Type": '"bf16"',
6465
"mlir::Float16Type": '"f16"',
6566
"mlir::FloatTF32Type": '"tf32"',

mlir/utils/tree-sitter-mlir/grammar.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,8 @@ const common = {
231231
token(seq(choice('si', 'ui', 'i'), /[1-9]/, repeat(/[0-9]/))),
232232
float_type : $ => token(
233233
choice('f16', 'f32', 'f64', 'f80', 'f128', 'bf16', 'f8E3M4', 'f8E4M3FN',
234-
'f8E4M3', 'f8E5M2', 'f4E2M1FN', 'f6E2M3FN', 'f6E3M2FN')),
234+
'f8E4M3', 'f8E5M2', 'f4E2M1FN', 'f6E2M3FN', 'f6E3M2FN',
235+
'f8E8M0FNU')),
235236
index_type : $ => token('index'),
236237
none_type : $ => token('none'),
237238
complex_type : $ => seq(token('complex'), '<', $._prim_type, '>'),

0 commit comments

Comments
 (0)