[Mlir-commits] [mlir] Extending UniformQuantizedType with interface-based support for new storage types in Quant dialect (PR #152966)
Javed Absar
llvmlistbot at llvm.org
Mon Feb 9 04:25:34 PST 2026
================
@@ -270,6 +332,34 @@ def Builtin_Float4E2M1FN : Builtin_FloatType<"Float4E2M1FN", "f4E2M1FN"> {
Open Compute Project (OCP) microscaling formats (MX) specification:
https://www.opencompute.org/documents/ocp-microscaling-formats-mx-v1-0-spec-final-pdf
}];
+
+ let extraClassDeclaration = [{
+ /// QuantStorageTypeInterface method implementations
+ /// Whether the storage type should default to signed when used in quantization.
+ bool shouldDefaultToSigned() const { return true; }
+ /// Get the bit width of this 4-bit floating point type.
+ unsigned getStorageWidth() const { return 4; }
+
+ /// Get default maximum value for this 4-bit floating point type.
+ int64_t getDefaultMaximum(bool isSigned) const { return 6; }
+ /// Get default minimum value for this 4-bit floating point type.
+ int64_t getDefaultMinimum(bool isSigned) const { return -getDefaultMaximum(isSigned); }
+
+ /// Get the storage type as a string.
+ std::string getStorageTypeName(bool isSigned) const { return "f4E2M1FN"; }
+
+ /// Check if this 4-bit floating point type uses packed representation.
+ bool isPacked() const { return true; }
+
+ /// Get the logical bit width per value for this 4-bit floating point type.
+ unsigned getLogicalBitWidth() const { return 4; }
+
+ /// Get the number of logical elements that fit in one byte for this 4-bit floating point type.
----------------
javedabsar1 wrote:
goes beyond 80 cols?
https://github.com/llvm/llvm-project/pull/152966
More information about the Mlir-commits
mailing list