Skip to content

Commit eef1d7e

Browse files
authored
[MLIR] Add f8E3M4 IEEE 754 type (#101230)
This PR adds `f8E3M4` type to mlir. `f8E3M4` type follows IEEE 754 convention ```c f8E3M4 (IEEE 754) - Exponent bias: 3 - Maximum stored exponent value: 6 (binary 110) - Maximum unbiased exponent value: 6 - 3 = 3 - Minimum stored exponent value: 1 (binary 001) - Minimum unbiased exponent value: 1 − 3 = −2 - Precision specifies the total number of bits used for the significand (mantissa), including implicit leading integer bit = 4 + 1 = 5 - Follows IEEE 754 conventions for representation of special values - Has Positive and Negative zero - Has Positive and Negative infinity - Has NaNs Additional details: - Max exp (unbiased): 3 - Min exp (unbiased): -2 - Infinities (+/-): S.111.0000 - Zeros (+/-): S.000.0000 - NaNs: S.111.{0,1}⁴ except S.111.0000 - Max normal number: S.110.1111 = +/-2^(6-3) x (1 + 15/16) = +/-2^3 x 31 x 2^(-4) = +/-15.5 - Min normal number: S.001.0000 = +/-2^(1-3) x (1 + 0) = +/-2^(-2) - Max subnormal number: S.000.1111 = +/-2^(-2) x 15/16 = +/-2^(-2) x 15 x 2^(-4) = +/-15 x 2^(-6) - Min subnormal number: S.000.0001 = +/-2^(-2) x 1/16 = +/-2^(-2) x 2^(-4) = +/-2^(-6) ``` Related PRs: - [PR-99698](#99698) [APFloat] Add support for f8E3M4 IEEE 754 type - [PR-97118](#97118) [MLIR] Add f8E4M3 IEEE 754 type
1 parent e9c20b9 commit eef1d7e

File tree

24 files changed

+133
-9
lines changed

24 files changed

+133
-9
lines changed

mlir/include/mlir-c/BuiltinTypes.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,16 @@ MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat8E4M3B11FNUZ(MlirType type);
139139
/// context.
140140
MLIR_CAPI_EXPORTED MlirType mlirFloat8E4M3B11FNUZTypeGet(MlirContext ctx);
141141

142+
/// Returns the typeID of an Float8E3M4 type.
143+
MLIR_CAPI_EXPORTED MlirTypeID mlirFloat8E3M4TypeGetTypeID(void);
144+
145+
/// Checks whether the given type is an f8E3M4 type.
146+
MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat8E3M4(MlirType type);
147+
148+
/// Creates an f8E3M4 type in the given context. The type is owned by the
149+
/// context.
150+
MLIR_CAPI_EXPORTED MlirType mlirFloat8E3M4TypeGet(MlirContext ctx);
151+
142152
/// Returns the typeID of an BFloat16 type.
143153
MLIR_CAPI_EXPORTED MlirTypeID mlirBFloat16TypeGetTypeID(void);
144154

mlir/include/mlir/IR/Builders.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class Builder {
6666
FloatType getFloat8E5M2FNUZType();
6767
FloatType getFloat8E4M3FNUZType();
6868
FloatType getFloat8E4M3B11FNUZType();
69+
FloatType getFloat8E3M4Type();
6970
FloatType getBF16Type();
7071
FloatType getF16Type();
7172
FloatType getTF32Type();

mlir/include/mlir/IR/BuiltinTypes.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class FloatType : public Type {
6666
static FloatType getFloat8E5M2FNUZ(MLIRContext *ctx);
6767
static FloatType getFloat8E4M3FNUZ(MLIRContext *ctx);
6868
static FloatType getFloat8E4M3B11FNUZ(MLIRContext *ctx);
69+
static FloatType getFloat8E3M4(MLIRContext *ctx);
6970

7071
/// Methods for support type inquiry through isa, cast, and dyn_cast.
7172
static bool classof(Type type);
@@ -411,10 +412,11 @@ inline bool BaseMemRefType::isValidElementType(Type type) {
411412
}
412413

413414
inline bool FloatType::classof(Type type) {
414-
return llvm::isa<
415-
Float8E5M2Type, Float8E4M3Type, Float8E4M3FNType, Float8E5M2FNUZType,
416-
Float8E4M3FNUZType, Float8E4M3B11FNUZType, BFloat16Type, Float16Type,
417-
FloatTF32Type, Float32Type, Float64Type, Float80Type, Float128Type>(type);
415+
return llvm::isa<Float8E5M2Type, Float8E4M3Type, Float8E4M3FNType,
416+
Float8E5M2FNUZType, Float8E4M3FNUZType,
417+
Float8E4M3B11FNUZType, Float8E3M4Type, BFloat16Type,
418+
Float16Type, FloatTF32Type, Float32Type, Float64Type,
419+
Float80Type, Float128Type>(type);
418420
}
419421

420422
inline FloatType FloatType::getFloat8E5M2(MLIRContext *ctx) {
@@ -441,6 +443,10 @@ inline FloatType FloatType::getFloat8E4M3B11FNUZ(MLIRContext *ctx) {
441443
return Float8E4M3B11FNUZType::get(ctx);
442444
}
443445

446+
inline FloatType FloatType::getFloat8E3M4(MLIRContext *ctx) {
447+
return Float8E3M4Type::get(ctx);
448+
}
449+
444450
inline FloatType FloatType::getBF16(MLIRContext *ctx) {
445451
return BFloat16Type::get(ctx);
446452
}

mlir/include/mlir/IR/BuiltinTypes.td

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,25 @@ def Builtin_Float8E4M3B11FNUZ : Builtin_FloatType<"Float8E4M3B11FNUZ", "f8E4M3B1
213213
}];
214214
}
215215

216+
//===----------------------------------------------------------------------===//
217+
// Float8E3M4Type
218+
219+
def Builtin_Float8E3M4 : Builtin_FloatType<"Float8E3M4", "f8E3M4"> {
220+
let summary = "8-bit floating point with 3 bits exponent and 4 bit mantissa";
221+
let description = [{
222+
An 8-bit floating point type with 1 sign bit, 3 bits exponent and 4 bits
223+
mantissa. This is not a standard type as defined by IEEE-754, but it
224+
follows similar conventions with the following characteristics:
225+
226+
* bit encoding: S1E3M4
227+
* exponent bias: 3
228+
* infinities: supported with exponent set to all 1s and mantissa 0s
229+
* NaNs: supported with exponent bits set to all 1s and mantissa values of
230+
{0,1}⁴ except S.111.0000
231+
* denormals when exponent is 0
232+
}];
233+
}
234+
216235
//===----------------------------------------------------------------------===//
217236
// BFloat16Type
218237

mlir/include/mlir/IR/CommonTypeConstraints.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,8 @@ def F8E4M3B11FNUZ : Type<CPred<"$_self.isFloat8E4M3B11FNUZ()">, "f8E4M3B11FNUZ t
342342
BuildableType<"$_builder.getFloat8E4M3B11FNUZType()">;
343343
def F8E5M2FNUZ : Type<CPred<"$_self.isFloat8E5M2FNUZ()">, "f8E5M2FNUZ type">,
344344
BuildableType<"$_builder.getFloat8E5M2FNUZType()">;
345+
def F8E3M4 : Type<CPred<"$_self.isFloat8E3M4()">, "f8E3M4 type">,
346+
BuildableType<"$_builder.getFloat8E3M4Type()">;
345347

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

mlir/include/mlir/IR/Types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ class Type {
131131
bool isFloat8E5M2FNUZ() const;
132132
bool isFloat8E4M3FNUZ() const;
133133
bool isFloat8E4M3B11FNUZ() const;
134+
bool isFloat8E3M4() const;
134135
bool isBF16() const;
135136
bool isF16() const;
136137
bool isTF32() const;

mlir/lib/AsmParser/TokenKinds.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ TOK_KEYWORD(f8E4M3FN)
100100
TOK_KEYWORD(f8E5M2FNUZ)
101101
TOK_KEYWORD(f8E4M3FNUZ)
102102
TOK_KEYWORD(f8E4M3B11FNUZ)
103+
TOK_KEYWORD(f8E3M4)
103104
TOK_KEYWORD(f128)
104105
TOK_KEYWORD(false)
105106
TOK_KEYWORD(floordiv)

mlir/lib/AsmParser/TypeParser.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ OptionalParseResult Parser::parseOptionalType(Type &type) {
4545
case Token::kw_f8E5M2FNUZ:
4646
case Token::kw_f8E4M3FNUZ:
4747
case Token::kw_f8E4M3B11FNUZ:
48+
case Token::kw_f8E3M4:
4849
case Token::kw_bf16:
4950
case Token::kw_f16:
5051
case Token::kw_tf32:
@@ -320,6 +321,9 @@ Type Parser::parseNonFunctionType() {
320321
case Token::kw_f8E4M3B11FNUZ:
321322
consumeToken(Token::kw_f8E4M3B11FNUZ);
322323
return builder.getFloat8E4M3B11FNUZType();
324+
case Token::kw_f8E3M4:
325+
consumeToken(Token::kw_f8E3M4);
326+
return builder.getFloat8E3M4Type();
323327
case Token::kw_bf16:
324328
consumeToken(Token::kw_bf16);
325329
return builder.getBF16Type();

mlir/lib/Bindings/Python/IRTypes.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,26 @@ class PyFloat8E5M2FNUZType
246246
}
247247
};
248248

249+
/// Floating Point Type subclass - Float8E3M4Type.
250+
class PyFloat8E3M4Type : public PyConcreteType<PyFloat8E3M4Type, PyFloatType> {
251+
public:
252+
static constexpr IsAFunctionTy isaFunction = mlirTypeIsAFloat8E3M4;
253+
static constexpr GetTypeIDFunctionTy getTypeIdFunction =
254+
mlirFloat8E3M4TypeGetTypeID;
255+
static constexpr const char *pyClassName = "Float8E3M4Type";
256+
using PyConcreteType::PyConcreteType;
257+
258+
static void bindDerived(ClassTy &c) {
259+
c.def_static(
260+
"get",
261+
[](DefaultingPyMlirContext context) {
262+
MlirType t = mlirFloat8E3M4TypeGet(context->get());
263+
return PyFloat8E3M4Type(context->getRef(), t);
264+
},
265+
py::arg("context") = py::none(), "Create a float8_e3m4 type.");
266+
}
267+
};
268+
249269
/// Floating Point Type subclass - BF16Type.
250270
class PyBF16Type : public PyConcreteType<PyBF16Type, PyFloatType> {
251271
public:
@@ -864,6 +884,7 @@ void mlir::python::populateIRTypes(py::module &m) {
864884
PyFloat8E4M3FNUZType::bind(m);
865885
PyFloat8E4M3B11FNUZType::bind(m);
866886
PyFloat8E5M2FNUZType::bind(m);
887+
PyFloat8E3M4Type::bind(m);
867888
PyBF16Type::bind(m);
868889
PyF16Type::bind(m);
869890
PyTF32Type::bind(m);

mlir/lib/CAPI/IR/BuiltinTypes.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,18 @@ MlirType mlirFloat8E4M3B11FNUZTypeGet(MlirContext ctx) {
157157
return wrap(FloatType::getFloat8E4M3B11FNUZ(unwrap(ctx)));
158158
}
159159

160+
MlirTypeID mlirFloat8E3M4TypeGetTypeID() {
161+
return wrap(Float8E3M4Type::getTypeID());
162+
}
163+
164+
bool mlirTypeIsAFloat8E3M4(MlirType type) {
165+
return unwrap(type).isFloat8E3M4();
166+
}
167+
168+
MlirType mlirFloat8E3M4TypeGet(MlirContext ctx) {
169+
return wrap(FloatType::getFloat8E3M4(unwrap(ctx)));
170+
}
171+
160172
MlirTypeID mlirBFloat16TypeGetTypeID() {
161173
return wrap(BFloat16Type::getTypeID());
162174
}

mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ Type LLVMTypeConverter::convertIntegerType(IntegerType type) const {
249249
Type LLVMTypeConverter::convertFloatType(FloatType type) const {
250250
if (type.isFloat8E5M2() || type.isFloat8E4M3() || type.isFloat8E4M3FN() ||
251251
type.isFloat8E5M2FNUZ() || type.isFloat8E4M3FNUZ() ||
252-
type.isFloat8E4M3B11FNUZ())
252+
type.isFloat8E4M3B11FNUZ() || type.isFloat8E3M4())
253253
return IntegerType::get(&getContext(), type.getWidth());
254254
return type;
255255
}

mlir/lib/Dialect/Arith/Transforms/EmulateUnsupportedFloats.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ static std::optional<FloatType> parseFloatType(MLIRContext *ctx,
6060
.Case("f8E4M3FN", b.getFloat8E4M3FNType())
6161
.Case("f8E5M2FNUZ", b.getFloat8E5M2FNUZType())
6262
.Case("f8E4M3FNUZ", b.getFloat8E4M3FNUZType())
63+
.Case("f8E3M4", b.getFloat8E3M4Type())
6364
.Case("bf16", b.getBF16Type())
6465
.Case("f16", b.getF16Type())
6566
.Case("f32", b.getF32Type())

mlir/lib/IR/AsmPrinter.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2581,6 +2581,7 @@ void AsmPrinter::Impl::printTypeImpl(Type type) {
25812581
.Case<Float8E5M2FNUZType>([&](Type) { os << "f8E5M2FNUZ"; })
25822582
.Case<Float8E4M3FNUZType>([&](Type) { os << "f8E4M3FNUZ"; })
25832583
.Case<Float8E4M3B11FNUZType>([&](Type) { os << "f8E4M3B11FNUZ"; })
2584+
.Case<Float8E3M4Type>([&](Type) { os << "f8E3M4"; })
25842585
.Case<BFloat16Type>([&](Type) { os << "bf16"; })
25852586
.Case<Float16Type>([&](Type) { os << "f16"; })
25862587
.Case<FloatTF32Type>([&](Type) { os << "tf32"; })

mlir/lib/IR/Builders.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ FloatType Builder::getFloat8E4M3B11FNUZType() {
5858
return FloatType::getFloat8E4M3B11FNUZ(context);
5959
}
6060

61+
FloatType Builder::getFloat8E3M4Type() {
62+
return FloatType::getFloat8E3M4(context);
63+
}
64+
6165
FloatType Builder::getBF16Type() { return FloatType::getBF16(context); }
6266

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

mlir/lib/IR/BuiltinTypes.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ IntegerType IntegerType::scaleElementBitwidth(unsigned scale) {
8888

8989
unsigned FloatType::getWidth() {
9090
if (llvm::isa<Float8E5M2Type, Float8E4M3Type, Float8E4M3FNType,
91-
Float8E5M2FNUZType, Float8E4M3FNUZType, Float8E4M3B11FNUZType>(
92-
*this))
91+
Float8E5M2FNUZType, Float8E4M3FNUZType, Float8E4M3B11FNUZType,
92+
Float8E3M4Type>(*this))
9393
return 8;
9494
if (llvm::isa<Float16Type, BFloat16Type>(*this))
9595
return 16;
@@ -118,6 +118,8 @@ const llvm::fltSemantics &FloatType::getFloatSemantics() {
118118
return APFloat::Float8E4M3FNUZ();
119119
if (llvm::isa<Float8E4M3B11FNUZType>(*this))
120120
return APFloat::Float8E4M3B11FNUZ();
121+
if (llvm::isa<Float8E3M4Type>(*this))
122+
return APFloat::Float8E3M4();
121123
if (llvm::isa<BFloat16Type>(*this))
122124
return APFloat::BFloat();
123125
if (llvm::isa<Float16Type>(*this))

mlir/lib/IR/MLIRContext.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ class MLIRContextImpl {
227227
Float8E5M2FNUZType f8E5M2FNUZTy;
228228
Float8E4M3FNUZType f8E4M3FNUZTy;
229229
Float8E4M3B11FNUZType f8E4M3B11FNUZTy;
230+
Float8E3M4Type f8E3M4Ty;
230231
BFloat16Type bf16Ty;
231232
Float16Type f16Ty;
232233
FloatTF32Type tf32Ty;
@@ -318,6 +319,7 @@ MLIRContext::MLIRContext(const DialectRegistry &registry, Threading setting)
318319
impl->f8E5M2FNUZTy = TypeUniquer::get<Float8E5M2FNUZType>(this);
319320
impl->f8E4M3FNUZTy = TypeUniquer::get<Float8E4M3FNUZType>(this);
320321
impl->f8E4M3B11FNUZTy = TypeUniquer::get<Float8E4M3B11FNUZType>(this);
322+
impl->f8E3M4Ty = TypeUniquer::get<Float8E3M4Type>(this);
321323
impl->bf16Ty = TypeUniquer::get<BFloat16Type>(this);
322324
impl->f16Ty = TypeUniquer::get<Float16Type>(this);
323325
impl->tf32Ty = TypeUniquer::get<FloatTF32Type>(this);
@@ -1029,6 +1031,9 @@ Float8E4M3FNUZType Float8E4M3FNUZType::get(MLIRContext *context) {
10291031
Float8E4M3B11FNUZType Float8E4M3B11FNUZType::get(MLIRContext *context) {
10301032
return context->getImpl().f8E4M3B11FNUZTy;
10311033
}
1034+
Float8E3M4Type Float8E3M4Type::get(MLIRContext *context) {
1035+
return context->getImpl().f8E3M4Ty;
1036+
}
10321037
BFloat16Type BFloat16Type::get(MLIRContext *context) {
10331038
return context->getImpl().bf16Ty;
10341039
}

mlir/lib/IR/Types.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ bool Type::isFloat8E4M3FNUZ() const {
4646
bool Type::isFloat8E4M3B11FNUZ() const {
4747
return llvm::isa<Float8E4M3B11FNUZType>(*this);
4848
}
49+
bool Type::isFloat8E3M4() const { return llvm::isa<Float8E3M4Type>(*this); }
4950
bool Type::isBF16() const { return llvm::isa<BFloat16Type>(*this); }
5051
bool Type::isF16() const { return llvm::isa<Float16Type>(*this); }
5152
bool Type::isTF32() const { return llvm::isa<FloatTF32Type>(*this); }

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ __all__ = [
120120
"F32Type",
121121
"F64Type",
122122
"FlatSymbolRefAttr",
123+
"Float8E3M4Type",
123124
"Float8E4M3B11FNUZType",
124125
"Float8E4M3FNType",
125126
"Float8E4M3FNUZType",
@@ -1537,6 +1538,19 @@ class FlatSymbolRefAttr(Attribute):
15371538
Returns the value of the FlatSymbolRef attribute as a string
15381539
"""
15391540

1541+
class Float8E3M4Type(FloatType):
1542+
static_typeid: ClassVar[TypeID]
1543+
@staticmethod
1544+
def get(context: Optional[Context] = None) -> Float8E3M4Type:
1545+
"""
1546+
Create a float8_e3m4 type.
1547+
"""
1548+
@staticmethod
1549+
def isinstance(other: Type) -> bool: ...
1550+
def __init__(self, cast_from_type: Type) -> None: ...
1551+
@property
1552+
def typeid(self) -> TypeID: ...
1553+
15401554
class Float8E4M3B11FNUZType(FloatType):
15411555
static_typeid: ClassVar[TypeID]
15421556
@staticmethod

mlir/python/mlir/extras/types.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
F16Type,
1313
F32Type,
1414
F64Type,
15+
Float8E3M4Type,
1516
Float8E4M3B11FNUZType,
1617
Float8E4M3FNType,
1718
Float8E4M3Type,
@@ -72,6 +73,7 @@ def ui(width):
7273
f8E4M3 = lambda: Float8E4M3Type.get()
7374
f8E4M3FN = lambda: Float8E4M3FNType.get()
7475
f8E4M3B11FNUZ = lambda: Float8E4M3B11FNUZType.get()
76+
f8E3M4 = lambda: Float8E3M4Type.get()
7577

7678
none = lambda: NoneType.get()
7779

mlir/test/IR/attribute.mlir

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ func.func @float_attrs_pass() {
6060
// CHECK: float_attr = 2.000000e+00 : f8E4M3B11FNUZ
6161
float_attr = 2. : f8E4M3B11FNUZ
6262
} : () -> ()
63+
"test.float_attrs"() {
64+
// CHECK: float_attr = 2.000000e+00 : f8E3M4
65+
float_attr = 2. : f8E3M4
66+
} : () -> ()
6367
"test.float_attrs"() {
6468
// CHECK: float_attr = 2.000000e+00 : f16
6569
float_attr = 2. : f16

mlir/test/Target/LLVMIR/llvmir.mlir

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ llvm.mlir.global internal constant @string_const("foobar") : !llvm.array<6 x i8>
3939
// CHECK: @int_global_undef = internal global i64 undef
4040
llvm.mlir.global internal @int_global_undef() : i64
4141

42+
// CHECK: @f8E3M4_global_as_i8 = internal global i8 56
43+
llvm.mlir.global internal @f8E3M4_global_as_i8(1.5 : f8E3M4) : i8
44+
4245
// CHECK: @f8E4M3_global_as_i8 = internal global i8 60
4346
llvm.mlir.global internal @f8E4M3_global_as_i8(1.5 : f8E4M3) : i8
4447

mlir/test/python/ir/builtin_types.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ def testTypeIsInstance():
113113
def testFloatTypeSubclasses():
114114
ctx = Context()
115115
# CHECK: True
116+
print(isinstance(Type.parse("f8E3M4", ctx), FloatType))
117+
# CHECK: True
116118
print(isinstance(Type.parse("f8E4M3", ctx), FloatType))
117119
# CHECK: True
118120
print(isinstance(Type.parse("f8E4M3FN", ctx), FloatType))
@@ -231,6 +233,8 @@ def testIndexType():
231233
@run
232234
def testFloatType():
233235
with Context():
236+
# CHECK: float: f8E3M4
237+
print("float:", Float8E3M4Type.get())
234238
# CHECK: float: f8E4M3
235239
print("float:", Float8E4M3Type.get())
236240
# CHECK: float: f8E4M3FN
@@ -605,6 +609,7 @@ def testTypeIDs():
605609
types = [
606610
(IntegerType, IntegerType.get_signless(16)),
607611
(IndexType, IndexType.get()),
612+
(Float8E3M4Type, Float8E3M4Type.get()),
608613
(Float8E4M3Type, Float8E4M3Type.get()),
609614
(Float8E4M3FNType, Float8E4M3FNType.get()),
610615
(Float8E5M2Type, Float8E5M2Type.get()),
@@ -629,6 +634,7 @@ def testTypeIDs():
629634

630635
# CHECK: IntegerType(i16)
631636
# CHECK: IndexType(index)
637+
# CHECK: Float8E3M4Type(f8E3M4)
632638
# CHECK: Float8E4M3Type(f8E4M3)
633639
# CHECK: Float8E4M3FNType(f8E4M3FN)
634640
# CHECK: Float8E5M2Type(f8E5M2)
@@ -707,6 +713,9 @@ def print_downcasted(typ):
707713
# CHECK: F64Type
708714
# CHECK: F64Type(f64)
709715
print_downcasted(F64Type.get())
716+
# CHECK: Float8E3M4Type
717+
# CHECK: Float8E3M4Type(f8E3M4)
718+
print_downcasted(Float8E3M4Type.get())
710719
# CHECK: Float8E4M3B11FNUZType
711720
# CHECK: Float8E4M3B11FNUZType(f8E4M3B11FNUZ)
712721
print_downcasted(Float8E4M3B11FNUZType.get())

mlir/utils/lldb-scripts/mlirDataFormatters.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def build_ptr_str_from_addr(addrValue: lldb.SBValue, type: lldb.SBType):
5656
"mlir::Float8E5M2FNUZType": '"f8E5M2FNUZ"',
5757
"mlir::Float8E4M3FNUZType": '"f8E4M3FNUZ"',
5858
"mlir::Float8E4M3B11FNUZType": '"f8E4M3B11FNUZ"',
59+
"mlir::Float8E3M4Type": '"f8E3M4"',
5960
"mlir::BFloat16Type": '"bf16"',
6061
"mlir::Float16Type": '"f16"',
6162
"mlir::FloatTF32Type": '"tf32"',

0 commit comments

Comments
 (0)