[Mlir-commits] [mlir] [MLIR] Use APFloat semantics to get floating type width (PR #107372)
Alexander Pivovarov
llvmlistbot at llvm.org
Mon Sep 9 12:55:13 PDT 2024
================
@@ -91,21 +91,9 @@ IntegerType IntegerType::scaleElementBitwidth(unsigned scale) {
//===----------------------------------------------------------------------===//
unsigned FloatType::getWidth() {
- if (llvm::isa<Float8E5M2Type, Float8E4M3Type, Float8E4M3FNType,
- Float8E5M2FNUZType, Float8E4M3FNUZType, Float8E4M3B11FNUZType,
- Float8E3M4Type>(*this))
- return 8;
- if (llvm::isa<Float16Type, BFloat16Type>(*this))
- return 16;
- if (llvm::isa<Float32Type, FloatTF32Type>(*this))
+ if (llvm::isa<FloatTF32Type>(*this))
return 32;
----------------
apivovarov wrote:
I'll add a comment noting that the actual width of TF32 is 19 bits. However, since it is a truncated version of Float32, we treat it as 32 bits in MLIR FloatType::getWidth for compatibility.
@jfurtek, @jpienaar , @River707 What are your thoughts on this approach?
https://github.com/llvm/llvm-project/pull/107372
More information about the Mlir-commits
mailing list