[PATCH] D141432: Add two additional float8 types to MLIR and APFloat.

Jake Hall via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 10 14:02:59 PST 2023


jakeh-gc created this revision.
Herald added subscribers: Moerafaat, zero9178, bzcheeseman, sdasgup3, wenzhicui, wrengr, cota, teijeong, rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, mgester, arpith-jacob, antiagainst, shauheen, rriddle, mehdi_amini, hiraditya.
Herald added a reviewer: rriddle.
Herald added a reviewer: antiagainst.
Herald added a project: All.
jakeh-gc requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, stephenneuendorffer, nicolasvasilache.
Herald added projects: clang, MLIR, LLVM.

Graphcore, AMD, and Qualcomm have proposed two new FP8 formats, Float8E4M3FZN and Float8E5M2FZN. These formats are presented in this paper: https://arxiv.org/abs/2206.02915. They are implemented in commercially available hardware and the ISA for this hardware is available here: https://docs.graphcore.ai/projects/isa-mk2-with-fp8/en/latest/_static/TileVertexISA-IPU21-1.3.1.pdf.

This patch adds support for these two types in MLIR and APFloat, alongside the previously added types Float8E4M3FN and Float8E5M2 (D133823 <https://reviews.llvm.org/D133823>, D137760 <https://reviews.llvm.org/D137760>, RFC <https://discourse.llvm.org/t/rfc-add-apfloat-and-mlir-type-support-for-fp8-e5m2/65279>).

Following the naming scheme from those existing types, the suffix "FZN" here refers to the fact that these types support finite values, positive-only zero (no negative zero), and a NaN encoding. In both types NaN has exactly one encoding `0b10000000`.

To support this behaviour I have added another value to the `fltNonfiniteBehavior` enum to represent this specific NaN encoding. I have also added a new field (`fltSignedZeroSupport`) to the `fltSemantics` struct to describe whether signed zero is supported.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141432

Files:
  clang/lib/AST/MicrosoftMangle.cpp
  llvm/include/llvm/ADT/APFloat.h
  llvm/lib/Support/APFloat.cpp
  llvm/unittests/ADT/APFloatTest.cpp
  mlir/include/mlir-c/BuiltinTypes.h
  mlir/include/mlir/IR/Builders.h
  mlir/include/mlir/IR/BuiltinTypes.h
  mlir/include/mlir/IR/BuiltinTypes.td
  mlir/include/mlir/IR/OpBase.td
  mlir/include/mlir/IR/Types.h
  mlir/lib/AsmParser/TokenKinds.def
  mlir/lib/AsmParser/TypeParser.cpp
  mlir/lib/Bindings/Python/IRTypes.cpp
  mlir/lib/CAPI/IR/BuiltinTypes.cpp
  mlir/lib/IR/AsmPrinter.cpp
  mlir/lib/IR/Builders.cpp
  mlir/lib/IR/BuiltinTypes.cpp
  mlir/lib/IR/MLIRContext.cpp
  mlir/lib/IR/Types.cpp
  mlir/python/mlir/_mlir_libs/_mlir/ir.pyi
  mlir/test/IR/attribute.mlir
  mlir/test/python/ir/builtin_types.py
  mlir/utils/lldb-scripts/mlirDataFormatters.py

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141432.487987.patch
Type: text/x-patch
Size: 59301 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230110/77bb4cef/attachment.bin>


More information about the llvm-commits mailing list