-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[MLIR] Add f6E3M2FN type #105573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MLIR] Add f6E3M2FN type #105573
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -233,6 +233,27 @@ def Builtin_Float8E3M4 : Builtin_FloatType<"Float8E3M4", "f8E3M4"> { | |
}]; | ||
} | ||
|
||
//===----------------------------------------------------------------------===// | ||
// Float6E3M2FNType | ||
|
||
def Builtin_Float6E3M2FN : Builtin_FloatType<"Float6E3M2FN", "f6E3M2FN"> { | ||
let summary = "6-bit floating point with 3 bits exponent and 2 bit mantissa"; | ||
let description = [{ | ||
An 6-bit floating point type with 1 sign bit, 3 bits exponent and 2 bits | ||
mantissa. This is not a standard type as defined by IEEE-754, but it | ||
follows similar conventions with the following characteristics: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add a reference to the OCP spec or at least mention it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a link. |
||
|
||
* bit encoding: S1E3M2 | ||
* exponent bias: 3 | ||
* infinities: Not supported | ||
* NaNs: Not supported | ||
* denormals when exponent is 0 | ||
|
||
Open Compute Project (OCP) microscaling formats (MX) specification: | ||
https://www.opencompute.org/documents/ocp-microscaling-formats-mx-v1-0-spec-final-pdf | ||
}]; | ||
} | ||
|
||
//===----------------------------------------------------------------------===// | ||
// BFloat16Type | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,6 +91,8 @@ IntegerType IntegerType::scaleElementBitwidth(unsigned scale) { | |
//===----------------------------------------------------------------------===// | ||
|
||
unsigned FloatType::getWidth() { | ||
if (llvm::isa<Float6E3M2FNType>(*this)) | ||
return 6; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why don't we use APFloat here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll do this in a separate PR, if you don't mind. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Created #107372 |
||
if (llvm::isa<Float8E5M2Type, Float8E4M3Type, Float8E4M3FNType, | ||
Float8E5M2FNUZType, Float8E4M3FNUZType, Float8E4M3B11FNUZType, | ||
Float8E3M4Type>(*this)) | ||
|
@@ -110,6 +112,8 @@ unsigned FloatType::getWidth() { | |
|
||
/// Returns the floating semantics for the given type. | ||
const llvm::fltSemantics &FloatType::getFloatSemantics() { | ||
if (llvm::isa<Float6E3M2FNType>(*this)) | ||
return APFloat::Float6E3M2FN(); | ||
if (llvm::isa<Float8E5M2Type>(*this)) | ||
return APFloat::Float8E5M2(); | ||
if (llvm::isa<Float8E4M3Type>(*this)) | ||
|
Uh oh!
There was an error while loading. Please reload this page.