Is that possible to extend FloatType (e.g., Float8Type)?

Is that possible to add Float8Type as a derived class of FloatType?

In C++, we can add Float8Type as a derived class of FloatType by using
class Float8Type : public FloatType.

However, in MLIR, we need to determine if Float8Type is FloatType by calling
ty.isa<FloatType>, which is hardcoded as

inline bool FloatType::classof(Type type) {
  return type.isa<BFloat16Type, Float16Type, Float32Type, Float64Type,
                  Float80Type, Float128Type>();
}

. This suggests that Float8Type is not FloatType.

Is that possible to make Float8Type a FloatType without touching FloatType::classof(…)?

Thanks!

No, it is not possible.

MLIR makes it easy to define dialect-specific types, consider that instead. If you have a very good rationale, we may consider adding float8 as built-in (note, however, that LLVM IR does not support it).

1 Like

FYI - related RFC at the LLVM level: RFC: Add APFloat and MLIR type support for fp8 (e5m2)

1 Like