Skip to content

Commit 2c58063

Browse files
authored
[MLIR] Add f4E2M1FN type (#108877)
This PR adds `f4E2M1FN` type to mlir. `f4E2M1FN` type is proposed in [OpenCompute MX Specification](https://www.opencompute.org/documents/ocp-microscaling-formats-mx-v1-0-spec-final-pdf). It defines a 4-bit floating point number with bit layout S1E2M1. Unlike IEEE-754 types, there are no infinity or NaN values. ```c f4E2M1FN - Exponent bias: 1 - Maximum stored exponent value: 3 (binary 11) - Maximum unbiased exponent value: 3 - 1 = 2 - Minimum stored exponent value: 1 (binary 01) - Minimum unbiased exponent value: 1 − 1 = 0 - Has Positive and Negative zero - Doesn't have infinity - Doesn't have NaNs Additional details: - Zeros (+/-): S.00.0 - Max normal number: S.11.1 = ±2^(2) x (1 + 0.5) = ±6.0 - Min normal number: S.01.0 = ±2^(0) = ±1.0 - Min subnormal number: S.00.1 = ±2^(0) x 0.5 = ±0.5 ``` Related PRs: - [PR-95392](#95392) [APFloat] Add APFloat support for FP4 data type - [PR-105573](#105573) [MLIR] Add f6E3M2FN type - was used as a template for this PR - [PR-107999](#107999) [MLIR] Add f6E2M3FN type
1 parent 63b2595 commit 2c58063

File tree

24 files changed

+133
-7
lines changed

24 files changed

+133
-7
lines changed

mlir/include/mlir-c/BuiltinTypes.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,16 @@ MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat(MlirType type);
7979
/// Returns the bitwidth of a floating-point type.
8080
MLIR_CAPI_EXPORTED unsigned mlirFloatTypeGetWidth(MlirType type);
8181

82+
/// Returns the typeID of an Float4E2M1FN type.
83+
MLIR_CAPI_EXPORTED MlirTypeID mlirFloat4E2M1FNTypeGetTypeID(void);
84+
85+
/// Checks whether the given type is an f4E2M1FN type.
86+
MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat4E2M1FN(MlirType type);
87+
88+
/// Creates an f4E2M1FN type in the given context. The type is owned by the
89+
/// context.
90+
MLIR_CAPI_EXPORTED MlirType mlirFloat4E2M1FNTypeGet(MlirContext ctx);
91+
8292
/// Returns the typeID of an Float6E2M3FN type.
8393
MLIR_CAPI_EXPORTED MlirTypeID mlirFloat6E2M3FNTypeGetTypeID(void);
8494

mlir/include/mlir/IR/Builders.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class Builder {
6060
Attribute metadata = Attribute());
6161

6262
// Types.
63+
FloatType getFloat4E2M1FNType();
6364
FloatType getFloat6E2M3FNType();
6465
FloatType getFloat6E3M2FNType();
6566
FloatType getFloat8E5M2Type();

mlir/include/mlir/IR/BuiltinTypes.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class FloatType : public Type {
6767
static FloatType getFloat8E4M3FNUZ(MLIRContext *ctx);
6868
static FloatType getFloat8E4M3B11FNUZ(MLIRContext *ctx);
6969
static FloatType getFloat8E3M4(MLIRContext *ctx);
70+
static FloatType getFloat4E2M1FN(MLIRContext *ctx);
7071
static FloatType getFloat6E2M3FN(MLIRContext *ctx);
7172
static FloatType getFloat6E3M2FN(MLIRContext *ctx);
7273

@@ -415,11 +416,15 @@ inline bool BaseMemRefType::isValidElementType(Type type) {
415416
}
416417

417418
inline bool FloatType::classof(Type type) {
418-
return llvm::isa<Float6E2M3FNType, Float6E3M2FNType, Float8E5M2Type,
419-
Float8E4M3Type, Float8E4M3FNType, Float8E5M2FNUZType,
420-
Float8E4M3FNUZType, Float8E4M3B11FNUZType, Float8E3M4Type,
421-
BFloat16Type, Float16Type, FloatTF32Type, Float32Type,
422-
Float64Type, Float80Type, Float128Type>(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);
424+
}
425+
426+
inline FloatType FloatType::getFloat4E2M1FN(MLIRContext *ctx) {
427+
return Float4E2M1FNType::get(ctx);
423428
}
424429

425430
inline FloatType FloatType::getFloat6E2M3FN(MLIRContext *ctx) {

mlir/include/mlir/IR/BuiltinTypes.td

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,27 @@ def Builtin_Float8E3M4 : Builtin_FloatType<"Float8E3M4", "f8E3M4"> {
233233
}];
234234
}
235235

236+
//===----------------------------------------------------------------------===//
237+
// Float4E2M1FNType
238+
239+
def Builtin_Float4E2M1FN : Builtin_FloatType<"Float4E2M1FN", "f4E2M1FN"> {
240+
let summary = "4-bit floating point with 2-bit exponent and 1-bit mantissa";
241+
let description = [{
242+
An 4-bit floating point type with 1 sign bit, 2 bits exponent and 1 bit
243+
mantissa. This is not a standard type as defined by IEEE-754, but it
244+
follows similar conventions with the following characteristics:
245+
246+
* bit encoding: S1E2M1
247+
* exponent bias: 1
248+
* infinities: Not supported
249+
* NaNs: Not supported
250+
* denormals when exponent is 0
251+
252+
Open Compute Project (OCP) microscaling formats (MX) specification:
253+
https://www.opencompute.org/documents/ocp-microscaling-formats-mx-v1-0-spec-final-pdf
254+
}];
255+
}
256+
236257
//===----------------------------------------------------------------------===//
237258
// Float6E2M3FNType
238259

mlir/include/mlir/IR/CommonTypeConstraints.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,8 @@ def F8E5M2FNUZ : Type<CPred<"$_self.isFloat8E5M2FNUZ()">, "f8E5M2FNUZ type">,
347347
BuildableType<"$_builder.getFloat8E5M2FNUZType()">;
348348
def F8E3M4 : Type<CPred<"$_self.isFloat8E3M4()">, "f8E3M4 type">,
349349
BuildableType<"$_builder.getFloat8E3M4Type()">;
350+
def F4E2M1FN : Type<CPred<"$_self.isFloat4E2M1FN()">, "f4E2M1FN type">,
351+
BuildableType<"$_builder.getFloat4E2M1FNType()">;
350352
def F6E2M3FN : Type<CPred<"$_self.isFloat6E2M3FN()">, "f6E2M3FN type">,
351353
BuildableType<"$_builder.getFloat6E2M3FNType()">;
352354
def F6E3M2FN : Type<CPred<"$_self.isFloat6E3M2FN()">, "f6E3M2FN type">,

mlir/include/mlir/IR/Types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ class Type {
125125
// Convenience predicates. This is only for floating point types,
126126
// derived types should use isa/dyn_cast.
127127
bool isIndex() const;
128+
bool isFloat4E2M1FN() const;
128129
bool isFloat6E2M3FN() const;
129130
bool isFloat6E3M2FN() const;
130131
bool isFloat8E5M2() const;

mlir/lib/AsmParser/TokenKinds.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ TOK_KEYWORD(f8E5M2FNUZ)
101101
TOK_KEYWORD(f8E4M3FNUZ)
102102
TOK_KEYWORD(f8E4M3B11FNUZ)
103103
TOK_KEYWORD(f8E3M4)
104+
TOK_KEYWORD(f4E2M1FN)
104105
TOK_KEYWORD(f6E2M3FN)
105106
TOK_KEYWORD(f6E3M2FN)
106107
TOK_KEYWORD(f128)

mlir/lib/AsmParser/TypeParser.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ OptionalParseResult Parser::parseOptionalType(Type &type) {
3939
case Token::kw_tuple:
4040
case Token::kw_vector:
4141
case Token::inttype:
42+
case Token::kw_f4E2M1FN:
4243
case Token::kw_f6E2M3FN:
4344
case Token::kw_f6E3M2FN:
4445
case Token::kw_f8E5M2:
@@ -305,6 +306,9 @@ Type Parser::parseNonFunctionType() {
305306
}
306307

307308
// float-type
309+
case Token::kw_f4E2M1FN:
310+
consumeToken(Token::kw_f4E2M1FN);
311+
return builder.getFloat4E2M1FNType();
308312
case Token::kw_f6E2M3FN:
309313
consumeToken(Token::kw_f6E2M3FN);
310314
return builder.getFloat6E2M3FNType();

mlir/lib/Bindings/Python/IRTypes.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,27 @@ class PyFloatType : public PyConcreteType<PyFloatType> {
124124
}
125125
};
126126

127+
/// Floating Point Type subclass - Float4E2M1FNType.
128+
class PyFloat4E2M1FNType
129+
: public PyConcreteType<PyFloat4E2M1FNType, PyFloatType> {
130+
public:
131+
static constexpr IsAFunctionTy isaFunction = mlirTypeIsAFloat4E2M1FN;
132+
static constexpr GetTypeIDFunctionTy getTypeIdFunction =
133+
mlirFloat4E2M1FNTypeGetTypeID;
134+
static constexpr const char *pyClassName = "Float4E2M1FNType";
135+
using PyConcreteType::PyConcreteType;
136+
137+
static void bindDerived(ClassTy &c) {
138+
c.def_static(
139+
"get",
140+
[](DefaultingPyMlirContext context) {
141+
MlirType t = mlirFloat4E2M1FNTypeGet(context->get());
142+
return PyFloat4E2M1FNType(context->getRef(), t);
143+
},
144+
py::arg("context") = py::none(), "Create a float4_e2m1fn type.");
145+
}
146+
};
147+
127148
/// Floating Point Type subclass - Float6E2M3FNType.
128149
class PyFloat6E2M3FNType
129150
: public PyConcreteType<PyFloat6E2M3FNType, PyFloatType> {
@@ -922,6 +943,7 @@ void mlir::python::populateIRTypes(py::module &m) {
922943
PyIntegerType::bind(m);
923944
PyFloatType::bind(m);
924945
PyIndexType::bind(m);
946+
PyFloat4E2M1FNType::bind(m);
925947
PyFloat6E2M3FNType::bind(m);
926948
PyFloat6E3M2FNType::bind(m);
927949
PyFloat8E4M3FNType::bind(m);

mlir/lib/CAPI/IR/BuiltinTypes.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,18 @@ unsigned mlirFloatTypeGetWidth(MlirType type) {
8585
return llvm::cast<FloatType>(unwrap(type)).getWidth();
8686
}
8787

88+
MlirTypeID mlirFloat4E2M1FNTypeGetTypeID() {
89+
return wrap(Float4E2M1FNType::getTypeID());
90+
}
91+
92+
bool mlirTypeIsAFloat4E2M1FN(MlirType type) {
93+
return unwrap(type).isFloat4E2M1FN();
94+
}
95+
96+
MlirType mlirFloat4E2M1FNTypeGet(MlirContext ctx) {
97+
return wrap(FloatType::getFloat4E2M1FN(unwrap(ctx)));
98+
}
99+
88100
MlirTypeID mlirFloat6E2M3FNTypeGetTypeID() {
89101
return wrap(Float6E2M3FNType::getTypeID());
90102
}

mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ 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.isFloat6E2M3FN() || type.isFloat6E3M2FN())
253+
type.isFloat4E2M1FN() || type.isFloat6E2M3FN() || type.isFloat6E3M2FN())
254254
return IntegerType::get(&getContext(), type.getWidth());
255255
return type;
256256
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ static std::optional<FloatType> parseFloatType(MLIRContext *ctx,
5555
StringRef name) {
5656
Builder b(ctx);
5757
return llvm::StringSwitch<std::optional<FloatType>>(name)
58+
.Case("f4E2M1FN", b.getFloat4E2M1FNType())
5859
.Case("f6E2M3FN", b.getFloat6E2M3FNType())
5960
.Case("f6E3M2FN", b.getFloat6E3M2FNType())
6061
.Case("f8E5M2", b.getFloat8E5M2Type())

mlir/lib/IR/AsmPrinter.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2575,6 +2575,7 @@ void AsmPrinter::Impl::printTypeImpl(Type type) {
25752575
opaqueTy.getTypeData());
25762576
})
25772577
.Case<IndexType>([&](Type) { os << "index"; })
2578+
.Case<Float4E2M1FNType>([&](Type) { os << "f4E2M1FN"; })
25782579
.Case<Float6E2M3FNType>([&](Type) { os << "f6E2M3FN"; })
25792580
.Case<Float6E3M2FNType>([&](Type) { os << "f6E3M2FN"; })
25802581
.Case<Float8E5M2Type>([&](Type) { os << "f8E5M2"; })

mlir/lib/IR/Builders.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ Location Builder::getFusedLoc(ArrayRef<Location> locs, Attribute metadata) {
3434
// Types.
3535
//===----------------------------------------------------------------------===//
3636

37+
FloatType Builder::getFloat4E2M1FNType() {
38+
return FloatType::getFloat4E2M1FN(context);
39+
}
40+
3741
FloatType Builder::getFloat6E2M3FNType() {
3842
return FloatType::getFloat6E2M3FN(context);
3943
}

mlir/lib/IR/BuiltinTypes.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ unsigned FloatType::getWidth() {
101101

102102
/// Returns the floating semantics for the given type.
103103
const llvm::fltSemantics &FloatType::getFloatSemantics() {
104+
if (llvm::isa<Float4E2M1FNType>(*this))
105+
return APFloat::Float4E2M1FN();
104106
if (llvm::isa<Float6E2M3FNType>(*this))
105107
return APFloat::Float6E2M3FN();
106108
if (llvm::isa<Float6E3M2FNType>(*this))

mlir/lib/IR/MLIRContext.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ class MLIRContextImpl {
221221
llvm::DenseMap<StringRef, AbstractType *> nameToType;
222222

223223
/// Cached Type Instances.
224+
Float4E2M1FNType f4E2M1FNTy;
224225
Float6E2M3FNType f6E2M3FNTy;
225226
Float6E3M2FNType f6E3M2FNTy;
226227
Float8E5M2Type f8E5M2Ty;
@@ -315,6 +316,7 @@ MLIRContext::MLIRContext(const DialectRegistry &registry, Threading setting)
315316

316317
//// Types.
317318
/// Floating-point Types.
319+
impl->f4E2M1FNTy = TypeUniquer::get<Float4E2M1FNType>(this);
318320
impl->f6E2M3FNTy = TypeUniquer::get<Float6E2M3FNType>(this);
319321
impl->f6E3M2FNTy = TypeUniquer::get<Float6E3M2FNType>(this);
320322
impl->f8E5M2Ty = TypeUniquer::get<Float8E5M2Type>(this);
@@ -1017,6 +1019,9 @@ AbstractType::lookup(StringRef name, MLIRContext *context) {
10171019
/// This should not be used directly.
10181020
StorageUniquer &MLIRContext::getTypeUniquer() { return getImpl().typeUniquer; }
10191021

1022+
Float4E2M1FNType Float4E2M1FNType::get(MLIRContext *context) {
1023+
return context->getImpl().f4E2M1FNTy;
1024+
}
10201025
Float6E2M3FNType Float6E2M3FNType::get(MLIRContext *context) {
10211026
return context->getImpl().f6E2M3FNTy;
10221027
}

mlir/lib/IR/Types.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Type AbstractType::replaceImmediateSubElements(Type type,
3434

3535
MLIRContext *Type::getContext() const { return getDialect().getContext(); }
3636

37+
bool Type::isFloat4E2M1FN() const { return llvm::isa<Float4E2M1FNType>(*this); }
3738
bool Type::isFloat6E2M3FN() const { return llvm::isa<Float6E2M3FNType>(*this); }
3839
bool Type::isFloat6E3M2FN() const { return llvm::isa<Float6E3M2FNType>(*this); }
3940
bool Type::isFloat8E5M2() const { return llvm::isa<Float8E5M2Type>(*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+
"Float4E2M1FNType",
123124
"Float6E2M3FNType",
124125
"Float6E3M2FNType",
125126
"Float8E3M4Type",
@@ -1542,6 +1543,19 @@ class FlatSymbolRefAttr(Attribute):
15421543
Returns the value of the FlatSymbolRef attribute as a string
15431544
"""
15441545

1546+
class Float4E2M1FNType(FloatType):
1547+
static_typeid: ClassVar[TypeID]
1548+
@staticmethod
1549+
def get(context: Optional[Context] = None) -> Float4E2M1FNType:
1550+
"""
1551+
Create a float4_e2m1fn type.
1552+
"""
1553+
@staticmethod
1554+
def isinstance(other: Type) -> bool: ...
1555+
def __init__(self, cast_from_type: Type) -> None: ...
1556+
@property
1557+
def typeid(self) -> TypeID: ...
1558+
15451559
class Float6E2M3FNType(FloatType):
15461560
static_typeid: ClassVar[TypeID]
15471561
@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+
Float4E2M1FNType,
1516
Float6E2M3FNType,
1617
Float6E3M2FNType,
1718
Float8E3M4Type,
@@ -76,6 +77,7 @@ def ui(width):
7677
f8E4M3FN = lambda: Float8E4M3FNType.get()
7778
f8E4M3B11FNUZ = lambda: Float8E4M3B11FNUZType.get()
7879
f8E3M4 = lambda: Float8E3M4Type.get()
80+
f4E2M1FN = lambda: Float4E2M1FNType.get()
7981
f6E2M3FN = lambda: Float6E2M3FNType.get()
8082
f6E3M2FN = lambda: Float6E3M2FNType.get()
8183

mlir/test/IR/attribute.mlir

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ func.func @any_attr_of_fail() {
3636
//===----------------------------------------------------------------------===//
3737

3838
func.func @float_attrs_pass() {
39+
"test.float_attrs"() {
40+
// CHECK: float_attr = 2.000000e+00 : f4E2M1FN
41+
float_attr = 2. : f4E2M1FN
42+
} : () -> ()
3943
"test.float_attrs"() {
4044
// CHECK: float_attr = 2.000000e+00 : f6E2M3FN
4145
float_attr = 2. : f6E2M3FN

mlir/test/Target/LLVMIR/llvmir.mlir

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ llvm.mlir.global internal @int_global_undef() : i64
4242
// CHECK: @externally_initialized_global = internal externally_initialized global i32 0
4343
llvm.mlir.global internal @externally_initialized_global(0 : i32) {externally_initialized} : i32
4444

45+
// CHECK: @f4E2M1FN_global_as_i4 = internal global i4 3
46+
llvm.mlir.global internal @f4E2M1FN_global_as_i4(1.5 : f4E2M1FN) : i4
47+
4548
// CHECK: @f6E2M3FN_global_as_i6 = internal global i6 12
4649
llvm.mlir.global internal @f6E2M3FN_global_as_i6(1.5 : f6E2M3FN) : i6
4750

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("f4E2M1FN", ctx), FloatType))
117+
# CHECK: True
116118
print(isinstance(Type.parse("f6E2M3FN", ctx), FloatType))
117119
# CHECK: True
118120
print(isinstance(Type.parse("f6E3M2FN", ctx), FloatType))
@@ -237,6 +239,8 @@ def testIndexType():
237239
@run
238240
def testFloatType():
239241
with Context():
242+
# CHECK: float: f4E2M1FN
243+
print("float:", Float4E2M1FNType.get())
240244
# CHECK: float: f6E2M3FN
241245
print("float:", Float6E2M3FNType.get())
242246
# CHECK: float: f6E3M2FN
@@ -617,6 +621,7 @@ def testTypeIDs():
617621
types = [
618622
(IntegerType, IntegerType.get_signless(16)),
619623
(IndexType, IndexType.get()),
624+
(Float4E2M1FNType, Float4E2M1FNType.get()),
620625
(Float6E2M3FNType, Float6E2M3FNType.get()),
621626
(Float6E3M2FNType, Float6E3M2FNType.get()),
622627
(Float8E3M4Type, Float8E3M4Type.get()),
@@ -644,6 +649,7 @@ def testTypeIDs():
644649

645650
# CHECK: IntegerType(i16)
646651
# CHECK: IndexType(index)
652+
# CHECK: Float4E2M1FNType(f4E2M1FN)
647653
# CHECK: Float6E2M3FNType(f6E2M3FN)
648654
# CHECK: Float6E3M2FNType(f6E3M2FN)
649655
# CHECK: Float8E3M4Type(f8E3M4)
@@ -725,6 +731,9 @@ def print_downcasted(typ):
725731
# CHECK: F64Type
726732
# CHECK: F64Type(f64)
727733
print_downcasted(F64Type.get())
734+
# CHECK: Float4E2M1FNType
735+
# CHECK: Float4E2M1FNType(f4E2M1FN)
736+
print_downcasted(Float4E2M1FNType.get())
728737
# CHECK: Float6E2M3FNType
729738
# CHECK: Float6E2M3FNType(f6E2M3FN)
730739
print_downcasted(Float6E2M3FNType.get())

mlir/utils/lldb-scripts/mlirDataFormatters.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def build_ptr_str_from_addr(addrValue: lldb.SBValue, type: lldb.SBType):
5050
"mlir::CallSiteLoc": '"loc(callsite(...))"',
5151
"mlir::FusedLoc": '"loc(fused<...>[...])"',
5252
"mlir::UnknownLoc": '"loc(unknown)"',
53+
"mlir::Float4E2M1FNType": '"f4E2M1FN"',
5354
"mlir::Float6E2M3FNType": '"f6E2M3FN"',
5455
"mlir::Float6E3M2FNType": '"f6E3M2FN"',
5556
"mlir::Float8E5M2Type": '"f8E5M2"',

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ 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', 'f6E2M3FN', 'f6E3M2FN')),
234+
'f8E4M3', 'f8E5M2', 'f4E2M1FN', 'f6E2M3FN', 'f6E3M2FN')),
235235
index_type : $ => token('index'),
236236
none_type : $ => token('none'),
237237
complex_type : $ => seq(token('complex'), '<', $._prim_type, '>'),

0 commit comments

Comments
 (0)