[Mlir-commits] [clang] [llvm] [mlir] [MLIR] Add f8E4M3 IEEE 754 type (PR #97118)
Maksim Levental
llvmlistbot at llvm.org
Mon Jul 8 19:38:19 PDT 2024
================
@@ -6532,6 +6534,34 @@ TEST(APFloatTest, Float8E5M2ToDouble) {
EXPECT_TRUE(std::isnan(QNaN.convertToDouble()));
}
+TEST(APFloatTest, Float8E4M3ToDouble) {
+ APFloat One(APFloat::Float8E4M3(), "1.0");
+ EXPECT_EQ(1.0, One.convertToDouble());
+ APFloat Two(APFloat::Float8E4M3(), "2.0");
+ EXPECT_EQ(2.0, Two.convertToDouble());
+ APFloat PosLargest = APFloat::getLargest(APFloat::Float8E4M3(), false);
+ EXPECT_EQ(240.0F, PosLargest.convertToDouble());
+ APFloat NegLargest = APFloat::getLargest(APFloat::Float8E4M3(), true);
+ EXPECT_EQ(-240.0F, NegLargest.convertToDouble());
+ APFloat PosSmallest =
+ APFloat::getSmallestNormalized(APFloat::Float8E4M3(), false);
+ EXPECT_EQ(0x1.p-6, PosSmallest.convertToDouble());
+ APFloat NegSmallest =
+ APFloat::getSmallestNormalized(APFloat::Float8E4M3(), true);
+ EXPECT_EQ(-0x1.p-6, NegSmallest.convertToDouble());
----------------
makslevental wrote:
Sanity check: this test is basically exactly the same as above except with exponent adjusted?
https://github.com/llvm/llvm-project/pull/97118
More information about the Mlir-commits
mailing list