Skip to content
This repository was archived by the owner on Oct 11, 2025. It is now read-only.

Commit af4e97d

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](llvm/llvm-project#107127) [APFloat] Add APFloat support for E8M0 type - [PR-105573](llvm/llvm-project#105573) [MLIR] Add f6E3M2FN type - was used as a template for this PR - [PR-107999](llvm/llvm-project#107999) [MLIR] Add f6E2M3FN type - [PR-108877](llvm/llvm-project#108877) [MLIR] Add f4E2M1FN type
1 parent f752bd4 commit af4e97d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

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);

0 commit comments

Comments
 (0)