From c51c1ce2ed731188a977b0654a66e929982d56d4 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Thu, 10 Oct 2024 17:53:07 -0500 Subject: [PATCH 01/72] first pass at integrating generic float --- src/include/migraphx/half.hpp | 263 ++++++++++++++++++++++++++++++++-- 1 file changed, 252 insertions(+), 11 deletions(-) diff --git a/src/include/migraphx/half.hpp b/src/include/migraphx/half.hpp index 3296e8c328d..3f63f0b52a5 100644 --- a/src/include/migraphx/half.hpp +++ b/src/include/migraphx/half.hpp @@ -31,8 +31,248 @@ namespace migraphx { inline namespace MIGRAPHX_INLINE_NS { +namespace half { -using half = half_float::half; +template +constexpr unsigned int all_ones() noexcept +{ + return (1 << N) - 1; +} + +struct float16_parts +{ + unsigned int mantissa : 10; + unsigned int exponent : 5; + unsigned int sign : 1; + + static constexpr unsigned int mantissa_width() + { + return 23; + } + + static constexpr unsigned int max_exponent() + { + return all_ones<5>(); + } + + static constexpr int exponent_bias() + { + return all_ones<4>(); + } + + constexpr float to_float() const noexcept + { + return migraphx::bit_cast(*this); + } +}; + +constexpr float16_parts get_parts(float f) +{ + return migraphx::bit_cast(f); +} + +template +struct generic_float +{ + unsigned int mantissa : MantissaSize; + unsigned int exponent : ExponentSize; + unsigned int sign : 1; + + static constexpr int exponent_bias() + { + return all_ones(); + } + + explicit generic_float(float f = 0.0) noexcept + { + from_float(get_parts(f)); + } + + constexpr float to_float() const noexcept + { + float16_parts f{}; + f.sign = sign; + f.mantissa = mantissa << (float16_parts::mantissa_width() - MantissaSize); + if(exponent == all_ones()) + { + f.exponent = float16_parts::max_exponent(); + } + else + { + constexpr const auto diff = float16_parts::exponent_bias() - exponent_bias(); + f.exponent = exponent + diff; + } + return f.to_float(); + } + + constexpr void from_float(float16_parts f) noexcept + { + sign = f.sign; + mantissa = f.mantissa >> (float16_parts::mantissa_width() - MantissaSize); + + if(f.exponent == 0) + { + exponent = 0; + } + else if(f.exponent == float16_parts::max_exponent()) + { + exponent = all_ones(); + } + else + { + constexpr const int diff = float16_parts::exponent_bias() - exponent_bias(); + auto e = int(f.exponent) - diff; + if(e >= all_ones()) + { + exponent = all_ones(); + mantissa = 0; + } + else if(e < 0) + { + exponent = 0; + mantissa = 0; + } + else + { + exponent = f.exponent - diff; + } + } + + exponent = std::min(f.exponent, all_ones()); + } + + constexpr bool is_normal() const noexcept + { + return exponent != all_ones() and exponent != 0; + } + + constexpr bool is_inf() const noexcept + { + return exponent == all_ones() and mantissa == 0; + } + + constexpr bool is_nan() const noexcept + { + return exponent == all_ones() and mantissa != 0; + } + + constexpr bool is_finite() const noexcept + { + return exponent != all_ones(); + } + + constexpr operator float() const noexcept + { + return this->to_float(); + } + + static constexpr generic_float infinity() + { + generic_float x{}; + x.exponent = all_ones(); + return x; + } + + static constexpr generic_float snan() + { + generic_float x{}; + x.exponent = all_ones(); + x.mantissa = 1 << (MantissaSize - 2); + return x; + } + + static constexpr generic_float qnan() + { + generic_float x{}; + x.exponent = all_ones(); + x.mantissa = 1 << (MantissaSize - 1); + return x; + } + + static constexpr generic_float min() + { + generic_float x{}; + x.exponent = 1; + x.mantissa = 0; + return x; + } + + static constexpr generic_float denorm_min() + { + generic_float x{}; + x.exponent = 0; + x.mantissa = 1; + x.sign = 0; + return x; + } + + static constexpr generic_float lowest() + { + generic_float x{}; + x.exponent = all_ones() - 1; + x.mantissa = all_ones(); + x.sign = 1; + return x; + } + + static constexpr generic_float max() + { + generic_float x{}; + x.exponent = all_ones() - 1; + x.mantissa = all_ones(); + x.sign = 0; + return x; + } + + static constexpr generic_float epsilon() + { + generic_float x{1.0}; + x.mantissa++; + return generic_float{x.to_float() - 1.0f}; + } +// NOLINTNEXTLINE +#define MIGRAPHX_GENERIC_FLOAT_ASSIGN_OP(op) \ + constexpr generic_float& operator op(const generic_float& rhs) \ + { \ + float self = *this; \ + float frhs = rhs; \ + self op frhs; \ + *this = generic_float(self); \ + return *this; \ + } + MIGRAPHX_GENERIC_FLOAT_ASSIGN_OP(*=) + MIGRAPHX_GENERIC_FLOAT_ASSIGN_OP(-=) + MIGRAPHX_GENERIC_FLOAT_ASSIGN_OP(+=) + MIGRAPHX_GENERIC_FLOAT_ASSIGN_OP(/=) +// NOLINTNEXTLINE +#define MIGRAPHX_GENERIC_FLOAT_BINARY_OP(op) \ + friend constexpr generic_float operator op(const generic_float& x, const generic_float& y) \ + { \ + return generic_float(float(x) op float(y)); \ + } + MIGRAPHX_GENERIC_FLOAT_BINARY_OP(*) + MIGRAPHX_GENERIC_FLOAT_BINARY_OP(-) + MIGRAPHX_GENERIC_FLOAT_BINARY_OP(+) + MIGRAPHX_GENERIC_FLOAT_BINARY_OP(/) + MIGRAPHX_GENERIC_FLOAT_BINARY_OP(<) + MIGRAPHX_GENERIC_FLOAT_BINARY_OP(<=) + MIGRAPHX_GENERIC_FLOAT_BINARY_OP(>) + MIGRAPHX_GENERIC_FLOAT_BINARY_OP(>=) + + friend constexpr generic_float operator==(const generic_float& x, const generic_float& y) + { + if (not x.is_finite() or not y.is_finite()) + return false; + return std::tie(x.mantissa, x.exponent, x.sign) == std::tie(y.mantissa, y.exponent, y.sign); + } + + friend constexpr generic_float operator!=(const generic_float& x, const generic_float& y) + { + return not(x == y); + } +}; + +using half = migraphx::half::generic_float<10, 5>; namespace detail { template @@ -53,61 +293,62 @@ struct deduce template using deduce = typename detail::deduce::type; +} // namespace half } // namespace MIGRAPHX_INLINE_NS } // namespace migraphx namespace std { template -struct common_type : std::common_type // NOLINT +struct common_type : std::common_type // NOLINT { }; template -struct common_type : std::common_type // NOLINT +struct common_type : std::common_type // NOLINT { }; template <> -struct common_type +struct common_type { using type = float; }; template <> -struct common_type +struct common_type { using type = float; }; template <> -struct common_type +struct common_type { using type = float; }; template <> -struct common_type +struct common_type { using type = float; }; template <> -struct common_type +struct common_type { using type = float; }; template <> -struct common_type +struct common_type { using type = float; }; template <> -struct common_type +struct common_type { - using type = migraphx::half; + using type = migraphx::half::half; }; } // namespace std From 134b408b7f0940ec7972809884af3c17ab20f905 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Thu, 10 Oct 2024 18:03:01 -0500 Subject: [PATCH 02/72] fix namespaces --- src/include/migraphx/half.hpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/include/migraphx/half.hpp b/src/include/migraphx/half.hpp index 3f63f0b52a5..6f37f1814d7 100644 --- a/src/include/migraphx/half.hpp +++ b/src/include/migraphx/half.hpp @@ -31,7 +31,6 @@ namespace migraphx { inline namespace MIGRAPHX_INLINE_NS { -namespace half { template constexpr unsigned int all_ones() noexcept @@ -272,7 +271,7 @@ struct generic_float } }; -using half = migraphx::half::generic_float<10, 5>; +using half = migraphx::generic_float<10, 5>; namespace detail { template @@ -293,62 +292,61 @@ struct deduce template using deduce = typename detail::deduce::type; -} // namespace half } // namespace MIGRAPHX_INLINE_NS } // namespace migraphx namespace std { template -struct common_type : std::common_type // NOLINT +struct common_type : std::common_type // NOLINT { }; template -struct common_type : std::common_type // NOLINT +struct common_type : std::common_type // NOLINT { }; template <> -struct common_type +struct common_type { using type = float; }; template <> -struct common_type +struct common_type { using type = float; }; template <> -struct common_type +struct common_type { using type = float; }; template <> -struct common_type +struct common_type { using type = float; }; template <> -struct common_type +struct common_type { using type = float; }; template <> -struct common_type +struct common_type { using type = float; }; template <> -struct common_type +struct common_type { - using type = migraphx::half::half; + using type = migraphx::half; }; } // namespace std From d4fa6eb210179b2dd58495710d62cc870189bb9e Mon Sep 17 00:00:00 2001 From: richagadgil Date: Thu, 10 Oct 2024 18:37:51 -0500 Subject: [PATCH 03/72] fix mantissa --- src/include/migraphx/half.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/migraphx/half.hpp b/src/include/migraphx/half.hpp index 6f37f1814d7..582550ecf22 100644 --- a/src/include/migraphx/half.hpp +++ b/src/include/migraphx/half.hpp @@ -46,7 +46,7 @@ struct float16_parts static constexpr unsigned int mantissa_width() { - return 23; + return 10; } static constexpr unsigned int max_exponent() From 0b60841f2bfeba29d3533faf67fc02ac03536995 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Thu, 10 Oct 2024 19:04:17 -0500 Subject: [PATCH 04/72] refactor --- src/include/migraphx/generic_float.hpp | 262 +++++++++++++++++++++++++ src/include/migraphx/half.hpp | 242 +---------------------- 2 files changed, 264 insertions(+), 240 deletions(-) create mode 100644 src/include/migraphx/generic_float.hpp diff --git a/src/include/migraphx/generic_float.hpp b/src/include/migraphx/generic_float.hpp new file mode 100644 index 00000000000..baad2c900a9 --- /dev/null +++ b/src/include/migraphx/generic_float.hpp @@ -0,0 +1,262 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +template +constexpr unsigned int all_ones() noexcept +{ + return (1 << N) - 1; +} + +struct float32_parts +{ + unsigned int mantissa : 23; + unsigned int exponent : 8; + unsigned int sign : 1; + + static constexpr unsigned int mantissa_width() + { + return 23; + } + + static constexpr unsigned int max_exponent() + { + return all_ones<8>(); + } + + static constexpr int exponent_bias() + { + return all_ones<7>(); + } + + constexpr float to_float() const noexcept + { + return migraphx::bit_cast(*this); + } +}; + +constexpr float32_parts get_parts(float f) +{ + return migraphx::bit_cast(f); +} + +template +struct generic_float +{ + unsigned int mantissa : MantissaSize; + unsigned int exponent : ExponentSize; + unsigned int sign : 1; + + static constexpr int exponent_bias() + { + return all_ones(); + } + + explicit generic_float(float f = 0.0) noexcept + { + from_float(get_parts(f)); + } + + constexpr float to_float() const noexcept + { + float32_parts f{}; + f.sign = sign; + f.mantissa = mantissa << (float32_parts::mantissa_width() - MantissaSize); + if(exponent == all_ones()) + { + f.exponent = float32_parts::max_exponent(); + } + else + { + constexpr const auto diff = float32_parts::exponent_bias() - exponent_bias(); + f.exponent = exponent + diff; + } + return f.to_float(); + } + + constexpr void from_float(float32_parts f) noexcept + { + sign = f.sign; + mantissa = f.mantissa >> (float32_parts::mantissa_width() - MantissaSize); + + if(f.exponent == 0) + { + exponent = 0; + } + else if(f.exponent == float32_parts::max_exponent()) + { + exponent = all_ones(); + } + else + { + constexpr const int diff = float32_parts::exponent_bias() - exponent_bias(); + auto e = int(f.exponent) - diff; + if(e >= all_ones()) + { + exponent = all_ones(); + mantissa = 0; + } + else if(e < 0) + { + exponent = 0; + mantissa = 0; + } + else + { + exponent = f.exponent - diff; + } + } + + exponent = std::min(f.exponent, all_ones()); + } + + constexpr bool is_normal() const noexcept + { + return exponent != all_ones() and exponent != 0; + } + + constexpr bool is_inf() const noexcept + { + return exponent == all_ones() and mantissa == 0; + } + + constexpr bool is_nan() const noexcept + { + return exponent == all_ones() and mantissa != 0; + } + + constexpr bool is_finite() const noexcept + { + return exponent != all_ones(); + } + + constexpr operator float() const noexcept + { + return this->to_float(); + } + + static constexpr generic_float infinity() + { + generic_float x{}; + x.exponent = all_ones(); + return x; + } + + static constexpr generic_float snan() + { + generic_float x{}; + x.exponent = all_ones(); + x.mantissa = 1 << (MantissaSize - 2); + return x; + } + + static constexpr generic_float qnan() + { + generic_float x{}; + x.exponent = all_ones(); + x.mantissa = 1 << (MantissaSize - 1); + return x; + } + + static constexpr generic_float min() + { + generic_float x{}; + x.exponent = 1; + x.mantissa = 0; + return x; + } + + static constexpr generic_float denorm_min() + { + generic_float x{}; + x.exponent = 0; + x.mantissa = 1; + x.sign = 0; + return x; + } + + static constexpr generic_float lowest() + { + generic_float x{}; + x.exponent = all_ones() - 1; + x.mantissa = all_ones(); + x.sign = 1; + return x; + } + + static constexpr generic_float max() + { + generic_float x{}; + x.exponent = all_ones() - 1; + x.mantissa = all_ones(); + x.sign = 0; + return x; + } + + static constexpr generic_float epsilon() + { + generic_float x{1.0}; + x.mantissa++; + return generic_float{x.to_float() - 1.0f}; + } +// NOLINTNEXTLINE +#define MIGRAPHX_GENERIC_FLOAT_ASSIGN_OP(op) \ + constexpr generic_float& operator op(const generic_float& rhs) \ + { \ + float self = *this; \ + float frhs = rhs; \ + self op frhs; \ + *this = generic_float(self); \ + return *this; \ + } + MIGRAPHX_GENERIC_FLOAT_ASSIGN_OP(*=) + MIGRAPHX_GENERIC_FLOAT_ASSIGN_OP(-=) + MIGRAPHX_GENERIC_FLOAT_ASSIGN_OP(+=) + MIGRAPHX_GENERIC_FLOAT_ASSIGN_OP(/=) +// NOLINTNEXTLINE +#define MIGRAPHX_GENERIC_FLOAT_BINARY_OP(op) \ + friend constexpr generic_float operator op(const generic_float& x, const generic_float& y) \ + { \ + return generic_float(float(x) op float(y)); \ + } + MIGRAPHX_GENERIC_FLOAT_BINARY_OP(*) + MIGRAPHX_GENERIC_FLOAT_BINARY_OP(-) + MIGRAPHX_GENERIC_FLOAT_BINARY_OP(+) + MIGRAPHX_GENERIC_FLOAT_BINARY_OP(/) + MIGRAPHX_GENERIC_FLOAT_BINARY_OP(<) + MIGRAPHX_GENERIC_FLOAT_BINARY_OP(<=) + MIGRAPHX_GENERIC_FLOAT_BINARY_OP(>) + MIGRAPHX_GENERIC_FLOAT_BINARY_OP(>=) + + friend constexpr generic_float operator==(const generic_float& x, const generic_float& y) + { + if (not x.is_finite() or not y.is_finite()) + return false; + return std::tie(x.mantissa, x.exponent, x.sign) == std::tie(y.mantissa, y.exponent, y.sign); + } + + friend constexpr generic_float operator!=(const generic_float& x, const generic_float& y) + { + return not(x == y); + } +}; diff --git a/src/include/migraphx/half.hpp b/src/include/migraphx/half.hpp index 582550ecf22..0a93d6a237b 100644 --- a/src/include/migraphx/half.hpp +++ b/src/include/migraphx/half.hpp @@ -28,250 +28,12 @@ #include #include #include +#include namespace migraphx { inline namespace MIGRAPHX_INLINE_NS { -template -constexpr unsigned int all_ones() noexcept -{ - return (1 << N) - 1; -} - -struct float16_parts -{ - unsigned int mantissa : 10; - unsigned int exponent : 5; - unsigned int sign : 1; - - static constexpr unsigned int mantissa_width() - { - return 10; - } - - static constexpr unsigned int max_exponent() - { - return all_ones<5>(); - } - - static constexpr int exponent_bias() - { - return all_ones<4>(); - } - - constexpr float to_float() const noexcept - { - return migraphx::bit_cast(*this); - } -}; - -constexpr float16_parts get_parts(float f) -{ - return migraphx::bit_cast(f); -} - -template -struct generic_float -{ - unsigned int mantissa : MantissaSize; - unsigned int exponent : ExponentSize; - unsigned int sign : 1; - - static constexpr int exponent_bias() - { - return all_ones(); - } - - explicit generic_float(float f = 0.0) noexcept - { - from_float(get_parts(f)); - } - - constexpr float to_float() const noexcept - { - float16_parts f{}; - f.sign = sign; - f.mantissa = mantissa << (float16_parts::mantissa_width() - MantissaSize); - if(exponent == all_ones()) - { - f.exponent = float16_parts::max_exponent(); - } - else - { - constexpr const auto diff = float16_parts::exponent_bias() - exponent_bias(); - f.exponent = exponent + diff; - } - return f.to_float(); - } - - constexpr void from_float(float16_parts f) noexcept - { - sign = f.sign; - mantissa = f.mantissa >> (float16_parts::mantissa_width() - MantissaSize); - - if(f.exponent == 0) - { - exponent = 0; - } - else if(f.exponent == float16_parts::max_exponent()) - { - exponent = all_ones(); - } - else - { - constexpr const int diff = float16_parts::exponent_bias() - exponent_bias(); - auto e = int(f.exponent) - diff; - if(e >= all_ones()) - { - exponent = all_ones(); - mantissa = 0; - } - else if(e < 0) - { - exponent = 0; - mantissa = 0; - } - else - { - exponent = f.exponent - diff; - } - } - - exponent = std::min(f.exponent, all_ones()); - } - - constexpr bool is_normal() const noexcept - { - return exponent != all_ones() and exponent != 0; - } - - constexpr bool is_inf() const noexcept - { - return exponent == all_ones() and mantissa == 0; - } - - constexpr bool is_nan() const noexcept - { - return exponent == all_ones() and mantissa != 0; - } - - constexpr bool is_finite() const noexcept - { - return exponent != all_ones(); - } - - constexpr operator float() const noexcept - { - return this->to_float(); - } - - static constexpr generic_float infinity() - { - generic_float x{}; - x.exponent = all_ones(); - return x; - } - - static constexpr generic_float snan() - { - generic_float x{}; - x.exponent = all_ones(); - x.mantissa = 1 << (MantissaSize - 2); - return x; - } - - static constexpr generic_float qnan() - { - generic_float x{}; - x.exponent = all_ones(); - x.mantissa = 1 << (MantissaSize - 1); - return x; - } - - static constexpr generic_float min() - { - generic_float x{}; - x.exponent = 1; - x.mantissa = 0; - return x; - } - - static constexpr generic_float denorm_min() - { - generic_float x{}; - x.exponent = 0; - x.mantissa = 1; - x.sign = 0; - return x; - } - - static constexpr generic_float lowest() - { - generic_float x{}; - x.exponent = all_ones() - 1; - x.mantissa = all_ones(); - x.sign = 1; - return x; - } - - static constexpr generic_float max() - { - generic_float x{}; - x.exponent = all_ones() - 1; - x.mantissa = all_ones(); - x.sign = 0; - return x; - } - - static constexpr generic_float epsilon() - { - generic_float x{1.0}; - x.mantissa++; - return generic_float{x.to_float() - 1.0f}; - } -// NOLINTNEXTLINE -#define MIGRAPHX_GENERIC_FLOAT_ASSIGN_OP(op) \ - constexpr generic_float& operator op(const generic_float& rhs) \ - { \ - float self = *this; \ - float frhs = rhs; \ - self op frhs; \ - *this = generic_float(self); \ - return *this; \ - } - MIGRAPHX_GENERIC_FLOAT_ASSIGN_OP(*=) - MIGRAPHX_GENERIC_FLOAT_ASSIGN_OP(-=) - MIGRAPHX_GENERIC_FLOAT_ASSIGN_OP(+=) - MIGRAPHX_GENERIC_FLOAT_ASSIGN_OP(/=) -// NOLINTNEXTLINE -#define MIGRAPHX_GENERIC_FLOAT_BINARY_OP(op) \ - friend constexpr generic_float operator op(const generic_float& x, const generic_float& y) \ - { \ - return generic_float(float(x) op float(y)); \ - } - MIGRAPHX_GENERIC_FLOAT_BINARY_OP(*) - MIGRAPHX_GENERIC_FLOAT_BINARY_OP(-) - MIGRAPHX_GENERIC_FLOAT_BINARY_OP(+) - MIGRAPHX_GENERIC_FLOAT_BINARY_OP(/) - MIGRAPHX_GENERIC_FLOAT_BINARY_OP(<) - MIGRAPHX_GENERIC_FLOAT_BINARY_OP(<=) - MIGRAPHX_GENERIC_FLOAT_BINARY_OP(>) - MIGRAPHX_GENERIC_FLOAT_BINARY_OP(>=) - - friend constexpr generic_float operator==(const generic_float& x, const generic_float& y) - { - if (not x.is_finite() or not y.is_finite()) - return false; - return std::tie(x.mantissa, x.exponent, x.sign) == std::tie(y.mantissa, y.exponent, y.sign); - } - - friend constexpr generic_float operator!=(const generic_float& x, const generic_float& y) - { - return not(x == y); - } -}; - -using half = migraphx::generic_float<10, 5>; +using half = generic_float<10,5>; namespace detail { template From 7a646f1b2fc77cedda6789190363c8ce4a16050d Mon Sep 17 00:00:00 2001 From: richagadgil Date: Fri, 11 Oct 2024 14:53:09 -0500 Subject: [PATCH 05/72] refactor --- src/include/migraphx/generic_float.hpp | 6 +++ src/include/migraphx/half.hpp | 61 +++++++++++--------------- 2 files changed, 31 insertions(+), 36 deletions(-) diff --git a/src/include/migraphx/generic_float.hpp b/src/include/migraphx/generic_float.hpp index baad2c900a9..6599ab0df94 100644 --- a/src/include/migraphx/generic_float.hpp +++ b/src/include/migraphx/generic_float.hpp @@ -22,6 +22,9 @@ * THE SOFTWARE. */ +namespace migraphx { +inline namespace MIGRAPHX_INLINE_NS { + template constexpr unsigned int all_ones() noexcept { @@ -260,3 +263,6 @@ struct generic_float return not(x == y); } }; + +} +} diff --git a/src/include/migraphx/half.hpp b/src/include/migraphx/half.hpp index 0a93d6a237b..013bc6c6394 100644 --- a/src/include/migraphx/half.hpp +++ b/src/include/migraphx/half.hpp @@ -33,7 +33,7 @@ namespace migraphx { inline namespace MIGRAPHX_INLINE_NS { -using half = generic_float<10,5>; +using half = migraphx::generic_float<10,5>; namespace detail { template @@ -59,56 +59,45 @@ using deduce = typename detail::deduce::type; namespace std { -template -struct common_type : std::common_type // NOLINT +template +class numeric_limits> { -}; + public: + static constexpr bool has_infinity = false; + static constexpr migraphx::generic_float epsilon() { return migraphx::generic_float::epsilon(); } -template -struct common_type : std::common_type // NOLINT -{ -}; + static constexpr migraphx::generic_float quiet_NaN() { return migraphx::generic_float::quiet_NaN(); } -template <> -struct common_type -{ - using type = float; -}; + static constexpr migraphx::generic_float max() { return migraphx::generic_float::max(); } -template <> -struct common_type -{ - using type = float; -}; + static constexpr migraphx::generic_float min() { return migraphx::generic_float::min(); } -template <> -struct common_type -{ - using type = float; -}; + static constexpr migraphx::generic_float lowest() { return migraphx::generic_float::lowest(); } -template <> -struct common_type -{ - using type = float; }; -template <> -struct common_type +template +struct common_type, T> : std::common_type // NOLINT { - using type = float; }; -template <> -struct common_type +template +struct common_type> : std::common_type // NOLINT { - using type = float; }; -template <> -struct common_type +template +struct common_type, migraphx::fp8::float8> : std::common_type +{}; + +template +struct common_type, migraphx::generic_float> : std::common_type +{}; + +template +struct common_type, migraphx::generic_float> { - using type = migraphx::half; + using type = migraphx::generic_float; }; } // namespace std From ebe819b619a38840f6b06bca88de523df3028afa Mon Sep 17 00:00:00 2001 From: richagadgil Date: Fri, 11 Oct 2024 15:13:00 -0500 Subject: [PATCH 06/72] add fp --- src/include/migraphx/half.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/include/migraphx/half.hpp b/src/include/migraphx/half.hpp index 013bc6c6394..df1a03b095c 100644 --- a/src/include/migraphx/half.hpp +++ b/src/include/migraphx/half.hpp @@ -54,6 +54,12 @@ struct deduce template using deduce = typename detail::deduce::type; +template +struct is_floating_point : std::false_type {}; + +template +struct is_floating_point> : std::true_type {}; + } // namespace MIGRAPHX_INLINE_NS } // namespace migraphx From 379a77a16ada3df39e39b9a0a3922d4898cdcec1 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Mon, 14 Oct 2024 17:04:13 -0500 Subject: [PATCH 07/72] fixed generic float class --- src/include/migraphx/generic_float.hpp | 88 +++++++++++++++++++++++++- src/include/migraphx/half.hpp | 65 ++++++++++--------- 2 files changed, 120 insertions(+), 33 deletions(-) diff --git a/src/include/migraphx/generic_float.hpp b/src/include/migraphx/generic_float.hpp index 6599ab0df94..57697e0fd6f 100644 --- a/src/include/migraphx/generic_float.hpp +++ b/src/include/migraphx/generic_float.hpp @@ -22,6 +22,11 @@ * THE SOFTWARE. */ +#include +#include +#include +#include + namespace migraphx { inline namespace MIGRAPHX_INLINE_NS { @@ -75,11 +80,25 @@ struct generic_float return all_ones(); } - explicit generic_float(float f = 0.0) noexcept + explicit constexpr generic_float(float f = 0.0) noexcept + { + from_float(get_parts(f)); + } + + constexpr generic_float &operator=(float f) noexcept { from_float(get_parts(f)); + return *this; } + constexpr generic_float operator-() const noexcept + { + generic_float result = *this; + result.sign = !this->sign; + return result; + } + + constexpr float to_float() const noexcept { float32_parts f{}; @@ -251,18 +270,81 @@ struct generic_float MIGRAPHX_GENERIC_FLOAT_BINARY_OP(>) MIGRAPHX_GENERIC_FLOAT_BINARY_OP(>=) - friend constexpr generic_float operator==(const generic_float& x, const generic_float& y) + friend constexpr bool operator==(const generic_float& x, const generic_float& y) { if (not x.is_finite() or not y.is_finite()) return false; return std::tie(x.mantissa, x.exponent, x.sign) == std::tie(y.mantissa, y.exponent, y.sign); } - friend constexpr generic_float operator!=(const generic_float& x, const generic_float& y) + friend constexpr bool operator!=(const generic_float& x, const generic_float& y) { return not(x == y); } }; + } } + +namespace std { + +template +class numeric_limits> +{ + public: + static constexpr bool has_infinity = true; + static constexpr migraphx::generic_float epsilon() { return migraphx::generic_float::epsilon(); } + + static constexpr migraphx::generic_float quiet_NaN() { return migraphx::generic_float::qnan(); } + + static constexpr migraphx::generic_float max() { return migraphx::generic_float::max(); } + + static constexpr migraphx::generic_float min() { return migraphx::generic_float::min(); } + + static constexpr migraphx::generic_float lowest() { return migraphx::generic_float::lowest(); } + + static constexpr migraphx::generic_float infinity() { return migraphx::generic_float::infinity(); } + +}; + +template +struct common_type, T> : std::common_type // NOLINT +{ +}; + +template +struct common_type> : std::common_type // NOLINT +{ +}; + +// template +// struct common_type, migraphx::fp8::float8> : std::common_type +// {}; + +// template +// struct common_type, migraphx::generic_float> : std::common_type +// {}; + +// template +// struct common_type, migraphx::fp8::float8> : std::common_type +// {}; + +// template +// struct common_type, migraphx::generic_float> : std::common_type +// {}; + +template +struct common_type, migraphx::generic_float> +{ + using type = migraphx::generic_float; +}; + +// template +// struct common_type, migraphx::generic_float> +// { +// using type = float; +// }; + + +} diff --git a/src/include/migraphx/half.hpp b/src/include/migraphx/half.hpp index df1a03b095c..5b7b0607fd8 100644 --- a/src/include/migraphx/half.hpp +++ b/src/include/migraphx/half.hpp @@ -54,56 +54,61 @@ struct deduce template using deduce = typename detail::deduce::type; -template -struct is_floating_point : std::false_type {}; - -template -struct is_floating_point> : std::true_type {}; - } // namespace MIGRAPHX_INLINE_NS } // namespace migraphx namespace std { -template -class numeric_limits> +template +struct common_type : std::common_type // NOLINT { - public: - static constexpr bool has_infinity = false; - static constexpr migraphx::generic_float epsilon() { return migraphx::generic_float::epsilon(); } - - static constexpr migraphx::generic_float quiet_NaN() { return migraphx::generic_float::quiet_NaN(); } - - static constexpr migraphx::generic_float max() { return migraphx::generic_float::max(); } +}; - static constexpr migraphx::generic_float min() { return migraphx::generic_float::min(); } +template +struct common_type : std::common_type // NOLINT +{ +}; - static constexpr migraphx::generic_float lowest() { return migraphx::generic_float::lowest(); } +template <> +struct common_type +{ + using type = float; +}; +template <> +struct common_type +{ + using type = float; }; -template -struct common_type, T> : std::common_type // NOLINT +template <> +struct common_type { + using type = float; }; -template -struct common_type> : std::common_type // NOLINT +template <> +struct common_type { + using type = float; }; -template -struct common_type, migraphx::fp8::float8> : std::common_type -{}; +template <> +struct common_type +{ + using type = float; +}; -template -struct common_type, migraphx::generic_float> : std::common_type -{}; +template <> +struct common_type +{ + using type = float; +}; -template -struct common_type, migraphx::generic_float> +template <> +struct common_type { - using type = migraphx::generic_float; + using type = migraphx::half; }; } // namespace std From 174384ca7df47391fb802610ad68a7a3857521c2 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Mon, 14 Oct 2024 18:30:07 -0500 Subject: [PATCH 08/72] add fp32 test --- test/float32.cpp | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 test/float32.cpp diff --git a/test/float32.cpp b/test/float32.cpp new file mode 100644 index 00000000000..12256eff38c --- /dev/null +++ b/test/float32.cpp @@ -0,0 +1,55 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#include +#include +#include +#include +#include "test.hpp" + +#include + +using fp32 = migraphx::generic_float<23, 8>; + +#define CHECK_FLOAT(x, y) \ + CHECK(migraphx::float_equal(x, y)); \ + CHECK(migraphx::float_equal(x, y.to_float())); \ + CHECK(migraphx::float_equal(fp32{x}, y)); \ + CHECK(migraphx::float_equal(fp32{x}.to_float(), y.to_float())) + + +TEST_CASE(fp32_values) +{ + CHECK_FLOAT(1.0f, fp32{1.0f}); + CHECK_FLOAT(-1.0f, fp32{-1.0f}); + CHECK_FLOAT(std::numeric_limits::min(), fp32::min()); + CHECK_FLOAT(std::numeric_limits::lowest(), fp32::lowest()); + CHECK_FLOAT(std::numeric_limits::max(), fp32::max()); + CHECK_FLOAT(std::numeric_limits::epsilon(), fp32::epsilon()); + CHECK_FLOAT(std::numeric_limits::infinity(), fp32::infinity()); + CHECK_FLOAT(std::numeric_limits::quiet_NaN(), fp32::qnan()); + CHECK_FLOAT(std::numeric_limits::signaling_NaN(), fp32::snan()); + CHECK_FLOAT(std::numeric_limits::denorm_min(), fp32::denorm_min()); +} + +int main(int argc, const char* argv[]) { test::run(argc, argv); } From 787b651868528d0393812a50f31aad51be081f8d Mon Sep 17 00:00:00 2001 From: richagadgil Date: Mon, 14 Oct 2024 18:31:24 -0500 Subject: [PATCH 09/72] remove import --- test/float32.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/test/float32.cpp b/test/float32.cpp index 12256eff38c..5cfa5b916d3 100644 --- a/test/float32.cpp +++ b/test/float32.cpp @@ -23,7 +23,6 @@ */ #include #include -#include #include #include "test.hpp" From 1d1fa1ccf5f473fddfc2af6370d9f38b7c55a8eb Mon Sep 17 00:00:00 2001 From: richagadgil Date: Tue, 15 Oct 2024 14:20:52 -0500 Subject: [PATCH 10/72] update tests --- test/float32.cpp | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/test/float32.cpp b/test/float32.cpp index 5cfa5b916d3..63b9db489d8 100644 --- a/test/float32.cpp +++ b/test/float32.cpp @@ -25,6 +25,7 @@ #include #include #include "test.hpp" +#include #include @@ -37,7 +38,7 @@ using fp32 = migraphx::generic_float<23, 8>; CHECK(migraphx::float_equal(fp32{x}.to_float(), y.to_float())) -TEST_CASE(fp32_values) +TEST_CASE(fp32_values_working) { CHECK_FLOAT(1.0f, fp32{1.0f}); CHECK_FLOAT(-1.0f, fp32{-1.0f}); @@ -45,10 +46,39 @@ TEST_CASE(fp32_values) CHECK_FLOAT(std::numeric_limits::lowest(), fp32::lowest()); CHECK_FLOAT(std::numeric_limits::max(), fp32::max()); CHECK_FLOAT(std::numeric_limits::epsilon(), fp32::epsilon()); - CHECK_FLOAT(std::numeric_limits::infinity(), fp32::infinity()); - CHECK_FLOAT(std::numeric_limits::quiet_NaN(), fp32::qnan()); - CHECK_FLOAT(std::numeric_limits::signaling_NaN(), fp32::snan()); CHECK_FLOAT(std::numeric_limits::denorm_min(), fp32::denorm_min()); + // CHECK_FLOAT(std::numeric_limits::infinity(), fp32::infinity()); + // CHECK_FLOAT(std::numeric_limits::quiet_NaN(), fp32::qnan()); + // CHECK_FLOAT(std::numeric_limits::signaling_NaN(), fp32::snan()); } +TEST_CASE(test_infinity_1) +{ + float f_inf = std::numeric_limits::infinity(); + float f32_inf = fp32::infinity().to_float(); + EXPECT(f32_inf == f_inf); +} + +TEST_CASE(test_infinity_2) +{ + float f_inf = -1.0 * std::numeric_limits::infinity(); + float f32_inf = -1.0 * fp32::infinity().to_float(); + EXPECT(f32_inf == f_inf); +} + +TEST_CASE(test_snan) +{ + fp32 fp32_snan = fp32::snan(); + EXPECT(fp32_snan.is_nan()); + EXPECT(std::isnan(fp32_snan)); +} + +TEST_CASE(test_qnan) +{ + fp32 fp32_snan = fp32::qnan(); + EXPECT(fp32_snan.is_nan()); + EXPECT(std::isnan(fp32_snan)); +} + + int main(int argc, const char* argv[]) { test::run(argc, argv); } From 179109294c3bcd68b8940a025741089f8ba24975 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Thu, 17 Oct 2024 18:16:10 -0500 Subject: [PATCH 11/72] fp16 tests that work --- src/include/migraphx/generic_float.hpp | 2 +- test/float16.cpp | 85 ++++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 test/float16.cpp diff --git a/src/include/migraphx/generic_float.hpp b/src/include/migraphx/generic_float.hpp index 57697e0fd6f..03f18de37af 100644 --- a/src/include/migraphx/generic_float.hpp +++ b/src/include/migraphx/generic_float.hpp @@ -149,7 +149,7 @@ struct generic_float } } - exponent = std::min(f.exponent, all_ones()); + exponent = std::min(exponent, all_ones()); } constexpr bool is_normal() const noexcept diff --git a/test/float16.cpp b/test/float16.cpp new file mode 100644 index 00000000000..4843338b92e --- /dev/null +++ b/test/float16.cpp @@ -0,0 +1,85 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#include +#include +#include +#include "test.hpp" +#define HIP_ENABLE_PRINTF + +#include + +using fp16 = migraphx::half; + +#define CHECK_FLOAT(x, y) \ + CHECK(migraphx::float_equal(x, y)); \ + CHECK(migraphx::float_equal(x, y.to_float())); \ + CHECK(migraphx::float_equal(fp16{x}, y)); \ + CHECK(migraphx::float_equal(fp16{x}.to_float(), y.to_float())) + + +TEST_CASE(fp16_values) +{ + + CHECK_FLOAT(1.0f, fp16{1.0f}); + CHECK_FLOAT(-1.0f, fp16{-1.0f}); + // CHECK_FLOAT(std::numeric_limits::min(), fp16::min()); + // CHECK_FLOAT(std::numeric_limits::lowest(), fp16::lowest()); + // CHECK_FLOAT(std::numeric_limits::max(), fp16::max()); + // CHECK_FLOAT(std::numeric_limits::epsilon(), fp16::epsilon()); + // CHECK_FLOAT(std::numeric_limits::infinity(), fp16::infinity()); + // CHECK_FLOAT(std::numeric_limits::quiet_NaN(), fp16::qnan()); + // CHECK_FLOAT(std::numeric_limits::signaling_NaN(), fp16::snan()); + // CHECK_FLOAT(std::numeric_limits::denorm_min(), fp16::denorm_min()); +} + +TEST_CASE(test_infinity_1) +{ + float f_inf = std::numeric_limits::infinity(); + float f16_inf = fp16::infinity().to_float(); + EXPECT(f16_inf == f_inf); +} + +TEST_CASE(test_infinity_2) +{ + float f_inf = -1.0 * std::numeric_limits::infinity(); + float f16_inf = -1.0 * fp16::infinity().to_float(); + EXPECT(f16_inf == f_inf); +} + +TEST_CASE(test_snan) +{ + fp16 fp16_snan = fp16::snan(); + EXPECT(fp16_snan.is_nan()); + EXPECT(std::isnan(fp16_snan)); +} + +TEST_CASE(test_qnan) +{ + fp16 fp16_snan = fp16::qnan(); + EXPECT(fp16_snan.is_nan()); + EXPECT(std::isnan(fp16_snan)); +} + + +int main(int argc, const char* argv[]) { test::run(argc, argv); } From a2eb0051414ca31b0a0178529330125537c5ec42 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Fri, 18 Oct 2024 00:03:05 -0500 Subject: [PATCH 12/72] update tests --- src/include/migraphx/generic_float.hpp | 14 ++++++++++++-- test/float16.cpp | 3 +-- test/float32.cpp | 1 + 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/include/migraphx/generic_float.hpp b/src/include/migraphx/generic_float.hpp index 03f18de37af..6352e8fc2d4 100644 --- a/src/include/migraphx/generic_float.hpp +++ b/src/include/migraphx/generic_float.hpp @@ -104,7 +104,12 @@ struct generic_float float32_parts f{}; f.sign = sign; f.mantissa = mantissa << (float32_parts::mantissa_width() - MantissaSize); - if(exponent == all_ones()) + + if(exponent == 1 and mantissa == 0) + { + f.exponent = 1; + } + else if(exponent == all_ones()) { f.exponent = float32_parts::max_exponent(); } @@ -125,6 +130,10 @@ struct generic_float { exponent = 0; } + else if (f.exponent == 1 and f.mantissa == 0) + { + exponent = 1; + } else if(f.exponent == float32_parts::max_exponent()) { exponent = all_ones(); @@ -133,7 +142,8 @@ struct generic_float { constexpr const int diff = float32_parts::exponent_bias() - exponent_bias(); auto e = int(f.exponent) - diff; - if(e >= all_ones()) + + if(e >= static_cast(all_ones())) { exponent = all_ones(); mantissa = 0; diff --git a/test/float16.cpp b/test/float16.cpp index 4843338b92e..9effc9a8f5a 100644 --- a/test/float16.cpp +++ b/test/float16.cpp @@ -25,7 +25,6 @@ #include #include #include "test.hpp" -#define HIP_ENABLE_PRINTF #include @@ -43,7 +42,7 @@ TEST_CASE(fp16_values) CHECK_FLOAT(1.0f, fp16{1.0f}); CHECK_FLOAT(-1.0f, fp16{-1.0f}); - // CHECK_FLOAT(std::numeric_limits::min(), fp16::min()); + CHECK_FLOAT(std::numeric_limits::min(), fp16::min()); // CHECK_FLOAT(std::numeric_limits::lowest(), fp16::lowest()); // CHECK_FLOAT(std::numeric_limits::max(), fp16::max()); // CHECK_FLOAT(std::numeric_limits::epsilon(), fp16::epsilon()); diff --git a/test/float32.cpp b/test/float32.cpp index 63b9db489d8..a6025cd8b21 100644 --- a/test/float32.cpp +++ b/test/float32.cpp @@ -47,6 +47,7 @@ TEST_CASE(fp32_values_working) CHECK_FLOAT(std::numeric_limits::max(), fp32::max()); CHECK_FLOAT(std::numeric_limits::epsilon(), fp32::epsilon()); CHECK_FLOAT(std::numeric_limits::denorm_min(), fp32::denorm_min()); + // CHECK_FLOAT(std::numeric_limits::infinity(), fp32::infinity()); // CHECK_FLOAT(std::numeric_limits::quiet_NaN(), fp32::qnan()); // CHECK_FLOAT(std::numeric_limits::signaling_NaN(), fp32::snan()); From ff8ffc7f3af9570eb7892cfa3b69cd5b2cc24373 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Fri, 18 Oct 2024 18:06:28 -0500 Subject: [PATCH 13/72] updated fp16 and fp32 tests --- src/include/migraphx/generic_float.hpp | 20 +- test/float16.cpp | 1115 +++++++++++++++++++++++- test/float32.cpp | 52 +- 3 files changed, 1097 insertions(+), 90 deletions(-) diff --git a/src/include/migraphx/generic_float.hpp b/src/include/migraphx/generic_float.hpp index 6352e8fc2d4..75ed3d21c1f 100644 --- a/src/include/migraphx/generic_float.hpp +++ b/src/include/migraphx/generic_float.hpp @@ -26,6 +26,7 @@ #include #include #include +#include namespace migraphx { inline namespace MIGRAPHX_INLINE_NS { @@ -33,7 +34,7 @@ inline namespace MIGRAPHX_INLINE_NS { template constexpr unsigned int all_ones() noexcept { - return (1 << N) - 1; + return (1u << N) - 1u; } struct float32_parts @@ -68,8 +69,9 @@ constexpr float32_parts get_parts(float f) return migraphx::bit_cast(f); } + template -struct generic_float +struct __attribute__((packed)) generic_float { unsigned int mantissa : MantissaSize; unsigned int exponent : ExponentSize; @@ -105,11 +107,7 @@ struct generic_float f.sign = sign; f.mantissa = mantissa << (float32_parts::mantissa_width() - MantissaSize); - if(exponent == 1 and mantissa == 0) - { - f.exponent = 1; - } - else if(exponent == all_ones()) + if(exponent == all_ones()) { f.exponent = float32_parts::max_exponent(); } @@ -130,10 +128,6 @@ struct generic_float { exponent = 0; } - else if (f.exponent == 1 and f.mantissa == 0) - { - exponent = 1; - } else if(f.exponent == float32_parts::max_exponent()) { exponent = all_ones(); @@ -308,6 +302,8 @@ class numeric_limits> static constexpr migraphx::generic_float quiet_NaN() { return migraphx::generic_float::qnan(); } + static constexpr migraphx::generic_float signaling_NaN() { return migraphx::generic_float::snan(); } + static constexpr migraphx::generic_float max() { return migraphx::generic_float::max(); } static constexpr migraphx::generic_float min() { return migraphx::generic_float::min(); } @@ -316,6 +312,8 @@ class numeric_limits> static constexpr migraphx::generic_float infinity() { return migraphx::generic_float::infinity(); } + static constexpr migraphx::generic_float denorm_min() { return migraphx::generic_float::denorm_min(); } + }; template diff --git a/test/float16.cpp b/test/float16.cpp index 9effc9a8f5a..e2153e095c0 100644 --- a/test/float16.cpp +++ b/test/float16.cpp @@ -24,61 +24,1090 @@ #include #include #include +#include #include "test.hpp" #include +#include -using fp16 = migraphx::half; - -#define CHECK_FLOAT(x, y) \ - CHECK(migraphx::float_equal(x, y)); \ - CHECK(migraphx::float_equal(x, y.to_float())); \ - CHECK(migraphx::float_equal(fp16{x}, y)); \ - CHECK(migraphx::float_equal(fp16{x}.to_float(), y.to_float())) - - -TEST_CASE(fp16_values) -{ - - CHECK_FLOAT(1.0f, fp16{1.0f}); - CHECK_FLOAT(-1.0f, fp16{-1.0f}); - CHECK_FLOAT(std::numeric_limits::min(), fp16::min()); - // CHECK_FLOAT(std::numeric_limits::lowest(), fp16::lowest()); - // CHECK_FLOAT(std::numeric_limits::max(), fp16::max()); - // CHECK_FLOAT(std::numeric_limits::epsilon(), fp16::epsilon()); - // CHECK_FLOAT(std::numeric_limits::infinity(), fp16::infinity()); - // CHECK_FLOAT(std::numeric_limits::quiet_NaN(), fp16::qnan()); - // CHECK_FLOAT(std::numeric_limits::signaling_NaN(), fp16::snan()); - // CHECK_FLOAT(std::numeric_limits::denorm_min(), fp16::denorm_min()); -} - -TEST_CASE(test_infinity_1) +template +bool bit_equal(const T& x, const U& y) { - float f_inf = std::numeric_limits::infinity(); - float f16_inf = fp16::infinity().to_float(); - EXPECT(f16_inf == f_inf); + static_assert(sizeof(T) == sizeof(U)); + using type = std::array; + return migraphx::bit_cast(x) == migraphx::bit_cast(y); } -TEST_CASE(test_infinity_2) +TEST_CASE(check_numeric_limits) { - float f_inf = -1.0 * std::numeric_limits::infinity(); - float f16_inf = -1.0 * fp16::infinity().to_float(); - EXPECT(f16_inf == f_inf); + CHECK(bit_equal(std::numeric_limits::min(), uint16_t{0x0400})); + CHECK(bit_equal(std::numeric_limits::lowest(), uint16_t{0xfbff})); + CHECK(bit_equal(std::numeric_limits::max(), uint16_t{0x7bff})); + CHECK(bit_equal(std::numeric_limits::epsilon(), uint16_t{0x1400})); + CHECK(bit_equal(std::numeric_limits::denorm_min(), uint16_t{0x0001})); + CHECK(bit_equal(std::numeric_limits::infinity(), uint16_t{0x7c00})); + CHECK(bit_equal(std::numeric_limits::quiet_NaN(), uint16_t{0x7e00})); + CHECK(bit_equal(std::numeric_limits::signaling_NaN(), uint16_t{0x7d00})); } -TEST_CASE(test_snan) -{ - fp16 fp16_snan = fp16::snan(); - EXPECT(fp16_snan.is_nan()); - EXPECT(std::isnan(fp16_snan)); -} +static const std::map half_lut = { + {0x0000, 0}, + {0x0058, 0.0000052452087402}, + {0x0079, 0.0000072121620178}, + {0x0097, 0.0000090003013611}, + {0x009e, 0.0000094175338745}, + {0x0125, 0.0000174641609192}, + {0x0167, 0.0000213980674744}, + {0x0196, 0.0000241994857788}, + {0x01c4, 0.0000269412994385}, + {0x01c8, 0.0000271797180176}, + {0x0236, 0.0000337362289429}, + {0x029f, 0.0000399947166443}, + {0x02bf, 0.0000419020652771}, + {0x02d6, 0.0000432729721069}, + {0x03a6, 0.0000556707382202}, + {0x03b7, 0.0000566840171814}, + {0x03d4, 0.0000584125518799}, + {0x03d8, 0.000058650970459}, + {0x03ed, 0.0000599026679993}, + {0x0427, 0.0000633597373962}, + {0x0430, 0.0000638961791992}, + {0x0435, 0.0000641942024231}, + {0x0454, 0.0000660419464111}, + {0x047a, 0.0000683069229126}, + {0x04b6, 0.0000718832015991}, + {0x056a, 0.0000826120376587}, + {0x056f, 0.0000829100608826}, + {0x0584, 0.0000841617584229}, + {0x05a1, 0.0000858902931213}, + {0x05a4, 0.0000860691070557}, + {0x05b8, 0.0000872611999512}, + {0x05bc, 0.0000874996185303}, + {0x0635, 0.0000947117805481}, + {0x0641, 0.0000954270362854}, + {0x0686, 0.0000995397567749}, + {0x0694, 0.0001003742218018}, + {0x06db, 0.0001046061515808}, + {0x0725, 0.0001090168952942}, + {0x0777, 0.0001139044761658}, + {0x07b2, 0.0001174211502075}, + {0x0812, 0.0001242160797119}, + {0x082e, 0.0001275539398193}, + {0x0859, 0.00013267993927}, + {0x0895, 0.0001398324966431}, + {0x08af, 0.0001429319381714}, + {0x08fc, 0.0001521110534668}, + {0x092e, 0.0001580715179443}, + {0x0971, 0.0001660585403442}, + {0x0991, 0.0001698732376099}, + {0x09ca, 0.0001766681671143}, + {0x0a63, 0.0001949071884155}, + {0x0a8e, 0.0002000331878662}, + {0x0a93, 0.000200629234314}, + {0x0b2a, 0.0002186298370361}, + {0x0b3a, 0.0002205371856689}, + {0x0b3c, 0.000220775604248}, + {0x0b4e, 0.00022292137146}, + {0x0bae, 0.0002343654632568}, + {0x0bff, 0.0002440214157104}, + {0x0c08, 0.0002460479736328}, + {0x0c56, 0.0002646446228027}, + {0x0c61, 0.0002672672271729}, + {0x0c70, 0.0002708435058594}, + {0x0c7c, 0.0002737045288086}, + {0x0cd8, 0.0002956390380859}, + {0x0cdd, 0.0002968311309814}, + {0x0d05, 0.0003063678741455}, + {0x0d61, 0.0003283023834229}, + {0x0d85, 0.0003368854522705}, + {0x0d8c, 0.0003385543823242}, + {0x0d90, 0.0003395080566406}, + {0x0d9e, 0.000342845916748}, + {0x0da5, 0.0003445148468018}, + {0x0dda, 0.0003571510314941}, + {0x0dde, 0.0003581047058105}, + {0x0df6, 0.000363826751709}, + {0x0eec, 0.000422477722168}, + {0x0f1c, 0.0004339218139648}, + {0x0f99, 0.0004637241363525}, + {0x0fac, 0.0004682540893555}, + {0x0fb0, 0.0004692077636719}, + {0x0ff5, 0.0004856586456299}, + {0x107f, 0.0005488395690918}, + {0x1096, 0.0005598068237305}, + {0x10c8, 0.0005836486816406}, + {0x10e9, 0.0005993843078613}, + {0x110a, 0.000615119934082}, + {0x118a, 0.000676155090332}, + {0x11b5, 0.0006966590881348}, + {0x1293, 0.0008025169372559}, + {0x133f, 0.0008845329284668}, + {0x1342, 0.0008859634399414}, + {0x1372, 0.0009088516235352}, + {0x13cf, 0.000953197479248}, + {0x140c, 0.0009880065917969}, + {0x1437, 0.0010290145874023}, + {0x14a3, 0.0011320114135742}, + {0x14a6, 0.0011348724365234}, + {0x14b2, 0.0011463165283203}, + {0x14ba, 0.0011539459228516}, + {0x14d9, 0.0011835098266602}, + {0x14da, 0.0011844635009766}, + {0x14e7, 0.0011968612670898}, + {0x14fe, 0.0012187957763672}, + {0x1521, 0.0012521743774414}, + {0x153d, 0.0012788772583008}, + {0x15ad, 0.0013856887817383}, + {0x15fd, 0.0014619827270508}, + {0x1649, 0.0015344619750977}, + {0x1658, 0.0015487670898438}, + {0x168a, 0.0015964508056641}, + {0x169d, 0.0016145706176758}, + {0x16b3, 0.0016355514526367}, + {0x16c9, 0.0016565322875977}, + {0x16d1, 0.0016641616821289}, + {0x16e0, 0.001678466796875}, + {0x170a, 0.0017185211181641}, + {0x176d, 0.0018129348754883}, + {0x185b, 0.0021266937255859}, + {0x185e, 0.0021324157714844}, + {0x187e, 0.0021934509277344}, + {0x18ca, 0.0023384094238281}, + {0x18e9, 0.0023975372314453}, + {0x1901, 0.0024433135986328}, + {0x191e, 0.0024986267089844}, + {0x1963, 0.0026302337646484}, + {0x199f, 0.0027446746826172}, + {0x19b2, 0.0027809143066406}, + {0x19d4, 0.0028457641601562}, + {0x1a31, 0.0030231475830078}, + {0x1a4a, 0.0030708312988281}, + {0x1a7a, 0.0031623840332031}, + {0x1ace, 0.0033226013183594}, + {0x1b03, 0.0034236907958984}, + {0x1b22, 0.0034828186035156}, + {0x1d49, 0.0051612854003906}, + {0x1d5a, 0.0052261352539062}, + {0x1d6c, 0.0052947998046875}, + {0x1e02, 0.0058670043945312}, + {0x1e19, 0.0059547424316406}, + {0x1e4c, 0.0061492919921875}, + {0x1eb3, 0.0065422058105469}, + {0x1f32, 0.0070266723632812}, + {0x1f36, 0.0070419311523438}, + {0x1f41, 0.0070838928222656}, + {0x1f7a, 0.0073013305664062}, + {0x1f8d, 0.0073738098144531}, + {0x200b, 0.0078964233398438}, + {0x205f, 0.0085372924804688}, + {0x2060, 0.008544921875}, + {0x2067, 0.0085983276367188}, + {0x20e2, 0.0095367431640625}, + {0x2164, 0.010528564453125}, + {0x22a4, 0.012969970703125}, + {0x22b4, 0.013092041015625}, + {0x22f2, 0.0135650634765625}, + {0x230c, 0.013763427734375}, + {0x2314, 0.013824462890625}, + {0x2341, 0.0141677856445312}, + {0x2356, 0.0143280029296875}, + {0x236e, 0.0145111083984375}, + {0x2371, 0.0145339965820312}, + {0x23cd, 0.0152359008789062}, + {0x2405, 0.0157012939453125}, + {0x24a2, 0.018096923828125}, + {0x24ba, 0.018463134765625}, + {0x24e7, 0.0191497802734375}, + {0x266c, 0.02508544921875}, + {0x26a2, 0.025909423828125}, + {0x26cc, 0.02655029296875}, + {0x26f0, 0.027099609375}, + {0x271e, 0.027801513671875}, + {0x2798, 0.0296630859375}, + {0x287d, 0.035064697265625}, + {0x28a2, 0.03619384765625}, + {0x28ca, 0.03741455078125}, + {0x2933, 0.040618896484375}, + {0x298d, 0.043365478515625}, + {0x299e, 0.04388427734375}, + {0x29c0, 0.044921875}, + {0x29c2, 0.04498291015625}, + {0x29cf, 0.045379638671875}, + {0x29fa, 0.04669189453125}, + {0x2a06, 0.04705810546875}, + {0x2aa5, 0.051910400390625}, + {0x2bcb, 0.060882568359375}, + {0x2c18, 0.06396484375}, + {0x2c65, 0.06866455078125}, + {0x2c66, 0.0687255859375}, + {0x2c93, 0.07147216796875}, + {0x2d24, 0.080322265625}, + {0x2d35, 0.08135986328125}, + {0x2d4c, 0.082763671875}, + {0x2db7, 0.08929443359375}, + {0x2dec, 0.092529296875}, + {0x2e31, 0.09674072265625}, + {0x2ec9, 0.10601806640625}, + {0x2f85, 0.11749267578125}, + {0x2f94, 0.118408203125}, + {0x302b, 0.1302490234375}, + {0x3094, 0.14306640625}, + {0x3096, 0.143310546875}, + {0x30ae, 0.146240234375}, + {0x30b9, 0.1475830078125}, + {0x310c, 0.15771484375}, + {0x31bd, 0.1793212890625}, + {0x3213, 0.1898193359375}, + {0x325b, 0.1986083984375}, + {0x32aa, 0.208251953125}, + {0x32c0, 0.2109375}, + {0x32d7, 0.2137451171875}, + {0x3391, 0.2364501953125}, + {0x340d, 0.253173828125}, + {0x343d, 0.264892578125}, + {0x3566, 0.33740234375}, + {0x35e6, 0.36865234375}, + {0x35f4, 0.3720703125}, + {0x363b, 0.389404296875}, + {0x363e, 0.39013671875}, + {0x3650, 0.39453125}, + {0x3698, 0.412109375}, + {0x36e7, 0.431396484375}, + {0x36fe, 0.43701171875}, + {0x374a, 0.45556640625}, + {0x3760, 0.4609375}, + {0x3761, 0.461181640625}, + {0x379e, 0.47607421875}, + {0x37cc, 0.4873046875}, + {0x37fd, 0.499267578125}, + {0x3828, 0.51953125}, + {0x3841, 0.53173828125}, + {0x3877, 0.55810546875}, + {0x38a4, 0.580078125}, + {0x38d3, 0.60302734375}, + {0x39b2, 0.7119140625}, + {0x3a60, 0.796875}, + {0x3aa3, 0.82958984375}, + {0x3aa6, 0.8310546875}, + {0x3ac9, 0.84814453125}, + {0x3acf, 0.85107421875}, + {0x3b14, 0.884765625}, + {0x3b42, 0.9072265625}, + {0x3b5c, 0.919921875}, + {0x3bde, 0.9833984375}, + {0x3c67, 1.1005859375}, + {0x3cb5, 1.1767578125}, + {0x3cca, 1.197265625}, + {0x3cdd, 1.2158203125}, + {0x3cfc, 1.24609375}, + {0x3d1f, 1.2802734375}, + {0x3e0c, 1.51171875}, + {0x3e1c, 1.52734375}, + {0x3e5b, 1.5888671875}, + {0x3e7f, 1.6240234375}, + {0x3eae, 1.669921875}, + {0x3efe, 1.748046875}, + {0x3f3e, 1.810546875}, + {0x3f9d, 1.9033203125}, + {0x400a, 2.01953125}, + {0x4070, 2.21875}, + {0x40a0, 2.3125}, + {0x40ce, 2.40234375}, + {0x40e6, 2.44921875}, + {0x410e, 2.52734375}, + {0x4129, 2.580078125}, + {0x4144, 2.6328125}, + {0x41a4, 2.8203125}, + {0x41f3, 2.974609375}, + {0x42f1, 3.470703125}, + {0x438f, 3.779296875}, + {0x43b0, 3.84375}, + {0x43c3, 3.880859375}, + {0x43de, 3.93359375}, + {0x4483, 4.51171875}, + {0x44f8, 4.96875}, + {0x4505, 5.01953125}, + {0x45dd, 5.86328125}, + {0x45f3, 5.94921875}, + {0x460e, 6.0546875}, + {0x46ce, 6.8046875}, + {0x4704, 7.015625}, + {0x471a, 7.1015625}, + {0x475e, 7.3671875}, + {0x4761, 7.37890625}, + {0x479f, 7.62109375}, + {0x47ca, 7.7890625}, + {0x47db, 7.85546875}, + {0x47fc, 7.984375}, + {0x481e, 8.234375}, + {0x4839, 8.4453125}, + {0x483d, 8.4765625}, + {0x48ac, 9.34375}, + {0x48da, 9.703125}, + {0x4919, 10.1953125}, + {0x4950, 10.625}, + {0x4987, 11.0546875}, + {0x49bb, 11.4609375}, + {0x4a14, 12.15625}, + {0x4a92, 13.140625}, + {0x4b25, 14.2890625}, + {0x4b81, 15.0078125}, + {0x4b99, 15.1953125}, + {0x4bbe, 15.484375}, + {0x4bf8, 15.9375}, + {0x4c1f, 16.484375}, + {0x4c49, 17.140625}, + {0x4d21, 20.515625}, + {0x4d4a, 21.15625}, + {0x4d51, 21.265625}, + {0x4de2, 23.53125}, + {0x4e05, 24.078125}, + {0x4ea3, 26.546875}, + {0x4eb0, 26.75}, + {0x4f0e, 28.21875}, + {0x4f4a, 29.15625}, + {0x4f6b, 29.671875}, + {0x4fa6, 30.59375}, + {0x4fae, 30.71875}, + {0x4ff6, 31.84375}, + {0x503c, 33.875}, + {0x50e4, 39.125}, + {0x514e, 42.4375}, + {0x516b, 43.34375}, + {0x51d3, 46.59375}, + {0x5213, 48.59375}, + {0x526e, 51.4375}, + {0x52a6, 53.1875}, + {0x52b4, 53.625}, + {0x52b6, 53.6875}, + {0x52bc, 53.875}, + {0x5300, 56}, + {0x5389, 60.28125}, + {0x5406, 64.375}, + {0x5498, 73.5}, + {0x54bd, 75.8125}, + {0x54cf, 76.9375}, + {0x5502, 80.125}, + {0x558e, 88.875}, + {0x5597, 89.4375}, + {0x55eb, 94.6875}, + {0x55f6, 95.375}, + {0x5629, 98.5625}, + {0x562b, 98.6875}, + {0x5635, 99.3125}, + {0x564e, 100.875}, + {0x5671, 103.0625}, + {0x5681, 104.0625}, + {0x56d1, 109.0625}, + {0x571c, 113.75}, + {0x5756, 117.375}, + {0x5790, 121}, + {0x57fd, 127.8125}, + {0x582d, 133.625}, + {0x5869, 141.125}, + {0x58ab, 149.375}, + {0x58ad, 149.625}, + {0x58c9, 153.125}, + {0x58f7, 158.875}, + {0x5904, 160.5}, + {0x59c2, 184.25}, + {0x59e6, 188.75}, + {0x5a88, 209}, + {0x5ada, 219.25}, + {0x5aef, 221.875}, + {0x5af5, 222.625}, + {0x5b7f, 239.875}, + {0x5ba4, 244.5}, + {0x5c08, 258}, + {0x5cbf, 303.75}, + {0x5d4d, 339.25}, + {0x5dc2, 368.5}, + {0x5dc4, 369}, + {0x5e31, 396.25}, + {0x5e38, 398}, + {0x5e7c, 415}, + {0x5e8d, 419.25}, + {0x5ead, 427.25}, + {0x5eb4, 429}, + {0x5ec0, 432}, + {0x5eef, 443.75}, + {0x5f04, 449}, + {0x5f41, 464.25}, + {0x5f58, 470}, + {0x5f61, 472.25}, + {0x5f77, 477.75}, + {0x5f7b, 478.75}, + {0x6029, 532.5}, + {0x6046, 547}, + {0x6055, 554.5}, + {0x60a8, 596}, + {0x60d7, 619.5}, + {0x6139, 668.5}, + {0x6167, 691.5}, + {0x61b5, 730.5}, + {0x61c0, 736}, + {0x61e6, 755}, + {0x625b, 813.5}, + {0x62c4, 866}, + {0x62fd, 894.5}, + {0x62fe, 895}, + {0x6332, 921}, + {0x636a, 949}, + {0x6374, 954}, + {0x6376, 955}, + {0x639f, 975.5}, + {0x63d6, 1003}, + {0x6417, 1047}, + {0x642e, 1070}, + {0x6431, 1073}, + {0x644f, 1103}, + {0x6459, 1113}, + {0x645b, 1115}, + {0x6480, 1152}, + {0x648d, 1165}, + {0x649f, 1183}, + {0x64bb, 1211}, + {0x6516, 1302}, + {0x6571, 1393}, + {0x6585, 1413}, + {0x65aa, 1450}, + {0x660c, 1548}, + {0x6694, 1684}, + {0x66d0, 1744}, + {0x6721, 1825}, + {0x672d, 1837}, + {0x6734, 1844}, + {0x6766, 1894}, + {0x6773, 1907}, + {0x677d, 1917}, + {0x679a, 1946}, + {0x690f, 2590}, + {0x6934, 2664}, + {0x6955, 2730}, + {0x697d, 2810}, + {0x698e, 2844}, + {0x6a3a, 3188}, + {0x6a63, 3270}, + {0x6a67, 3278}, + {0x6a7c, 3320}, + {0x6a87, 3342}, + {0x6b07, 3598}, + {0x6b11, 3618}, + {0x6b36, 3692}, + {0x6b3c, 3704}, + {0x6b75, 3818}, + {0x6b88, 3856}, + {0x6be6, 4044}, + {0x6bee, 4060}, + {0x6c62, 4488}, + {0x6c8b, 4652}, + {0x6d30, 5312}, + {0x6d48, 5408}, + {0x6ddd, 6004}, + {0x6de9, 6052}, + {0x6e39, 6372}, + {0x6e7e, 6648}, + {0x6ea5, 6804}, + {0x6ec5, 6932}, + {0x6ee1, 7044}, + {0x6ef1, 7108}, + {0x6fa2, 7816}, + {0x6fbc, 7920}, + {0x704c, 8800}, + {0x7083, 9240}, + {0x7108, 10304}, + {0x7115, 10408}, + {0x7128, 10560}, + {0x71af, 11640}, + {0x7222, 12560}, + {0x7228, 12608}, + {0x72a5, 13608}, + {0x72e0, 14080}, + {0x72e6, 14128}, + {0x731e, 14576}, + {0x7377, 15288}, + {0x741d, 16848}, + {0x7423, 16944}, + {0x7424, 16960}, + {0x7466, 18016}, + {0x74b0, 19200}, + {0x74ce, 19680}, + {0x74f0, 20224}, + {0x754b, 21680}, + {0x7575, 22352}, + {0x7594, 22848}, + {0x75b1, 23312}, + {0x7614, 24896}, + {0x7618, 24960}, + {0x7631, 25360}, + {0x7660, 26112}, + {0x76c8, 27776}, + {0x7773, 30512}, + {0x77af, 31472}, + {0x77b9, 31632}, + {0x77de, 32224}, + {0x7844, 34944}, + {0x78d2, 39488}, + {0x7924, 42112}, + {0x793b, 42848}, + {0x79db, 47968}, + {0x7a0f, 49632}, + {0x7a1a, 49984}, + {0x7a6c, 52608}, + {0x7a99, 54048}, + {0x7ada, 56128}, + {0x7b0f, 57824}, + {0x7b15, 58016}, + {0x7b41, 59424}, + {0x7b51, 59936}, + {0x7b9c, 62336}, + {0x7ba3, 62560}, + {0x7c00, std::numeric_limits::infinity()}, + {0x7c05, std::numeric_limits::quiet_NaN()}, + {0x7c0e, std::numeric_limits::quiet_NaN()}, + {0x7c3e, std::numeric_limits::quiet_NaN()}, + {0x7c4e, std::numeric_limits::quiet_NaN()}, + {0x7c55, std::numeric_limits::quiet_NaN()}, + {0x7c58, std::numeric_limits::quiet_NaN()}, + {0x7c66, std::numeric_limits::quiet_NaN()}, + {0x7cc9, std::numeric_limits::quiet_NaN()}, + {0x7cd8, std::numeric_limits::quiet_NaN()}, + {0x7d2d, std::numeric_limits::quiet_NaN()}, + {0x7d60, std::numeric_limits::quiet_NaN()}, + {0x7d79, std::numeric_limits::quiet_NaN()}, + {0x7dc7, std::numeric_limits::quiet_NaN()}, + {0x7dcf, std::numeric_limits::quiet_NaN()}, + {0x7dd8, std::numeric_limits::quiet_NaN()}, + {0x7dfb, std::numeric_limits::quiet_NaN()}, + {0x7e0f, std::numeric_limits::quiet_NaN()}, + {0x7e56, std::numeric_limits::quiet_NaN()}, + {0x7e89, std::numeric_limits::quiet_NaN()}, + {0x7e9c, std::numeric_limits::quiet_NaN()}, + {0x7eb2, std::numeric_limits::quiet_NaN()}, + {0x7ec3, std::numeric_limits::quiet_NaN()}, + {0x7ef9, std::numeric_limits::quiet_NaN()}, + {0x7f36, std::numeric_limits::quiet_NaN()}, + {0x8040, -0.0000038146972656}, + {0x8101, -0.0000153183937073}, + {0x813d, -0.0000188946723938}, + {0x81a8, -0.0000252723693848}, + {0x81bc, -0.0000264644622803}, + {0x81c2, -0.0000268220901489}, + {0x8259, -0.00003582239151}, + {0x8330, -0.0000486373901367}, + {0x8366, -0.0000518560409546}, + {0x8392, -0.0000544786453247}, + {0x83e4, -0.0000593662261963}, + {0x83ee, -0.000059962272644}, + {0x8402, -0.0000611543655396}, + {0x845e, -0.0000666379928589}, + {0x84ac, -0.0000712871551514}, + {0x84b1, -0.0000715851783752}, + {0x84fb, -0.0000759959220886}, + {0x8546, -0.0000804662704468}, + {0x856f, -0.0000829100608826}, + {0x85b5, -0.0000870823860168}, + {0x8638, -0.0000948905944824}, + {0x8656, -0.0000966787338257}, + {0x86b9, -0.0001025795936584}, + {0x86ba, -0.0001026391983032}, + {0x86fe, -0.0001066923141479}, + {0x8731, -0.0001097321510315}, + {0x8740, -0.0001106262207031}, + {0x8793, -0.0001155734062195}, + {0x87bd, -0.0001180768013}, + {0x87f1, -0.0001211762428284}, + {0x87f4, -0.0001213550567627}, + {0x8809, -0.000123143196106}, + {0x882a, -0.0001270771026611}, + {0x8848, -0.0001306533813477}, + {0x8852, -0.0001318454742432}, + {0x8874, -0.0001358985900879}, + {0x8892, -0.0001394748687744}, + {0x88a7, -0.000141978263855}, + {0x88c8, -0.0001459121704102}, + {0x8927, -0.0001572370529175}, + {0x892a, -0.0001575946807861}, + {0x8989, -0.0001689195632935}, + {0x89b9, -0.0001746416091919}, + {0x8b18, -0.0002164840698242}, + {0x8b4b, -0.0002225637435913}, + {0x8b62, -0.000225305557251}, + {0x8b7f, -0.0002287626266479}, + {0x8bca, -0.0002377033233643}, + {0x8bcf, -0.000238299369812}, + {0x8bff, -0.0002440214157104}, + {0x8c0b, -0.0002467632293701}, + {0x8c55, -0.0002644062042236}, + {0x8c63, -0.0002677440643311}, + {0x8d53, -0.0003249645233154}, + {0x8dba, -0.0003495216369629}, + {0x8e03, -0.0003669261932373}, + {0x8e82, -0.0003972053527832}, + {0x8e9c, -0.0004034042358398}, + {0x8faa, -0.0004677772521973}, + {0x902f, -0.0005106925964355}, + {0x9051, -0.0005269050598145}, + {0x9066, -0.0005369186401367}, + {0x907e, -0.0005483627319336}, + {0x9080, -0.00054931640625}, + {0x908e, -0.0005559921264648}, + {0x9102, -0.0006113052368164}, + {0x91eb, -0.0007224082946777}, + {0x9215, -0.0007424354553223}, + {0x9252, -0.0007715225219727}, + {0x9294, -0.0008029937744141}, + {0x9297, -0.0008044242858887}, + {0x933d, -0.0008835792541504}, + {0x936f, -0.0009074211120605}, + {0x93aa, -0.0009355545043945}, + {0x93f2, -0.0009698867797852}, + {0x941d, -0.0010042190551758}, + {0x945a, -0.0010623931884766}, + {0x94ad, -0.0011415481567383}, + {0x94d2, -0.0011768341064453}, + {0x951c, -0.0012474060058594}, + {0x9520, -0.001251220703125}, + {0x952f, -0.0012655258178711}, + {0x953f, -0.0012807846069336}, + {0x9549, -0.0012903213500977}, + {0x95c6, -0.0014095306396484}, + {0x9602, -0.0014667510986328}, + {0x969b, -0.001612663269043}, + {0x96fa, -0.0017032623291016}, + {0x977d, -0.0018281936645508}, + {0x97c3, -0.0018949508666992}, + {0x97c6, -0.0018978118896484}, + {0x97db, -0.001917839050293}, + {0x97f9, -0.0019464492797852}, + {0x983f, -0.0020732879638672}, + {0x984e, -0.0021018981933594}, + {0x985a, -0.0021247863769531}, + {0x988c, -0.0022201538085938}, + {0x990d, -0.0024662017822266}, + {0x9958, -0.0026092529296875}, + {0x9971, -0.0026569366455078}, + {0x9a4e, -0.0030784606933594}, + {0x9a8f, -0.0032024383544922}, + {0x9abe, -0.0032920837402344}, + {0x9ace, -0.0033226013183594}, + {0x9b1e, -0.0034751892089844}, + {0x9b3e, -0.0035362243652344}, + {0x9b77, -0.0036449432373047}, + {0x9b89, -0.0036792755126953}, + {0x9b90, -0.003692626953125}, + {0x9bec, -0.0038681030273438}, + {0x9c03, -0.0039176940917969}, + {0x9c75, -0.0043525695800781}, + {0x9d6c, -0.0052947998046875}, + {0x9d74, -0.0053253173828125}, + {0x9da7, -0.0055198669433594}, + {0x9e73, -0.0062980651855469}, + {0x9e94, -0.0064239501953125}, + {0x9f17, -0.0069236755371094}, + {0x9f3a, -0.0070571899414062}, + {0x9f6c, -0.0072479248046875}, + {0x9f89, -0.0073585510253906}, + {0x9fbd, -0.0075569152832031}, + {0xa003, -0.0078353881835938}, + {0xa014, -0.007965087890625}, + {0xa019, -0.0080032348632812}, + {0xa01d, -0.0080337524414062}, + {0xa090, -0.0089111328125}, + {0xa1cf, -0.0113449096679688}, + {0xa1dd, -0.0114517211914062}, + {0xa249, -0.0122756958007812}, + {0xa26d, -0.0125503540039062}, + {0xa288, -0.01275634765625}, + {0xa2fb, -0.0136337280273438}, + {0xa390, -0.0147705078125}, + {0xa3b3, -0.0150375366210938}, + {0xa3ed, -0.0154800415039062}, + {0xa434, -0.01641845703125}, + {0xa476, -0.017425537109375}, + {0xa571, -0.0212554931640625}, + {0xa57d, -0.0214385986328125}, + {0xa597, -0.0218353271484375}, + {0xa5d1, -0.0227203369140625}, + {0xa5f9, -0.0233306884765625}, + {0xa680, -0.025390625}, + {0xa6e3, -0.0269012451171875}, + {0xa6f0, -0.027099609375}, + {0xa72d, -0.0280303955078125}, + {0xa77e, -0.029266357421875}, + {0xa7d0, -0.030517578125}, + {0xa7ee, -0.030975341796875}, + {0xa7f3, -0.0310516357421875}, + {0xa80c, -0.0316162109375}, + {0xa827, -0.032440185546875}, + {0xa89f, -0.036102294921875}, + {0xa8a0, -0.0361328125}, + {0xa8a5, -0.036285400390625}, + {0xa948, -0.041259765625}, + {0xaa0c, -0.0472412109375}, + {0xaa16, -0.04754638671875}, + {0xaa9a, -0.05157470703125}, + {0xaaeb, -0.054046630859375}, + {0xab5c, -0.0574951171875}, + {0xac7e, -0.0701904296875}, + {0xad33, -0.08123779296875}, + {0xad37, -0.08148193359375}, + {0xad90, -0.0869140625}, + {0xada0, -0.087890625}, + {0xade5, -0.09210205078125}, + {0xadf8, -0.09326171875}, + {0xae02, -0.0938720703125}, + {0xae04, -0.093994140625}, + {0xae4f, -0.09857177734375}, + {0xae63, -0.09979248046875}, + {0xaebe, -0.1053466796875}, + {0xaee1, -0.10748291015625}, + {0xaef9, -0.10894775390625}, + {0xaf0b, -0.11004638671875}, + {0xaf78, -0.11669921875}, + {0xaf7d, -0.11700439453125}, + {0xaf7f, -0.11712646484375}, + {0xaf8c, -0.117919921875}, + {0xafcb, -0.12176513671875}, + {0xb06b, -0.1380615234375}, + {0xb07b, -0.1400146484375}, + {0xb088, -0.1416015625}, + {0xb0b2, -0.146728515625}, + {0xb0ed, -0.1539306640625}, + {0xb0f9, -0.1553955078125}, + {0xb16c, -0.16943359375}, + {0xb189, -0.1729736328125}, + {0xb1c5, -0.1802978515625}, + {0xb1f7, -0.1864013671875}, + {0xb22d, -0.1929931640625}, + {0xb23c, -0.19482421875}, + {0xb258, -0.1982421875}, + {0xb2c7, -0.2117919921875}, + {0xb2de, -0.214599609375}, + {0xb2e1, -0.2149658203125}, + {0xb317, -0.2215576171875}, + {0xb31d, -0.2222900390625}, + {0xb3ef, -0.2479248046875}, + {0xb3f8, -0.2490234375}, + {0xb45a, -0.27197265625}, + {0xb548, -0.330078125}, + {0xb5d8, -0.365234375}, + {0xb64e, -0.39404296875}, + {0xb69f, -0.413818359375}, + {0xb6e6, -0.43115234375}, + {0xb6ed, -0.432861328125}, + {0xb6f7, -0.435302734375}, + {0xb79a, -0.47509765625}, + {0xb7b6, -0.48193359375}, + {0xb7ee, -0.49560546875}, + {0xb856, -0.5419921875}, + {0xb8c0, -0.59375}, + {0xb96f, -0.67919921875}, + {0xb9a5, -0.70556640625}, + {0xba1e, -0.7646484375}, + {0xba2d, -0.77197265625}, + {0xba48, -0.78515625}, + {0xba65, -0.79931640625}, + {0xbaaf, -0.83544921875}, + {0xbab0, -0.8359375}, + {0xbb12, -0.8837890625}, + {0xbb35, -0.90087890625}, + {0xbb47, -0.90966796875}, + {0xbb97, -0.94873046875}, + {0xbba3, -0.95458984375}, + {0xbbcb, -0.97412109375}, + {0xbbe8, -0.98828125}, + {0xbbee, -0.9912109375}, + {0xbd03, -1.2529296875}, + {0xbd4b, -1.3232421875}, + {0xbd4c, -1.32421875}, + {0xbd8a, -1.384765625}, + {0xbdb6, -1.427734375}, + {0xbde1, -1.4697265625}, + {0xbe04, -1.50390625}, + {0xbe50, -1.578125}, + {0xbe54, -1.58203125}, + {0xbe6a, -1.603515625}, + {0xbf31, -1.7978515625}, + {0xbf87, -1.8818359375}, + {0xbfa2, -1.908203125}, + {0xc016, -2.04296875}, + {0xc074, -2.2265625}, + {0xc0ca, -2.39453125}, + {0xc100, -2.5}, + {0xc1b7, -2.857421875}, + {0xc1b9, -2.861328125}, + {0xc1d3, -2.912109375}, + {0xc23f, -3.123046875}, + {0xc2d5, -3.416015625}, + {0xc32f, -3.591796875}, + {0xc3e3, -3.943359375}, + {0xc412, -4.0703125}, + {0xc49a, -4.6015625}, + {0xc4ca, -4.7890625}, + {0xc4cf, -4.80859375}, + {0xc523, -5.13671875}, + {0xc55d, -5.36328125}, + {0xc5aa, -5.6640625}, + {0xc604, -6.015625}, + {0xc61b, -6.10546875}, + {0xc642, -6.2578125}, + {0xc68b, -6.54296875}, + {0xc69e, -6.6171875}, + {0xc6b0, -6.6875}, + {0xc6ca, -6.7890625}, + {0xc71e, -7.1171875}, + {0xc721, -7.12890625}, + {0xc73b, -7.23046875}, + {0xc7d4, -7.828125}, + {0xc831, -8.3828125}, + {0xc89a, -9.203125}, + {0xc8be, -9.484375}, + {0xc8dc, -9.71875}, + {0xc8e4, -9.78125}, + {0xc8fa, -9.953125}, + {0xc8fe, -9.984375}, + {0xc969, -10.8203125}, + {0xca0f, -12.1171875}, + {0xca1a, -12.203125}, + {0xca6f, -12.8671875}, + {0xca7b, -12.9609375}, + {0xca8f, -13.1171875}, + {0xcaca, -13.578125}, + {0xcafd, -13.9765625}, + {0xcb05, -14.0390625}, + {0xcb6b, -14.8359375}, + {0xcbaf, -15.3671875}, + {0xcbb4, -15.40625}, + {0xcbdf, -15.7421875}, + {0xcc2d, -16.703125}, + {0xcc74, -17.8125}, + {0xccac, -18.6875}, + {0xcd11, -20.265625}, + {0xce04, -24.0625}, + {0xce0f, -24.234375}, + {0xceaf, -26.734375}, + {0xceb8, -26.875}, + {0xcf36, -28.84375}, + {0xcfad, -30.703125}, + {0xd019, -32.78125}, + {0xd08d, -36.40625}, + {0xd115, -40.65625}, + {0xd119, -40.78125}, + {0xd128, -41.25}, + {0xd1a4, -45.125}, + {0xd1b7, -45.71875}, + {0xd1b8, -45.75}, + {0xd203, -48.09375}, + {0xd20a, -48.3125}, + {0xd28b, -52.34375}, + {0xd2ac, -53.375}, + {0xd2ae, -53.4375}, + {0xd2c5, -54.15625}, + {0xd2f2, -55.5625}, + {0xd326, -57.1875}, + {0xd337, -57.71875}, + {0xd343, -58.09375}, + {0xd34e, -58.4375}, + {0xd40c, -64.75}, + {0xd43b, -67.6875}, + {0xd45a, -69.625}, + {0xd464, -70.25}, + {0xd4c3, -76.1875}, + {0xd505, -80.3125}, + {0xd52d, -82.8125}, + {0xd5cf, -92.9375}, + {0xd5f0, -95}, + {0xd607, -96.4375}, + {0xd635, -99.3125}, + {0xd63d, -99.8125}, + {0xd644, -100.25}, + {0xd658, -101.5}, + {0xd789, -120.5625}, + {0xd863, -140.375}, + {0xd866, -140.75}, + {0xd884, -144.5}, + {0xd88d, -145.625}, + {0xd89b, -147.375}, + {0xd8da, -155.25}, + {0xd93b, -167.375}, + {0xd982, -176.25}, + {0xd995, -178.625}, + {0xd99d, -179.625}, + {0xd9cf, -185.875}, + {0xdaaf, -213.875}, + {0xdabd, -215.625}, + {0xdb54, -234.5}, + {0xdc10, -260}, + {0xdca1, -296.25}, + {0xdd0a, -322.5}, + {0xdd56, -341.5}, + {0xddcf, -371.75}, + {0xde04, -385}, + {0xde0d, -387.25}, + {0xde3d, -399.25}, + {0xde4f, -403.75}, + {0xde66, -409.5}, + {0xdeae, -427.5}, + {0xdf52, -468.5}, + {0xdf63, -472.75}, + {0xdf6a, -474.5}, + {0xdf77, -477.75}, + {0xdf7b, -478.75}, + {0xdfc5, -497.25}, + {0xdfcf, -499.75}, + {0xdfd2, -500.5}, + {0xdfd8, -502}, + {0xdfe1, -504.25}, + {0xe022, -529}, + {0xe046, -547}, + {0xe092, -585}, + {0xe0b0, -600}, + {0xe0be, -607}, + {0xe0f4, -634}, + {0xe11b, -653.5}, + {0xe19c, -718}, + {0xe213, -777.5}, + {0xe232, -793}, + {0xe25b, -813.5}, + {0xe262, -817}, + {0xe279, -828.5}, + {0xe2cc, -870}, + {0xe2da, -877}, + {0xe326, -915}, + {0xe330, -920}, + {0xe3c3, -993.5}, + {0xe3cc, -998}, + {0xe566, -1382}, + {0xe57e, -1406}, + {0xe5c8, -1480}, + {0xe609, -1545}, + {0xe628, -1576}, + {0xe663, -1635}, + {0xe6ac, -1708}, + {0xe710, -1808}, + {0xe77f, -1919}, + {0xe7e7, -2023}, + {0xe868, -2256}, + {0xe885, -2314}, + {0xe8ea, -2516}, + {0xe919, -2610}, + {0xe92c, -2648}, + {0xea60, -3264}, + {0xeac1, -3458}, + {0xeacb, -3478}, + {0xeb22, -3652}, + {0xeb2c, -3672}, + {0xeb59, -3762}, + {0xeba5, -3914}, + {0xec53, -4428}, + {0xec97, -4700}, + {0xed16, -5208}, + {0xed4a, -5416}, + {0xed69, -5540}, + {0xee14, -6224}, + {0xee59, -6500}, + {0xee8a, -6696}, + {0xee93, -6732}, + {0xeed7, -7004}, + {0xef0b, -7212}, + {0xef59, -7524}, + {0xef61, -7556}, + {0xef67, -7580}, + {0xefb6, -7896}, + {0xf03a, -8656}, + {0xf04e, -8816}, + {0xf05f, -8952}, + {0xf09f, -9464}, + {0xf0c0, -9728}, + {0xf173, -11160}, + {0xf1d7, -11960}, + {0xf225, -12584}, + {0xf2ca, -13904}, + {0xf2d8, -14016}, + {0xf2e5, -14120}, + {0xf317, -14520}, + {0xf35d, -15080}, + {0xf3bd, -15848}, + {0xf3d3, -16024}, + {0xf3e6, -16176}, + {0xf3fb, -16344}, + {0xf477, -18288}, + {0xf4e0, -19968}, + {0xf4e5, -20048}, + {0xf50b, -20656}, + {0xf5a2, -23072}, + {0xf5c1, -23568}, + {0xf634, -25408}, + {0xf651, -25872}, + {0xf68a, -26784}, + {0xf69c, -27072}, + {0xf6ce, -27872}, + {0xf816, -33472}, + {0xf849, -35104}, + {0xf869, -36128}, + {0xf878, -36608}, + {0xf8cf, -39392}, + {0xf90a, -41280}, + {0xf916, -41664}, + {0xf91e, -41920}, + {0xf9c1, -47136}, + {0xfa0a, -49472}, + {0xfa11, -49696}, + {0xfa1d, -50080}, + {0xfa51, -51744}, + {0xfa86, -53440}, + {0xfaac, -54656}, + {0xfb95, -62112}, + {0xfbd1, -64032}, + {0xfbe0, -64512}, + {0xfbf5, -65184}, + {0xfc00, -std::numeric_limits::infinity()}, + {0xfca5, std::numeric_limits::quiet_NaN()}, + {0xfcb9, std::numeric_limits::quiet_NaN()}, + {0xfcc6, std::numeric_limits::quiet_NaN()}, + {0xfd72, std::numeric_limits::quiet_NaN()}, + {0xfd77, std::numeric_limits::quiet_NaN()}, + {0xfda3, std::numeric_limits::quiet_NaN()}, + {0xfe3e, std::numeric_limits::quiet_NaN()}, + {0xfe89, std::numeric_limits::quiet_NaN()}, + {0xfe91, std::numeric_limits::quiet_NaN()}, + {0xfe93, std::numeric_limits::quiet_NaN()}, + {0xfed1, std::numeric_limits::quiet_NaN()}, + {0xff7a, std::numeric_limits::quiet_NaN()}, + {0xffa3, std::numeric_limits::quiet_NaN()}, +}; + -TEST_CASE(test_qnan) +TEST_CASE(check_half_values) { - fp16 fp16_snan = fp16::qnan(); - EXPECT(fp16_snan.is_nan()); - EXPECT(std::isnan(fp16_snan)); -} + for(auto [x, f] : half_lut) + { + auto h = migraphx::bit_cast(x); + if(std::isnan(f)) + { + CHECK(std::isnan(h)); + } + else if(std::isinf(f)) + { + CHECK(std::isinf(h)); + CHECK((h < 0) == (f < 0)); + CHECK(bit_equal(x, migraphx::half(f))); + } + else + { + std::cout << h << " " << x << " " << f << std::endl; + std::cout << float(h) << " " << f << std::endl; + + std::cout << x << " " << migraphx::half(f) << std::endl; + + CHECK(migraphx::float_equal(float(h), f)); + CHECK(bit_equal(x, migraphx::half(f))); + std::cout << " " << std::endl; + std::cout << " " << std::endl; + } + } +} int main(int argc, const char* argv[]) { test::run(argc, argv); } diff --git a/test/float32.cpp b/test/float32.cpp index a6025cd8b21..d18b924bad1 100644 --- a/test/float32.cpp +++ b/test/float32.cpp @@ -23,6 +23,7 @@ */ #include #include +#include #include #include "test.hpp" #include @@ -31,11 +32,19 @@ using fp32 = migraphx::generic_float<23, 8>; +template +bool bit_equal(const T& x, const U& y) +{ + static_assert(sizeof(T) == sizeof(U)); + using type = std::array; + return migraphx::bit_cast(x) == migraphx::bit_cast(y); +} + #define CHECK_FLOAT(x, y) \ - CHECK(migraphx::float_equal(x, y)); \ - CHECK(migraphx::float_equal(x, y.to_float())); \ - CHECK(migraphx::float_equal(fp32{x}, y)); \ - CHECK(migraphx::float_equal(fp32{x}.to_float(), y.to_float())) + CHECK(bit_equal(x, y)); \ + CHECK(bit_equal(x, y.to_float())); \ + CHECK(bit_equal(fp32{x}, y)); \ + CHECK(bit_equal(fp32{x}.to_float(), y.to_float())) TEST_CASE(fp32_values_working) @@ -47,38 +56,9 @@ TEST_CASE(fp32_values_working) CHECK_FLOAT(std::numeric_limits::max(), fp32::max()); CHECK_FLOAT(std::numeric_limits::epsilon(), fp32::epsilon()); CHECK_FLOAT(std::numeric_limits::denorm_min(), fp32::denorm_min()); - - // CHECK_FLOAT(std::numeric_limits::infinity(), fp32::infinity()); - // CHECK_FLOAT(std::numeric_limits::quiet_NaN(), fp32::qnan()); - // CHECK_FLOAT(std::numeric_limits::signaling_NaN(), fp32::snan()); -} - -TEST_CASE(test_infinity_1) -{ - float f_inf = std::numeric_limits::infinity(); - float f32_inf = fp32::infinity().to_float(); - EXPECT(f32_inf == f_inf); -} - -TEST_CASE(test_infinity_2) -{ - float f_inf = -1.0 * std::numeric_limits::infinity(); - float f32_inf = -1.0 * fp32::infinity().to_float(); - EXPECT(f32_inf == f_inf); -} - -TEST_CASE(test_snan) -{ - fp32 fp32_snan = fp32::snan(); - EXPECT(fp32_snan.is_nan()); - EXPECT(std::isnan(fp32_snan)); -} - -TEST_CASE(test_qnan) -{ - fp32 fp32_snan = fp32::qnan(); - EXPECT(fp32_snan.is_nan()); - EXPECT(std::isnan(fp32_snan)); + CHECK_FLOAT(std::numeric_limits::infinity(), fp32::infinity()); + CHECK_FLOAT(std::numeric_limits::quiet_NaN(), fp32::qnan()); + CHECK_FLOAT(std::numeric_limits::signaling_NaN(), fp32::snan()); } From e36fd65141d9b99caa6627964dd77dd8232e0441 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Tue, 22 Oct 2024 06:49:23 +0000 Subject: [PATCH 14/72] half tests --- src/include/migraphx/generic_float.hpp | 56 +++++++++++++++++++++----- test/{float16.cpp => half.cpp} | 14 ++----- 2 files changed, 48 insertions(+), 22 deletions(-) rename test/{float16.cpp => half.cpp} (99%) diff --git a/src/include/migraphx/generic_float.hpp b/src/include/migraphx/generic_float.hpp index 75ed3d21c1f..e8fb2feb0bd 100644 --- a/src/include/migraphx/generic_float.hpp +++ b/src/include/migraphx/generic_float.hpp @@ -27,6 +27,7 @@ #include #include #include +#include namespace migraphx { inline namespace MIGRAPHX_INLINE_NS { @@ -34,7 +35,7 @@ inline namespace MIGRAPHX_INLINE_NS { template constexpr unsigned int all_ones() noexcept { - return (1u << N) - 1u; + return (1 << N) - 1; } struct float32_parts @@ -100,37 +101,65 @@ struct __attribute__((packed)) generic_float return result; } - constexpr float to_float() const noexcept { float32_parts f{}; + f.sign = sign; - f.mantissa = mantissa << (float32_parts::mantissa_width() - MantissaSize); - if(exponent == all_ones()) + if(exponent == 0) { + + if(mantissa == 0) + { + + f.exponent = 0; + f.mantissa = 0; + } + else + { + int shift = 0; + f.mantissa = mantissa; + + while((f.mantissa & (1 << MantissaSize)) == 0) + { + f.mantissa <<= 1; + shift++; + } + + f.mantissa &= all_ones(); + + f.exponent = float32_parts::exponent_bias() - exponent_bias() - shift + 1; + f.mantissa = f.mantissa << (float32_parts::mantissa_width() - MantissaSize); + } + } + else if(exponent == all_ones()) + { + f.mantissa = mantissa << (float32_parts::mantissa_width() - MantissaSize); f.exponent = float32_parts::max_exponent(); } else { - constexpr const auto diff = float32_parts::exponent_bias() - exponent_bias(); - f.exponent = exponent + diff; + f.mantissa = mantissa << (float32_parts::mantissa_width() - MantissaSize); + constexpr const int diff = float32_parts::exponent_bias() - exponent_bias(); + f.exponent = int(exponent) + diff; } return f.to_float(); } constexpr void from_float(float32_parts f) noexcept { - sign = f.sign; - mantissa = f.mantissa >> (float32_parts::mantissa_width() - MantissaSize); + sign = f.sign; if(f.exponent == 0) { exponent = 0; + mantissa = f.mantissa >> (float32_parts::mantissa_width() - MantissaSize); } else if(f.exponent == float32_parts::max_exponent()) { exponent = all_ones(); + mantissa = f.mantissa >> (float32_parts::mantissa_width() - MantissaSize); } else { @@ -142,14 +171,19 @@ struct __attribute__((packed)) generic_float exponent = all_ones(); mantissa = 0; } - else if(e < 0) + else if(e <= 0) { exponent = 0; - mantissa = 0; + + auto shift = diff - int(f.exponent); + mantissa = + (f.mantissa | (1 << static_cast(float32_parts::mantissa_width()))) >> + (shift + (float32_parts::mantissa_width() - MantissaSize) + 1); } else { - exponent = f.exponent - diff; + exponent = int(f.exponent) - diff; + mantissa = f.mantissa >> (float32_parts::mantissa_width() - MantissaSize); } } diff --git a/test/float16.cpp b/test/half.cpp similarity index 99% rename from test/float16.cpp rename to test/half.cpp index e2153e095c0..07a01106cc6 100644 --- a/test/float16.cpp +++ b/test/half.cpp @@ -29,8 +29,9 @@ #include #include +#include -template +template bool bit_equal(const T& x, const U& y) { static_assert(sizeof(T) == sizeof(U)); @@ -1078,7 +1079,6 @@ static const std::map half_lut = { {0xffa3, std::numeric_limits::quiet_NaN()}, }; - TEST_CASE(check_half_values) { for(auto [x, f] : half_lut) @@ -1096,16 +1096,8 @@ TEST_CASE(check_half_values) } else { - std::cout << h << " " << x << " " << f << std::endl; - - std::cout << float(h) << " " << f << std::endl; - - std::cout << x << " " << migraphx::half(f) << std::endl; - - CHECK(migraphx::float_equal(float(h), f)); CHECK(bit_equal(x, migraphx::half(f))); - std::cout << " " << std::endl; - std::cout << " " << std::endl; + CHECK(migraphx::float_equal(float(h), f)); } } } From 9ac4e2a99bd2457afeb48139170853424bd66287 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Tue, 22 Oct 2024 19:20:21 +0000 Subject: [PATCH 15/72] underflow and overflow tests --- test/half.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/half.cpp b/test/half.cpp index 07a01106cc6..390baf5b776 100644 --- a/test/half.cpp +++ b/test/half.cpp @@ -1102,4 +1102,17 @@ TEST_CASE(check_half_values) } } +TEST_CASE(check_flows) +{ + // check positive underflow + CHECK(bit_equal(std::numeric_limits::min() * std::numeric_limits::min(), migraphx::half(0))); + + // check overflow + CHECK(bit_equal(std::numeric_limits::max() + std::numeric_limits::max(), std::numeric_limits::infinity())); + CHECK(bit_equal(std::numeric_limits::max() / std::numeric_limits::epsilon(), std::numeric_limits::infinity())); + + // check negative underflow + CHECK(bit_equal(std::numeric_limits::lowest() + std::numeric_limits::lowest(), -std::numeric_limits::infinity())); +} + int main(int argc, const char* argv[]) { test::run(argc, argv); } From f05fd319dbd4ef2d4c61d04f52ef7784bedfe99a Mon Sep 17 00:00:00 2001 From: richagadgil Date: Tue, 22 Oct 2024 20:19:06 +0000 Subject: [PATCH 16/72] generate map --- test/half.cpp | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/test/half.cpp b/test/half.cpp index 390baf5b776..963c3987b31 100644 --- a/test/half.cpp +++ b/test/half.cpp @@ -1115,4 +1115,68 @@ TEST_CASE(check_flows) CHECK(bit_equal(std::numeric_limits::lowest() + std::numeric_limits::lowest(), -std::numeric_limits::infinity())); } + +float halfToFloat(uint16_t half) { + uint32_t sign = (half >> 15) & 0x1; + uint32_t exponent = (half >> 10) & 0x1F; + uint32_t mantissa = half & 0x3FF; + + if (exponent == 31) { + if (mantissa == 0) { + return sign ? -std::numeric_limits::infinity() : std::numeric_limits::infinity(); + } else { + return std::numeric_limits::quiet_NaN(); + } + } + + float result; + if (exponent == 0) { + result = std::ldexp(static_cast(mantissa), -24); + } else { + result = std::ldexp(static_cast(mantissa | 0x400), exponent - 25); + } + + if (sign) { + result = -result; + } + + return result; +} + +TEST_CASE(check_map) { + std::map half_lut_all; + + for (uint16_t hexValue = 0x0000; hexValue <= 0x03FF; ++hexValue) { + float floatValue = halfToFloat(hexValue); + half_lut_all[hexValue] = floatValue; + } + + half_lut_all[0x7c00] = std::numeric_limits::infinity(); + half_lut_all[0xfc00] = -std::numeric_limits::infinity(); + half_lut_all[0x7c05] = std::numeric_limits::quiet_NaN(); + + + for(auto [x, f] : half_lut_all) + { + auto h = migraphx::bit_cast(x); + if(std::isnan(f)) + { + CHECK(std::isnan(h)); + } + else if(std::isinf(f)) + { + CHECK(std::isinf(h)); + CHECK((h < 0) == (f < 0)); + CHECK(bit_equal(x, migraphx::half(f))); + } + else + { + CHECK(bit_equal(x, migraphx::half(f))); + CHECK(migraphx::float_equal(float(h), f)); + } + } + +} + + int main(int argc, const char* argv[]) { test::run(argc, argv); } From cb4d92df73600457b32e05cf8557a7cf1f12ec63 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Tue, 22 Oct 2024 20:53:15 +0000 Subject: [PATCH 17/72] add more tests --- test/half.cpp | 140 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 91 insertions(+), 49 deletions(-) diff --git a/test/half.cpp b/test/half.cpp index 963c3987b31..5abbb76a02b 100644 --- a/test/half.cpp +++ b/test/half.cpp @@ -1108,74 +1108,116 @@ TEST_CASE(check_flows) CHECK(bit_equal(std::numeric_limits::min() * std::numeric_limits::min(), migraphx::half(0))); // check overflow + CHECK(bit_equal(std::numeric_limits::infinity() + std::numeric_limits::infinity(), std::numeric_limits::infinity())); CHECK(bit_equal(std::numeric_limits::max() + std::numeric_limits::max(), std::numeric_limits::infinity())); CHECK(bit_equal(std::numeric_limits::max() / std::numeric_limits::epsilon(), std::numeric_limits::infinity())); // check negative underflow CHECK(bit_equal(std::numeric_limits::lowest() + std::numeric_limits::lowest(), -std::numeric_limits::infinity())); + CHECK(bit_equal(-std::numeric_limits::infinity() - std::numeric_limits::infinity(), -std::numeric_limits::infinity())); } +TEST_CASE(test_nan) +{ + float f_qnan = std::numeric_limits::quiet_NaN(); + migraphx::half half_qnan(f_qnan); + EXPECT(half_qnan.is_nan()); + EXPECT(std::isnan(half_qnan)); -float halfToFloat(uint16_t half) { - uint32_t sign = (half >> 15) & 0x1; - uint32_t exponent = (half >> 10) & 0x1F; - uint32_t mantissa = half & 0x3FF; + float f_snan = std::numeric_limits::signaling_NaN(); + migraphx::half half_snan(f_snan); + EXPECT(half_snan.is_nan()); + EXPECT(std::isnan(half_snan)); +} - if (exponent == 31) { - if (mantissa == 0) { - return sign ? -std::numeric_limits::infinity() : std::numeric_limits::infinity(); - } else { - return std::numeric_limits::quiet_NaN(); - } - } +TEST_CASE(test_bool) +{ + float zero = 0.0; + float two = 2.0; + float other = -0.375; + migraphx::half fp8_zero(zero); + migraphx::half fp8_two(two); + migraphx::half fp8_other(other); + EXPECT(not static_cast(fp8_zero)); + EXPECT(static_cast(fp8_two)); + EXPECT(static_cast(fp8_other)); +} - float result; - if (exponent == 0) { - result = std::ldexp(static_cast(mantissa), -24); - } else { - result = std::ldexp(static_cast(mantissa | 0x400), exponent - 25); - } +TEST_CASE(test_pos_infinity) +{ + float finf = std::numeric_limits::infinity(); + migraphx::half half_inf_1(finf); + CHECK(bit_equal(half_inf_1, std::numeric_limits::infinity())); +} - if (sign) { - result = -result; - } +TEST_CASE(test_neg_infinity) +{ + float finf = -1.0 * std::numeric_limits::infinity(); + migraphx::half half_neginf_1(finf); + CHECK(bit_equal(half_neginf_1, -std::numeric_limits::infinity())); +} - return result; +TEST_CASE(test_numeric_max_1) +{ + float fmax = std::numeric_limits::max(); // fp32 max is fp16 inf + migraphx::half half_inf(fmax); + CHECK(bit_equal(half_inf, std::numeric_limits::infinity())); } -TEST_CASE(check_map) { - std::map half_lut_all; - for (uint16_t hexValue = 0x0000; hexValue <= 0x03FF; ++hexValue) { - float floatValue = halfToFloat(hexValue); - half_lut_all[hexValue] = floatValue; - } +TEST_CASE(test_numeric_lowest_1) +{ + float flowest = std::numeric_limits::lowest(); + migraphx::half half_neginf(flowest); + CHECK(bit_equal(half_neginf, -std::numeric_limits::infinity())); +} - half_lut_all[0x7c00] = std::numeric_limits::infinity(); - half_lut_all[0xfc00] = -std::numeric_limits::infinity(); - half_lut_all[0x7c05] = std::numeric_limits::quiet_NaN(); +TEST_CASE(test_max_eq_lowest) +{ + EXPECT(migraphx::float_equal(std::numeric_limits::lowest(), + -1 * std::numeric_limits::max())); +} +TEST_CASE(test_isfinite) +{ + EXPECT(std::isfinite(migraphx::half(0.0))); + EXPECT(std::isfinite(migraphx::half(-0.0))); + EXPECT(not std::isfinite( + migraphx::half(std::numeric_limits::quiet_NaN()))); +} - for(auto [x, f] : half_lut_all) - { - auto h = migraphx::bit_cast(x); - if(std::isnan(f)) - { - CHECK(std::isnan(h)); - } - else if(std::isinf(f)) - { - CHECK(std::isinf(h)); - CHECK((h < 0) == (f < 0)); - CHECK(bit_equal(x, migraphx::half(f))); - } - else - { - CHECK(bit_equal(x, migraphx::half(f))); - CHECK(migraphx::float_equal(float(h), f)); - } - } +TEST_CASE(test_binary_ops) +{ + auto a = migraphx::half(-1.0); + auto b = migraphx::half(1.0); + auto c = migraphx::half(0.0); + auto d = migraphx::half(-0.0); + EXPECT(migraphx::float_equal((c + d), c)); + EXPECT(migraphx::float_equal((c + d), d)); + EXPECT(migraphx::float_equal((a + b), c)); + EXPECT(migraphx::float_equal((a + b), d)); + auto e = migraphx::half(10.0); + auto f = migraphx::half(-10.0); + EXPECT(e > f); + EXPECT(f < e); + EXPECT(f <= e); + EXPECT(e >= f); + EXPECT(e <= e); + EXPECT(f >= f); + EXPECT(not migraphx::float_equal(f, e)); +} + +TEST_CASE(test_stream_op) +{ + auto a = migraphx::half(-1.0); + std::stringstream ss; + ss << a; + EXPECT(std::string("-1") == ss.str()); + ss = std::stringstream(); + auto b = std::numeric_limits::quiet_NaN(); + ss << b; + EXPECT(std::string("nan") == ss.str()); } From 0cc1946a8b223235ee71fd5aa4b680a1d552a544 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Tue, 22 Oct 2024 22:26:12 +0000 Subject: [PATCH 18/72] fix names --- test/half.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/half.cpp b/test/half.cpp index 5abbb76a02b..300f8ac40e4 100644 --- a/test/half.cpp +++ b/test/half.cpp @@ -1135,12 +1135,12 @@ TEST_CASE(test_bool) float zero = 0.0; float two = 2.0; float other = -0.375; - migraphx::half fp8_zero(zero); - migraphx::half fp8_two(two); - migraphx::half fp8_other(other); - EXPECT(not static_cast(fp8_zero)); - EXPECT(static_cast(fp8_two)); - EXPECT(static_cast(fp8_other)); + migraphx::half half_zero(zero); + migraphx::half half_two(two); + migraphx::half half_other(other); + EXPECT(not static_cast(half_zero)); + EXPECT(static_cast(half_two)); + EXPECT(static_cast(half_other)); } TEST_CASE(test_pos_infinity) From 85a761b3b10af457803a4ba3d7593447b441dcb1 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Wed, 23 Oct 2024 17:41:25 +0000 Subject: [PATCH 19/72] update tests --- test/half.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/half.cpp b/test/half.cpp index 300f8ac40e4..96d76c9a15a 100644 --- a/test/half.cpp +++ b/test/half.cpp @@ -1111,10 +1111,13 @@ TEST_CASE(check_flows) CHECK(bit_equal(std::numeric_limits::infinity() + std::numeric_limits::infinity(), std::numeric_limits::infinity())); CHECK(bit_equal(std::numeric_limits::max() + std::numeric_limits::max(), std::numeric_limits::infinity())); CHECK(bit_equal(std::numeric_limits::max() / std::numeric_limits::epsilon(), std::numeric_limits::infinity())); + CHECK(bit_equal(std::numeric_limits::max() + std::numeric_limits::min(), std::numeric_limits::max())); // check negative underflow CHECK(bit_equal(std::numeric_limits::lowest() + std::numeric_limits::lowest(), -std::numeric_limits::infinity())); CHECK(bit_equal(-std::numeric_limits::infinity() - std::numeric_limits::infinity(), -std::numeric_limits::infinity())); + CHECK(bit_equal(std::numeric_limits::lowest() - std::numeric_limits::min(), std::numeric_limits::lowest())); + } TEST_CASE(test_nan) From 65cf9ae975ce5a083caf2df7ded9b9fed10728d0 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Thu, 24 Oct 2024 16:42:25 -0500 Subject: [PATCH 20/72] remove and --- src/include/migraphx/generic_float.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/include/migraphx/generic_float.hpp b/src/include/migraphx/generic_float.hpp index e8fb2feb0bd..44a6e82e0e6 100644 --- a/src/include/migraphx/generic_float.hpp +++ b/src/include/migraphx/generic_float.hpp @@ -127,8 +127,6 @@ struct __attribute__((packed)) generic_float shift++; } - f.mantissa &= all_ones(); - f.exponent = float32_parts::exponent_bias() - exponent_bias() - shift + 1; f.mantissa = f.mantissa << (float32_parts::mantissa_width() - MantissaSize); } From fbabf54a2b53e397bc885a644705209e61e17b9f Mon Sep 17 00:00:00 2001 From: richagadgil Date: Thu, 24 Oct 2024 16:48:21 -0500 Subject: [PATCH 21/72] disable warning --- src/include/migraphx/bit_cast.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/include/migraphx/bit_cast.hpp b/src/include/migraphx/bit_cast.hpp index 951b34bc340..4711819779d 100644 --- a/src/include/migraphx/bit_cast.hpp +++ b/src/include/migraphx/bit_cast.hpp @@ -30,8 +30,12 @@ #include #include +#if defined(__GNUC__) and !defined(__clang__) +#define MIGRAPHX_CONST_FOLD(x) (x) +#else // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define MIGRAPHX_CONST_FOLD(x) (__builtin_constant_p(x) ? (x) : (x)) +#endif namespace migraphx { inline namespace MIGRAPHX_INLINE_NS { From 549f5e6646e5bc1f013738a01fa5b4d814e05c32 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Thu, 24 Oct 2024 17:08:07 -0500 Subject: [PATCH 22/72] fix tidy warning --- src/include/migraphx/generic_float.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/migraphx/generic_float.hpp b/src/include/migraphx/generic_float.hpp index 44a6e82e0e6..53790337956 100644 --- a/src/include/migraphx/generic_float.hpp +++ b/src/include/migraphx/generic_float.hpp @@ -35,7 +35,7 @@ inline namespace MIGRAPHX_INLINE_NS { template constexpr unsigned int all_ones() noexcept { - return (1 << N) - 1; + return (1u << N) - 1u; } struct float32_parts From d302e5d0dd01e965bb0cc004e89c96855726f907 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Fri, 25 Oct 2024 13:19:12 -0500 Subject: [PATCH 23/72] migraphx py fix --- src/py/migraphx_py.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/py/migraphx_py.cpp b/src/py/migraphx_py.cpp index 04daa5e35a3..9d05e32e67d 100644 --- a/src/py/migraphx_py.cpp +++ b/src/py/migraphx_py.cpp @@ -48,7 +48,7 @@ #include #endif -using half = half_float::half; +using half = migraphx::half; namespace py = pybind11; #ifdef __clang__ From 8d475e38475fbd11209b88ae61c729629bafa10c Mon Sep 17 00:00:00 2001 From: richagadgil Date: Fri, 25 Oct 2024 15:26:17 -0500 Subject: [PATCH 24/72] add increments --- src/include/migraphx/generic_float.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/include/migraphx/generic_float.hpp b/src/include/migraphx/generic_float.hpp index 53790337956..919b5ec02ce 100644 --- a/src/include/migraphx/generic_float.hpp +++ b/src/include/migraphx/generic_float.hpp @@ -317,6 +317,12 @@ struct __attribute__((packed)) generic_float { return not(x == y); } + + constexpr generic_float& operator++() noexcept + { + *this += generic_float(1.0f); + return *this; + } }; From a0fd055bee1b28bcccae82ac905a9b4261e76947 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Fri, 25 Oct 2024 16:41:45 -0500 Subject: [PATCH 25/72] fix warnings --- src/include/migraphx/bit_cast.hpp | 60 ------------------------------- 1 file changed, 60 deletions(-) diff --git a/src/include/migraphx/bit_cast.hpp b/src/include/migraphx/bit_cast.hpp index 4711819779d..e69de29bb2d 100644 --- a/src/include/migraphx/bit_cast.hpp +++ b/src/include/migraphx/bit_cast.hpp @@ -1,60 +0,0 @@ -/* ************************************************************************ - * Copyright (C) 2015-2023 Advanced Micro Devices, Inc. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell cop- - * ies of the Software, and to permit persons to whom the Software is furnished - * to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IM- - * PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNE- - * CTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * ************************************************************************ */ -#ifndef MIGRAPHX_GUARD_RTGLIB_BITCAST_HPP -#define MIGRAPHX_GUARD_RTGLIB_BITCAST_HPP -#include -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wstrict-aliasing" -#endif - -#include -#include - -#if defined(__GNUC__) and !defined(__clang__) -#define MIGRAPHX_CONST_FOLD(x) (x) -#else -// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define MIGRAPHX_CONST_FOLD(x) (__builtin_constant_p(x) ? (x) : (x)) -#endif - -namespace migraphx { -inline namespace MIGRAPHX_INLINE_NS { -template {} and - std::is_trivially_copyable{})> -inline constexpr To bit_cast(From fr) noexcept -{ - static_assert(sizeof(To) == sizeof(From)); -#if defined(__GNUC__) and !defined(__clang__) - return MIGRAPHX_CONST_FOLD(*reinterpret_cast(&fr)); -#else - return __builtin_bit_cast(To, fr); -#endif -} -} // namespace MIGRAPHX_INLINE_NS -} // namespace migraphx -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC diagnostic pop -#endif -#endif // MIGRAPHX_GUARD_RTGLIB_BITCAST_HPP From 41379fea0ddd1a7d031886d982c300ca3feb0820 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Fri, 25 Oct 2024 16:46:01 -0500 Subject: [PATCH 26/72] disable duplicate branch warning --- src/include/migraphx/bit_cast.hpp | 57 +++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/src/include/migraphx/bit_cast.hpp b/src/include/migraphx/bit_cast.hpp index e69de29bb2d..fc4aab2e3b6 100644 --- a/src/include/migraphx/bit_cast.hpp +++ b/src/include/migraphx/bit_cast.hpp @@ -0,0 +1,57 @@ +/* ************************************************************************ + * Copyright (C) 2015-2023 Advanced Micro Devices, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell cop- + * ies of the Software, and to permit persons to whom the Software is furnished + * to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IM- + * PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNE- + * CTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * ************************************************************************ */ +#ifndef MIGRAPHX_GUARD_RTGLIB_BITCAST_HPP +#define MIGRAPHX_GUARD_RTGLIB_BITCAST_HPP +#include +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstrict-aliasing" +#pragma GCC diagnostic ignored "-Wduplicated-branches" +#endif + +#include +#include + +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) +#define MIGRAPHX_CONST_FOLD(x) (__builtin_constant_p(x) ? (x) : (x)) + +namespace migraphx { +inline namespace MIGRAPHX_INLINE_NS { +template {} and + std::is_trivially_copyable{})> +inline constexpr To bit_cast(From fr) noexcept +{ + static_assert(sizeof(To) == sizeof(From)); +#if defined(__GNUC__) and !defined(__clang__) + return MIGRAPHX_CONST_FOLD(*reinterpret_cast(&fr)); +#else + return __builtin_bit_cast(To, fr); +#endif +} +} // namespace MIGRAPHX_INLINE_NS +} // namespace migraphx +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic pop +#endif +#endif // MIGRAPHX_GUARD_RTGLIB_BITCAST_HPP From 0c29c7bba23c3223eba894f8a5d313367baf2535 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Mon, 28 Oct 2024 13:35:28 -0500 Subject: [PATCH 27/72] add countzero_std --- src/include/migraphx/generic_float.hpp | 31 +++++++++++++++++++------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/include/migraphx/generic_float.hpp b/src/include/migraphx/generic_float.hpp index 919b5ec02ce..74b4b8a5b77 100644 --- a/src/include/migraphx/generic_float.hpp +++ b/src/include/migraphx/generic_float.hpp @@ -27,7 +27,6 @@ #include #include #include -#include namespace migraphx { inline namespace MIGRAPHX_INLINE_NS { @@ -38,6 +37,23 @@ constexpr unsigned int all_ones() noexcept return (1u << N) - 1u; } +template +constexpr int countl_zero(T value) +{ + if(value == 0) + return sizeof(T) * 8; + + int count = 0; + constexpr int bits = sizeof(T) * 8; + + while(count < bits && (value & (static_cast(1) << (bits - 1 - count))) == 0) + { + count++; + } + + return count; +} + struct float32_parts { unsigned int mantissa : 23; @@ -104,7 +120,6 @@ struct __attribute__((packed)) generic_float constexpr float to_float() const noexcept { float32_parts f{}; - f.sign = sign; if(exponent == 0) @@ -112,7 +127,6 @@ struct __attribute__((packed)) generic_float if(mantissa == 0) { - f.exponent = 0; f.mantissa = 0; } @@ -121,13 +135,13 @@ struct __attribute__((packed)) generic_float int shift = 0; f.mantissa = mantissa; - while((f.mantissa & (1 << MantissaSize)) == 0) + if(MantissaSize < float32_parts::mantissa_width()) { - f.mantissa <<= 1; - shift++; + shift = MantissaSize - (32 - countl_zero(mantissa)); + f.mantissa <<= (shift + 1); } - f.exponent = float32_parts::exponent_bias() - exponent_bias() - shift + 1; + f.exponent = float32_parts::exponent_bias() - exponent_bias() - shift; f.mantissa = f.mantissa << (float32_parts::mantissa_width() - MantissaSize); } } @@ -142,6 +156,7 @@ struct __attribute__((packed)) generic_float constexpr const int diff = float32_parts::exponent_bias() - exponent_bias(); f.exponent = int(exponent) + diff; } + return f.to_float(); } @@ -175,7 +190,7 @@ struct __attribute__((packed)) generic_float auto shift = diff - int(f.exponent); mantissa = - (f.mantissa | (1 << static_cast(float32_parts::mantissa_width()))) >> + (f.mantissa | (1u << static_cast(float32_parts::mantissa_width()))) >> (shift + (float32_parts::mantissa_width() - MantissaSize) + 1); } else From 4b012a86658173df509bf9973e6df1e744802755 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Mon, 28 Oct 2024 16:35:23 -0500 Subject: [PATCH 28/72] ci error --- src/include/migraphx/generic_float.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/include/migraphx/generic_float.hpp b/src/include/migraphx/generic_float.hpp index 74b4b8a5b77..44eec0bf28b 100644 --- a/src/include/migraphx/generic_float.hpp +++ b/src/include/migraphx/generic_float.hpp @@ -60,6 +60,9 @@ struct float32_parts unsigned int exponent : 8; unsigned int sign : 1; + constexpr float32_parts(unsigned int m = 0, unsigned int e = 0, unsigned int s = 0) + : mantissa(m), exponent(e), sign(s) {} + static constexpr unsigned int mantissa_width() { return 23; From dbaa3a8c88acde648c616006b76fad0d089b9343 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Mon, 28 Oct 2024 17:49:18 -0500 Subject: [PATCH 29/72] simplify countl --- src/include/migraphx/generic_float.hpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/include/migraphx/generic_float.hpp b/src/include/migraphx/generic_float.hpp index 44eec0bf28b..1eefd339553 100644 --- a/src/include/migraphx/generic_float.hpp +++ b/src/include/migraphx/generic_float.hpp @@ -40,18 +40,10 @@ constexpr unsigned int all_ones() noexcept template constexpr int countl_zero(T value) { - if(value == 0) - return sizeof(T) * 8; - - int count = 0; - constexpr int bits = sizeof(T) * 8; - - while(count < bits && (value & (static_cast(1) << (bits - 1 - count))) == 0) - { - count++; - } - - return count; + unsigned int r = 0; + for(; value != 0; value >>= 1) + r++; + return 8 * sizeof(value) - r; } struct float32_parts From b2bd2a0cee82c0a5b6baa44919dbb925d90846b8 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Mon, 28 Oct 2024 18:00:17 -0500 Subject: [PATCH 30/72] fix ci --- src/include/migraphx/generic_float.hpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/include/migraphx/generic_float.hpp b/src/include/migraphx/generic_float.hpp index 1eefd339553..7032cd2236b 100644 --- a/src/include/migraphx/generic_float.hpp +++ b/src/include/migraphx/generic_float.hpp @@ -52,9 +52,6 @@ struct float32_parts unsigned int exponent : 8; unsigned int sign : 1; - constexpr float32_parts(unsigned int m = 0, unsigned int e = 0, unsigned int s = 0) - : mantissa(m), exponent(e), sign(s) {} - static constexpr unsigned int mantissa_width() { return 23; @@ -83,7 +80,7 @@ constexpr float32_parts get_parts(float f) template -struct __attribute__((packed)) generic_float +struct __attribute__((packed, may_alias)) generic_float { unsigned int mantissa : MantissaSize; unsigned int exponent : ExponentSize; From 6f328f013db49eabbd9101366d857651e5f39f3c Mon Sep 17 00:00:00 2001 From: richagadgil Date: Mon, 28 Oct 2024 19:31:45 -0500 Subject: [PATCH 31/72] src --- src/include/migraphx/bit_cast.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/include/migraphx/bit_cast.hpp b/src/include/migraphx/bit_cast.hpp index fc4aab2e3b6..69824acf66c 100644 --- a/src/include/migraphx/bit_cast.hpp +++ b/src/include/migraphx/bit_cast.hpp @@ -24,6 +24,7 @@ #include #if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpsabi" #pragma GCC diagnostic ignored "-Wstrict-aliasing" #pragma GCC diagnostic ignored "-Wduplicated-branches" #endif From e6d9763559c29783c4445a65ae3f5e08352e0445 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Mon, 28 Oct 2024 20:07:09 -0500 Subject: [PATCH 32/72] remove flag --- src/include/migraphx/bit_cast.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/include/migraphx/bit_cast.hpp b/src/include/migraphx/bit_cast.hpp index 69824acf66c..fc4aab2e3b6 100644 --- a/src/include/migraphx/bit_cast.hpp +++ b/src/include/migraphx/bit_cast.hpp @@ -24,7 +24,6 @@ #include #if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wpsabi" #pragma GCC diagnostic ignored "-Wstrict-aliasing" #pragma GCC diagnostic ignored "-Wduplicated-branches" #endif From 65380506c9eff6e26bdc5fda10c9ad0d723551ee Mon Sep 17 00:00:00 2001 From: richagadgil Date: Tue, 29 Oct 2024 12:22:31 -0500 Subject: [PATCH 33/72] hide abi warning --- src/include/migraphx/generic_float.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/include/migraphx/generic_float.hpp b/src/include/migraphx/generic_float.hpp index 7032cd2236b..d467aa57ca1 100644 --- a/src/include/migraphx/generic_float.hpp +++ b/src/include/migraphx/generic_float.hpp @@ -28,6 +28,11 @@ #include #include +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wabi" +// Code that triggers the ABI warning +#pragma GCC diagnostic pop + namespace migraphx { inline namespace MIGRAPHX_INLINE_NS { From 4e96d4da9930ea6cd92f17b44c2404dddbdd8f1b Mon Sep 17 00:00:00 2001 From: richagadgil Date: Tue, 29 Oct 2024 12:48:44 -0500 Subject: [PATCH 34/72] revert changes --- src/include/migraphx/generic_float.hpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/include/migraphx/generic_float.hpp b/src/include/migraphx/generic_float.hpp index d467aa57ca1..7032cd2236b 100644 --- a/src/include/migraphx/generic_float.hpp +++ b/src/include/migraphx/generic_float.hpp @@ -28,11 +28,6 @@ #include #include -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wabi" -// Code that triggers the ABI warning -#pragma GCC diagnostic pop - namespace migraphx { inline namespace MIGRAPHX_INLINE_NS { From e4a25bd3f3fac026b2d54e4d0d41476089d46cdb Mon Sep 17 00:00:00 2001 From: richagadgil Date: Tue, 29 Oct 2024 13:05:41 -0500 Subject: [PATCH 35/72] change half in tests --- test/onnx/verify/negativelogliklihood_kd_dim_weighted.cpp | 6 +++--- .../onnx/verify/softmaxcrossentropyloss_kd_dim_weighted.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/onnx/verify/negativelogliklihood_kd_dim_weighted.cpp b/test/onnx/verify/negativelogliklihood_kd_dim_weighted.cpp index 06865e637b2..69de5d2c15f 100644 --- a/test/onnx/verify/negativelogliklihood_kd_dim_weighted.cpp +++ b/test/onnx/verify/negativelogliklihood_kd_dim_weighted.cpp @@ -170,7 +170,7 @@ TEST_CASE(negativeloglikelihoodloss_kd_mean_reduction_weighted_test) pp["2"] = migraphx::argument(weight_shape, weight_data.data()); auto result = p.eval(pp).back(); - std::vector result_vector; + std::vector result_vector; result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); }); std::vector gold = {half{-35.266666666666666}}; EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); @@ -200,7 +200,7 @@ TEST_CASE(negativeloglikelihoodloss_kd_mean_reduction_weighted_test2) migraphx::shape label_shape{migraphx::shape::int32_type, {2, 2}}; std::vector label_data = {2, 1, 0, 2}; migraphx::shape weight_shape{migraphx::shape::half_type, {3}}; - std::vector weight_data = {half(0.2), half(0.3), half(0.1)}; + std::vector weight_data = {half(0.2), half(0.3), half(0.1)}; migraphx::parameter_map pp; pp["0"] = migraphx::argument(score_shape, score_data.data()); @@ -208,7 +208,7 @@ TEST_CASE(negativeloglikelihoodloss_kd_mean_reduction_weighted_test2) pp["2"] = migraphx::argument(weight_shape, weight_data.data()); auto result = p.eval(pp).back(); - std::vector result_vector; + std::vector result_vector; result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); }); std::vector gold = {half{-1.5714285714285714}}; EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); diff --git a/test/onnx/verify/softmaxcrossentropyloss_kd_dim_weighted.cpp b/test/onnx/verify/softmaxcrossentropyloss_kd_dim_weighted.cpp index 14b5a0da963..34fb82c9070 100644 --- a/test/onnx/verify/softmaxcrossentropyloss_kd_dim_weighted.cpp +++ b/test/onnx/verify/softmaxcrossentropyloss_kd_dim_weighted.cpp @@ -180,7 +180,7 @@ TEST_CASE(softmaxcrossentropyloss_kd_mean_reduction_weighted_test) pp["2"] = migraphx::argument(weight_shape, weight_data.data()); auto result = p.eval(pp).back(); - std::vector result_vector; + std::vector result_vector; result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); }); std::vector gold = {half{1.38629436}}; EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); @@ -207,7 +207,7 @@ TEST_CASE(softmaxcrossentropyloss_kd_mean_reduction_uneven_weighted_test) pp["2"] = migraphx::argument(weight_shape, weight_data.data()); auto result = p.eval(pp).back(); - std::vector result_vector; + std::vector result_vector; result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); }); std::vector gold = {half{1.38629436}}; From 3354c6e9bab593174002917afdedb79bca6f7cf3 Mon Sep 17 00:00:00 2001 From: Richa Gadgil Date: Tue, 29 Oct 2024 14:17:38 -0700 Subject: [PATCH 36/72] Update generic_float.hpp --- src/include/migraphx/generic_float.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/migraphx/generic_float.hpp b/src/include/migraphx/generic_float.hpp index 7032cd2236b..01efd56ff2d 100644 --- a/src/include/migraphx/generic_float.hpp +++ b/src/include/migraphx/generic_float.hpp @@ -129,7 +129,7 @@ struct __attribute__((packed, may_alias)) generic_float if(MantissaSize < float32_parts::mantissa_width()) { - shift = MantissaSize - (32 - countl_zero(mantissa)); + shift = MantissaSize - ((sizeof(unsigned int) * 8) - countl_zero(mantissa)); f.mantissa <<= (shift + 1); } From 6de079b3ee5fea98ddf083244afee5284343947d Mon Sep 17 00:00:00 2001 From: richagadgil Date: Tue, 29 Oct 2024 21:56:13 +0000 Subject: [PATCH 37/72] format --- src/include/migraphx/generic_float.hpp | 163 ++++++++++++------------- src/include/migraphx/half.hpp | 2 +- test/float32.cpp | 10 +- test/half.cpp | 40 +++--- 4 files changed, 111 insertions(+), 104 deletions(-) diff --git a/src/include/migraphx/generic_float.hpp b/src/include/migraphx/generic_float.hpp index 01efd56ff2d..aad985984de 100644 --- a/src/include/migraphx/generic_float.hpp +++ b/src/include/migraphx/generic_float.hpp @@ -31,7 +31,7 @@ namespace migraphx { inline namespace MIGRAPHX_INLINE_NS { -template +template constexpr unsigned int all_ones() noexcept { return (1u << N) - 1u; @@ -46,57 +46,35 @@ constexpr int countl_zero(T value) return 8 * sizeof(value) - r; } -struct float32_parts +struct float32_parts { unsigned int mantissa : 23; unsigned int exponent : 8; unsigned int sign : 1; - static constexpr unsigned int mantissa_width() - { - return 23; - } + static constexpr unsigned int mantissa_width() { return 23; } - static constexpr unsigned int max_exponent() - { - return all_ones<8>(); - } + static constexpr unsigned int max_exponent() { return all_ones<8>(); } - static constexpr int exponent_bias() - { - return all_ones<7>(); - } + static constexpr int exponent_bias() { return all_ones<7>(); } - constexpr float to_float() const noexcept - { - return migraphx::bit_cast(*this); - } + constexpr float to_float() const noexcept { return migraphx::bit_cast(*this); } }; -constexpr float32_parts get_parts(float f) -{ - return migraphx::bit_cast(f); -} - +constexpr float32_parts get_parts(float f) { return migraphx::bit_cast(f); } -template +template struct __attribute__((packed, may_alias)) generic_float { unsigned int mantissa : MantissaSize; unsigned int exponent : ExponentSize; unsigned int sign : 1; - static constexpr int exponent_bias() - { - return all_ones(); - } + static constexpr int exponent_bias() { return all_ones(); } - explicit constexpr generic_float(float f = 0.0) noexcept - { - from_float(get_parts(f)); - } + explicit constexpr generic_float(float f = 0.0) noexcept { from_float(get_parts(f)); } - constexpr generic_float &operator=(float f) noexcept + constexpr generic_float& operator=(float f) noexcept { from_float(get_parts(f)); return *this; @@ -105,7 +83,7 @@ struct __attribute__((packed, may_alias)) generic_float constexpr generic_float operator-() const noexcept { generic_float result = *this; - result.sign = !this->sign; + result.sign = !this->sign; return result; } @@ -169,7 +147,7 @@ struct __attribute__((packed, may_alias)) generic_float else { constexpr const int diff = float32_parts::exponent_bias() - exponent_bias(); - auto e = int(f.exponent) - diff; + auto e = int(f.exponent) - diff; if(e >= static_cast(all_ones())) { @@ -210,15 +188,9 @@ struct __attribute__((packed, may_alias)) generic_float return exponent == all_ones() and mantissa != 0; } - constexpr bool is_finite() const noexcept - { - return exponent != all_ones(); - } + constexpr bool is_finite() const noexcept { return exponent != all_ones(); } - constexpr operator float() const noexcept - { - return this->to_float(); - } + constexpr operator float() const noexcept { return this->to_float(); } static constexpr generic_float infinity() { @@ -256,7 +228,7 @@ struct __attribute__((packed, may_alias)) generic_float generic_float x{}; x.exponent = 0; x.mantissa = 1; - x.sign = 0; + x.sign = 0; return x; } @@ -265,7 +237,7 @@ struct __attribute__((packed, may_alias)) generic_float generic_float x{}; x.exponent = all_ones() - 1; x.mantissa = all_ones(); - x.sign = 1; + x.sign = 1; return x; } @@ -274,7 +246,7 @@ struct __attribute__((packed, may_alias)) generic_float generic_float x{}; x.exponent = all_ones() - 1; x.mantissa = all_ones(); - x.sign = 0; + x.sign = 0; return x; } @@ -285,24 +257,24 @@ struct __attribute__((packed, may_alias)) generic_float return generic_float{x.to_float() - 1.0f}; } // NOLINTNEXTLINE -#define MIGRAPHX_GENERIC_FLOAT_ASSIGN_OP(op) \ - constexpr generic_float& operator op(const generic_float& rhs) \ - { \ - float self = *this; \ - float frhs = rhs; \ - self op frhs; \ - *this = generic_float(self); \ - return *this; \ +#define MIGRAPHX_GENERIC_FLOAT_ASSIGN_OP(op) \ + constexpr generic_float& operator op(const generic_float & rhs) \ + { \ + float self = *this; \ + float frhs = rhs; \ + self op frhs; \ + *this = generic_float(self); \ + return *this; \ } MIGRAPHX_GENERIC_FLOAT_ASSIGN_OP(*=) MIGRAPHX_GENERIC_FLOAT_ASSIGN_OP(-=) MIGRAPHX_GENERIC_FLOAT_ASSIGN_OP(+=) MIGRAPHX_GENERIC_FLOAT_ASSIGN_OP(/=) // NOLINTNEXTLINE -#define MIGRAPHX_GENERIC_FLOAT_BINARY_OP(op) \ +#define MIGRAPHX_GENERIC_FLOAT_BINARY_OP(op) \ friend constexpr generic_float operator op(const generic_float& x, const generic_float& y) \ - { \ - return generic_float(float(x) op float(y)); \ + { \ + return generic_float(float(x) op float(y)); \ } MIGRAPHX_GENERIC_FLOAT_BINARY_OP(*) MIGRAPHX_GENERIC_FLOAT_BINARY_OP(-) @@ -315,7 +287,7 @@ struct __attribute__((packed, may_alias)) generic_float friend constexpr bool operator==(const generic_float& x, const generic_float& y) { - if (not x.is_finite() or not y.is_finite()) + if(not x.is_finite() or not y.is_finite()) return false; return std::tie(x.mantissa, x.exponent, x.sign) == std::tie(y.mantissa, y.exponent, y.sign); } @@ -325,70 +297,96 @@ struct __attribute__((packed, may_alias)) generic_float return not(x == y); } - constexpr generic_float& operator++() noexcept + constexpr generic_float& operator++() noexcept { - *this += generic_float(1.0f); + *this += generic_float(1.0f); return *this; } }; - -} -} +} // namespace MIGRAPHX_INLINE_NS +} // namespace migraphx namespace std { -template +template class numeric_limits> { public: static constexpr bool has_infinity = true; - static constexpr migraphx::generic_float epsilon() { return migraphx::generic_float::epsilon(); } - - static constexpr migraphx::generic_float quiet_NaN() { return migraphx::generic_float::qnan(); } + static constexpr migraphx::generic_float epsilon() + { + return migraphx::generic_float::epsilon(); + } - static constexpr migraphx::generic_float signaling_NaN() { return migraphx::generic_float::snan(); } + static constexpr migraphx::generic_float quiet_NaN() + { + return migraphx::generic_float::qnan(); + } - static constexpr migraphx::generic_float max() { return migraphx::generic_float::max(); } + static constexpr migraphx::generic_float signaling_NaN() + { + return migraphx::generic_float::snan(); + } - static constexpr migraphx::generic_float min() { return migraphx::generic_float::min(); } + static constexpr migraphx::generic_float max() + { + return migraphx::generic_float::max(); + } - static constexpr migraphx::generic_float lowest() { return migraphx::generic_float::lowest(); } + static constexpr migraphx::generic_float min() + { + return migraphx::generic_float::min(); + } - static constexpr migraphx::generic_float infinity() { return migraphx::generic_float::infinity(); } + static constexpr migraphx::generic_float lowest() + { + return migraphx::generic_float::lowest(); + } - static constexpr migraphx::generic_float denorm_min() { return migraphx::generic_float::denorm_min(); } + static constexpr migraphx::generic_float infinity() + { + return migraphx::generic_float::infinity(); + } + static constexpr migraphx::generic_float denorm_min() + { + return migraphx::generic_float::denorm_min(); + } }; -template +template struct common_type, T> : std::common_type // NOLINT { }; -template +template struct common_type> : std::common_type // NOLINT { }; // template -// struct common_type, migraphx::fp8::float8> : std::common_type +// struct common_type, +// migraphx::fp8::float8> : std::common_type // {}; // template -// struct common_type, migraphx::generic_float> : std::common_type +// struct common_type, +// migraphx::generic_float> : std::common_type // {}; // template -// struct common_type, migraphx::fp8::float8> : std::common_type +// struct common_type, migraphx::fp8::float8> : +// std::common_type // {}; // template -// struct common_type, migraphx::generic_float> : std::common_type +// struct common_type, migraphx::generic_float> : +// std::common_type // {}; -template -struct common_type, migraphx::generic_float> +template +struct common_type, migraphx::generic_float> { using type = migraphx::generic_float; }; @@ -399,5 +397,4 @@ struct common_type, migraphx::generic_float; +using half = migraphx::generic_float<10, 5>; namespace detail { template diff --git a/test/float32.cpp b/test/float32.cpp index d18b924bad1..d5960cd7fdd 100644 --- a/test/float32.cpp +++ b/test/float32.cpp @@ -32,7 +32,7 @@ using fp32 = migraphx::generic_float<23, 8>; -template +template bool bit_equal(const T& x, const U& y) { static_assert(sizeof(T) == sizeof(U)); @@ -40,13 +40,12 @@ bool bit_equal(const T& x, const U& y) return migraphx::bit_cast(x) == migraphx::bit_cast(y); } -#define CHECK_FLOAT(x, y) \ - CHECK(bit_equal(x, y)); \ +#define CHECK_FLOAT(x, y) \ + CHECK(bit_equal(x, y)); \ CHECK(bit_equal(x, y.to_float())); \ - CHECK(bit_equal(fp32{x}, y)); \ + CHECK(bit_equal(fp32{x}, y)); \ CHECK(bit_equal(fp32{x}.to_float(), y.to_float())) - TEST_CASE(fp32_values_working) { CHECK_FLOAT(1.0f, fp32{1.0f}); @@ -61,5 +60,4 @@ TEST_CASE(fp32_values_working) CHECK_FLOAT(std::numeric_limits::signaling_NaN(), fp32::snan()); } - int main(int argc, const char* argv[]) { test::run(argc, argv); } diff --git a/test/half.cpp b/test/half.cpp index 96d76c9a15a..99171880bc6 100644 --- a/test/half.cpp +++ b/test/half.cpp @@ -1105,19 +1105,34 @@ TEST_CASE(check_half_values) TEST_CASE(check_flows) { // check positive underflow - CHECK(bit_equal(std::numeric_limits::min() * std::numeric_limits::min(), migraphx::half(0))); + CHECK(bit_equal(std::numeric_limits::min() * + std::numeric_limits::min(), + migraphx::half(0))); // check overflow - CHECK(bit_equal(std::numeric_limits::infinity() + std::numeric_limits::infinity(), std::numeric_limits::infinity())); - CHECK(bit_equal(std::numeric_limits::max() + std::numeric_limits::max(), std::numeric_limits::infinity())); - CHECK(bit_equal(std::numeric_limits::max() / std::numeric_limits::epsilon(), std::numeric_limits::infinity())); - CHECK(bit_equal(std::numeric_limits::max() + std::numeric_limits::min(), std::numeric_limits::max())); - - // check negative underflow - CHECK(bit_equal(std::numeric_limits::lowest() + std::numeric_limits::lowest(), -std::numeric_limits::infinity())); - CHECK(bit_equal(-std::numeric_limits::infinity() - std::numeric_limits::infinity(), -std::numeric_limits::infinity())); - CHECK(bit_equal(std::numeric_limits::lowest() - std::numeric_limits::min(), std::numeric_limits::lowest())); + CHECK(bit_equal(std::numeric_limits::infinity() + + std::numeric_limits::infinity(), + std::numeric_limits::infinity())); + CHECK(bit_equal(std::numeric_limits::max() + + std::numeric_limits::max(), + std::numeric_limits::infinity())); + CHECK(bit_equal(std::numeric_limits::max() / + std::numeric_limits::epsilon(), + std::numeric_limits::infinity())); + CHECK(bit_equal(std::numeric_limits::max() + + std::numeric_limits::min(), + std::numeric_limits::max())); + // check negative underflow + CHECK(bit_equal(std::numeric_limits::lowest() + + std::numeric_limits::lowest(), + -std::numeric_limits::infinity())); + CHECK(bit_equal(-std::numeric_limits::infinity() - + std::numeric_limits::infinity(), + -std::numeric_limits::infinity())); + CHECK(bit_equal(std::numeric_limits::lowest() - + std::numeric_limits::min(), + std::numeric_limits::lowest())); } TEST_CASE(test_nan) @@ -1167,7 +1182,6 @@ TEST_CASE(test_numeric_max_1) CHECK(bit_equal(half_inf, std::numeric_limits::infinity())); } - TEST_CASE(test_numeric_lowest_1) { float flowest = std::numeric_limits::lowest(); @@ -1185,8 +1199,7 @@ TEST_CASE(test_isfinite) { EXPECT(std::isfinite(migraphx::half(0.0))); EXPECT(std::isfinite(migraphx::half(-0.0))); - EXPECT(not std::isfinite( - migraphx::half(std::numeric_limits::quiet_NaN()))); + EXPECT(not std::isfinite(migraphx::half(std::numeric_limits::quiet_NaN()))); } TEST_CASE(test_binary_ops) @@ -1223,5 +1236,4 @@ TEST_CASE(test_stream_op) EXPECT(std::string("nan") == ss.str()); } - int main(int argc, const char* argv[]) { test::run(argc, argv); } From 33e2c8df60c40fe95667005b907bcb76916c5389 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Wed, 30 Oct 2024 19:23:45 +0000 Subject: [PATCH 38/72] fix bug --- src/include/migraphx/generic_float.hpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/include/migraphx/generic_float.hpp b/src/include/migraphx/generic_float.hpp index aad985984de..758875d3767 100644 --- a/src/include/migraphx/generic_float.hpp +++ b/src/include/migraphx/generic_float.hpp @@ -27,6 +27,7 @@ #include #include #include +#include namespace migraphx { inline namespace MIGRAPHX_INLINE_NS { @@ -154,14 +155,21 @@ struct __attribute__((packed, may_alias)) generic_float exponent = all_ones(); mantissa = 0; } - else if(e <= 0) + else if(e < 1) { exponent = 0; auto shift = diff - int(f.exponent); - mantissa = - (f.mantissa | (1u << static_cast(float32_parts::mantissa_width()))) >> - (shift + (float32_parts::mantissa_width() - MantissaSize) + 1); + auto shift_amount = shift + (float32_parts::mantissa_width() - MantissaSize) + 1; + + if (shift_amount <= 32) { + mantissa = + (f.mantissa | (1u << static_cast(float32_parts::mantissa_width()))) >> + shift_amount; + } else { + mantissa = 0; + } + } else { From b3c345dffc84a81492d8bdd2402eef16ca056875 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Wed, 30 Oct 2024 21:02:32 +0000 Subject: [PATCH 39/72] fix err --- src/include/migraphx/generic_float.hpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/include/migraphx/generic_float.hpp b/src/include/migraphx/generic_float.hpp index 758875d3767..90276813b05 100644 --- a/src/include/migraphx/generic_float.hpp +++ b/src/include/migraphx/generic_float.hpp @@ -155,21 +155,23 @@ struct __attribute__((packed, may_alias)) generic_float exponent = all_ones(); mantissa = 0; } - else if(e < 1) + else if(e < 1) { exponent = 0; auto shift = diff - int(f.exponent); auto shift_amount = shift + (float32_parts::mantissa_width() - MantissaSize) + 1; - - if (shift_amount <= 32) { + + if(shift_amount < 32) + { mantissa = (f.mantissa | (1u << static_cast(float32_parts::mantissa_width()))) >> - shift_amount; - } else { + (shift + (float32_parts::mantissa_width() - MantissaSize) + 1); + } + else + { mantissa = 0; - } - + } } else { From 03df6f9cd48efe1eb96baf20d0b8005766494221 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Thu, 31 Oct 2024 18:09:13 +0000 Subject: [PATCH 40/72] edits --- src/include/migraphx/generic_float.hpp | 2 +- src/include/migraphx/half.hpp | 9 --------- test/float32.cpp | 22 +++++++++++----------- 3 files changed, 12 insertions(+), 21 deletions(-) diff --git a/src/include/migraphx/generic_float.hpp b/src/include/migraphx/generic_float.hpp index 90276813b05..690bd81d219 100644 --- a/src/include/migraphx/generic_float.hpp +++ b/src/include/migraphx/generic_float.hpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include namespace migraphx { inline namespace MIGRAPHX_INLINE_NS { diff --git a/src/include/migraphx/half.hpp b/src/include/migraphx/half.hpp index ea2f251c12c..34cf3f96a3b 100644 --- a/src/include/migraphx/half.hpp +++ b/src/include/migraphx/half.hpp @@ -25,7 +25,6 @@ #ifndef MIGRAPHX_GUARD_RTGLIB_HALF_HPP #define MIGRAPHX_GUARD_RTGLIB_HALF_HPP -#include #include #include #include @@ -41,14 +40,6 @@ struct deduce { using type = T; }; - -#ifdef HAS_HALF_V1 -template <> -struct deduce -{ - using type = half; -}; -#endif } // namespace detail template diff --git a/test/float32.cpp b/test/float32.cpp index d5960cd7fdd..04994124253 100644 --- a/test/float32.cpp +++ b/test/float32.cpp @@ -40,7 +40,7 @@ bool bit_equal(const T& x, const U& y) return migraphx::bit_cast(x) == migraphx::bit_cast(y); } -#define CHECK_FLOAT(x, y) \ +#define MIGRAPHX_CHECK_FLOAT(x, y) \ CHECK(bit_equal(x, y)); \ CHECK(bit_equal(x, y.to_float())); \ CHECK(bit_equal(fp32{x}, y)); \ @@ -48,16 +48,16 @@ bool bit_equal(const T& x, const U& y) TEST_CASE(fp32_values_working) { - CHECK_FLOAT(1.0f, fp32{1.0f}); - CHECK_FLOAT(-1.0f, fp32{-1.0f}); - CHECK_FLOAT(std::numeric_limits::min(), fp32::min()); - CHECK_FLOAT(std::numeric_limits::lowest(), fp32::lowest()); - CHECK_FLOAT(std::numeric_limits::max(), fp32::max()); - CHECK_FLOAT(std::numeric_limits::epsilon(), fp32::epsilon()); - CHECK_FLOAT(std::numeric_limits::denorm_min(), fp32::denorm_min()); - CHECK_FLOAT(std::numeric_limits::infinity(), fp32::infinity()); - CHECK_FLOAT(std::numeric_limits::quiet_NaN(), fp32::qnan()); - CHECK_FLOAT(std::numeric_limits::signaling_NaN(), fp32::snan()); + MIGRAPHX_CHECK_FLOAT(1.0f, fp32{1.0f}); + MIGRAPHX_CHECK_FLOAT(-1.0f, fp32{-1.0f}); + MIGRAPHX_CHECK_FLOAT(std::numeric_limits::min(), fp32::min()); + MIGRAPHX_CHECK_FLOAT(std::numeric_limits::lowest(), fp32::lowest()); + MIGRAPHX_CHECK_FLOAT(std::numeric_limits::max(), fp32::max()); + MIGRAPHX_CHECK_FLOAT(std::numeric_limits::epsilon(), fp32::epsilon()); + MIGRAPHX_CHECK_FLOAT(std::numeric_limits::denorm_min(), fp32::denorm_min()); + MIGRAPHX_CHECK_FLOAT(std::numeric_limits::infinity(), fp32::infinity()); + MIGRAPHX_CHECK_FLOAT(std::numeric_limits::quiet_NaN(), fp32::qnan()); + MIGRAPHX_CHECK_FLOAT(std::numeric_limits::signaling_NaN(), fp32::snan()); } int main(int argc, const char* argv[]) { test::run(argc, argv); } From ad817b262756ba3033126d8008fd11b1685aa701 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Thu, 31 Oct 2024 20:32:46 +0000 Subject: [PATCH 41/72] tidy and format --- src/include/migraphx/generic_float.hpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/include/migraphx/generic_float.hpp b/src/include/migraphx/generic_float.hpp index 690bd81d219..2209d7914c8 100644 --- a/src/include/migraphx/generic_float.hpp +++ b/src/include/migraphx/generic_float.hpp @@ -84,7 +84,7 @@ struct __attribute__((packed, may_alias)) generic_float constexpr generic_float operator-() const noexcept { generic_float result = *this; - result.sign = !this->sign; + result.sign = not this->sign; return result; } @@ -109,7 +109,7 @@ struct __attribute__((packed, may_alias)) generic_float if(MantissaSize < float32_parts::mantissa_width()) { shift = MantissaSize - ((sizeof(unsigned int) * 8) - countl_zero(mantissa)); - f.mantissa <<= (shift + 1); + f.mantissa <<= static_cast(shift + 1); } f.exponent = float32_parts::exponent_bias() - exponent_bias() - shift; @@ -159,13 +159,14 @@ struct __attribute__((packed, may_alias)) generic_float { exponent = 0; - auto shift = diff - int(f.exponent); + auto shift = diff - int(f.exponent); auto shift_amount = shift + (float32_parts::mantissa_width() - MantissaSize) + 1; - if(shift_amount < 32) + if(shift_amount < (sizeof(unsigned int) * 8)) { mantissa = - (f.mantissa | (1u << static_cast(float32_parts::mantissa_width()))) >> + (f.mantissa | + (1u << static_cast(float32_parts::mantissa_width()))) >> (shift + (float32_parts::mantissa_width() - MantissaSize) + 1); } else @@ -213,7 +214,7 @@ struct __attribute__((packed, may_alias)) generic_float { generic_float x{}; x.exponent = all_ones(); - x.mantissa = 1 << (MantissaSize - 2); + x.mantissa = 1u << static_cast(MantissaSize - 2); return x; } @@ -221,7 +222,7 @@ struct __attribute__((packed, may_alias)) generic_float { generic_float x{}; x.exponent = all_ones(); - x.mantissa = 1 << (MantissaSize - 1); + x.mantissa = 1u << static_cast(MantissaSize - 1); return x; } From 898417bb83566ad1ff39e0039bc94cbaef3afd05 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Thu, 31 Oct 2024 22:41:34 +0000 Subject: [PATCH 42/72] tidy etc --- src/include/migraphx/generic_float.hpp | 37 +++++++++++++++++--------- 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/src/include/migraphx/generic_float.hpp b/src/include/migraphx/generic_float.hpp index 2209d7914c8..cc5988ba4b9 100644 --- a/src/include/migraphx/generic_float.hpp +++ b/src/include/migraphx/generic_float.hpp @@ -88,6 +88,8 @@ struct __attribute__((packed, may_alias)) generic_float return result; } + constexpr generic_float operator+() const noexcept { return *this; } + constexpr float to_float() const noexcept { float32_parts f{}; @@ -103,13 +105,13 @@ struct __attribute__((packed, may_alias)) generic_float } else { - int shift = 0; + unsigned int shift = 0; f.mantissa = mantissa; if(MantissaSize < float32_parts::mantissa_width()) { shift = MantissaSize - ((sizeof(unsigned int) * 8) - countl_zero(mantissa)); - f.mantissa <<= static_cast(shift + 1); + f.mantissa <<= (shift + 1); } f.exponent = float32_parts::exponent_bias() - exponent_bias() - shift; @@ -164,10 +166,8 @@ struct __attribute__((packed, may_alias)) generic_float if(shift_amount < (sizeof(unsigned int) * 8)) { - mantissa = - (f.mantissa | - (1u << static_cast(float32_parts::mantissa_width()))) >> - (shift + (float32_parts::mantissa_width() - MantissaSize) + 1); + mantissa = (f.mantissa | (1u << float32_parts::mantissa_width())) >> + (shift + (float32_parts::mantissa_width() - MantissaSize) + 1); } else { @@ -214,7 +214,7 @@ struct __attribute__((packed, may_alias)) generic_float { generic_float x{}; x.exponent = all_ones(); - x.mantissa = 1u << static_cast(MantissaSize - 2); + x.mantissa = 1u << (MantissaSize - 2u); return x; } @@ -222,7 +222,7 @@ struct __attribute__((packed, may_alias)) generic_float { generic_float x{}; x.exponent = all_ones(); - x.mantissa = 1u << static_cast(MantissaSize - 1); + x.mantissa = 1u << (MantissaSize - 1u); return x; } @@ -291,10 +291,16 @@ struct __attribute__((packed, may_alias)) generic_float MIGRAPHX_GENERIC_FLOAT_BINARY_OP(-) MIGRAPHX_GENERIC_FLOAT_BINARY_OP(+) MIGRAPHX_GENERIC_FLOAT_BINARY_OP(/) - MIGRAPHX_GENERIC_FLOAT_BINARY_OP(<) - MIGRAPHX_GENERIC_FLOAT_BINARY_OP(<=) - MIGRAPHX_GENERIC_FLOAT_BINARY_OP(>) - MIGRAPHX_GENERIC_FLOAT_BINARY_OP(>=) +// NOLINTNEXTLINE +#define MIGRAPHX_GENERIC_FLOAT_COMPARE_OP(op) \ + friend constexpr bool operator op(const generic_float& x, const generic_float& y) \ + { \ + return float(x) op float(y); \ + } + MIGRAPHX_GENERIC_FLOAT_COMPARE_OP(<) + MIGRAPHX_GENERIC_FLOAT_COMPARE_OP(<=) + MIGRAPHX_GENERIC_FLOAT_COMPARE_OP(>) + MIGRAPHX_GENERIC_FLOAT_COMPARE_OP(>=) friend constexpr bool operator==(const generic_float& x, const generic_float& y) { @@ -313,6 +319,13 @@ struct __attribute__((packed, may_alias)) generic_float *this += generic_float(1.0f); return *this; } + + constexpr generic_float operator++(int) noexcept + { + generic_float temp = *this; + *this += generic_float(1.0f); + return temp; + } }; } // namespace MIGRAPHX_INLINE_NS From aa5b9c9b5cf495de523e0b4359f66e030a6a2303 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Thu, 31 Oct 2024 23:30:21 +0000 Subject: [PATCH 43/72] gf --- src/include/migraphx/generic_float.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/migraphx/generic_float.hpp b/src/include/migraphx/generic_float.hpp index cc5988ba4b9..ddf9a79e980 100644 --- a/src/include/migraphx/generic_float.hpp +++ b/src/include/migraphx/generic_float.hpp @@ -106,7 +106,7 @@ struct __attribute__((packed, may_alias)) generic_float else { unsigned int shift = 0; - f.mantissa = mantissa; + f.mantissa = mantissa; if(MantissaSize < float32_parts::mantissa_width()) { From 6f7237076ce147ae13327827cc661f2be7718a11 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Fri, 1 Nov 2024 11:27:29 -0500 Subject: [PATCH 44/72] fix tidy errs --- .clang-tidy | 2 ++ src/include/migraphx/generic_float.hpp | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index caecc0cb295..f4262fd3c13 100755 --- a/.clang-tidy +++ b/.clang-tidy @@ -115,3 +115,5 @@ CheckOptions: value: UPPER_CASE - key: readability-identifier-naming.MacroDefinitionPrefix value: MIGRAPHX_ + - key: readability-identifier-naming.ConstexprMethodIgnoredRegexp + value: 'quiet_NaN|signaling_NaN' diff --git a/src/include/migraphx/generic_float.hpp b/src/include/migraphx/generic_float.hpp index ddf9a79e980..93992953658 100644 --- a/src/include/migraphx/generic_float.hpp +++ b/src/include/migraphx/generic_float.hpp @@ -95,7 +95,7 @@ struct __attribute__((packed, may_alias)) generic_float float32_parts f{}; f.sign = sign; - if(exponent == 0) + if(exponent == 0) // subnormal fps { if(mantissa == 0) @@ -320,7 +320,7 @@ struct __attribute__((packed, may_alias)) generic_float return *this; } - constexpr generic_float operator++(int) noexcept + const generic_float operator++(int) noexcept { generic_float temp = *this; *this += generic_float(1.0f); @@ -331,6 +331,7 @@ struct __attribute__((packed, may_alias)) generic_float } // namespace MIGRAPHX_INLINE_NS } // namespace migraphx +// NOLINT(cert-dcl58-cpp) namespace std { template From 0aab1a0635082ac569c4ec9d9e6030a91f65332d Mon Sep 17 00:00:00 2001 From: richagadgil Date: Mon, 4 Nov 2024 11:16:33 -0600 Subject: [PATCH 45/72] bf16 changes --- src/include/migraphx/generic_float.hpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/include/migraphx/generic_float.hpp b/src/include/migraphx/generic_float.hpp index 93992953658..6526a1943b9 100644 --- a/src/include/migraphx/generic_float.hpp +++ b/src/include/migraphx/generic_float.hpp @@ -42,7 +42,7 @@ template constexpr int countl_zero(T value) { unsigned int r = 0; - for(; value != 0; value >>= 1) + for(; value != 0u; value >>= 1u) r++; return 8 * sizeof(value) - r; } @@ -95,7 +95,7 @@ struct __attribute__((packed, may_alias)) generic_float float32_parts f{}; f.sign = sign; - if(exponent == 0) // subnormal fps + if(exponent == 0 and ExponentSize != 8) // subnormal fps { if(mantissa == 0) @@ -306,6 +306,12 @@ struct __attribute__((packed, may_alias)) generic_float { if(not x.is_finite() or not y.is_finite()) return false; + + if((x.mantissa == 0 and x.exponent == 0) and (y.mantissa == 0 and y.exponent == 0)) + { + return true; + } + return std::tie(x.mantissa, x.exponent, x.sign) == std::tie(y.mantissa, y.exponent, y.sign); } @@ -320,7 +326,7 @@ struct __attribute__((packed, may_alias)) generic_float return *this; } - const generic_float operator++(int) noexcept + const generic_float operator++(int) noexcept // NOLINT(readability-const-return-type) { generic_float temp = *this; *this += generic_float(1.0f); @@ -331,11 +337,10 @@ struct __attribute__((packed, may_alias)) generic_float } // namespace MIGRAPHX_INLINE_NS } // namespace migraphx -// NOLINT(cert-dcl58-cpp) namespace std { template -class numeric_limits> +class numeric_limits> // NOLINT(cert-dcl58-cpp) { public: static constexpr bool has_infinity = true; From 7b965c0c436084605733027bd8663217f2529799 Mon Sep 17 00:00:00 2001 From: shivadbhavsar <105248561+shivadbhavsar@users.noreply.github.com> Date: Tue, 29 Oct 2024 19:09:49 -0700 Subject: [PATCH 46/72] add flag to trace quantization passes (#3571) --- docs/dev/env_vars.rst | 5 +++++ src/quantization.cpp | 22 +++++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/docs/dev/env_vars.rst b/docs/dev/env_vars.rst index a1193c1af64..06e9624741c 100644 --- a/docs/dev/env_vars.rst +++ b/docs/dev/env_vars.rst @@ -82,6 +82,11 @@ Prints debug statements for the ``schedule`` pass. Set to "1", "enable", "enabled", "yes", or "true" to use. Traces instructions replaced with a constant. +.. envvar:: MIGRAPHX_TRACE_QUANTIZATION + +Set to "1", "enable", "enabled", "yes", or "true" to use. +Prints traces for any passes run during quantization. + .. envvar:: MIGRAPHX_8BITS_QUANTIZATION_PARAMS Set to "1", "enable", "enabled", "yes", or "true" to use. diff --git a/src/quantization.cpp b/src/quantization.cpp index cb591eaf7c6..a9b47d1d503 100644 --- a/src/quantization.cpp +++ b/src/quantization.cpp @@ -49,6 +49,15 @@ namespace migraphx { inline namespace MIGRAPHX_INLINE_NS { MIGRAPHX_DECLARE_ENV_VAR(MIGRAPHX_8BITS_QUANTIZATION_PARAMS) +MIGRAPHX_DECLARE_ENV_VAR(MIGRAPHX_TRACE_QUANTIZATION) + +tracer quant_tracer() +{ + if(enabled(MIGRAPHX_TRACE_QUANTIZATION{})) + return tracer{std::cout}; + + return tracer{}; +}; // This function is to convert any instructions specified in the input // from double or float to float16 by inserting a convert operator. @@ -61,7 +70,8 @@ void quantize_fp16(program& prog, const std::vector& ins_names) {normalize_ops{}, optimize_module{{"quantizelinear", "dequantizelinear"}}, quantize_fp16_pass{ins_names}, - optimize_module{{"quantizelinear", "dequantizelinear"}}}); + optimize_module{{"quantizelinear", "dequantizelinear"}}}, + quant_tracer()); } void quantize_8bits(program& prog, @@ -72,7 +82,7 @@ void quantize_8bits(program& prog, { // Run optimize_module() before converting to int8/fp8 to const eval and fold in FP32 to // avoid loss of precision. - run_passes(prog, {normalize_ops{}, optimize_module{}}); + run_passes(prog, {normalize_ops{}, optimize_module{}}, quant_tracer()); std::shared_ptr>> quant_8bit_params = std::make_shared>>(); @@ -106,7 +116,8 @@ void quantize_8bits(program& prog, // pass to add capture argument op std::size_t param_num = 0; - run_passes(prog, {capture_arguments_pass{ins_names, calc_quant_params, ¶m_num}}); + run_passes( + prog, {capture_arguments_pass{ins_names, calc_quant_params, ¶m_num}}, quant_tracer()); quant_8bit_params->resize(param_num, std::pair(64.0f, 0.0f)); max_abs_vals->resize(param_num, 0.0f); @@ -150,7 +161,8 @@ void quantize_8bits(program& prog, {quantize_8bits_pass{precision, *quant_8bit_params}, simplify_qdq{}, optimize_module{}, - dead_code_elimination{}}); + dead_code_elimination{}}, + quant_tracer()); } void quantize_int8(program& prog, @@ -168,7 +180,7 @@ void quantize_int8(program& prog, void quantize_int4_weights(program& prog) { - run_passes(prog, {normalize_ops{}, optimize_module{}, quantize_int4_pass{}}); + run_passes(prog, {normalize_ops{}, optimize_module{}, quantize_int4_pass{}}, quant_tracer()); } void quantize_fp8(program& prog, const target& t, const std::vector& calibration) From 5f5f13dcb5f9cb0776017268526f915611a84e25 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Wed, 30 Oct 2024 22:37:59 +0000 Subject: [PATCH 47/72] bf16 --- src/include/migraphx/bf16.hpp | 99 +++++++++++++++++ test/bf16.cpp | 196 ++++++++++++++++++++++++++++++++++ 2 files changed, 295 insertions(+) create mode 100644 src/include/migraphx/bf16.hpp create mode 100644 test/bf16.cpp diff --git a/src/include/migraphx/bf16.hpp b/src/include/migraphx/bf16.hpp new file mode 100644 index 00000000000..8c9ed6fd9f3 --- /dev/null +++ b/src/include/migraphx/bf16.hpp @@ -0,0 +1,99 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MIGRAPHX_GUARD_RTGLIB_BF16_HPP +#define MIGRAPHX_GUARD_RTGLIB_BF16_HPP + +#include +#include +#include + +namespace migraphx { +inline namespace MIGRAPHX_INLINE_NS { + +using bf16 = migraphx::generic_float<7, 8>; + +template +using deduce = typename detail::deduce::type; + +} // namespace MIGRAPHX_INLINE_NS +} // namespace migraphx + +namespace std { + +template +struct common_type : std::common_type // NOLINT +{ +}; + +template +struct common_type : std::common_type // NOLINT +{ +}; + +template <> +struct common_type +{ + using type = float; +}; + +template <> +struct common_type +{ + using type = float; +}; + +template <> +struct common_type +{ + using type = float; +}; + +template <> +struct common_type +{ + using type = float; +}; + +template <> +struct common_type +{ + using type = float; +}; + +template <> +struct common_type +{ + using type = float; +}; + +template <> +struct common_type +{ + using type = migraphx::bf16; +}; + +} // namespace std + +#endif diff --git a/test/bf16.cpp b/test/bf16.cpp new file mode 100644 index 00000000000..16982c96a87 --- /dev/null +++ b/test/bf16.cpp @@ -0,0 +1,196 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#include +#include +#include +#include +#include "test.hpp" + +#include +#include +#include + +template +bool bit_equal(const T& x, const U& y) +{ + static_assert(sizeof(T) == sizeof(U)); + using type = std::array; + return migraphx::bit_cast(x) == migraphx::bit_cast(y); +} + +TEST_CASE(check_numeric_limits) +{ + std::bitset<8> exponentBits(std::numeric_limits::quiet_NaN().exponent); + std::cout << "Exponent bits: " << exponentBits << std::endl; + + std::bitset<7> mantissaBits(std::numeric_limits::quiet_NaN().mantissa); + std::cout << "Mantissa bits: " << mantissaBits << std::endl; + + std::cout << std::numeric_limits::min() << std::endl; + CHECK(bit_equal(std::numeric_limits::min(), uint16_t{0x0080})); + CHECK(bit_equal(std::numeric_limits::lowest(), uint16_t{0xff7f})); + CHECK(bit_equal(std::numeric_limits::max(), uint16_t{0x7f7f})); + CHECK(bit_equal(std::numeric_limits::epsilon(), uint16_t{0x3c00})); + CHECK(bit_equal(std::numeric_limits::denorm_min(), uint16_t{0x0001})); + CHECK(bit_equal(std::numeric_limits::infinity(), uint16_t{0x7f80})); + CHECK(bit_equal(std::numeric_limits::quiet_NaN(), uint16_t{0x7fc0})); + CHECK(bit_equal(std::numeric_limits::signaling_NaN(), uint16_t{0x7fa0})); +} + + +TEST_CASE(check_flows) +{ + // check positive underflow + CHECK(bit_equal(std::numeric_limits::min() * + std::numeric_limits::min(), + migraphx::bf16(0))); + + // check overflow + CHECK(bit_equal(std::numeric_limits::infinity() + + std::numeric_limits::infinity(), + std::numeric_limits::infinity())); + CHECK(bit_equal(std::numeric_limits::max() + + std::numeric_limits::max(), + std::numeric_limits::infinity())); + CHECK(bit_equal(std::numeric_limits::max() / + std::numeric_limits::epsilon(), + std::numeric_limits::infinity())); + CHECK(bit_equal(std::numeric_limits::max() + + std::numeric_limits::min(), + std::numeric_limits::max())); + + // check negative underflow + CHECK(bit_equal(std::numeric_limits::lowest() + + std::numeric_limits::lowest(), + -std::numeric_limits::infinity())); + CHECK(bit_equal(-std::numeric_limits::infinity() - + std::numeric_limits::infinity(), + -std::numeric_limits::infinity())); + CHECK(bit_equal(std::numeric_limits::lowest() - + std::numeric_limits::min(), + std::numeric_limits::lowest())); +} + +TEST_CASE(test_nan) +{ + float f_qnan = std::numeric_limits::quiet_NaN(); + migraphx::bf16 bf16_qnan(f_qnan); + EXPECT(bf16_qnan.is_nan()); + EXPECT(std::isnan(bf16_qnan)); + + float f_snan = std::numeric_limits::signaling_NaN(); + migraphx::bf16 bf16_snan(f_snan); + EXPECT(bf16_snan.is_nan()); + EXPECT(std::isnan(bf16_snan)); +} + +TEST_CASE(test_bool) +{ + float zero = 0.0; + float two = 2.0; + float other = -0.375; + migraphx::bf16 bf16_zero(zero); + migraphx::bf16 bf16_two(two); + migraphx::bf16 bf16_other(other); + EXPECT(not static_cast(bf16_zero)); + EXPECT(static_cast(bf16_two)); + EXPECT(static_cast(bf16_other)); +} + +TEST_CASE(test_pos_infinity) +{ + float finf = std::numeric_limits::infinity(); + migraphx::bf16 bf16_inf_1(finf); + CHECK(bit_equal(bf16_inf_1, std::numeric_limits::infinity())); +} + +TEST_CASE(test_neg_infinity) +{ + float finf = -1.0 * std::numeric_limits::infinity(); + migraphx::bf16 bf16_neginf_1(finf); + CHECK(bit_equal(bf16_neginf_1, -std::numeric_limits::infinity())); +} + +TEST_CASE(test_numeric_max_1) +{ + float fmax = std::numeric_limits::max(); // fp32 max is fp16 inf + migraphx::bf16 bf16_inf(fmax); + CHECK(bit_equal(bf16_inf, std::numeric_limits::max())); +} + +TEST_CASE(test_numeric_lowest_1) +{ + float flowest = std::numeric_limits::lowest(); + migraphx::bf16 bf16_neginf(flowest); + CHECK(bit_equal(bf16_neginf, std::numeric_limits::lowest())); +} + +TEST_CASE(test_max_eq_lowest) +{ + EXPECT(migraphx::float_equal(std::numeric_limits::lowest(), + -1 * std::numeric_limits::max())); +} + +TEST_CASE(test_isfinite) +{ + EXPECT(std::isfinite(migraphx::bf16(0.0))); + EXPECT(std::isfinite(migraphx::bf16(-0.0))); + EXPECT(not std::isfinite(migraphx::bf16(std::numeric_limits::quiet_NaN()))); +} + +TEST_CASE(test_binary_ops) +{ + auto a = migraphx::bf16(-1.0); + auto b = migraphx::bf16(1.0); + auto c = migraphx::bf16(0.0); + auto d = migraphx::bf16(-0.0); + EXPECT(migraphx::float_equal((c + d), c)); + // EXPECT(migraphx::float_equal((c + d), d)); + EXPECT(migraphx::float_equal((a + b), c)); + EXPECT(migraphx::float_equal((a + b), d)); + + auto e = migraphx::bf16(10.0); + auto f = migraphx::bf16(-10.0); + EXPECT(e > f); + EXPECT(f < e); + EXPECT(f <= e); + EXPECT(e >= f); + EXPECT(e <= e); + EXPECT(f >= f); + EXPECT(not migraphx::float_equal(f, e)); +} + +TEST_CASE(test_stream_op) +{ + auto a = migraphx::bf16(-1.0); + std::stringstream ss; + ss << a; + EXPECT(std::string("-1") == ss.str()); + ss = std::stringstream(); + auto b = std::numeric_limits::quiet_NaN(); + ss << b; + EXPECT(std::string("nan") == ss.str()); +} + +int main(int argc, const char* argv[]) { test::run(argc, argv); } From d64b124b0ee85241426e35163cee22df3716219d Mon Sep 17 00:00:00 2001 From: Richa Gadgil Date: Fri, 1 Nov 2024 15:42:05 -0700 Subject: [PATCH 48/72] Update bf16.cpp --- test/bf16.cpp | 1097 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 1096 insertions(+), 1 deletion(-) diff --git a/test/bf16.cpp b/test/bf16.cpp index 16982c96a87..5f9275c6220 100644 --- a/test/bf16.cpp +++ b/test/bf16.cpp @@ -30,6 +30,9 @@ #include #include #include +#include +#include +#include template bool bit_equal(const T& x, const U& y) @@ -51,7 +54,7 @@ TEST_CASE(check_numeric_limits) CHECK(bit_equal(std::numeric_limits::min(), uint16_t{0x0080})); CHECK(bit_equal(std::numeric_limits::lowest(), uint16_t{0xff7f})); CHECK(bit_equal(std::numeric_limits::max(), uint16_t{0x7f7f})); - CHECK(bit_equal(std::numeric_limits::epsilon(), uint16_t{0x3c00})); + CHECK(bit_equal(std::numeric_limits::epsilon(), uint16_t{0x3c0})); CHECK(bit_equal(std::numeric_limits::denorm_min(), uint16_t{0x0001})); CHECK(bit_equal(std::numeric_limits::infinity(), uint16_t{0x7f80})); CHECK(bit_equal(std::numeric_limits::quiet_NaN(), uint16_t{0x7fc0})); @@ -59,6 +62,1098 @@ TEST_CASE(check_numeric_limits) } + + +static const std::map half_lut = { +{0x0000, 0.0}, +{0x004d, 0.0000000000000000000000000000000000000071}, +{0x0078, 0.0000000000000000000000000000000000000110}, +{0x00e4, 0.0000000000000000000000000000000000000209}, +{0x016c, 0.0000000000000000000000000000000000000433}, +{0x01da, 0.0000000000000000000000000000000000000801}, +{0x01dd, 0.0000000000000000000000000000000000000812}, +{0x0345, 0.0000000000000000000000000000000000005789}, +{0x0406, 0.0000000000000000000000000000000000015752}, +{0x0426, 0.0000000000000000000000000000000000019513}, +{0x04c2, 0.0000000000000000000000000000000000045609}, +{0x052f, 0.0000000000000000000000000000000000082285}, +{0x053f, 0.0000000000000000000000000000000000089808}, +{0x054c, 0.0000000000000000000000000000000000095920}, +{0x0648, 0.0000000000000000000000000000000000376158}, +{0x0659, 0.0000000000000000000000000000000000408132}, +{0x0676, 0.0000000000000000000000000000000000462675}, +{0x0695, 0.0000000000000000000000000000000000560476}, +{0x069a, 0.0000000000000000000000000000000000579284}, +{0x06b3, 0.0000000000000000000000000000000000673323}, +{0x06b9, 0.0000000000000000000000000000000000695893}, +{0x06cf, 0.0000000000000000000000000000000000778647}, +{0x0751, 0.0000000000000000000000000000000001572341}, +{0x0768, 0.0000000000000000000000000000000001745374}, +{0x076a, 0.0000000000000000000000000000000001760420}, +{0x07ba, 0.0000000000000000000000000000000002798617}, +{0x07c2, 0.0000000000000000000000000000000002918988}, +{0x07fe, 0.0000000000000000000000000000000003821767}, +{0x0801, 0.0000000000000000000000000000000003881953}, +{0x0838, 0.0000000000000000000000000000000005537049}, +{0x08fd, 0.0000000000000000000000000000000015226884}, +{0x0909, 0.0000000000000000000000000000000016490775}, +{0x0917, 0.0000000000000000000000000000000018175964}, +{0x0931, 0.000000000000000000000000000000002130560}, +{0x0953, 0.0000000000000000000000000000000025398201}, +{0x099f, 0.0000000000000000000000000000000038277858}, +{0x09b3, 0.0000000000000000000000000000000043092683}, +{0x09ec, 0.0000000000000000000000000000000056814933}, +{0x0a6a, 0.0000000000000000000000000000000112666902}, +{0x0ad7, 0.0000000000000000000000000000000207037469}, +{0x0ae2, 0.0000000000000000000000000000000217630084}, +{0x0b4c, 0.0000000000000000000000000000000392889709}, +{0x0c5b, 0.0000000000000000000000000000001687114631}, +{0x0cde, 0.0000000000000000000000000000003420451581}, +{0x0ce8, 0.0000000000000000000000000000003574525977}, +{0x0d3b, 0.0000000000000000000000000000005762382394}, +{0x0da1, 0.0000000000000000000000000000009922391073}, +{0x0dcc, 0.0000000000000000000000000000012572470677}, +{0x0e4d, 0.0000000000000000000000000000025268200870}, +{0x0e58, 0.0000000000000000000000000000026624055551}, +{0x0e94, 0.0000000000000000000000000000036484816866}, +{0x0eb8, 0.0000000000000000000000000000045359502050}, +{0x0efe, 0.0000000000000000000000000000062615834352}, +{0x0f61, 0.0000000000000000000000000000110933564797}, +{0x0f7b, 0.0000000000000000000000000000123752554507}, +{0x0ff0, 0.0000000000000000000000000000236658271566}, +{0x10f0, 0.0000000000000000000000000000946633086265}, +{0x10fe, 0.0000000000000000000000000001001853349631}, +{0x1109, 0.0000000000000000000000000001080739440153}, +{0x118a, 0.0000000000000000000000000002177256098410}, +{0x11c1, 0.0000000000000000000000000003045003094153}, +{0x11c3, 0.0000000000000000000000000003076557530362}, +{0x11d2, 0.0000000000000000000000000003313215801928}, +{0x1224, 0.0000000000000000000000000005174927538250}, +{0x12d7, 0.0000000000000000000000000013568407569801}, +{0x1306, 0.0000000000000000000000000016913177807938}, +{0x1309, 0.0000000000000000000000000017291831042445}, +{0x1351, 0.0000000000000000000000000026379508670591}, +{0x1366, 0.0000000000000000000000000029030081312133}, +{0x136c, 0.0000000000000000000000000029787387781145}, +{0x139c, 0.0000000000000000000000000039379936388633}, +{0x13a4, 0.0000000000000000000000000041399420305999}, +{0x13cb, 0.0000000000000000000000000051244404403157}, +{0x13f6, 0.0000000000000000000000000062099130458998}, +{0x13fe, 0.0000000000000000000000000064118614376364}, +{0x1423, 0.0000000000000000000000000082293969632656}, +{0x1471, 0.0000000000000000000000000121673906021289}, +{0x1566, 0.0000000000000000000000000464481300994132}, +{0x1571, 0.0000000000000000000000000486695624085155}, +{0x15ad, 0.0000000000000000000000000698741435408563}, +{0x15bf, 0.0000000000000000000000000771442856433732}, +{0x15d0, 0.0000000000000000000000000840105309624169}, +{0x15ef, 0.0000000000000000000000000965313312500848}, +{0x1659, 0.0000000000000000000000001752912040273506}, +{0x16d0, 0.0000000000000000000000003360421238496675}, +{0x173d, 0.0000000000000000000000006106919366114150}, +{0x174c, 0.0000000000000000000000006591595506281939}, +{0x1769, 0.0000000000000000000000007528636043939666}, +{0x17c4, 0.0000000000000000000000012666203129718236}, +{0x1882, 0.0000000000000000000000033604212384966749}, +{0x18ae, 0.0000000000000000000000044977945807570880}, +{0x18c1, 0.0000000000000000000000049889330694604482}, +{0x18d1, 0.0000000000000000000000054025233757369620}, +{0x18d2, 0.0000000000000000000000054283727698792441}, +{0x18e5, 0.0000000000000000000000059195112585826043}, +{0x1947, 0.0000000000000000000000102880588686282817}, +{0x1998, 0.0000000000000000000000157164316385075258}, +{0x19e9, 0.0000000000000000000000240916353406069310}, +{0x1a1b, 0.0000000000000000000000320532487364298224}, +{0x1a8a, 0.0000000000000000000000570754622661589096}, +{0x1a8c, 0.0000000000000000000000579026428787119372}, +{0x1b70, 0.0000000000000000000001985233470127266420}, +{0x1b90, 0.0000000000000000000002382280164152719704}, +{0x1bea, 0.0000000000000000000003871205266748169518}, +{0x1c1d, 0.0000000000000000000005194694246833013798}, +{0x1c7e, 0.0000000000000000000008404155023538761177}, +{0x1c91, 0.0000000000000000000009595295105615121029}, +{0x1cab, 0.0000000000000000000011315830779725418592}, +{0x1d62, 0.0000000000000000000029910850949917480723}, +{0x1e7d, 0.0000000000000000000133937084784586241115}, +{0x1eca, 0.0000000000000000000213875819181710835615}, +{0x1efb, 0.0000000000000000000265756587201036731383}, +{0x1efc, 0.0000000000000000000266815378385104606807}, +{0x1f0f, 0.0000000000000000000302814278643412371217}, +{0x1f6b, 0.0000000000000000000497631856511901449203}, +{0x1f85, 0.0000000000000000000563276909924109725480}, +{0x1f8a, 0.0000000000000000000584452733605467233957}, +{0x1f9c, 0.0000000000000000000660685698858354264473}, +{0x1fdc, 0.0000000000000000000931736241979730372975}, +{0x1ffc, 0.0000000000000000001067261513540418427226}, +{0x2084, 0.0000000000000000002236166980751352895140}, +{0x20fb, 0.0000000000000000004252105395216587702123}, +{0x2153, 0.0000000000000000007148958074826294861737}, +{0x21bb, 0.0000000000000000012671612890924333072462}, +{0x2207, 0.0000000000000000018295911660692887323876}, +{0x220c, 0.0000000000000000018973538018496327595130}, +{0x2265, 0.0000000000000000031035287187397564423463}, +{0x2268, 0.0000000000000000031441863002079628586216}, +{0x2298, 0.0000000000000000041199682554449168492283}, +{0x22a1, 0.000000000000000004363913744254155346880}, +{0x2310, 0.0000000000000000078062556418956319248537}, +{0x2313, 0.0000000000000000079688859677684575899548}, +{0x232d, 0.0000000000000000093783487919996133541645}, +{0x23e5, 0.0000000000000000248282297499180515387707}, +{0x23f5, 0.0000000000000000265629532258948586331826}, +{0x2452, 0.0000000000000000455364912443911862283130}, +{0x2462, 0.0000000000000000490059381963448004171369}, +{0x2472, 0.0000000000000000524753851482984146059607}, +{0x24be, 0.0000000000000000823993651088983369845664}, +{0x24e3, 0.0000000000000000984455572616838026078767}, +{0x2509, 0.0000000000000001188285581044112859672168}, +{0x250b, 0.0000000000000001205632815803880930616288}, +{0x2546, 0.0000000000000001717376241217039023467805}, +{0x254a, 0.0000000000000001752070710736575165356044}, +{0x2550, 0.0000000000000001804112415015879378188401}, +{0x2585, 0.0000000000000002307182223049153435567860}, +{0x25d2, 0.0000000000000003642919299551294898265041}, +{0x2608, 0.0000000000000004718447854656915296800435}, +{0x261d, 0.0000000000000005447031714567174276453443}, +{0x2622, 0.0000000000000005620504062164854985894635}, +{0x26e1, 0.0000000000000015612511283791263849707320}, +{0x2726, 0.0000000000000023037127760971998213790357}, +{0x2731, 0.0000000000000024563684419831588456872851}, +{0x2737, 0.0000000000000025396351688300455862190574}, +{0x2750, 0.0000000000000028865798640254070051014423}, +{0x275c, 0.0000000000000030531133177191804861649871}, +{0x2776, 0.0000000000000034139358007223563618026674}, +{0x2781, 0.0000000000000035804692544161298428662121}, +{0x27c3, 0.0000000000000054123372450476381345652044}, +{0x27e3, 0.0000000000000063005156647477633669041097}, +{0x2804, 0.0000000000000073274719625260331667959690}, +{0x2838, 0.0000000000000102140518265514401718974113}, +{0x2887, 0.0000000000000149880108324396132957190275}, +{0x28e0, 0.0000000000000248689957516035065054893494}, +{0x28fe, 0.0000000000000281996648254789761267602444}, +{0x29b4, 0.0000000000000799360577730112709105014801}, +{0x29d6, 0.0000000000000950350909079133998602628708}, +{0x29f9, 0.0000000000001105782132526655914261937141}, +{0x2a58, 0.0000000000001918465386552270501852035522}, +{0x2aac, 0.0000000000003055333763768430799245834351}, +{0x2aea, 0.0000000000004156675004196586087346076965}, +{0x2b19, 0.0000000000005435651928564766421914100647}, +{0x2b80, 0.0000000000009094947017729282379150390625}, +{0x2bff, 0.0000000000018118839761882554739713668823}, +{0x2c4c, 0.0000000000028990143619012087583541870117}, +{0x2c8d, 0.0000000000040074610296869650483131408691}, +{0x2ccb, 0.0000000000057696070143720135092735290527}, +{0x2cfd, 0.0000000000071906924858922138810157775879}, +{0x2d31, 0.0000000000100612851383630186319351196289}, +{0x2d68, 0.0000000000131876731757074594497680664062}, +{0x2d77, 0.0000000000140403244586195796728134155273}, +{0x2dab, 0.0000000000194404492503963410854339599609}, +{0x2db1, 0.0000000000201225702767260372638702392578}, +{0x2de3, 0.0000000000258069121628068387508392333984}, +{0x2df1, 0.0000000000273985278909094631671905517578}, +{0x2e6a, 0.0000000000532054400537163019180297851562}, +{0x2eaa, 0.0000000000773070496506989002227783203125}, +{0x2ecf, 0.0000000000941327016334980726242065429688}, +{0x2f88, 0.0000000002473825588822364807128906250}, +{0x2fbb, 0.0000000003401510184630751609802246093750}, +{0x2fcd, 0.0000000003728928277269005775451660156250}, +{0x3035, 0.000000000658474164083600044250488281250}, +{0x3065, 0.000000000833097146824002265930175781250}, +{0x30ad, 0.00000000125874066725373268127441406250}, +{0x30ea, 0.0000000017025740817189216613769531250}, +{0x3143, 0.0000000028376234695315361022949218750}, +{0x317d, 0.0000000036816345527768135070800781250}, +{0x31eb, 0.000000006839400157332420349121093750}, +{0x31fa, 0.00000000727595761418342590332031250}, +{0x325b, 0.00000001274747774004936218261718750}, +{0x32da, 0.000000025378540158271789550781250}, +{0x332e, 0.00000004051253199577331542968750}, +{0x3333, 0.000000041676685214042663574218750}, +{0x336e, 0.00000005541369318962097167968750}, +{0x33aa, 0.0000000791624188423156738281250}, +{0x3446, 0.000000184401869773864746093750}, +{0x3456, 0.000000199303030967712402343750}, +{0x345c, 0.00000020489096641540527343750}, +{0x345d, 0.0000002058222889900207519531250}, +{0x350e, 0.0000005289912223815917968750}, +{0x3551, 0.00000077858567237854003906250}, +{0x357c, 0.000000938773155212402343750}, +{0x3684, 0.000003933906555175781250}, +{0x369f, 0.00000473856925964355468750}, +{0x36b2, 0.0000053048133850097656250}, +{0x37ab, 0.000020384788513183593750}, +{0x37c1, 0.000023007392883300781250}, +{0x37e4, 0.0000271797180175781250}, +{0x3814, 0.000035285949707031250}, +{0x3863, 0.00005412101745605468750}, +{0x3869, 0.00005555152893066406250}, +{0x388c, 0.00006675720214843750}, +{0x3895, 0.0000710487365722656250}, +{0x38ab, 0.0000815391540527343750}, +{0x38d0, 0.000099182128906250}, +{0x38e6, 0.000109672546386718750}, +{0x3930, 0.00016784667968750}, +{0x393a, 0.00017738342285156250}, +{0x395f, 0.000212669372558593750}, +{0x3978, 0.000236511230468750}, +{0x397a, 0.00023841857910156250}, +{0x3a1a, 0.000587463378906250}, +{0x3aac, 0.0013122558593750}, +{0x3af3, 0.001853942871093750}, +{0x3bcf, 0.0063171386718750}, +{0x3c1d, 0.009582519531250}, +{0x3c26, 0.01013183593750}, +{0x3c2a, 0.01037597656250}, +{0x3c71, 0.014709472656250}, +{0x3c7a, 0.01525878906250}, +{0x3cef, 0.02917480468750}, +{0x3d0c, 0.03417968750}, +{0x3d5e, 0.054199218750}, +{0x3d61, 0.0549316406250}, +{0x3e47, 0.19433593750}, +{0x3e96, 0.292968750}, +{0x3e9d, 0.3066406250}, +{0x3eb1, 0.3457031250}, +{0x3ef9, 0.4863281250}, +{0x3f7b, 0.980468750}, +{0x3f7d, 0.988281250}, +{0x3fb7, 1.42968750}, +{0x3ff0, 1.8750}, +{0x402d, 2.7031250}, +{0x4042, 3.031250}, +{0x405d, 3.4531250}, +{0x40a6, 5.18750}, +{0x40b1, 5.531250}, +{0x40b9, 5.781250}, +{0x40f2, 7.56250}, +{0x4128, 10.50}, +{0x416d, 14.81250}, +{0x41ef, 29.8750}, +{0x41f5, 30.6250}, +{0x4204, 33.0}, +{0x4237, 45.750}, +{0x429b, 77.50}, +{0x429d, 78.50}, +{0x42ee, 119.0}, +{0x43b4, 360.0}, +{0x43e7, 462.0}, +{0x43f7, 494.0}, +{0x4469, 932.0}, +{0x446d, 948.0}, +{0x447a, 1000.0}, +{0x447f, 1020.0}, +{0x44ca, 1616.0}, +{0x4525, 2640.0}, +{0x458b, 4448.0}, +{0x45a2, 5184.0}, +{0x464b, 12992.0}, +{0x47a0, 81920.0}, +{0x47a2, 82944.0}, +{0x480e, 145408.0}, +{0x4983, 1073152.0}, +{0x49bb, 1531904.0}, +{0x49f4, 1998848.0}, +{0x49fd, 2072576.0}, +{0x4a50, 3407872.0}, +{0x4a72, 3964928.0}, +{0x4aa4, 5373952.0}, +{0x4af1, 7897088.0}, +{0x4b04, 8650752.0}, +{0x4b12, 9568256.0}, +{0x4b13, 9633792.0}, +{0x4b6f, 15663104.0}, +{0x4c12, 38273024.0}, +{0x4c24, 42991616.0}, +{0x4c36, 47710208.0}, +{0x4c46, 51904512.0}, +{0x4c50, 54525952.0}, +{0x4cf0, 125829120.0}, +{0x4d8d, 295698432.0}, +{0x4dcb, 425721856.0}, +{0x4e25, 692060160.0}, +{0x4e91, 1216348160.0}, +{0x4ed0, 1744830464.0}, +{0x4ef3, 2038431744.0}, +{0x4efc, 2113929216.0}, +{0x4f43, 3271557120.0}, +{0x4fac, 5771362304.0}, +{0x4fc2, 6509559808.0}, +{0x4fea, 7851737088.0}, +{0x50a1, 21609054208.0}, +{0x50e1, 30198988800.0}, +{0x50f6, 33017561088.0}, +{0x51ae, 93415538688.0}, +{0x5205, 142807662592.0}, +{0x5218, 163208757248.0}, +{0x521c, 167503724544.0}, +{0x5362, 970662608896.0}, +{0x546f, 4105988734976.0}, +{0x5476, 4226247819264.0}, +{0x54d2, 7215545057280.0}, +{0x5511, 9964324126720.0}, +{0x569d, 86311662780416.0}, +{0x56f9, 136889197658112.0}, +{0x5702, 142936511610880.0}, +{0x570b, 152832116260864.0}, +{0x573a, 204509162766336.0}, +{0x578f, 314460325543936.0}, +{0x5812, 642114790621184.0}, +{0x584e, 905997581287424.0}, +{0x5851, 919191720820736.0}, +{0x5860, 985162418487296.0}, +{0x5907, 2374945115996160.0}, +{0x5938, 3236962232172544.0}, +{0x59e3, 7986852464164864.0}, +{0x5a27, 11751580277669888.0}, +{0x5a5b, 15410754974908416.0}, +{0x5aad, 24347585485471744.0}, +{0x5ab7, 25754960369025024.0}, +{0x5ada, 30680772461461504.0}, +{0x5aef, 33636259716923392.0}, +{0x5b09, 38562071809359872.0}, +{0x5c1f, 179018085187977216.0}, +{0x5d62, 1017813515785732096.0}, +{0x5d70, 1080863910568919040.0}, +{0x5dbb, 1684346260636565504.0}, +{0x5dea, 2107684625609392128.0}, +{0x5e0a, 2485986994308513792.0}, +{0x5e2e, 3134505340649865216.0}, +{0x5e3d, 3404721318292094976.0}, +{0x5ea7, 6016809102166982656.0}, +{0x5f1f, 11457157452030541824.0}, +{0x5f51, 15060037153926938624.0}, +{0x5f64, 16429131440647569408.0}, +{0x5f99, 22049623775605948416.0}, +{0x5fda, 31417111000536580096.0}, +{0x5ffc, 36317027395115679744.0}, +{0x604a, 58222535982645772288.0}, +{0x607f, 73498745918686494720.0}, +{0x608a, 79551583817872441344.0}, +{0x60c1, 111256925194560733184.0}, +{0x60eb, 135468276791304519680.0}, +{0x614b, 234043065435189936128.0}, +{0x616c, 272089475087215886336.0}, +{0x61cc, 470391973879593566208.0}, +{0x6270, 1106804644422573096960.0}, +{0x6291, 1337388945343942492160.0}, +{0x62bd, 1743217314965552627712.0}, +{0x630c, 2582544170319337226240.0}, +{0x6325, 3043712772162076016640.0}, +{0x633f, 3523328118078524358656.0}, +{0x63a0, 5902958103587056517120.0}, +{0x63b3, 6603934378388019478528.0}, +{0x63e0, 8264141345021879123968.0}, +{0x63eb, 8669969714643489259520.0}, +{0x63fc, 9297159013149614014464.0}, +{0x6427, 12322425041237980479488.0}, +{0x6469, 17192365476697302106112.0}, +{0x648c, 20660353362554697809920.0}, +{0x64b3, 26415737513552077914112.0}, +{0x64c3, 28776920754986900520960.0}, +{0x64ea, 34532304905984280625152.0}, +{0x64ed, 34975026763753309863936.0}, +{0x6503, 38664375578495220187136.0}, +{0x6531, 52241179216745450176512.0}, +{0x6566, 67884018191251149946880.0}, +{0x657b, 74082124200017559289856.0}, +{0x65af, 103301766812773489049600.0}, +{0x65b5, 106843541674925722959872.0}, +{0x65d9, 128094190847839126421504.0}, +{0x6611, 171185785004024638996480.0}, +{0x6613, 173546968245459461603328.0}, +{0x6635, 213687083349851445919744.0}, +{0x6699, 361261035939527858847744.0}, +{0x66c0, 453347182355485940514816.0}, +{0x6768, 1095589024025757689577472.0}, +{0x6798, 1435599410792372144963584.0}, +{0x67d3, 1992838655770990280179712.0}, +{0x67d6, 2021172854668208151461888.0}, +{0x681d, 2965646151242137194201088.0}, +{0x6854, 4004566777473459141214208.0}, +{0x6857, 4061235175267894883778560.0}, +{0x6876, 4646808619143730890276864.0}, +{0x689b, 5855734438758360064983040.0}, +{0x68ed, 8953606851520847325167616.0}, +{0x68fc, 9520290829465204750811136.0}, +{0x6908, 10275869466724347985002496.0}, +{0x6aaa, 102758694667243479850024960.0}, +{0x6ad0, 125728285239921434169442304.0}, +{0x6b26, 200681686056028443001225216.0}, +{0x6b60, 270799383593676935134183424.0}, +{0x6bd1, 505330992598914995027181568.0}, +{0x6c4b, 981647765527078889861414912.0}, +{0x6cb4, 1740853180245066011576893440.0}, +{0x6d68, 4487532642409503496509325312.0}, +{0x6d86, 5183873914507529901140082688.0}, +{0x6ead, 26770453349546348444693561344.0}, +{0x6f07, 41780476325881584277845442560.0}, +{0x6f1e, 48898631551772520858515406848.0}, +{0x6f69, 72110007288373401012873986048.0}, +{0x6fb5, 112033573555326914878370742272.0}, +{0x70a0, 396140812571321687967719751680.0}, +{0x713a, 921027389228322924524948422656.0}, +{0x713b, 925979149385464445624544919552.0}, +{0x715c, 1089387234571134641911229317120.0}, +{0x7178, 1228036518971097232699931230208.0}, +{0x719a, 1525142128399588498675721043968.0}, +{0x719e, 1564756209656720667472493019136.0}, +{0x71a5, 1634080851856701962866843975680.0}, +{0x71c4, 1941089981599476271041826783232.0}, +{0x71e0, 2218388550399401452619230609408.0}, +{0x721b, 3070091297427743081749828075520.0}, +{0x7333, 14181841090053316429244367110144.0}, +{0x734c, 16162545152909924869082965868544.0}, +{0x7354, 16796370453024039569831317471232.0}, +{0x7376, 19490127978509027048011811782656.0}, +{0x73fc, 39930993907189226147146150969344.0}, +{0x745d, 70037695662609674432692852097024.0}, +{0x74f1, 152751897327501642880352736247808.0}, +{0x7538, 233247710441994209875393389789184.0}, +{0x7539, 234515361042222439276890092994560.0}, +{0x7562, 286489035651579844738254924414976.0}, +{0x7563, 287756686251808074139751627620352.0}, +{0x759f, 403112890872576949675951619309568.0}, +{0x760d, 714954938528721382444140607832064.0}, +{0x768e, 1440051081859268600100254841307136.0}, +{0x7691, 1470474696264746105736175718236160.0}, +{0x770c, 2839537344511233859352615180042240.0}, +{0x771c, 3164055898169660586135771200618496.0}, +{0x776a, 4746083847254490879203656800927744.0}, +{0x7773, 4928625533687355913019182062501888.0}, +{0x7798, 6165852519510107808879964390948864.0}, +{0x77ca, 8194093479875274851274689519550464.0}, +{0x77db, 8883695406399431645688896063275008.0}, +{0x77eb, 9532732513716285099255208104427520.0}, +{0x7855, 17280612982311223201203058095685632.0}, +{0x788c, 22716298756089870874820921440337920.0}, +{0x789a, 24987928631698857962303013584371712.0}, +{0x789b, 25150187908528071325694591594659840.0}, +{0x78de, 36021559456085366672930318283964416.0}, +{0x7900, 41538374868278621028243970633760768.0}, +{0x7915, 48353264495105582290690247065862144.0}, +{0x791a, 49975857263397715924606027168743424.0}, +{0x7999, 99302677419478578395645742296334336.0}, +{0x79c6, 128509347248736983806129784148197376.0}, +{0x79d9, 140841052287757199423889712930095104.0}, +{0x7a28, 218076468058462760398280845827244032.0}, +{0x7a2d, 224566839131631294933943966238769152.0}, +{0x7a4f, 268701362429177329776453185037139968.0}, +{0x7aa2, 420576045541321037910970202666827776.0}, +{0x7aa9, 438749084546192934610826939819098112.0}, +{0x7b14, 768459935063154489022513456724574208.0}, +{0x7b2e, 903459653385060007364306361284296704.0}, +{0x7b4b, 1054036262282570008591690754831679488.0}, +{0x7b93, 1526535276409239322787965920790708224.0}, +{0x7b99, 1588842838711657254330331876741349376.0}, +{0x7bbe, 1973072806243234498841588605103636480.0}, +{0x7bc0, 1993841993677373809355710590420516864.0}, +{0x7c49, 4174606674262001413338519048692957184.0}, +{0x7c7f, 5296142795705524181101106255804497920.0}, +{0x7c98, 6313832979978350396293083536331636736.0}, +{0x7cda, 9055365721284739384157185598159847424.0}, +{0x7d06, 11132284464698670435569384129847885824.0}, +{0x7d1d, 13043049708639487002868606779000881152.0}, +{0x7d3d, 15701505700209318748676220899561570304.0}, +{0x7d4c, 16947656946257677379523540018574393344.0}, +{0x7d58, 17944577943096364284201395313784651776.0}, +{0x7d85, 22098415429924226387025792377160728576.0}, +{0x7da9, 28079941410956347815092924148422279168.0}, +{0x7db1, 29409169406741263687996731208702623744.0}, +{0x7db2, 29575322906214378172109707091237666816.0}, +{0x7dfc, 41870681867224849996469922398830854144.0}, +{0x7e0f, 47519900849310742456311102405022318592.0}, +{0x7e15, 49513742842988116265666812995442835456.0}, +{0x7e50, 69119855780815625390997967134577917952.0}, +{0x7e55, 70781390775546770232127725959928348672.0}, +{0x7e73, 80750600743933639278906278912030932992.0}, +{0x7f08, 180775007426748558714917760198126862336.0}, +{0x7f67, 307051667026315566640779430924759597056.0}, +{0x7f6a, 311039351013670314259490852105600630784.0}, +{0x7f7b, 333636226942013884098855572130366488576.0}, +{0x7f7e, 337623910929368631717566993311207522304.0}, +{0x7f9a, std::numeric_limits::quiet_NaN()}, +{0x8022, -0.0000000000000000000000000000000000000031}, +{0x8075, -0.0000000000000000000000000000000000000107}, +{0x807d, -0.0000000000000000000000000000000000000115}, +{0x8095, -0.0000000000000000000000000000000000000137}, +{0x80c6, -0.0000000000000000000000000000000000000182}, +{0x80fc, -0.0000000000000000000000000000000000000231}, +{0x814d, -0.0000000000000000000000000000000000000377}, +{0x8181, -0.0000000000000000000000000000000000000474}, +{0x818a, -0.0000000000000000000000000000000000000507}, +{0x819c, -0.0000000000000000000000000000000000000573}, +{0x81be, -0.0000000000000000000000000000000000000698}, +{0x8201, -0.0000000000000000000000000000000000000948}, +{0x8232, -0.0000000000000000000000000000000000001308}, +{0x8241, -0.0000000000000000000000000000000000001418}, +{0x82c3, -0.0000000000000000000000000000000000002865}, +{0x82f2, -0.0000000000000000000000000000000000003556}, +{0x82fd, -0.0000000000000000000000000000000000003718}, +{0x8340, -0.0000000000000000000000000000000000005642}, +{0x8349, -0.0000000000000000000000000000000000005907}, +{0x835b, -0.0000000000000000000000000000000000006436}, +{0x83a0, -0.0000000000000000000000000000000000009404}, +{0x83b6, -0.0000000000000000000000000000000000010697}, +{0x83ca, -0.0000000000000000000000000000000000011872}, +{0x842e, -0.0000000000000000000000000000000000020454}, +{0x8445, -0.0000000000000000000000000000000000023157}, +{0x847d, -0.0000000000000000000000000000000000029740}, +{0x8486, -0.0000000000000000000000000000000000031503}, +{0x84bc, -0.0000000000000000000000000000000000044199}, +{0x84da, -0.0000000000000000000000000000000000051252}, +{0x84e2, -0.0000000000000000000000000000000000053132}, +{0x84fd, -0.0000000000000000000000000000000000059480}, +{0x8546, -0.0000000000000000000000000000000000093099}, +{0x8594, -0.0000000000000000000000000000000000139179}, +{0x859a, -0.0000000000000000000000000000000000144821}, +{0x85e3, -0.0000000000000000000000000000000000213470}, +{0x85e5, -0.0000000000000000000000000000000000215351}, +{0x86ee, -0.0000000000000000000000000000000000895256}, +{0x86ef, -0.0000000000000000000000000000000000899018}, +{0x871d, -0.0000000000000000000000000000000001181137}, +{0x876b, -0.0000000000000000000000000000000001767944}, +{0x8783, -0.0000000000000000000000000000000001971069}, +{0x87a9, -0.0000000000000000000000000000000002542829}, +{0x87fb, -0.0000000000000000000000000000000003776628}, +{0x8822, -0.0000000000000000000000000000000004875010}, +{0x885e, -0.0000000000000000000000000000000006680569}, +{0x888a, -0.0000000000000000000000000000000008305573}, +{0x8891, -0.0000000000000000000000000000000008726870}, +{0x891c, -0.0000000000000000000000000000000018777817}, +{0x89a0, -0.0000000000000000000000000000000038518599}, +{0x89d0, -0.0000000000000000000000000000000050074179}, +{0x8a05, -0.0000000000000000000000000000000064037171}, +{0x8a3a, -0.0000000000000000000000000000000089555742}, +{0x8a3f, -0.0000000000000000000000000000000091963155}, +{0x8a7e, -0.0000000000000000000000000000000122296551}, +{0x8ae4, -0.0000000000000000000000000000000219556014}, +{0x8afb, -0.0000000000000000000000000000000241704208}, +{0x8b18, -0.0000000000000000000000000000000292741352}, +{0x8b86, -0.0000000000000000000000000000000516149225}, +{0x8ba2, -0.0000000000000000000000000000000624001302}, +{0x8be0, -0.0000000000000000000000000000000862816615}, +{0x8c00, -0.0000000000000000000000000000000986076132}, +{0x8c34, -0.0000000000000000000000000000001386669560}, +{0x8c9f, -0.0000000000000000000000000000002449782889}, +{0x8caa, -0.0000000000000000000000000000002619264724}, +{0x8cb3, -0.0000000000000000000000000000002757931680}, +{0x8d34, -0.0000000000000000000000000000005546678240}, +{0x8d48, -0.0000000000000000000000000000006162975822}, +{0x8d58, -0.0000000000000000000000000000006656013888}, +{0x8d5f, -0.0000000000000000000000000000006871718042}, +{0x8d6a, -0.0000000000000000000000000000007210681712}, +{0x8d7f, -0.0000000000000000000000000000007857794173}, +{0x8d91, -0.0000000000000000000000000000008936314942}, +{0x8df0, -0.0000000000000000000000000000014791141973}, +{0x8e06, -0.0000000000000000000000000000016516775203}, +{0x8e1a, -0.0000000000000000000000000000018981965532}, +{0x8e9f, -0.0000000000000000000000000000039196526228}, +{0x8ed1, -0.0000000000000000000000000000051522477872}, +{0x8f1d, -0.0000000000000000000000000000077406976325}, +{0x8f23, -0.0000000000000000000000000000080365204719}, +{0x8f4f, -0.0000000000000000000000000000102058879613}, +{0x901b, -0.0000000000000000000000000000305683600773}, +{0x9059, -0.0000000000000000000000000000427957041082}, +{0x90c1, -0.0000000000000000000000000000761250773538}, +{0x911c, -0.0000000000000000000000000001230623012145}, +{0x9131, -0.0000000000000000000000000001396283802241}, +{0x919d, -0.0000000000000000000000000002477023242394}, +{0x9243, -0.0000000000000000000000000006153115060724}, +{0x9268, -0.0000000000000000000000000007320629200451}, +{0x92b7, -0.0000000000000000000000000011548923652436}, +{0x9308, -0.0000000000000000000000000017165613297609}, +{0x9319, -0.0000000000000000000000000019311314959810}, +{0x9353, -0.0000000000000000000000000026631944160261}, +{0x9411, -0.0000000000000000000000000073206292004510}, +{0x941e, -0.0000000000000000000000000079769614735949}, +{0x943d, -0.0000000000000000000000000095420615095534}, +{0x9456, -0.0000000000000000000000000108042389579070}, +{0x947d, -0.0000000000000000000000000127732357773386}, +{0x94f8, -0.0000000000000000000000000250416005753358}, +{0x95b2, -0.0000000000000000000000000718936274582221}, +{0x9629, -0.0000000000000000000000001365171128139274}, +{0x965a, -0.0000000000000000000000001760989975942969}, +{0x966c, -0.0000000000000000000000001906392817993306}, +{0x971a, -0.0000000000000000000000004976008372389307}, +{0x9728, -0.0000000000000000000000005428372769879244}, +{0x977b, -0.0000000000000000000000008110247412141014}, +{0x97b9, -0.0000000000000000000000011955344790805478}, +{0x98f2, -0.0000000000000000000000062555533824322718}, +{0x9912, -0.0000000000000000000000075480230895463775}, +{0x9973, -0.0000000000000000000000125628055531491078}, +{0x9978, -0.0000000000000000000000128212994945719290}, +{0x9994, -0.0000000000000000000000153028413322310120}, +{0x9a97, -0.0000000000000000000000624521362477535895}, +{0x9aa0, -0.0000000000000000000000661744490042422140}, +{0x9aaf, -0.0000000000000000000000723783035983899216}, +{0x9ac4, -0.0000000000000000000000810637000301967121}, +{0x9ad9, -0.0000000000000000000000897490964620035027}, +{0x9b02, -0.0000000000000000000001075334796318935977}, +{0x9b19, -0.0000000000000000000001265586337206132343}, +{0x9b75, -0.0000000000000000000002026592500754917803}, +{0x9ba8, -0.0000000000000000000002779326858178172988}, +{0x9bb5, -0.0000000000000000000002994393817441960183}, +{0x9bc1, -0.0000000000000000000003192917164454686825}, +{0x9be2, -0.0000000000000000000003738856368739685090}, +{0x9c65, -0.0000000000000000000007576974410985733502}, +{0x9c76, -0.0000000000000000000008139457227521792321}, +{0x9cb0, -0.0000000000000000000011646703024746629662}, +{0x9cef, -0.0000000000000000000015815693312013889144}, +{0x9d01, -0.0000000000000000000017073007843094491209}, +{0x9d33, -0.0000000000000000000023690452743518712608}, +{0x9d91, -0.0000000000000000000038381180422460484114}, +{0x9db1, -0.0000000000000000000046851509895003487505}, +{0x9de7, -0.0000000000000000000061145190879919805726}, +{0x9dea, -0.0000000000000000000061939284267970712294}, +{0x9e48, -0.0000000000000000000105879118406787542384}, +{0x9fb7, -0.0000000000000000000775035146737684810248}, +{0x9ff7, -0.0000000000000000001046085689859060918749}, +{0xa009, -0.0000000000000000001160435137738391464524}, +{0xa0a4, -0.0000000000000000002778268066994105112144}, +{0xa217, -0.0000000000000000020464316005663896191891}, +{0xa225, -0.0000000000000000022361669807513528951404}, +{0xa22f, -0.0000000000000000023716922523120409493913}, +{0xa241, -0.0000000000000000026156377411212794470430}, +{0xa281, -0.0000000000000000034965520062657517996740}, +{0xa29a, -0.0000000000000000041741783640691920709287}, +{0xa2ce, -0.0000000000000000055836411883003478351384}, +{0xa2d4, -0.0000000000000000057462715141731735002395}, +{0xa2f6, -0.0000000000000000066678433607858522691458}, +{0xa394, -0.0000000000000000160461921527854656233103}, +{0xa3f3, -0.0000000000000000263461127913977577463811}, +{0xa403, -0.0000000000000000284060969191202161709953}, +{0xa416, -0.0000000000000000325260651745651330202236}, +{0xa432, -0.0000000000000000385975973404839578506653}, +{0xa46c, -0.0000000000000000511743425413158092851518}, +{0xa482, -0.0000000000000000563785129692462305683875}, +{0xa4b0, -0.0000000000000000763278329429795121541247}, +{0xa4d4, -0.0000000000000000919403442267707760038320}, +{0xa4dc, -0.0000000000000000954097911787243901926558}, +{0xa52c, -0.0000000000000001491862189340054101194255}, +{0xa595, -0.0000000000000002584737979205442570673767}, +{0xa604, -0.0000000000000004579669976578770729247481}, +{0xa607, -0.0000000000000004683753385137379154912196}, +{0xa62e, -0.0000000000000006036837696399288688553497}, +{0xa641, -0.0000000000000006696032617270475384430028}, +{0xa67b, -0.0000000000000008708311849403571613947861}, +{0xa708, -0.0000000000000018873791418627661187201738}, +{0xa72f, -0.0000000000000024286128663675299321766943}, +{0xa74c, -0.0000000000000028310687127941491780802608}, +{0xa779, -0.0000000000000034555691641457997320685536}, +{0xa7a0, -0.0000000000000044408920985006261616945267}, +{0xa81d, -0.0000000000000087152507433074788423255086}, +{0xa822, -0.0000000000000089928064994637679774314165}, +{0xa83e, -0.0000000000000105471187339389871340245008}, +{0xa8c6, -0.0000000000000219824158875780995003879070}, +{0xa8cd, -0.0000000000000227595720048157090786844492}, +{0xa8fc, -0.0000000000000279776202205539448186755180}, +{0xa909, -0.0000000000000304201108747292892076075077}, +{0xa911, -0.0000000000000321964677141295396722853184}, +{0xa934, -0.0000000000000399680288865056354552507401}, +{0xa9b5, -0.0000000000000803801469828613335266709328}, +{0xa9e9, -0.0000000000001034727858950645895674824715}, +{0xaa3f, -0.0000000000001696420781627239193767309189}, +{0xab0d, -0.0000000000005009326287108706310391426086}, +{0xab40, -0.0000000000006821210263296961784362792969}, +{0xab44, -0.0000000000006963318810448981821537017822}, +{0xab4a, -0.0000000000007176481631177011877298355103}, +{0xab69, -0.0000000000008277822871605167165398597717}, +{0xab6a, -0.0000000000008313350008393172174692153931}, +{0xab85, -0.0000000000009450218385609332472085952759}, +{0xabba, -0.0000000000013216094885137863457202911377}, +{0xac1f, -0.0000000000022595258997171185910701751709}, +{0xac94, -0.0000000000042064129956997931003570556641}, +{0xaca6, -0.0000000000047180037654470652341842651367}, +{0xacbf, -0.0000000000054285465012071654200553894043}, +{0xacf2, -0.0000000000068780536821577697992324829102}, +{0xad7a, -0.0000000000142108547152020037174224853516}, +{0xadaf, -0.0000000000198951966012828052043914794922}, +{0xadfd, -0.0000000000287627699435688555240631103516}, +{0xae3e, -0.0000000000432009983342140913009643554688}, +{0xae45, -0.0000000000447926140623167157173156738281}, +{0xae8a, -0.0000000000627551344223320484161376953125}, +{0xaeda, -0.0000000000991349224932491779327392578125}, +{0xafa2, -0.000000000294676283374428749084472656250}, +{0xaffc, -0.00000000045838532969355583190917968750}, +{0xb016, -0.00000000054569682106375694274902343750}, +{0xb086, -0.0000000009749783203005790710449218750}, +{0xb09d, -0.00000000114232534542679786682128906250}, +{0xb0bd, -0.00000000137515598908066749572753906250}, +{0xb0d1, -0.00000000152067514136433601379394531250}, +{0xb121, -0.0000000023428583517670631408691406250}, +{0xb13a, -0.000000002706656232476234436035156250}, +{0xb259, -0.00000001263106241822242736816406250}, +{0xb25c, -0.000000012805685400962829589843750}, +{0xb2fa, -0.000000029103830456733703613281250}, +{0xb3e2, -0.0000001052394509315490722656250}, +{0xb3ff, -0.00000011874362826347351074218750}, +{0xb44f, -0.0000001927837729454040527343750}, +{0xb4c9, -0.000000374391674995422363281250}, +{0xb4e9, -0.000000433996319770812988281250}, +{0xb4fa, -0.00000046566128730773925781250}, +{0xb5cc, -0.00000151991844177246093750}, +{0xb5df, -0.0000016614794731140136718750}, +{0xb630, -0.00000262260437011718750}, +{0xb648, -0.000002980232238769531250}, +{0xb717, -0.0000090003013610839843750}, +{0xb76f, -0.0000142455101013183593750}, +{0xb78a, -0.00001645088195800781250}, +{0xb7f7, -0.000029444694519042968750}, +{0xb86d, -0.00005650520324707031250}, +{0xb885, -0.0000634193420410156250}, +{0xb8cc, -0.00009727478027343750}, +{0xb8d5, -0.0001015663146972656250}, +{0xb95a, -0.00020790100097656250}, +{0xb967, -0.000220298767089843750}, +{0xb9fc, -0.000480651855468750}, +{0xba87, -0.001029968261718750}, +{0xbac9, -0.001533508300781250}, +{0xbb04, -0.002014160156250}, +{0xbb7b, -0.00382995605468750}, +{0xbbb1, -0.0054016113281250}, +{0xbc7c, -0.0153808593750}, +{0xbc8d, -0.01721191406250}, +{0xbcb7, -0.02233886718750}, +{0xbce7, -0.02819824218750}, +{0xbcfd, -0.03088378906250}, +{0xbd14, -0.03613281250}, +{0xbd44, -0.04785156250}, +{0xbd75, -0.0598144531250}, +{0xbd7e, -0.062011718750}, +{0xbe39, -0.18066406250}, +{0xbebd, -0.3691406250}, +{0xbec2, -0.378906250}, +{0xbee7, -0.4511718750}, +{0xbf16, -0.58593750}, +{0xbf74, -0.9531250}, +{0xbf86, -1.0468750}, +{0xbfab, -1.33593750}, +{0xbfc1, -1.50781250}, +{0xbfc2, -1.5156250}, +{0xbfe1, -1.75781250}, +{0xc01e, -2.468750}, +{0xc02d, -2.7031250}, +{0xc04a, -3.156250}, +{0xc090, -4.50}, +{0xc095, -4.656250}, +{0xc0ce, -6.43750}, +{0xc105, -8.31250}, +{0xc175, -15.31250}, +{0xc18f, -17.8750}, +{0xc1b3, -22.3750}, +{0xc1b6, -22.750}, +{0xc2a0, -80.0}, +{0xc327, -167.0}, +{0xc352, -210.0}, +{0xc380, -256.0}, +{0xc3bb, -374.0}, +{0xc3c4, -392.0}, +{0xc464, -912.0}, +{0xc4ad, -1384.0}, +{0xc4c5, -1576.0}, +{0xc4e7, -1848.0}, +{0xc540, -3072.0}, +{0xc569, -3728.0}, +{0xc56b, -3760.0}, +{0xc57a, -4000.0}, +{0xc5b4, -5760.0}, +{0xc5d0, -6656.0}, +{0xc5d2, -6720.0}, +{0xc5db, -7008.0}, +{0xc5f5, -7840.0}, +{0xc643, -12480.0}, +{0xc655, -13632.0}, +{0xc690, -18432.0}, +{0xc6bc, -24064.0}, +{0xc761, -57600.0}, +{0xc7b4, -92160.0}, +{0xc8a9, -346112.0}, +{0xc8d1, -428032.0}, +{0xc91b, -634880.0}, +{0xca23, -2670592.0}, +{0xca44, -3211264.0}, +{0xcabe, -6225920.0}, +{0xcac8, -6553600.0}, +{0xcb88, -17825792.0}, +{0xcbc4, -25690112.0}, +{0xcbf5, -32112640.0}, +{0xcbfc, -33030144.0}, +{0xcc6e, -62390272.0}, +{0xcc74, -63963136.0}, +{0xcce7, -121110528.0}, +{0xcceb, -123207680.0}, +{0xccee, -124780544.0}, +{0xcd4e, -216006656.0}, +{0xcd5c, -230686720.0}, +{0xcdfd, -530579456.0}, +{0xce03, -549453824.0}, +{0xce35, -759169024.0}, +{0xce6b, -985661440.0}, +{0xce94, -1241513984.0}, +{0xceab, -1434451968.0}, +{0xceb5, -1518338048.0}, +{0xcee0, -1879048192.0}, +{0xcf36, -3053453312.0}, +{0xcf4e, -3456106496.0}, +{0xcfe5, -7683964928.0}, +{0xd023, -10938744832.0}, +{0xd055, -14294188032.0}, +{0xd059, -14562623488.0}, +{0xd0ac, -23085449216.0}, +{0xd0b9, -24830279680.0}, +{0xd0bd, -25367150592.0}, +{0xd14a, -54223962112.0}, +{0xd204, -141733920768.0}, +{0xd216, -161061273600.0}, +{0xd26d, -254476812288.0}, +{0xd37b, -1078036791296.0}, +{0xd37c, -1082331758592.0}, +{0xd471, -4140348473344.0}, +{0xd4a6, -5703716569088.0}, +{0xd4d2, -7215545057280.0}, +{0xd4d3, -7249904795648.0}, +{0xd5a6, -22814866276352.0}, +{0xd5c2, -26663156973568.0}, +{0xd67b, -68994354642944.0}, +{0xd714, -162727720910848.0}, +{0xd754, -233096465088512.0}, +{0xd777, -271579372060672.0}, +{0xd7a5, -362838837166080.0}, +{0xd7bd, -415615395299328.0}, +{0xd809, -602532372021248.0}, +{0xd819, -672901116198912.0}, +{0xd827, -734473767354368.0}, +{0xd82e, -765260092932096.0}, +{0xd859, -954376092909568.0}, +{0xd8a6, -1460151441686528.0}, +{0xd8fc, -2216615441596416.0}, +{0xd93e, -3342515348439040.0}, +{0xd97e, -4468415255281664.0}, +{0xd9a7, -5875790138834944.0}, +{0xd9e0, -7881299347898368.0}, +{0xda46, -13933011347177472.0}, +{0xda4e, -14495961300598784.0}, +{0xda6e, -16747761114284032.0}, +{0xda83, -18436610974547968.0}, +{0xda8e, -19984723346456576.0}, +{0xdb78, -69805794224242688.0}, +{0xdb81, -72620543991349248.0}, +{0xdbaa, -95701492081623040.0}, +{0xdc01, -145241087982698496.0}, +{0xdc2a, -191402984163246080.0}, +{0xdc50, -234187180623265792.0}, +{0xdcf1, -542683755098144768.0}, +{0xdcf9, -560698153607626752.0}, +{0xde68, -4179340454199820288.0}, +{0xdf9c, -22481969339833516032.0}, +{0xdfa6, -23923121220592074752.0}, +{0xdff4, -35164105890508832768.0}, +{0xe018, -43811017175060185088.0}, +{0xe0b2, -102610013910009380864.0}, +{0xe0d9, -125091983249842896896.0}, +{0xe0ff, -146997491837372989440.0}, +{0xe113, -169479461177206505472.0}, +{0xe137, -210984635343052996608.0}, +{0xe1ae, -401216683603182747648.0}, +{0xe261, -1037629354146162278400.0}, +{0xe277, -1139086446551564812288.0}, +{0xe296, -1383505805528216371200.0}, +{0xe2a6, -1531079758117892784128.0}, +{0xe2d0, -1918461383665793368064.0}, +{0xe2dc, -2029141848108050677760.0}, +{0xe2e2, -2084482080329179332608.0}, +{0xe327, -3080606260309495119872.0}, +{0xe336, -3357307421415138394112.0}, +{0xe34d, -3781582535110458081280.0}, +{0xe3e5, -8448608785758974640128.0}, +{0xe457, -15864199903390214389760.0}, +{0xe496, -22136092888451461939200.0}, +{0xe498, -22431240793630814765056.0}, +{0xe51c, -46043073207979040833536.0}, +{0xe53d, -55782954078897684086784.0}, +{0xe547, -58734433130691212345344.0}, +{0xe59a, -90905554795240670363648.0}, +{0xe5ae, -102711471002414783397888.0}, +{0xe5e8, -136948628003219711197184.0}, +{0xe5ed, -139900107055013239455744.0}, +{0xe6f5, -578489894151531538677760.0}, +{0xe730, -831136500985057557610496.0}, +{0xe73c, -887804898779493300174848.0}, +{0xe743, -920861464159580816670720.0}, +{0xe792, -1378931012997936402399232.0}, +{0xe82c, -3248988140214315907022848.0}, +{0xe899, -5780176575032445741563904.0}, +{0xe89a, -5817955506895402903273472.0}, +{0xe8eb, -8878048987794933001748480.0}, +{0xe8ed, -8953606851520847325167616.0}, +{0xe90d, -10653658785353919602098176.0}, +{0xe953, -15942709246167922241437696.0}, +{0xe9a5, -24934095029551726728314880.0}, +{0xea47, -60144059525827801441632256.0}, +{0xeaa2, -97922991388784963151200256.0}, +{0xeae1, -136004154706645782154444800.0}, +{0xeb36, -220024499169862509796524032.0}, +{0xeb58, -261127977036759901736534016.0}, +{0xeb85, -321574268017491360471842816.0}, +{0xec33, -865590886844074489089622016.0}, +{0xec5e, -1073526127817790707139084288.0}, +{0xecc6, -1914938498269572612734582784.0}, +{0xecd2, -2030995376952577013506375680.0}, +{0xed02, -2514565704798428683388846080.0}, +{0xed5f, -4313447324384996895351635968.0}, +{0xed61, -4352132950612665028942233600.0}, +{0xedb2, -6886041468524927779126378496.0}, +{0xedda, -8433466517631653122750283776.0}, +{0xeded, -9168493415957347660971638784.0}, +{0xee2f, -13539969179683846756709171200.0}, +{0xef22, -50136571591057901133414531072.0}, +{0xef24, -50755541610700591270864093184.0}, +{0xef46, -61278031944626323607506649088.0}, +{0xef5a, -67467732141053224982002270208.0}, +{0xef67, -71491037268730710875424423936.0}, +{0xefc6, -122556063889252647215013298176.0}, +{0xf003, -162170145146384816011785273344.0}, +{0xf0a3, -403568452807033969617114497024.0}, +{0xf0b7, -453086054378449180613079465984.0}, +{0xf0e1, -557073017678421123704605900800.0}, +{0xf14d, -1015110832214011825417281863680.0}, +{0xf18c, -1386492843999625907887019130880.0}, +{0xf1c1, -1911379420656627144444247801856.0}, +{0xf21d, -3109705378684875250546600050688.0}, +{0xf22a, -3367196906856234347725617889280.0}, +{0xf22c, -3406810988113366516522389864448.0}, +{0xf239, -3664302516284725613701407703040.0}, +{0xf240, -3802951800684688204490109616128.0}, +{0xf267, -4575426385198765496027163131904.0}, +{0xf270, -4753689750855860255612637020160.0}, +{0xf27f, -5050795360284351521588426833920.0}, +{0xf2df, -8833940120340473641680150462464.0}, +{0xf2f8, -9824292151768777861599449841664.0}, +{0xf335, -14340297415081845104431455010816.0}, +{0xf368, -18380933703309326321702196477952.0}, +{0xf3ba, -29472876455306333584798349524992.0}, +{0xf3c1, -30582070730506034311107964829696.0}, +{0xf418, -48170722808672717256874721804288.0}, +{0xf435, -57361189660327380417725820043264.0}, +{0xf494, -93806144416888975710756037197824.0}, +{0xf49b, -98242921517687778615994498416640.0}, +{0xf4a0, -101412048018258352119736256430080.0}, +{0xf4ec, -149582770826931069376610978234368.0}, +{0xf50a, -174935782831495657406545042341888.0}, +{0xf563, -287756686251808074139751627620352.0}, +{0xf583, -332124457259796103192136239808512.0}, +{0xf5a0, -405648192073033408478945025720320.0}, +{0xf5f0, -608472288109550112718417538580480.0}, +{0xf60c, -709884336127808464838153795010560.0}, +{0xf614, -750449155335111805686048297582592.0}, +{0xf6d9, -2200641441996206240998276764532736.0}, +{0xf6f2, -2454171562041852121297617405607936.0}, +{0xf700, -2596148429267413814265248164610048.0}, +{0xf730, -3569704090242693994614716226338816.0}, +{0xf77b, -5090884810516569276410760072790016.0}, +{0xf7a0, -6490371073168534535663120411525120.0}, +{0xf7ae, -7058278542070781307533643447533568.0}, +{0xf7da, -8843130587192128304841001560702976.0}, +{0xf7f2, -9816686248167408485190469622431744.0}, +{0xf7f3, -9857251067374711826038364125003776.0}, +{0xf7fa, -10141204801825835211973625643008000.0}, +{0xf831, -14359945999385382660154653910499328.0}, +{0xf84d, -16631575874994369747636746054533120.0}, +{0xf85c, -17848520451213469973073581131694080.0}, +{0xf8ac, -27908595614624698503351417769558016.0}, +{0xf90e, -46081634619496595203208154921828352.0}, +{0xf93f, -61983043748759504815582799930064896.0}, +{0xf97c, -81778675521923535149355317185216512.0}, +{0xf98e, -92163269238993190406416309843656704.0}, +{0xf9dc, -142788163609707759784588649053552640.0}, +{0xf9e7, -149927571790193147773818081506230272.0}, +{0xfa00, -166153499473114484112975882535043072.0}, +{0xfa45, -255720620282840260705126944214089728.0}, +{0xfa78, -321922405229159312968890772411645952.0}, +{0xfae3, -589325693443702935838211333366480896.0}, +{0xfb2b, -887882762809455524478714872296636416.0}, +{0xfb59, -1126728418302057595391117703440760832.0}, +{0xfb82, -1349997183219055183417929045597224960.0}, +{0xfb94, -1536919870126308978045026913449148416.0}, +{0xfb96, -1557689057560448288559148898766028800.0}, +{0xfb9e, -1640765807297005530615636840033550336.0}, +{0xfbad, -1796534713053050359471551729910153216.0}, +{0xfbc2, -2014611181111513119869832575737397248.0}, +{0xfbde, -2305379805189463467067540370173722624.0}, +{0xfbfd, -2627302210418622780036431142585368576.0}, +{0xfc37, -3800761300447493824084323312989110272.0}, +{0xfd39, -15369198701263089780450269134491484160.0}, +{0xfd4a, -16781503446784562895410564136039350272.0}, +{0xfd84, -21932261930451111902912816494625685504.0}, +{0xfdcc, -33895313892515354759047080037148786688.0}, +{0xff1b, -206030339346661960300090094343453409280.0}, +{0xff45, -261857915169628426962049990875227881472.0}, +{0xff51, -277808651119047417436895675598592016384.0} +}; + +// TEST_CASE(clang_bf16) { + +// std::set samples = {0}; +// auto ns = migraphx::range(1, 65535); +// std::sample(ns.begin(), +// ns.end(), +// std::inserter(samples, samples.begin()), +// 1022, +// std::mt19937{std::random_device{}()}); +// samples.insert(65536); + + +// for(uint16_t i : samples) +// { + +// float f = migraphx::bit_cast<__bf16>(i); + +// std::cout << "{0x" << std::hex << std::setw(4) << std::setfill('0') << i << ", "; + +// if(std::isfinite(f)) +// { +// std::cout << std::fixed << std::setprecision(40) << static_cast(f); +// } +// else if(std::isinf(f)) +// { +// if(f < 0) +// std::cout << "-"; +// std::cout << "std::numeric_limits::infinity()"; +// } +// else if(std::isnan(f)) +// { +// std::cout << "std::numeric_limits::quiet_NaN()"; +// } +// std::cout << "},\n"; +// } + +// } + + +TEST_CASE(check_half_values) +{ + for(auto [x, f] : half_lut) + { + + auto h = migraphx::bit_cast(x); + if(std::isnan(f)) + { + CHECK(std::isnan(h)); + } + else if(std::isinf(f)) + { + CHECK(std::isinf(h)); + CHECK((h < 0) == (f < 0)); + CHECK(bit_equal(x, migraphx::bf16(f))); + } + else + { + CHECK(bit_equal(x, migraphx::bf16(f))); + CHECK(migraphx::float_equal(float(h), f)); + } + } +} + + TEST_CASE(check_flows) { // check positive underflow From a064eaa76c364c0b8c1af17982025d457de11e86 Mon Sep 17 00:00:00 2001 From: Richa Gadgil Date: Fri, 1 Nov 2024 17:15:10 -0700 Subject: [PATCH 49/72] Update bf16.hpp --- src/include/migraphx/bf16.hpp | 1241 +++++++++++++++++++++++++++++++-- 1 file changed, 1192 insertions(+), 49 deletions(-) diff --git a/src/include/migraphx/bf16.hpp b/src/include/migraphx/bf16.hpp index 8c9ed6fd9f3..176cd401605 100644 --- a/src/include/migraphx/bf16.hpp +++ b/src/include/migraphx/bf16.hpp @@ -21,79 +21,1222 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#include +#include +#include +#include +#include "test.hpp" -#ifndef MIGRAPHX_GUARD_RTGLIB_BF16_HPP -#define MIGRAPHX_GUARD_RTGLIB_BF16_HPP +#include +#include +#include +#include +#include +#include -#include -#include -#include +template +bool bit_equal(const T& x, const U& y) +{ + static_assert(sizeof(T) == sizeof(U)); + using type = std::array; + return migraphx::bit_cast(x) == migraphx::bit_cast(y); +} -namespace migraphx { -inline namespace MIGRAPHX_INLINE_NS { +TEST_CASE(check_numeric_limits) +{ + CHECK(bit_equal(std::numeric_limits::min(), uint16_t{0x0080})); + CHECK(bit_equal(std::numeric_limits::lowest(), uint16_t{0xff7f})); + CHECK(bit_equal(std::numeric_limits::max(), uint16_t{0x7f7f})); + CHECK(bit_equal(std::numeric_limits::epsilon(), uint16_t{0x3c0})); + CHECK(bit_equal(std::numeric_limits::denorm_min(), uint16_t{0x0001})); + CHECK(bit_equal(std::numeric_limits::infinity(), uint16_t{0x7f80})); + CHECK(bit_equal(std::numeric_limits::quiet_NaN(), uint16_t{0x7fc0})); + CHECK(bit_equal(std::numeric_limits::signaling_NaN(), uint16_t{0x7fa0})); +} -using bf16 = migraphx::generic_float<7, 8>; +static const std::map bf16_lut = { +{0x0000, 0.0}, +{0x002d, 0.00000000000000000000000000000000000000413259732711}, +{0x004e, 0.00000000000000000000000000000000000000716316870032}, +{0x005b, 0.00000000000000000000000000000000000000835703015038}, +{0x00cd, 0.00000000000000000000000000000000000001882627671239}, +{0x00ce, 0.00000000000000000000000000000000000001891811220855}, +{0x0170, 0.00000000000000000000000000000000000004408103815584}, +{0x01be, 0.00000000000000000000000000000000000006979497708007}, +{0x01fe, 0.00000000000000000000000000000000000009330486409652}, +{0x0211, 0.00000000000000000000000000000000000010652917554327}, +{0x028f, 0.00000000000000000000000000000000000021011961520948}, +{0x02bc, 0.00000000000000000000000000000000000027624117244324}, +{0x02e8, 0.00000000000000000000000000000000000034089336173846}, +{0x039c, 0.00000000000000000000000000000000000091688559364138}, +{0x03a9, 0.00000000000000000000000000000000000099329272644483}, +{0x03cf, 0.00000000000000000000000000000000000121663665310107}, +{0x03da, 0.00000000000000000000000000000000000128128884239629}, +{0x03f3, 0.00000000000000000000000000000000000142822563624908}, +{0x0427, 0.00000000000000000000000000000000000196307556587322}, +{0x044c, 0.00000000000000000000000000000000000239800847567747}, +{0x0485, 0.00000000000000000000000000000000000312681497318728}, +{0x0498, 0.00000000000000000000000000000000000357350282649975}, +{0x04da, 0.00000000000000000000000000000000000512515536958517}, +{0x051b, 0.00000000000000000000000000000000000728806497509818}, +{0x0533, 0.00000000000000000000000000000000000841653955188758}, +{0x0536, 0.00000000000000000000000000000000000855759887398625}, +{0x0577, 0.00000000000000000000000000000000001161388418612420}, +{0x0587, 0.00000000000000000000000000000000001269533898888071}, +{0x065a, 0.00000000000000000000000000000000004100124295668139}, +{0x0735, 0.00000000000000000000000000000000013616926559925378}, +{0x075e, 0.00000000000000000000000000000000016701423736483061}, +{0x0765, 0.00000000000000000000000000000000017228045205651446}, +{0x076b, 0.00000000000000000000000000000000017679435036367204}, +{0x07ba, 0.00000000000000000000000000000000027986169504377021}, +{0x07d1, 0.00000000000000000000000000000000031446824873197835}, +{0x07db, 0.00000000000000000000000000000000032951457642250363}, +{0x07eb, 0.00000000000000000000000000000000035358870072734408}, +{0x080d, 0.00000000000000000000000000000000042430644087281290}, +{0x0841, 0.00000000000000000000000000000000058078824885427581}, +{0x08ff, 0.00000000000000000000000000000000153472542443357857}, +{0x09e1, 0.00000000000000000000000000000000541667796858910084}, +{0x0a0b, 0.00000000000000000000000000000000669260655674564459}, +{0x0a0f, 0.00000000000000000000000000000000688519955118436817}, +{0x0a12, 0.00000000000000000000000000000000702964429701341086}, +{0x0a1d, 0.00000000000000000000000000000000755927503171990072}, +{0x0aa2, 0.00000000000000000000000000000001560003254953661041}, +{0x0aaf, 0.00000000000000000000000000000001685188701338831371}, +{0x0ab4, 0.00000000000000000000000000000001733336949948512268}, +{0x0ade, 0.00000000000000000000000000000002137782238269831797}, +{0x0b6e, 0.00000000000000000000000000000004583713267641621330}, +{0x0bb6, 0.00000000000000000000000000000007010384997569538505}, +{0x0c8c, 0.00000000000000000000000000000021570415377137041554}, +{0x0cf7, 0.00000000000000000000000000000038056375701091780456}, +{0x0d06, 0.00000000000000000000000000000041291938007662336690}, +{0x0d20, 0.00000000000000000000000000000049303806576313237838}, +{0x0d5e, 0.00000000000000000000000000000068409031624634617501}, +{0x0d60, 0.00000000000000000000000000000069025329206838532974}, +{0x0d6a, 0.00000000000000000000000000000072106817117858110338}, +{0x0d76, 0.00000000000000000000000000000075804602611081603176}, +{0x0d7e, 0.00000000000000000000000000000078269792939897265068}, +{0x0dcc, 0.00000000000000000000000000000125724706769598756487}, +{0x0dfc, 0.00000000000000000000000000000155306990715386699190}, +{0x0e09, 0.00000000000000000000000000000168865537523872839596}, +{0x0e3c, 0.00000000000000000000000000000231727890908672217840}, +{0x0e69, 0.00000000000000000000000000000287194673307024610408}, +{0x0f42, 0.00000000000000000000000000000956493847580476814062}, +{0x0f8f, 0.00000000000000000000000000001410088868082558602173}, +{0x0fa2, 0.00000000000000000000000000001597443333072548905959}, +{0x1007, 0.00000000000000000000000000002662405555120914843265}, +{0x1015, 0.00000000000000000000000000002938506871948268975159}, +{0x1030, 0.00000000000000000000000000003470987982972451943812}, +{0x1042, 0.00000000000000000000000000003825975390321907256247}, +{0x1056, 0.00000000000000000000000000004220405842932413158953}, +{0x1166, 0.00000000000000000000000000018143800820083271524470}, +{0x1182, 0.00000000000000000000000000020510383535746306940705}, +{0x128a, 0.00000000000000000000000000087090243936399703317455}, +{0x1295, 0.00000000000000000000000000094032219902344607205078}, +{0x129e, 0.00000000000000000000000000099712018419935892204042}, +{0x12b0, 0.00000000000000000000000000111071615455118462201971}, +{0x12bf, 0.00000000000000000000000000120537946317770603866912}, +{0x1315, 0.00000000000000000000000000188064439804689214410156}, +{0x1343, 0.00000000000000000000000000246124602428955683288459}, +{0x13e2, 0.00000000000000000000000000570504206655835737673762}, +{0x13ee, 0.00000000000000000000000000600796465416322591001572}, +{0x1445, 0.00000000000000000000000000994595829302651684263107}, +{0x1469, 0.00000000000000000000000001176349381865572804229970}, +{0x14bd, 0.00000000000000000000000001908412301910671759652054}, +{0x1541, 0.00000000000000000000000003897603960515975128178268}, +{0x1546, 0.00000000000000000000000003998578156384264639270970}, +{0x1569, 0.00000000000000000000000004705397527462291216919879}, +{0x16a1, 0.00000000000000000000000026010952855671378057479844}, +{0x16b6, 0.00000000000000000000000029403685836845905630194606}, +{0x16f4, 0.00000000000000000000000039420326066980225130590570}, +{0x1703, 0.00000000000000000000000042328382907986963050060367}, +{0x1720, 0.00000000000000000000000051698788284564229679463043}, +{0x178e, 0.00000000000000000000000091765349205101507681046902}, +{0x17f6, 0.00000000000000000000000158973773975035006264348858}, +{0x18e8, 0.00000000000000000000000599705944100945064281771302}, +{0x18f1, 0.00000000000000000000000622970398828998967637529671}, +{0x1927, 0.00000000000000000000000863369764352222635647032822}, +{0x1a39, 0.00000000000000000000003825710333057752996280265201}, +{0x1a60, 0.00000000000000000000004632211430296954979279888676}, +{0x1a69, 0.00000000000000000000004818327068121386206125955631}, +{0x1b1f, 0.00000000000000000000013152171739593140030455398204}, +{0x1b43, 0.00000000000000000000016130021944784039659992469495}, +{0x1ba0, 0.00000000000000000000026469779601696885595885078146}, +{0x1bc0, 0.00000000000000000000031763735522036262715062093775}, +{0x1bea, 0.00000000000000000000038712052667481695183981926789}, +{0x1c25, 0.00000000000000000000054593920428499826541512973677}, +{0x1c32, 0.00000000000000000000058895259613775570450844298875}, +{0x1cbe, 0.00000000000000000000125731453108060206580454121195}, +{0x1ccd, 0.00000000000000000000135657620458696538678911025499}, +{0x1cd6, 0.00000000000000000000141613320869078337937985168082}, +{0x1d23, 0.00000000000000000000215728703753829617606463386892}, +{0x1d38, 0.00000000000000000000243521972335611347482142718945}, +{0x1dce, 0.00000000000000000000545277459794955843275232609813}, +{0x1e7c, 0.00000000000000000001334076891925523034032607938570}, +{0x1e9e, 0.00000000000000000001672890070827243169659936938842}, +{0x1eb1, 0.00000000000000000001874060395800139500188663532754}, +{0x1f33, 0.00000000000000000003790472438962994017330743190541}, +{0x1f56, 0.00000000000000000004531626267810506814015525378636}, +{0x1fa8, 0.00000000000000000007115076756936122848173909005709}, +{0x1fed, 0.00000000000000000010037340424963459017959621633054}, +{0x2001, 0.00000000000000000010926725019580474373981360258767}, +{0x213f, 0.00000000000000000064713317170228545904819839051925}, +{0x2154, 0.00000000000000000071828393927164668752993748057634}, +{0x216b, 0.00000000000000000079621097041904231872422315063886}, +{0x219f, 0.00000000000000000107742590890747003129490622086450}, +{0x2225, 0.00000000000000000223616698075135289514037140179425}, +{0x2229, 0.00000000000000000229037708937562811684074404183775}, +{0x2274, 0.00000000000000000330681662608078852372273104265332}, +{0x227b, 0.00000000000000000340168431617327016169838316272944}, +{0x2294, 0.00000000000000000401154803819636640582757536321878}, +{0x22b7, 0.00000000000000000496022493912118278558409656397998}, +{0x2379, 0.00000000000000001349831704744453020339278737083077}, +{0x2389, 0.00000000000000001485356976305141074590210337191820}, +{0x2464, 0.00000000000000004943961906533900219073984771966934}, +{0x2475, 0.00000000000000005312590645178971726636518724262714}, +{0x2491, 0.00000000000000006288372600415925717243226245045662}, +{0x24f6, 0.00000000000000010668549377257363630633335560560226}, +{0x2567, 0.00000000000000020036056147532121940457727760076523}, +{0x256a, 0.00000000000000020296264668928643004619516432285309}, +{0x257f, 0.00000000000000022117724318704290453752037137746811}, +{0x25f9, 0.00000000000000043194614551822496650856919586658478}, +{0x263b, 0.00000000000000064878658001532585331005975604057312}, +{0x270c, 0.00000000000000194289029309402394574135541915893555}, +{0x272c, 0.00000000000000238697950294408656191080808639526367}, +{0x2745, 0.00000000000000273392419813944798079319298267364502}, +{0x2791, 0.00000000000000402455846426619245903566479682922363}, +{0x2792, 0.00000000000000405231403988182137254625558853149414}, +{0x27a0, 0.00000000000000444089209850062616169452667236328125}, +{0x27a3, 0.00000000000000452415882534751290222629904747009277}, +{0x27d4, 0.00000000000000588418203051332966424524784088134766}, +{0x27dd, 0.00000000000000613398221105398988584056496620178223}, +{0x2821, 0.00000000000000893729534823251015041023492813110352}, +{0x28d9, 0.00000000000002409183963436589692719280719757080078}, +{0x2981, 0.00000000000005728750807065807748585939407348632812}, +{0x29ca, 0.00000000000008970602038971264846622943878173828125}, +{0x2a5b, 0.00000000000019451107391432742588222026824951171875}, +{0x2aa8, 0.00000000000029842794901924207806587219238281250}, +{0x2ac4, 0.000000000000348165940522449091076850891113281250}, +{0x2ae7, 0.00000000000041033842990145785734057426452636718750}, +{0x2af1, 0.00000000000042810199829546036198735237121582031250}, +{0x2afe, 0.0000000000004511946372076636180281639099121093750}, +{0x2b24, 0.00000000000058264504332328215241432189941406250}, +{0x2b4c, 0.00000000000072475359047530218958854675292968750}, +{0x2b85, 0.000000000000945021838560933247208595275878906250}, +{0x2bed, 0.000000000001683986283751437440514564514160156250}, +{0x2c18, 0.00000000000216004991671070456504821777343750}, +{0x2cdf, 0.0000000000063380412029800936579704284667968750}, +{0x2d6b, 0.000000000013358203432289883494377136230468750}, +{0x2d96, 0.0000000000170530256582424044609069824218750}, +{0x2da2, 0.0000000000184172677109017968177795410156250}, +{0x2db8, 0.00000000002091837814077734947204589843750}, +{0x2de1, 0.00000000002557953848736360669136047363281250}, +{0x2e90, 0.00000000006548361852765083312988281250}, +{0x2ea3, 0.000000000074123818194493651390075683593750}, +{0x2ef0, 0.00000000010913936421275138854980468750}, +{0x2f09, 0.00000000012460077414289116859436035156250}, +{0x2f6b, 0.00000000021373125491663813591003417968750}, +{0x303b, 0.000000000680302036926150321960449218750}, +{0x308f, 0.00000000104046193882822990417480468750}, +{0x309c, 0.000000001135049387812614440917968750}, +{0x30a9, 0.00000000122963683679699897766113281250}, +{0x312a, 0.000000002473825588822364807128906250}, +{0x313d, 0.0000000027503119781613349914550781250}, +{0x3159, 0.0000000031577656045556068420410156250}, +{0x31c6, 0.00000000576255843043327331542968750}, +{0x3212, 0.0000000084983184933662414550781250}, +{0x3245, 0.00000001146690919995307922363281250}, +{0x329b, 0.0000000180443748831748962402343750}, +{0x32ba, 0.000000021653249859809875488281250}, +{0x32cc, 0.00000002374872565269470214843750}, +{0x3332, 0.00000004144385457038879394531250}, +{0x33c4, 0.000000091269612312316894531250}, +{0x3424, 0.00000015273690223693847656250}, +{0x3589, 0.0000010207295417785644531250}, +{0x3594, 0.00000110268592834472656250}, +{0x368b, 0.00000414252281188964843750}, +{0x36a0, 0.000004768371582031250}, +{0x36e9, 0.00000694394111633300781250}, +{0x36ed, 0.00000706315040588378906250}, +{0x3750, 0.000012397766113281250}, +{0x375f, 0.0000132918357849121093750}, +{0x37ce, 0.00002455711364746093750}, +{0x37d2, 0.00002503395080566406250}, +{0x37f0, 0.00002861022949218750}, +{0x380e, 0.0000338554382324218750}, +{0x3826, 0.0000395774841308593750}, +{0x387f, 0.00006079673767089843750}, +{0x38e1, 0.0001072883605957031250}, +{0x38e9, 0.0001111030578613281250}, +{0x3964, 0.0002174377441406250}, +{0x3994, 0.000282287597656250}, +{0x3a26, 0.000633239746093750}, +{0x3a2c, 0.00065612792968750}, +{0x3a6a, 0.000892639160156250}, +{0x3a85, 0.001014709472656250}, +{0x3ab9, 0.001411437988281250}, +{0x3aba, 0.00141906738281250}, +{0x3af7, 0.001884460449218750}, +{0x3b03, 0.00199890136718750}, +{0x3bb3, 0.0054626464843750}, +{0x3bbf, 0.0058288574218750}, +{0x3be8, 0.0070800781250}, +{0x3c06, 0.00817871093750}, +{0x3c29, 0.010314941406250}, +{0x3c3f, 0.011657714843750}, +{0x3c73, 0.014831542968750}, +{0x3ce9, 0.02844238281250}, +{0x3cfa, 0.0305175781250}, +{0x3cfb, 0.03063964843750}, +{0x3d0f, 0.0349121093750}, +{0x3d2a, 0.041503906250}, +{0x3d43, 0.0476074218750}, +{0x3dd0, 0.10156250}, +{0x3dd9, 0.105957031250}, +{0x3de9, 0.113769531250}, +{0x3df9, 0.121582031250}, +{0x3e1e, 0.1542968750}, +{0x3e77, 0.24121093750}, +{0x3e95, 0.2910156250}, +{0x3f38, 0.718750}, +{0x3fb3, 1.39843750}, +{0x3fc5, 1.53906250}, +{0x3fd3, 1.64843750}, +{0x3fd7, 1.67968750}, +{0x400b, 2.1718750}, +{0x40bf, 5.968750}, +{0x40c7, 6.218750}, +{0x4123, 10.18750}, +{0x412b, 10.68750}, +{0x41bf, 23.8750}, +{0x41ca, 25.250}, +{0x421b, 38.750}, +{0x4226, 41.50}, +{0x42a7, 83.50}, +{0x42b7, 91.50}, +{0x4311, 145.0}, +{0x431f, 159.0}, +{0x4334, 180.0}, +{0x434f, 207.0}, +{0x43b1, 354.0}, +{0x43e5, 458.0}, +{0x4476, 984.0}, +{0x4496, 1200.0}, +{0x44a4, 1312.0}, +{0x458b, 4448.0}, +{0x45a9, 5408.0}, +{0x45df, 7136.0}, +{0x45f6, 7872.0}, +{0x45fa, 8000.0}, +{0x4602, 8320.0}, +{0x4640, 12288.0}, +{0x4648, 12800.0}, +{0x46a7, 21376.0}, +{0x46b1, 22656.0}, +{0x4742, 49664.0}, +{0x4744, 50176.0}, +{0x475e, 56832.0}, +{0x477a, 64000.0}, +{0x4837, 187392.0}, +{0x488a, 282624.0}, +{0x488f, 292864.0}, +{0x48ea, 479232.0}, +{0x495c, 901120.0}, +{0x49aa, 1392640.0}, +{0x49b9, 1515520.0}, +{0x4a1e, 2588672.0}, +{0x4a2b, 2801664.0}, +{0x4a4c, 3342336.0}, +{0x4ab6, 5963776.0}, +{0x4b34, 11796480.0}, +{0x4b73, 15925248.0}, +{0x4b7b, 16449536.0}, +{0x4bcd, 26869760.0}, +{0x4bd0, 27262976.0}, +{0x4c07, 35389440.0}, +{0x4c17, 39583744.0}, +{0x4c53, 55312384.0}, +{0x4cad, 90701824.0}, +{0x4d1c, 163577856.0}, +{0x4dc0, 402653184.0}, +{0x4dde, 465567744.0}, +{0x4eef, 2004877312.0}, +{0x4efc, 2113929216.0}, +{0x4f12, 2449473536.0}, +{0x4f2f, 2936012800.0}, +{0x4f92, 4898947072.0}, +{0x4fad, 5804916736.0}, +{0x4fdc, 7381975040.0}, +{0x4feb, 7885291520.0}, +{0x5076, 16508780544.0}, +{0x5083, 17582522368.0}, +{0x5215, 159987531776.0}, +{0x52a9, 362924736512.0}, +{0x5394, 1271310319616.0}, +{0x53a0, 1374389534720.0}, +{0x53b7, 1571958030336.0}, +{0x540e, 2439541424128.0}, +{0x542f, 3006477107200.0}, +{0x5465, 3934190043136.0}, +{0x5529, 11613591568384.0}, +{0x554c, 14018773254144.0}, +{0x5596, 20615843020800.0}, +{0x55ae, 23914377904128.0}, +{0x55be, 26113401159680.0}, +{0x55da, 29961691856896.0}, +{0x568d, 77515569758208.0}, +{0x5690, 79164837199872.0}, +{0x56ad, 95107755802624.0}, +{0x5718, 167125767421952.0}, +{0x571c, 171523813933056.0}, +{0x571d, 172623325560832.0}, +{0x5826, 730075720843264.0}, +{0x587c, 1108307720798208.0}, +{0x5890, 1266637395197952.0}, +{0x58a8, 1477743627730944.0}, +{0x58f6, 2163838883463168.0}, +{0x5966, 4046202790215680.0}, +{0x5985, 4679521487814656.0}, +{0x59ad, 6086896371367936.0}, +{0x59b0, 6192449487634432.0}, +{0x59bc, 6614661952700416.0}, +{0x5a93, 20688410788233216.0}, +{0x5ab0, 24769797950537728.0}, +{0x5ab6, 25614222880669696.0}, +{0x5ae3, 31947409856659456.0}, +{0x5af5, 34480684647055360.0}, +{0x5afd, 35606584553897984.0}, +{0x5bb6, 102456891522678784.0}, +{0x5c3d, 212795082393255936.0}, +{0x5d57, 968273919884656640.0}, +{0x5d76, 1107885508333142016.0}, +{0x5d86, 1206964700135292928.0}, +{0x5db2, 1603281467343896576.0}, +{0x5dc1, 1738389456165011456.0}, +{0x5dc5, 1774418253183975424.0}, +{0x5e5d, 3981182070595518464.0}, +{0x5fa4, 23634890844440363008.0}, +{0x5fa8, 24211351596743786496.0}, +{0x5ff8, 35740566642812256256.0}, +{0x6006, 38622870404329373696.0}, +{0x6051, 60240148615707754496.0}, +{0x60ed, 136621198295911366656.0}, +{0x610b, 160256089140351729664.0}, +{0x6114, 170632382681813352448.0}, +{0x613b, 215596321361480384512.0}, +{0x6148, 230584300921369395200.0}, +{0x61ad, 398910840593969053696.0}, +{0x61fd, 583378281331064569856.0}, +{0x629f, 1466516153859909353472.0}, +{0x62a4, 1512633014044183232512.0}, +{0x62fb, 2315066381250548727808.0}, +{0x634b, 3744689046963038978048.0}, +{0x635a, 4021390208068682252288.0}, +{0x635f, 4113623928437230010368.0}, +{0x637c, 4648579506574807007232.0}, +{0x638d, 5201981828786093555712.0}, +{0x63a9, 6234999496913828446208.0}, +{0x6469, 17192365476697302106112.0}, +{0x64c0, 28334198897217871282176.0}, +{0x64d1, 30842956091242370301952.0}, +{0x64dd, 32613843522318487257088.0}, +{0x64ee, 35122600716342986276864.0}, +{0x64ef, 35270174668932662689792.0}, +{0x64fb, 37041062100008779644928.0}, +{0x6510, 42501298345826806923264.0}, +{0x6581, 76148159536273029070848.0}, +{0x65d4, 125142711796045598162944.0}, +{0x6612, 172366376624742050299904.0}, +{0x661c, 184172292831916163334144.0}, +{0x66c6, 467514281804094876155904.0}, +{0x66ed, 559600428220052957822976.0}, +{0x66f9, 587934627117270829105152.0}, +{0x6703, 618630009255923522994176.0}, +{0x6752, 991696961402625494876160.0}, +{0x6797, 1426154677826632854536192.0}, +{0x679c, 1473378342655329306673152.0}, +{0x67e3, 2143954383222818927017984.0}, +{0x6862, 4269019300514159273181184.0}, +{0x692f, 13222626152035006598348800.0}, +{0x693d, 14280436244197807126216704.0}, +{0x6943, 14733783426553293066731520.0}, +{0x695e, 16773845747152979799048192.0}, +{0x69ec, 35663311678631560653832192.0}, +{0x69f4, 36872237498246189828538368.0}, +{0x6a5c, 66490920078804604608839680.0}, +{0x6a7a, 75557863725914323419136000.0}, +{0x6ac3, 117870267412426344533852160.0}, +{0x6ad8, 130563988518379950868267008.0}, +{0x6ae3, 137213080526260411329150976.0}, +{0x6b37, 221233424989477138971230208.0}, +{0x6b77, 298604677444813406152425472.0}, +{0x6bd7, 519838102434290545123655680.0}, +{0x6be7, 558523728661958678714253312.0}, +{0x6c15, 720519788490318988124880896.0}, +{0x6c33, 865590886844074489089622016.0}, +{0x6c43, 942962139299410756270817280.0}, +{0x6c45, 952633545856327789668466688.0}, +{0x6c48, 967140655691703339764940800.0}, +{0x6da6, 6421813953792910176039206912.0}, +{0x6dba, 7195526478346272847851159552.0}, +{0x6def, 9245864668412683928152834048.0}, +{0x6e24, 12688885402675147817716023296.0}, +{0x6e28, 12998370412496492886440804352.0}, +{0x6e3d, 14623166714058554497245904896.0}, +{0x6ea0, 24758800785707605497982484480.0}, +{0x6eef, 36983458673650735712611336192.0}, +{0x6ef9, 38530883722757461056235241472.0}, +{0x6f55, 65920307091946499638378364928.0}, +{0x6f5c, 68086702160695915119451832320.0}, +{0x6f65, 70872067249088020737974861824.0}, +{0x6f9e, 97797263103545041717030813696.0}, +{0x6fdc, 136173404321391830238903664640.0}, +{0x70ab, 423375493435600054015500484608.0}, +{0x70dc, 544693617285567320955614658560.0}, +{0x714a, 1000255551742587262118492372992.0}, +{0x71ba, 1842054778456645849049896845312.0}, +{0x71d3, 2089642786313721904029721690112.0}, +{0x71ee, 2357037834799364043407932522496.0}, +{0x71f6, 2436265997313628381001476472832.0}, +{0x7251, 4139671491370311639262671405056.0}, +{0x72b8, 7288990951312319058606043430912.0}, +{0x731f, 12597277839768029677373488103424.0}, +{0x7328, 13310331302396408715715383656448.0}, +{0x7356, 16954826778052568245018405371904.0}, +{0x7358, 17113283103081096920205493272576.0}, +{0x7375, 19410899815994762710418267832320.0}, +{0x737c, 19965496953594613073573075484672.0}, +{0x7467, 73206822163180247936434610110464.0}, +{0x74a4, 103947349218714810922729662840832.0}, +{0x74b1, 112187078120198302032458233675776.0}, +{0x7530, 223106505640168374663419764146176.0}, +{0x7563, 287756686251808074139751627620352.0}, +{0x756f, 302968493454546826957712066084864.0}, +{0x7571, 305503794655003285760705472495616.0}, +{0x7626, 841719998551544322593810928369664.0}, +{0x7660, 1135814937804493543741046072016896.0}, +{0x7675, 1242297588223664813466769141268480.0}, +{0x76b2, 1805134454724998667731305364455424.0}, +{0x772c, 3488574451828087312918927221194752.0}, +{0x77b2, 7220537818899994670925221457821696.0}, +{0x783a, 15090112745116842795416754956795904.0}, +{0x795d, 71718600358512306619077480547352576.0}, +{0x796e, 77235415770705560974391132897148928.0}, +{0x798c, 90865195024359483499283685761351680.0}, +{0x79af, 113581493780449354374104607201689600.0}, +{0x7aa5, 428364490829123279353765947160657920.0}, +{0x7acf, 537402724858354659552906370074279936.0}, +{0x7adc, 571152654438831039138354596214210560.0}, +{0x7b07, 700960075902201729851617004444712960.0}, +{0x7b0f, 742498450770480350879860975078473728.0}, +{0x7b12, 758075341346084833765452464066134016.0}, +{0x7b30, 913844247102129662621367353942736896.0}, +{0x7bc2, 2014611181111513119869832575737397248.0}, +{0x7bd1, 2170380086867557948725747465614000128.0}, +{0x7bd5, 2211918461735836569753991436247760896.0}, +{0x7cf1, 10010748343255147667806796922736345088.0}, +{0x7d2f, 14538431203897517359885389721816268800.0}, +{0x7da0, 26584559915698317458076141205606891520.0}, +{0x7e58, 71778311772385457136805581255138607104.0}, +{0x7e81, 85735205728127073802295555388082225152.0}, +{0x7f09, 182104235422533474587821567258407206912.0}, +{0x7f24, 217993391308726203156224357885976510464.0}, +{0x7f86, std::numeric_limits::quiet_NaN()}, +{0x7f88, std::numeric_limits::quiet_NaN()}, +{0x7f8f, std::numeric_limits::quiet_NaN()}, +{0x7fa0, std::numeric_limits::quiet_NaN()}, +{0x7fcd, std::numeric_limits::quiet_NaN()}, +{0x8023, -0.00000000000000000000000000000000000000321424236553}, +{0x8074, -0.00000000000000000000000000000000000001065291755433}, +{0x8080, -0.00000000000000000000000000000000000001175494350822}, +{0x80a5, -0.00000000000000000000000000000000000001515285686607}, +{0x80d2, -0.00000000000000000000000000000000000001928545419318}, +{0x80fd, -0.00000000000000000000000000000000000002323438052797}, +{0x810a, -0.00000000000000000000000000000000000002534659693961}, +{0x8124, -0.00000000000000000000000000000000000003012204273982}, +{0x81e3, -0.00000000000000000000000000000000000008338663051146}, +{0x81f1, -0.00000000000000000000000000000000000008852941829630}, +{0x8285, -0.00000000000000000000000000000000000019542593582421}, +{0x828b, -0.00000000000000000000000000000000000020424214345537}, +{0x829f, -0.00000000000000000000000000000000000023362950222593}, +{0x82bc, -0.00000000000000000000000000000000000027624117244324}, +{0x82ee, -0.00000000000000000000000000000000000034970956936963}, +{0x82f9, -0.00000000000000000000000000000000000036587261669344}, +{0x8393, -0.00000000000000000000000000000000000086398834785438}, +{0x8394, -0.00000000000000000000000000000000000086986581960849}, +{0x843e, -0.00000000000000000000000000000000000223343926656235}, +{0x8451, -0.00000000000000000000000000000000000245678319321858}, +{0x847f, -0.00000000000000000000000000000000000299751059459683}, +{0x8483, -0.00000000000000000000000000000000000307979519915439}, +{0x84a0, -0.00000000000000000000000000000000000376158192263132}, +{0x84aa, -0.00000000000000000000000000000000000399668079279578}, +{0x84ba, -0.00000000000000000000000000000000000437283898505891}, +{0x84e4, -0.00000000000000000000000000000000000536025423974963}, +{0x8510, -0.00000000000000000000000000000000000677084746073638}, +{0x854d, -0.00000000000000000000000000000000000963905367674276}, +{0x8557, -0.00000000000000000000000000000000001010925141707167}, +{0x8584, -0.00000000000000000000000000000000001241322034468336}, +{0x85b7, -0.00000000000000000000000000000000001720923729603829}, +{0x8656, -0.00000000000000000000000000000000004024892657215512}, +{0x87c7, -0.00000000000000000000000000000000029942192104145307}, +{0x88d9, -0.00000000000000000000000000000000130602124353759431}, +{0x896c, -0.00000000000000000000000000000000284074666797117288}, +{0x89a0, -0.00000000000000000000000000000000385185988877447171}, +{0x89b2, -0.00000000000000000000000000000000428519412626159977}, +{0x89fe, -0.00000000000000000000000000000000611482757342947383}, +{0x8a31, -0.00000000000000000000000000000000852224000391351865}, +{0x8a55, -0.00000000000000000000000000000001025557695386203092}, +{0x8a68, -0.00000000000000000000000000000001117039367744596795}, +{0x8b4a, -0.00000000000000000000000000000003890378487662216423}, +{0x8b4c, -0.00000000000000000000000000000003928897086549961140}, +{0x8b5b, -0.00000000000000000000000000000004217786578208046518}, +{0x8bbf, -0.00000000000000000000000000000007357052387559240959}, +{0x8bff, -0.00000000000000000000000000000009822242716374902851}, +{0x8c43, -0.00000000000000000000000000000015022253566220439654}, +{0x8c6b, -0.00000000000000000000000000000018103741477240017019}, +{0x8d1d, -0.00000000000000000000000000000048379360203007364629}, +{0x8d23, -0.00000000000000000000000000000050228252949619111048}, +{0x8d30, -0.00000000000000000000000000000054234187233944561622}, +{0x8dee, -0.00000000000000000000000000000146678824564531882569}, +{0x8e54, -0.00000000000000000000000000000261310174854460160543}, +{0x8e68, -0.00000000000000000000000000000285962078142616779462}, +{0x8eb0, -0.00000000000000000000000000000433873497871556492976}, +{0x8efe, -0.00000000000000000000000000000626158343519178120546}, +{0x8f3d, -0.00000000000000000000000000000931841944292320195143}, +{0x8f95, -0.00000000000000000000000000001469253435974134487579}, +{0x8fa3, -0.00000000000000000000000000001607304094387811553526}, +{0x8fbe, -0.00000000000000000000000000001873544649899903037853}, +{0x9009, -0.00000000000000000000000000002701848600381965433535}, +{0x9017, -0.00000000000000000000000000002977949917209319565429}, +{0x90a8, -0.00000000000000000000000000006626431603856499165459}, +{0x90d2, -0.00000000000000000000000000008283039504820623956823}, +{0x9260, -0.00000000000000000000000000070681937107802657764891}, +{0x92d0, -0.00000000000000000000000000131266454628776364420512}, +{0x92ed, -0.00000000000000000000000000149568027629903838306064}, +{0x9356, -0.00000000000000000000000000270105973947674442172976}, +{0x94af, -0.00000000000000000000000001767048427695066444122272}, +{0x9503, -0.00000000000000000000000002645523931749185190628773}, +{0x953c, -0.00000000000000000000000003796629764647685617085567}, +{0x9556, -0.00000000000000000000000004321695583162791074767614}, +{0x9598, -0.00000000000000000000000006139231108792002274436236}, +{0x9599, -0.00000000000000000000000006179620787139318078873317}, +{0x95cf, -0.00000000000000000000000008360663417894371518475664}, +{0x95df, -0.00000000000000000000000009006898271451424389468952}, +{0x95f4, -0.00000000000000000000000009855081516745056282647643}, +{0x960f, -0.00000000000000000000000011551448007332320069005024}, +{0x9615, -0.00000000000000000000000012036124147500109722249990}, +{0x966a, -0.00000000000000000000000018902369466543796476553675}, +{0x968c, -0.00000000000000000000000022618219874496850484765081}, +{0x96b3, -0.00000000000000000000000028919009696678115976949640}, +{0x96d7, -0.00000000000000000000000034735123378691591815889232}, +{0x9719, -0.00000000000000000000000049436966297114544630986535}, +{0x9761, -0.00000000000000000000000072701421025168447986744905}, +{0x97f0, -0.00000000000000000000000155096364853692689038389130}, +{0x97fd, -0.00000000000000000000000163497417949934376361301874}, +{0x983c, -0.00000000000000000000000242984304937451879493476303}, +{0x987d, -0.00000000000000000000000326994835899868752722603749}, +{0x9895, -0.00000000000000000000000385155972720003511111999672}, +{0x98b3, -0.00000000000000000000000462704155146849855631194237}, +{0x98fa, -0.00000000000000000000000646234853557052870993288041}, +{0x998f, -0.00000000000000000000001478585344938536968832643037}, +{0x999b, -0.00000000000000000000001602662436821491120063354341}, +{0x99e4, -0.00000000000000000000002357464745776128873383514772}, +{0x9a8b, -0.00000000000000000000005748905257243542340356290410}, +{0x9a95, -0.00000000000000000000006162495563520056177791994756}, +{0x9a9f, -0.00000000000000000000006576085869796570015227699102}, +{0x9bb2, -0.00000000000000000000029447629806887785225422149438}, +{0x9bc4, -0.00000000000000000000032425480012078684854959220729}, +{0x9c09, -0.00000000000000000000045329497567905916582953196325}, +{0x9c79, -0.00000000000000000000082387189010281556417192305730}, +{0x9cca, -0.00000000000000000000133672386988569272259219644639}, +{0x9d21, -0.00000000000000000000213081725793659929046874879077}, +{0x9d2d, -0.00000000000000000000228963593554678060404405925965}, +{0x9d53, -0.00000000000000000000279256174797902143036587574443}, +{0x9d59, -0.00000000000000000000287197108678411208715353097887}, +{0x9d9b, -0.00000000000000000000410281583826301726736218711267}, +{0x9dc9, -0.00000000000000000000532042569994107400477290070739}, +{0x9e3a, -0.00000000000000000000984675801183124144166924907040}, +{0x9eb4, -0.00000000000000000001905824131322175762903725626529}, +{0x9eb7, -0.00000000000000000001937587866844212025618787720305}, +{0x9ec3, -0.00000000000000000002064642808932357076479036095407}, +{0x9ee0, -0.00000000000000000002371692252312040949391303001903}, +{0x9f0a, -0.00000000000000000002922263668027336169785712627345}, +{0x9f5b, -0.00000000000000000004637505386217294356399065691221}, +{0x9fb7, -0.00000000000000000007750351467376848102475150881219}, +{0xa007, -0.00000000000000000011434944787933054577422353759175}, +{0xa06c, -0.00000000000000000019989977555201488002012411016040}, +{0xa07a, -0.00000000000000000021175823681357508476708062516991}, +{0xa0c0, -0.00000000000000000032526065174565133020223584026098}, +{0xa0e5, -0.00000000000000000038794108984246955529329170531128}, +{0xa108, -0.00000000000000000046078592330633938445316744036973}, +{0xa128, -0.00000000000000000056920614055488982785391272045672}, +{0xa178, -0.00000000000000000084025668367626593635577592067420}, +{0xa1f6, -0.00000000000000000166696084019646306728645868133754}, +{0xa305, -0.00000000000000000720994444702860448614956112578511}, +{0xa312, -0.00000000000000000791467585914418236825440544635057}, +{0xa3f2, -0.00000000000000002623769257414920730298035778105259}, +{0xa3f3, -0.00000000000000002634611279139775774638110306113958}, +{0xa40a, -0.00000000000000002992397996059992237860569730401039}, +{0xa412, -0.00000000000000003165870343657672947301762178540230}, +{0xa413, -0.00000000000000003187554387107383035981911234557629}, +{0xa421, -0.00000000000000003491130995403324277503998018801212}, +{0xa450, -0.00000000000000004510281037539698445471003651618958}, +{0xa456, -0.00000000000000004640385298237958977551897987723351}, +{0xa4a4, -0.00000000000000007112366251504909087088890373706818}, +{0xa4c9, -0.00000000000000008716985466783455649419920518994331}, +{0xa4ed, -0.00000000000000010278236595162582034390652552247047}, +{0xa522, -0.00000000000000014051260155412137464736588299274445}, +{0xa53a, -0.00000000000000016132928326584305978030897676944733}, +{0xa541, -0.0000000000000001674008154317618846107507124543190}, +{0xa6f7, -0.00000000000000171390679426508540927898138761520386}, +{0xa76c, -0.00000000000000327515792264421179424971342086791992}, +{0xa7a3, -0.00000000000000452415882534751290222629904747009277}, +{0xa7ae, -0.00000000000000482947015711943095084279775619506836}, +{0xa7bc, -0.00000000000000521804821573823573999106884002685547}, +{0xa837, -0.00000000000001015854067532018234487622976303100586}, +{0xa83e, -0.00000000000001054711873393898713402450084686279297}, +{0xa881, -0.00000000000001432187701766451937146484851837158203}, +{0xa8b9, -0.00000000000002053912595556539599783718585968017578}, +{0xa8c2, -0.00000000000002153832667772803688421845436096191406}, +{0xa8ca, -0.00000000000002242650509742816211655735969543457031}, +{0xa8d6, -0.00000000000002375877272697834996506571769714355469}, +{0xa8e4, -0.00000000000002531308496145356912165880203247070312}, +{0xa92d, -0.00000000000003841371665203041629865765571594238281}, +{0xa933, -0.00000000000003974598428158060414716601371765136719}, +{0xa937, -0.00000000000004063416270128072937950491905212402344}, +{0xa950, -0.0000000000000461852778244065120816230773925781250}, +{0xa956, -0.00000000000004751754545395669993013143539428710938}, +{0xa9b8, -0.0000000000000817124146124115213751792907714843750}, +{0xa9c6, -0.00000000000008792966355031239800155162811279296875}, +{0xa9f0, -0.000000000000106581410364015027880668640136718750}, +{0xaa2d, -0.00000000000015365486660812166519463062286376953125}, +{0xaae6, -0.0000000000004085620730620576068758964538574218750}, +{0xaaff, -0.00000000000045297099404706386849284172058105468750}, +{0xab12, -0.000000000000518696197104873135685920715332031250}, +{0xab42, -0.000000000000689226453687297180294990539550781250}, +{0xabfa, -0.00000000000177635683940025046467781066894531250}, +{0xac3a, -0.0000000000026432189770275726914405822753906250}, +{0xadbb, -0.00000000002125943865394219756126403808593750}, +{0xadc3, -0.00000000002216893335571512579917907714843750}, +{0xadda, -0.0000000000247837306233122944831848144531250}, +{0xaddf, -0.00000000002535216481192037463188171386718750}, +{0xae16, -0.000000000034106051316484808921813964843750}, +{0xae77, -0.0000000000561612978344783186912536621093750}, +{0xaee2, -0.00000000010277290130034089088439941406250}, +{0xb03e, -0.00000000069121597334742546081542968750}, +{0xb050, -0.00000000075669959187507629394531250}, +{0xb075, -0.000000000891304807737469673156738281250}, +{0xb11d, -0.0000000022846506908535957336425781250}, +{0xb125, -0.0000000024010660126805305480957031250}, +{0xb139, -0.0000000026921043172478675842285156250}, +{0xb155, -0.0000000030995579436421394348144531250}, +{0xb18d, -0.000000004103640094399452209472656250}, +{0xb23c, -0.000000010943040251731872558593750}, +{0xb2a8, -0.0000000195577740669250488281250}, +{0xb341, -0.000000044936314225196838378906250}, +{0xb369, -0.000000054249539971351623535156250}, +{0xb37b, -0.000000058440491557121276855468750}, +{0xb3c6, -0.0000000922009348869323730468750}, +{0xb3c9, -0.00000009359791874885559082031250}, +{0xb3dc, -0.000000102445483207702636718750}, +{0xb3e2, -0.0000001052394509315490722656250}, +{0xb404, -0.00000012293457984924316406250}, +{0xb42d, -0.0000001611188054084777832031250}, +{0xb487, -0.000000251457095146179199218750}, +{0xb499, -0.000000284984707832336425781250}, +{0xb49b, -0.000000288709998130798339843750}, +{0xb4be, -0.00000035390257835388183593750}, +{0xb599, -0.0000011399388313293457031250}, +{0xb5be, -0.000001415610313415527343750}, +{0xb661, -0.000003352761268615722656250}, +{0xb67f, -0.000003799796104431152343750}, +{0xb6f4, -0.000007271766662597656250}, +{0xb70f, -0.0000085234642028808593750}, +{0xb729, -0.0000100731849670410156250}, +{0xb731, -0.0000105500221252441406250}, +{0xb735, -0.0000107884407043457031250}, +{0xb76f, -0.0000142455101013183593750}, +{0xb770, -0.000014305114746093750}, +{0xb7a4, -0.0000195503234863281250}, +{0xb7b1, -0.000021100044250488281250}, +{0xb829, -0.00004029273986816406250}, +{0xb882, -0.000061988830566406250}, +{0xb9a6, -0.0003166198730468750}, +{0xb9c5, -0.00037574768066406250}, +{0xb9cc, -0.000389099121093750}, +{0xb9d3, -0.00040245056152343750}, +{0xb9dd, -0.00042152404785156250}, +{0xbb04, -0.002014160156250}, +{0xbb14, -0.002258300781250}, +{0xbb19, -0.00233459472656250}, +{0xbb33, -0.00273132324218750}, +{0xbb66, -0.0035095214843750}, +{0xbbc5, -0.0060119628906250}, +{0xbc0d, -0.008605957031250}, +{0xbcb0, -0.0214843750}, +{0xbcc8, -0.02441406250}, +{0xbce0, -0.027343750}, +{0xbce8, -0.02832031250}, +{0xbd06, -0.032714843750}, +{0xbd77, -0.0603027343750}, +{0xbe31, -0.17285156250}, +{0xbe3a, -0.1816406250}, +{0xbe5d, -0.21582031250}, +{0xbe85, -0.2597656250}, +{0xbe9a, -0.300781250}, +{0xbea5, -0.3222656250}, +{0xbeb0, -0.343750}, +{0xbebf, -0.3730468750}, +{0xbeee, -0.464843750}, +{0xbf2b, -0.667968750}, +{0xbfac, -1.343750}, +{0xc022, -2.531250}, +{0xc026, -2.593750}, +{0xc05e, -3.468750}, +{0xc07e, -3.968750}, +{0xc07f, -3.9843750}, +{0xc086, -4.18750}, +{0xc0ae, -5.43750}, +{0xc0c2, -6.06250}, +{0xc0e6, -7.18750}, +{0xc13e, -11.8750}, +{0xc198, -19.0}, +{0xc1be, -23.750}, +{0xc1c1, -24.1250}, +{0xc1eb, -29.3750}, +{0xc225, -41.250}, +{0xc276, -61.50}, +{0xc27f, -63.750}, +{0xc29f, -79.50}, +{0xc313, -147.0}, +{0xc31b, -155.0}, +{0xc324, -164.0}, +{0xc35b, -219.0}, +{0xc394, -296.0}, +{0xc39d, -314.0}, +{0xc3b5, -362.0}, +{0xc3be, -380.0}, +{0xc429, -676.0}, +{0xc444, -784.0}, +{0xc44b, -812.0}, +{0xc4b5, -1448.0}, +{0xc4eb, -1880.0}, +{0xc523, -2608.0}, +{0xc557, -3440.0}, +{0xc55e, -3552.0}, +{0xc56d, -3792.0}, +{0xc58b, -4448.0}, +{0xc64d, -13120.0}, +{0xc6b8, -23552.0}, +{0xc6ca, -25856.0}, +{0xc777, -63232.0}, +{0xc7d6, -109568.0}, +{0xc868, -237568.0}, +{0xc8ca, -413696.0}, +{0xc910, -589824.0}, +{0xc9c5, -1613824.0}, +{0xc9c8, -1638400.0}, +{0xc9df, -1826816.0}, +{0xca3a, -3047424.0}, +{0xca42, -3178496.0}, +{0xca6b, -3850240.0}, +{0xcaa0, -5242880.0}, +{0xcaa2, -5308416.0}, +{0xcaac, -5636096.0}, +{0xcb3a, -12189696.0}, +{0xcb84, -17301504.0}, +{0xcc50, -54525952.0}, +{0xcc89, -71827456.0}, +{0xcc94, -77594624.0}, +{0xccaf, -91750400.0}, +{0xcce0, -117440512.0}, +{0xcce1, -117964800.0}, +{0xcd6d, -248512512.0}, +{0xcda8, -352321536.0}, +{0xcdba, -390070272.0}, +{0xcdd0, -436207616.0}, +{0xcde5, -480247808.0}, +{0xcdf7, -517996544.0}, +{0xce30, -738197504.0}, +{0xcec2, -1627389952.0}, +{0xcf03, -2197815296.0}, +{0xcf25, -2768240640.0}, +{0xcf57, -3607101440.0}, +{0xd036, -12213813248.0}, +{0xd09e, -21206401024.0}, +{0xd103, -35165044736.0}, +{0xd104, -35433480192.0}, +{0xd11f, -42681237504.0}, +{0xd125, -44291850240.0}, +{0xd19c, -83751862272.0}, +{0xd1c7, -106837311488.0}, +{0xd1cf, -111132278784.0}, +{0xd1d8, -115964116992.0}, +{0xd231, -190052302848.0}, +{0xd28a, -296352743424.0}, +{0xd294, -317827579904.0}, +{0xd2be, -408021893120.0}, +{0xd2c1, -414464344064.0}, +{0xd2c6, -425201762304.0}, +{0xd2db, -470298918912.0}, +{0xd334, -773094113280.0}, +{0xd36f, -1026497183744.0}, +{0xd375, -1052266987520.0}, +{0xd3c3, -1675037245440.0}, +{0xd3d5, -1829656068096.0}, +{0xd3f2, -2078764171264.0}, +{0xd44c, -3504693313536.0}, +{0xd49b, -5325759447040.0}, +{0xd4cd, -7043746365440.0}, +{0xd4e8, -7971459301376.0}, +{0xd538, -12644383719424.0}, +{0xd54c, -14018773254144.0}, +{0xd554, -14568529068032.0}, +{0xd5a3, -22402549415936.0}, +{0xd5bf, -26250840113152.0}, +{0xd64a, -55525337202688.0}, +{0xd74f, -227598906949632.0}, +{0xd75f, -245191092994048.0}, +{0xd762, -248489627877376.0}, +{0xd7d6, -470590976688128.0}, +{0xd7db, -481586092965888.0}, +{0xd819, -672901116198912.0}, +{0xd82d, -760862046420992.0}, +{0xd85b, -963172185931776.0}, +{0xd936, -3201777860083712.0}, +{0xd967, -4063794976260096.0}, +{0xd976, -4327677766926336.0}, +{0xd985, -4679521487814656.0}, +{0xd98c, -4925812092436480.0}, +{0xd9c9, -7072058789855232.0}, +{0xda1b, -10907155347537920.0}, +{0xda5a, -15340386230730752.0}, +{0xdab6, -25614222880669696.0}, +{0xdacc, -28710447624486912.0}, +{0xdb00, -36028797018963968.0}, +{0xdb0d, -39687971716202496.0}, +{0xdb24, -46161896180547584.0}, +{0xdb4c, -57420895248973824.0}, +{0xdbbd, -106397541196627968.0}, +{0xdbbf, -107523441103470592.0}, +{0xdbcc, -114841790497947648.0}, +{0xdbf4, -137359788634800128.0}, +{0xdc88, -306244774661193728.0}, +{0xdc9c, -351280770934898688.0}, +{0xdd24, -738590338888761344.0}, +{0xdd71, -1085367510196289536.0}, +{0xdd86, -1206964700135292928.0}, +{0xdd8f, -1288029493427961856.0}, +{0xdea9, -6088866696204910592.0}, +{0xded6, -7710162562058289152.0}, +{0xdedf, -8034421735228964864.0}, +{0xdef6, -8863084066665136128.0}, +{0xdf62, -16285016252571713536.0}, +{0xdf6a, -16861477004875137024.0}, +{0xdf71, -17365880163140632576.0}, +{0xdfc9, -28967152803247030272.0}, +{0xdff0, -34587645138205409280.0}, +{0xdff5, -35308221078584688640.0}, +{0xe037, -52746158835763249152.0}, +{0xe07e, -73210515542534782976.0}, +{0xe09a, -88774955854727217152.0}, +{0xe09d, -90504338111637487616.0}, +{0xe0cc, -117597993469898391552.0}, +{0xe113, -169479461177206505472.0}, +{0xe18f, -329735550317558235136.0}, +{0xe1aa, -391993311566327971840.0}, +{0xe21a, -710199646837817737216.0}, +{0xe233, -825491797298502434816.0}, +{0xe238, -848550227390639374336.0}, +{0xe247, -917725517667050192896.0}, +{0xe262, -1042241040164589666304.0}, +{0xe26a, -1079134528312008769536.0}, +{0xe271, -1111416330441000484864.0}, +{0xe28b, -1282048713122813837312.0}, +{0xe290, -1328165573307087716352.0}, +{0xe2b2, -1641760222560150093824.0}, +{0xe2eb, -2167492428660872314880.0}, +{0xe2f5, -2259726149029420072960.0}, +{0xe34b, -3744689046963038978048.0}, +{0xe363, -4187410904732068216832.0}, +{0xe388, -5017514388048998039552.0}, +{0xe3a0, -5902958103587056517120.0}, +{0xe3bd, -6972869259862210510848.0}, +{0xe3d6, -7895206463547688091648.0}, +{0xe3e4, -8411715297611555536896.0}, +{0xe406, -9887454823508319666176.0}, +{0xe5a3, -96218217088469021229056.0}, +{0xe5ae, -102711471002414783397888.0}, +{0xe5d7, -126913599227121715118080.0}, +{0xe5d9, -128094190847839126421504.0}, +{0xe644, -231395957660612615471104.0}, +{0xe66e, -280980805730743890214912.0}, +{0xe6b8, -434457716424007359660032.0}, +{0xe7f4, -2304514843640386864283648.0}, +{0xe824, -3097872412762487260184576.0}, +{0xe827, -3154540810556923002748928.0}, +{0xe880, -4835703278458516698824704.0}, +{0xe8f2, -9142501510835633133715456.0}, +{0xe928, -12693721105953606334414848.0}, +{0xe980, -19342813113834066795298816.0}, +{0xe9d1, -31583187037432187189198848.0}, +{0xe9fa, -37778931862957161709568000.0}, +{0xea15, -45032486780644936757805056.0}, +{0xea77, -74651169361203351538106368.0}, +{0xeaca, -122101507781077546645323776.0}, +{0xeacd, -123914896510499490407383040.0}, +{0xead9, -131168451428187265455620096.0}, +{0xeada, -131772914337994580042973184.0}, +{0xeb79, -301022529084042664501837824.0}, +{0xeba3, -394109817194369110954213376.0}, +{0xebf3, -587537948332709778907201536.0}, +{0xec09, -662491349148816787738984448.0}, +{0xec13, -710848381933401954727231488.0}, +{0xec48, -967140655691703339764940800.0}, +{0xece9, -2253437727761668781652312064.0}, +{0xed1f, -3075507285099616620452511744.0}, +{0xed24, -3172221350668786954429005824.0}, +{0xed9f, -6151014570199233240905023488.0}, +{0xede6, -8897694032363670725837455360.0}, +{0xedfe, -9826149061827705932011798528.0}, +{0xeea3, -25223028300439623101069656064.0}, +{0xeea5, -25532513310260968169794437120.0}, +{0xeec4, -30329530962491816735028543488.0}, +{0xeee0, -34662321099990647697175478272.0}, +{0xef23, -50446056600879246202139312128.0}, +{0xefa0, -99035203142830421991929937920.0}, +{0xefab, -105843873358900013503875121152.0}, +{0xf020, -198070406285660843983859875840.0}, +{0xf099, -378809652021326364119132012544.0}, +{0xf0a9, -418423733278458532915903987712.0}, +{0xf0cc, -505079536028435152158842683392.0}, +{0xf0e6, -569452418071274926453597143040.0}, +{0xf16b, -1163663636928257458405176770560.0}, +{0xf19b, -1535045648713871540874914037760.0}, +{0xf1bc, -1861861819085211933448282832896.0}, +{0xf1da, -2158967428513703199424072646656.0}, +{0xf231, -3505846191256196938514319802368.0}, +{0xf253, -4179285572627443808059443380224.0}, +{0xf287, -5347900969712842787564216647680.0}, +{0xf296, -5942112188569825319515796275200.0}, +{0xf2f3, -9626221745483117017615589965824.0}, +{0xf339, -14657210065138902454805630812160.0}, +{0xf36e, -18856302678394912347263460179968.0}, +{0xf3b3, -28363682180106632858488734220288.0}, +{0xf3c0, -30423614405477505635920876929024.0}, +{0xf3da, -34543478856219251190785162346496.0}, +{0xf3eb, -37237236381704238668965656657920.0}, +{0xf407, -42783207757702742300513733181440.0}, +{0xf418, -48170722808672717256874721804288.0}, +{0xf425, -52290587259414462811739007221760.0}, +{0xf473, -77009773963864936140924719726592.0}, +{0xf515, -188879939434006180823008777601024.0}, +{0xf57a, -316912650057057350374175801344000.0}, +{0xf594, -375224577667555902843024148791296.0}, +{0xf61c, -791013974542415146533942800154624.0}, +{0xf634, -912708432164325169077626307870720.0}, +{0xf69f, -1612451563490307798703806477238272.0}, +{0xf6b2, -1805134454724998667731305364455424.0}, +{0xf6f0, -2433889152438200450873670154321920.0}, +{0xf71e, -3204620717376963926983665703190528.0}, +{0xf735, -3671116138260952346734452482768896.0}, +{0xf748, -4056481920730334084789450257203200.0}, +{0xf75f, -4522977341614322504540237036781568.0}, +{0xf796, -6084722881095501127184175385804800.0}, +{0xf8a3, -26448262123161778232827215676964864.0}, +{0xf8d0, -33749929580476379585448226139930624.0}, +{0xf8ef, -38779967162181993850587144458862592.0}, +{0xf9a3, -105793048492647112931308862707859456.0}, +{0xfa0d, -183028464263352673905699995605008384.0}, +{0xfa18, -197307280624323449884158860510363648.0}, +{0xfa31, -229759135990166122562474462567989248.0}, +{0xfaa9, -438749084546192934610826939819098112.0}, +{0xfab5, -469902865697401900382009917794418688.0}, +{0xfacd, -532210427999819831924375873745059840.0}, +{0xfb84, -1370766370653194493932051030914105344.0}, +{0xfba8, -1744611744467702083186246766617952256.0}, +{0xfbfa, -2596148429267413814265248164610048000.0}, +{0xfc20, -3323069989462289682259517650700861440.0}, +{0xfc76, -5109220108798270386474008387952574464.0}, +{0xfc93, -6106141105636957291151863683162832896.0}, +{0xfccf, -8598443597733674552846501921188478976.0}, +{0xfcdc, -9138442471021296626213673539427368960.0}, +{0xfcf0, -9969209968386869046778552952102584320.0}, +{0xfd5b, -18193808192306036010370859137587216384.0}, +{0xfda9, -28079941410956347815092924148422279168.0}, +{0xfdca, -33563006893569125790821128272078700544.0}, +{0xfe1d, -52172198834557948011474427116003524608.0}, +{0xfe24, -54498347827181550789056089471494127616.0}, +{0xfe4b, -67458320786084480549868208309227487232.0}, +{0xfe4f, -68787548781869396422772015369507831808.0}, +{0xfe64, -75765995759740204755517002435979640832.0}, +{0xfea2, -107667467658578185705208371882707910656.0}, +{0xfec2, -128935115591136839671669284847193423872.0}, +{0xfee3, -150867377521587951574582101341819109376.0}, +{0xfee9, -154855061508942699193293522522660143104.0}, +{0xff57, -285784019093756912674318517960274083840.0}, +{0xff60, -297747071055821155530452781502797185024.0}, +{0xff8e, std::numeric_limits::quiet_NaN()}, +{0xffb0, std::numeric_limits::quiet_NaN()}, +{0xfffa, std::numeric_limits::quiet_NaN()}, +}; -template -using deduce = typename detail::deduce::type; +TEST_CASE(check_bf16_values) +{ + for(auto [x, f] : bf16_lut) + { -} // namespace MIGRAPHX_INLINE_NS -} // namespace migraphx + auto h = migraphx::bit_cast(x); + if(std::isnan(f)) + { + CHECK(std::isnan(h)); + } + else if(std::isinf(f)) + { + CHECK(std::isinf(h)); + CHECK((h < 0) == (f < 0)); + CHECK(bit_equal(x, migraphx::bf16(f))); + } + else + { + CHECK(bit_equal(x, migraphx::bf16(f))); + CHECK(migraphx::float_equal(float(h), f)); + } + } +} -namespace std { -template -struct common_type : std::common_type // NOLINT +TEST_CASE(check_flows) { -}; + // check positive underflow + CHECK(bit_equal(std::numeric_limits::min() * + std::numeric_limits::min(), + migraphx::bf16(0))); -template -struct common_type : std::common_type // NOLINT + // check overflow + CHECK(bit_equal(std::numeric_limits::infinity() + + std::numeric_limits::infinity(), + std::numeric_limits::infinity())); + CHECK(bit_equal(std::numeric_limits::max() + + std::numeric_limits::max(), + std::numeric_limits::infinity())); + CHECK(bit_equal(std::numeric_limits::max() / + std::numeric_limits::epsilon(), + std::numeric_limits::infinity())); + CHECK(bit_equal(std::numeric_limits::max() + + std::numeric_limits::min(), + std::numeric_limits::max())); + + // check negative underflow + CHECK(bit_equal(std::numeric_limits::lowest() + + std::numeric_limits::lowest(), + -std::numeric_limits::infinity())); + CHECK(bit_equal(-std::numeric_limits::infinity() - + std::numeric_limits::infinity(), + -std::numeric_limits::infinity())); + CHECK(bit_equal(std::numeric_limits::lowest() - + std::numeric_limits::min(), + std::numeric_limits::lowest())); +} + +TEST_CASE(test_nan) { -}; + float f_qnan = std::numeric_limits::quiet_NaN(); + migraphx::bf16 bf16_qnan(f_qnan); + EXPECT(bf16_qnan.is_nan()); + EXPECT(std::isnan(bf16_qnan)); -template <> -struct common_type + float f_snan = std::numeric_limits::signaling_NaN(); + migraphx::bf16 bf16_snan(f_snan); + EXPECT(bf16_snan.is_nan()); + EXPECT(std::isnan(bf16_snan)); +} + +TEST_CASE(test_bool) { - using type = float; -}; + float zero = 0.0; + float two = 2.0; + float other = -0.375; + migraphx::bf16 bf16_zero(zero); + migraphx::bf16 bf16_two(two); + migraphx::bf16 bf16_other(other); + EXPECT(not static_cast(bf16_zero)); + EXPECT(static_cast(bf16_two)); + EXPECT(static_cast(bf16_other)); +} -template <> -struct common_type +TEST_CASE(test_pos_infinity) { - using type = float; -}; + float finf = std::numeric_limits::infinity(); + migraphx::bf16 bf16_inf_1(finf); + CHECK(bit_equal(bf16_inf_1, std::numeric_limits::infinity())); +} -template <> -struct common_type +TEST_CASE(test_neg_infinity) { - using type = float; -}; + float finf = -1.0 * std::numeric_limits::infinity(); + migraphx::bf16 bf16_neginf_1(finf); + CHECK(bit_equal(bf16_neginf_1, -std::numeric_limits::infinity())); +} -template <> -struct common_type +TEST_CASE(test_numeric_max_1) { - using type = float; -}; + float fmax = std::numeric_limits::max(); // fp32 max is fp16 inf + migraphx::bf16 bf16_inf(fmax); + CHECK(bit_equal(bf16_inf, std::numeric_limits::max())); +} -template <> -struct common_type +TEST_CASE(test_numeric_lowest_1) { - using type = float; -}; + float flowest = std::numeric_limits::lowest(); + migraphx::bf16 bf16_neginf(flowest); + CHECK(bit_equal(bf16_neginf, std::numeric_limits::lowest())); +} -template <> -struct common_type +TEST_CASE(test_max_eq_lowest) { - using type = float; -}; + EXPECT(migraphx::float_equal(std::numeric_limits::lowest(), + -1 * std::numeric_limits::max())); +} -template <> -struct common_type +TEST_CASE(test_isfinite) { - using type = migraphx::bf16; -}; + EXPECT(std::isfinite(migraphx::bf16(0.0))); + EXPECT(std::isfinite(migraphx::bf16(-0.0))); + EXPECT(not std::isfinite(migraphx::bf16(std::numeric_limits::quiet_NaN()))); +} + +TEST_CASE(test_binary_ops) +{ + auto a = migraphx::bf16(-1.0); + auto b = migraphx::bf16(1.0); + auto c = migraphx::bf16(0.0); + auto d = migraphx::bf16(-0.0); + EXPECT(migraphx::float_equal((c + d), c)); + EXPECT(migraphx::float_equal((c + d), d)); + EXPECT(migraphx::float_equal((a + b), c)); + EXPECT(migraphx::float_equal((a + b), d)); -} // namespace std + auto e = migraphx::bf16(10.0); + auto f = migraphx::bf16(-10.0); + EXPECT(e > f); + EXPECT(f < e); + EXPECT(f <= e); + EXPECT(e >= f); + EXPECT(e <= e); + EXPECT(f >= f); + EXPECT(not migraphx::float_equal(f, e)); +} + +TEST_CASE(test_stream_op) +{ + auto a = migraphx::bf16(-1.0); + std::stringstream ss; + ss << a; + EXPECT(std::string("-1") == ss.str()); + ss = std::stringstream(); + auto b = std::numeric_limits::quiet_NaN(); + ss << b; + EXPECT(std::string("nan") == ss.str()); +} -#endif +int main(int argc, const char* argv[]) { test::run(argc, argv); } From befbd9eb4f0e450300b19c64781062c9365f6a73 Mon Sep 17 00:00:00 2001 From: Richa Gadgil Date: Fri, 1 Nov 2024 17:22:41 -0700 Subject: [PATCH 50/72] Update bf16.hpp --- src/include/migraphx/bf16.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/migraphx/bf16.hpp b/src/include/migraphx/bf16.hpp index 176cd401605..d6b145c50b3 100644 --- a/src/include/migraphx/bf16.hpp +++ b/src/include/migraphx/bf16.hpp @@ -47,7 +47,7 @@ TEST_CASE(check_numeric_limits) CHECK(bit_equal(std::numeric_limits::min(), uint16_t{0x0080})); CHECK(bit_equal(std::numeric_limits::lowest(), uint16_t{0xff7f})); CHECK(bit_equal(std::numeric_limits::max(), uint16_t{0x7f7f})); - CHECK(bit_equal(std::numeric_limits::epsilon(), uint16_t{0x3c0})); + CHECK(bit_equal(std::numeric_limits::epsilon(), uint16_t{0x3c00})); CHECK(bit_equal(std::numeric_limits::denorm_min(), uint16_t{0x0001})); CHECK(bit_equal(std::numeric_limits::infinity(), uint16_t{0x7f80})); CHECK(bit_equal(std::numeric_limits::quiet_NaN(), uint16_t{0x7fc0})); From 08b951129aa93aab455884555d3209370f1775a4 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Mon, 4 Nov 2024 11:40:56 -0600 Subject: [PATCH 51/72] update files with working version --- src/include/migraphx/bf16.hpp | 1241 +------------------ test/bf16.cpp | 2105 ++++++++++++++++----------------- 2 files changed, 1077 insertions(+), 2269 deletions(-) diff --git a/src/include/migraphx/bf16.hpp b/src/include/migraphx/bf16.hpp index d6b145c50b3..8c9ed6fd9f3 100644 --- a/src/include/migraphx/bf16.hpp +++ b/src/include/migraphx/bf16.hpp @@ -21,1222 +21,79 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include -#include -#include -#include -#include "test.hpp" -#include -#include -#include -#include -#include -#include +#ifndef MIGRAPHX_GUARD_RTGLIB_BF16_HPP +#define MIGRAPHX_GUARD_RTGLIB_BF16_HPP -template -bool bit_equal(const T& x, const U& y) -{ - static_assert(sizeof(T) == sizeof(U)); - using type = std::array; - return migraphx::bit_cast(x) == migraphx::bit_cast(y); -} - -TEST_CASE(check_numeric_limits) -{ - CHECK(bit_equal(std::numeric_limits::min(), uint16_t{0x0080})); - CHECK(bit_equal(std::numeric_limits::lowest(), uint16_t{0xff7f})); - CHECK(bit_equal(std::numeric_limits::max(), uint16_t{0x7f7f})); - CHECK(bit_equal(std::numeric_limits::epsilon(), uint16_t{0x3c00})); - CHECK(bit_equal(std::numeric_limits::denorm_min(), uint16_t{0x0001})); - CHECK(bit_equal(std::numeric_limits::infinity(), uint16_t{0x7f80})); - CHECK(bit_equal(std::numeric_limits::quiet_NaN(), uint16_t{0x7fc0})); - CHECK(bit_equal(std::numeric_limits::signaling_NaN(), uint16_t{0x7fa0})); -} - -static const std::map bf16_lut = { -{0x0000, 0.0}, -{0x002d, 0.00000000000000000000000000000000000000413259732711}, -{0x004e, 0.00000000000000000000000000000000000000716316870032}, -{0x005b, 0.00000000000000000000000000000000000000835703015038}, -{0x00cd, 0.00000000000000000000000000000000000001882627671239}, -{0x00ce, 0.00000000000000000000000000000000000001891811220855}, -{0x0170, 0.00000000000000000000000000000000000004408103815584}, -{0x01be, 0.00000000000000000000000000000000000006979497708007}, -{0x01fe, 0.00000000000000000000000000000000000009330486409652}, -{0x0211, 0.00000000000000000000000000000000000010652917554327}, -{0x028f, 0.00000000000000000000000000000000000021011961520948}, -{0x02bc, 0.00000000000000000000000000000000000027624117244324}, -{0x02e8, 0.00000000000000000000000000000000000034089336173846}, -{0x039c, 0.00000000000000000000000000000000000091688559364138}, -{0x03a9, 0.00000000000000000000000000000000000099329272644483}, -{0x03cf, 0.00000000000000000000000000000000000121663665310107}, -{0x03da, 0.00000000000000000000000000000000000128128884239629}, -{0x03f3, 0.00000000000000000000000000000000000142822563624908}, -{0x0427, 0.00000000000000000000000000000000000196307556587322}, -{0x044c, 0.00000000000000000000000000000000000239800847567747}, -{0x0485, 0.00000000000000000000000000000000000312681497318728}, -{0x0498, 0.00000000000000000000000000000000000357350282649975}, -{0x04da, 0.00000000000000000000000000000000000512515536958517}, -{0x051b, 0.00000000000000000000000000000000000728806497509818}, -{0x0533, 0.00000000000000000000000000000000000841653955188758}, -{0x0536, 0.00000000000000000000000000000000000855759887398625}, -{0x0577, 0.00000000000000000000000000000000001161388418612420}, -{0x0587, 0.00000000000000000000000000000000001269533898888071}, -{0x065a, 0.00000000000000000000000000000000004100124295668139}, -{0x0735, 0.00000000000000000000000000000000013616926559925378}, -{0x075e, 0.00000000000000000000000000000000016701423736483061}, -{0x0765, 0.00000000000000000000000000000000017228045205651446}, -{0x076b, 0.00000000000000000000000000000000017679435036367204}, -{0x07ba, 0.00000000000000000000000000000000027986169504377021}, -{0x07d1, 0.00000000000000000000000000000000031446824873197835}, -{0x07db, 0.00000000000000000000000000000000032951457642250363}, -{0x07eb, 0.00000000000000000000000000000000035358870072734408}, -{0x080d, 0.00000000000000000000000000000000042430644087281290}, -{0x0841, 0.00000000000000000000000000000000058078824885427581}, -{0x08ff, 0.00000000000000000000000000000000153472542443357857}, -{0x09e1, 0.00000000000000000000000000000000541667796858910084}, -{0x0a0b, 0.00000000000000000000000000000000669260655674564459}, -{0x0a0f, 0.00000000000000000000000000000000688519955118436817}, -{0x0a12, 0.00000000000000000000000000000000702964429701341086}, -{0x0a1d, 0.00000000000000000000000000000000755927503171990072}, -{0x0aa2, 0.00000000000000000000000000000001560003254953661041}, -{0x0aaf, 0.00000000000000000000000000000001685188701338831371}, -{0x0ab4, 0.00000000000000000000000000000001733336949948512268}, -{0x0ade, 0.00000000000000000000000000000002137782238269831797}, -{0x0b6e, 0.00000000000000000000000000000004583713267641621330}, -{0x0bb6, 0.00000000000000000000000000000007010384997569538505}, -{0x0c8c, 0.00000000000000000000000000000021570415377137041554}, -{0x0cf7, 0.00000000000000000000000000000038056375701091780456}, -{0x0d06, 0.00000000000000000000000000000041291938007662336690}, -{0x0d20, 0.00000000000000000000000000000049303806576313237838}, -{0x0d5e, 0.00000000000000000000000000000068409031624634617501}, -{0x0d60, 0.00000000000000000000000000000069025329206838532974}, -{0x0d6a, 0.00000000000000000000000000000072106817117858110338}, -{0x0d76, 0.00000000000000000000000000000075804602611081603176}, -{0x0d7e, 0.00000000000000000000000000000078269792939897265068}, -{0x0dcc, 0.00000000000000000000000000000125724706769598756487}, -{0x0dfc, 0.00000000000000000000000000000155306990715386699190}, -{0x0e09, 0.00000000000000000000000000000168865537523872839596}, -{0x0e3c, 0.00000000000000000000000000000231727890908672217840}, -{0x0e69, 0.00000000000000000000000000000287194673307024610408}, -{0x0f42, 0.00000000000000000000000000000956493847580476814062}, -{0x0f8f, 0.00000000000000000000000000001410088868082558602173}, -{0x0fa2, 0.00000000000000000000000000001597443333072548905959}, -{0x1007, 0.00000000000000000000000000002662405555120914843265}, -{0x1015, 0.00000000000000000000000000002938506871948268975159}, -{0x1030, 0.00000000000000000000000000003470987982972451943812}, -{0x1042, 0.00000000000000000000000000003825975390321907256247}, -{0x1056, 0.00000000000000000000000000004220405842932413158953}, -{0x1166, 0.00000000000000000000000000018143800820083271524470}, -{0x1182, 0.00000000000000000000000000020510383535746306940705}, -{0x128a, 0.00000000000000000000000000087090243936399703317455}, -{0x1295, 0.00000000000000000000000000094032219902344607205078}, -{0x129e, 0.00000000000000000000000000099712018419935892204042}, -{0x12b0, 0.00000000000000000000000000111071615455118462201971}, -{0x12bf, 0.00000000000000000000000000120537946317770603866912}, -{0x1315, 0.00000000000000000000000000188064439804689214410156}, -{0x1343, 0.00000000000000000000000000246124602428955683288459}, -{0x13e2, 0.00000000000000000000000000570504206655835737673762}, -{0x13ee, 0.00000000000000000000000000600796465416322591001572}, -{0x1445, 0.00000000000000000000000000994595829302651684263107}, -{0x1469, 0.00000000000000000000000001176349381865572804229970}, -{0x14bd, 0.00000000000000000000000001908412301910671759652054}, -{0x1541, 0.00000000000000000000000003897603960515975128178268}, -{0x1546, 0.00000000000000000000000003998578156384264639270970}, -{0x1569, 0.00000000000000000000000004705397527462291216919879}, -{0x16a1, 0.00000000000000000000000026010952855671378057479844}, -{0x16b6, 0.00000000000000000000000029403685836845905630194606}, -{0x16f4, 0.00000000000000000000000039420326066980225130590570}, -{0x1703, 0.00000000000000000000000042328382907986963050060367}, -{0x1720, 0.00000000000000000000000051698788284564229679463043}, -{0x178e, 0.00000000000000000000000091765349205101507681046902}, -{0x17f6, 0.00000000000000000000000158973773975035006264348858}, -{0x18e8, 0.00000000000000000000000599705944100945064281771302}, -{0x18f1, 0.00000000000000000000000622970398828998967637529671}, -{0x1927, 0.00000000000000000000000863369764352222635647032822}, -{0x1a39, 0.00000000000000000000003825710333057752996280265201}, -{0x1a60, 0.00000000000000000000004632211430296954979279888676}, -{0x1a69, 0.00000000000000000000004818327068121386206125955631}, -{0x1b1f, 0.00000000000000000000013152171739593140030455398204}, -{0x1b43, 0.00000000000000000000016130021944784039659992469495}, -{0x1ba0, 0.00000000000000000000026469779601696885595885078146}, -{0x1bc0, 0.00000000000000000000031763735522036262715062093775}, -{0x1bea, 0.00000000000000000000038712052667481695183981926789}, -{0x1c25, 0.00000000000000000000054593920428499826541512973677}, -{0x1c32, 0.00000000000000000000058895259613775570450844298875}, -{0x1cbe, 0.00000000000000000000125731453108060206580454121195}, -{0x1ccd, 0.00000000000000000000135657620458696538678911025499}, -{0x1cd6, 0.00000000000000000000141613320869078337937985168082}, -{0x1d23, 0.00000000000000000000215728703753829617606463386892}, -{0x1d38, 0.00000000000000000000243521972335611347482142718945}, -{0x1dce, 0.00000000000000000000545277459794955843275232609813}, -{0x1e7c, 0.00000000000000000001334076891925523034032607938570}, -{0x1e9e, 0.00000000000000000001672890070827243169659936938842}, -{0x1eb1, 0.00000000000000000001874060395800139500188663532754}, -{0x1f33, 0.00000000000000000003790472438962994017330743190541}, -{0x1f56, 0.00000000000000000004531626267810506814015525378636}, -{0x1fa8, 0.00000000000000000007115076756936122848173909005709}, -{0x1fed, 0.00000000000000000010037340424963459017959621633054}, -{0x2001, 0.00000000000000000010926725019580474373981360258767}, -{0x213f, 0.00000000000000000064713317170228545904819839051925}, -{0x2154, 0.00000000000000000071828393927164668752993748057634}, -{0x216b, 0.00000000000000000079621097041904231872422315063886}, -{0x219f, 0.00000000000000000107742590890747003129490622086450}, -{0x2225, 0.00000000000000000223616698075135289514037140179425}, -{0x2229, 0.00000000000000000229037708937562811684074404183775}, -{0x2274, 0.00000000000000000330681662608078852372273104265332}, -{0x227b, 0.00000000000000000340168431617327016169838316272944}, -{0x2294, 0.00000000000000000401154803819636640582757536321878}, -{0x22b7, 0.00000000000000000496022493912118278558409656397998}, -{0x2379, 0.00000000000000001349831704744453020339278737083077}, -{0x2389, 0.00000000000000001485356976305141074590210337191820}, -{0x2464, 0.00000000000000004943961906533900219073984771966934}, -{0x2475, 0.00000000000000005312590645178971726636518724262714}, -{0x2491, 0.00000000000000006288372600415925717243226245045662}, -{0x24f6, 0.00000000000000010668549377257363630633335560560226}, -{0x2567, 0.00000000000000020036056147532121940457727760076523}, -{0x256a, 0.00000000000000020296264668928643004619516432285309}, -{0x257f, 0.00000000000000022117724318704290453752037137746811}, -{0x25f9, 0.00000000000000043194614551822496650856919586658478}, -{0x263b, 0.00000000000000064878658001532585331005975604057312}, -{0x270c, 0.00000000000000194289029309402394574135541915893555}, -{0x272c, 0.00000000000000238697950294408656191080808639526367}, -{0x2745, 0.00000000000000273392419813944798079319298267364502}, -{0x2791, 0.00000000000000402455846426619245903566479682922363}, -{0x2792, 0.00000000000000405231403988182137254625558853149414}, -{0x27a0, 0.00000000000000444089209850062616169452667236328125}, -{0x27a3, 0.00000000000000452415882534751290222629904747009277}, -{0x27d4, 0.00000000000000588418203051332966424524784088134766}, -{0x27dd, 0.00000000000000613398221105398988584056496620178223}, -{0x2821, 0.00000000000000893729534823251015041023492813110352}, -{0x28d9, 0.00000000000002409183963436589692719280719757080078}, -{0x2981, 0.00000000000005728750807065807748585939407348632812}, -{0x29ca, 0.00000000000008970602038971264846622943878173828125}, -{0x2a5b, 0.00000000000019451107391432742588222026824951171875}, -{0x2aa8, 0.00000000000029842794901924207806587219238281250}, -{0x2ac4, 0.000000000000348165940522449091076850891113281250}, -{0x2ae7, 0.00000000000041033842990145785734057426452636718750}, -{0x2af1, 0.00000000000042810199829546036198735237121582031250}, -{0x2afe, 0.0000000000004511946372076636180281639099121093750}, -{0x2b24, 0.00000000000058264504332328215241432189941406250}, -{0x2b4c, 0.00000000000072475359047530218958854675292968750}, -{0x2b85, 0.000000000000945021838560933247208595275878906250}, -{0x2bed, 0.000000000001683986283751437440514564514160156250}, -{0x2c18, 0.00000000000216004991671070456504821777343750}, -{0x2cdf, 0.0000000000063380412029800936579704284667968750}, -{0x2d6b, 0.000000000013358203432289883494377136230468750}, -{0x2d96, 0.0000000000170530256582424044609069824218750}, -{0x2da2, 0.0000000000184172677109017968177795410156250}, -{0x2db8, 0.00000000002091837814077734947204589843750}, -{0x2de1, 0.00000000002557953848736360669136047363281250}, -{0x2e90, 0.00000000006548361852765083312988281250}, -{0x2ea3, 0.000000000074123818194493651390075683593750}, -{0x2ef0, 0.00000000010913936421275138854980468750}, -{0x2f09, 0.00000000012460077414289116859436035156250}, -{0x2f6b, 0.00000000021373125491663813591003417968750}, -{0x303b, 0.000000000680302036926150321960449218750}, -{0x308f, 0.00000000104046193882822990417480468750}, -{0x309c, 0.000000001135049387812614440917968750}, -{0x30a9, 0.00000000122963683679699897766113281250}, -{0x312a, 0.000000002473825588822364807128906250}, -{0x313d, 0.0000000027503119781613349914550781250}, -{0x3159, 0.0000000031577656045556068420410156250}, -{0x31c6, 0.00000000576255843043327331542968750}, -{0x3212, 0.0000000084983184933662414550781250}, -{0x3245, 0.00000001146690919995307922363281250}, -{0x329b, 0.0000000180443748831748962402343750}, -{0x32ba, 0.000000021653249859809875488281250}, -{0x32cc, 0.00000002374872565269470214843750}, -{0x3332, 0.00000004144385457038879394531250}, -{0x33c4, 0.000000091269612312316894531250}, -{0x3424, 0.00000015273690223693847656250}, -{0x3589, 0.0000010207295417785644531250}, -{0x3594, 0.00000110268592834472656250}, -{0x368b, 0.00000414252281188964843750}, -{0x36a0, 0.000004768371582031250}, -{0x36e9, 0.00000694394111633300781250}, -{0x36ed, 0.00000706315040588378906250}, -{0x3750, 0.000012397766113281250}, -{0x375f, 0.0000132918357849121093750}, -{0x37ce, 0.00002455711364746093750}, -{0x37d2, 0.00002503395080566406250}, -{0x37f0, 0.00002861022949218750}, -{0x380e, 0.0000338554382324218750}, -{0x3826, 0.0000395774841308593750}, -{0x387f, 0.00006079673767089843750}, -{0x38e1, 0.0001072883605957031250}, -{0x38e9, 0.0001111030578613281250}, -{0x3964, 0.0002174377441406250}, -{0x3994, 0.000282287597656250}, -{0x3a26, 0.000633239746093750}, -{0x3a2c, 0.00065612792968750}, -{0x3a6a, 0.000892639160156250}, -{0x3a85, 0.001014709472656250}, -{0x3ab9, 0.001411437988281250}, -{0x3aba, 0.00141906738281250}, -{0x3af7, 0.001884460449218750}, -{0x3b03, 0.00199890136718750}, -{0x3bb3, 0.0054626464843750}, -{0x3bbf, 0.0058288574218750}, -{0x3be8, 0.0070800781250}, -{0x3c06, 0.00817871093750}, -{0x3c29, 0.010314941406250}, -{0x3c3f, 0.011657714843750}, -{0x3c73, 0.014831542968750}, -{0x3ce9, 0.02844238281250}, -{0x3cfa, 0.0305175781250}, -{0x3cfb, 0.03063964843750}, -{0x3d0f, 0.0349121093750}, -{0x3d2a, 0.041503906250}, -{0x3d43, 0.0476074218750}, -{0x3dd0, 0.10156250}, -{0x3dd9, 0.105957031250}, -{0x3de9, 0.113769531250}, -{0x3df9, 0.121582031250}, -{0x3e1e, 0.1542968750}, -{0x3e77, 0.24121093750}, -{0x3e95, 0.2910156250}, -{0x3f38, 0.718750}, -{0x3fb3, 1.39843750}, -{0x3fc5, 1.53906250}, -{0x3fd3, 1.64843750}, -{0x3fd7, 1.67968750}, -{0x400b, 2.1718750}, -{0x40bf, 5.968750}, -{0x40c7, 6.218750}, -{0x4123, 10.18750}, -{0x412b, 10.68750}, -{0x41bf, 23.8750}, -{0x41ca, 25.250}, -{0x421b, 38.750}, -{0x4226, 41.50}, -{0x42a7, 83.50}, -{0x42b7, 91.50}, -{0x4311, 145.0}, -{0x431f, 159.0}, -{0x4334, 180.0}, -{0x434f, 207.0}, -{0x43b1, 354.0}, -{0x43e5, 458.0}, -{0x4476, 984.0}, -{0x4496, 1200.0}, -{0x44a4, 1312.0}, -{0x458b, 4448.0}, -{0x45a9, 5408.0}, -{0x45df, 7136.0}, -{0x45f6, 7872.0}, -{0x45fa, 8000.0}, -{0x4602, 8320.0}, -{0x4640, 12288.0}, -{0x4648, 12800.0}, -{0x46a7, 21376.0}, -{0x46b1, 22656.0}, -{0x4742, 49664.0}, -{0x4744, 50176.0}, -{0x475e, 56832.0}, -{0x477a, 64000.0}, -{0x4837, 187392.0}, -{0x488a, 282624.0}, -{0x488f, 292864.0}, -{0x48ea, 479232.0}, -{0x495c, 901120.0}, -{0x49aa, 1392640.0}, -{0x49b9, 1515520.0}, -{0x4a1e, 2588672.0}, -{0x4a2b, 2801664.0}, -{0x4a4c, 3342336.0}, -{0x4ab6, 5963776.0}, -{0x4b34, 11796480.0}, -{0x4b73, 15925248.0}, -{0x4b7b, 16449536.0}, -{0x4bcd, 26869760.0}, -{0x4bd0, 27262976.0}, -{0x4c07, 35389440.0}, -{0x4c17, 39583744.0}, -{0x4c53, 55312384.0}, -{0x4cad, 90701824.0}, -{0x4d1c, 163577856.0}, -{0x4dc0, 402653184.0}, -{0x4dde, 465567744.0}, -{0x4eef, 2004877312.0}, -{0x4efc, 2113929216.0}, -{0x4f12, 2449473536.0}, -{0x4f2f, 2936012800.0}, -{0x4f92, 4898947072.0}, -{0x4fad, 5804916736.0}, -{0x4fdc, 7381975040.0}, -{0x4feb, 7885291520.0}, -{0x5076, 16508780544.0}, -{0x5083, 17582522368.0}, -{0x5215, 159987531776.0}, -{0x52a9, 362924736512.0}, -{0x5394, 1271310319616.0}, -{0x53a0, 1374389534720.0}, -{0x53b7, 1571958030336.0}, -{0x540e, 2439541424128.0}, -{0x542f, 3006477107200.0}, -{0x5465, 3934190043136.0}, -{0x5529, 11613591568384.0}, -{0x554c, 14018773254144.0}, -{0x5596, 20615843020800.0}, -{0x55ae, 23914377904128.0}, -{0x55be, 26113401159680.0}, -{0x55da, 29961691856896.0}, -{0x568d, 77515569758208.0}, -{0x5690, 79164837199872.0}, -{0x56ad, 95107755802624.0}, -{0x5718, 167125767421952.0}, -{0x571c, 171523813933056.0}, -{0x571d, 172623325560832.0}, -{0x5826, 730075720843264.0}, -{0x587c, 1108307720798208.0}, -{0x5890, 1266637395197952.0}, -{0x58a8, 1477743627730944.0}, -{0x58f6, 2163838883463168.0}, -{0x5966, 4046202790215680.0}, -{0x5985, 4679521487814656.0}, -{0x59ad, 6086896371367936.0}, -{0x59b0, 6192449487634432.0}, -{0x59bc, 6614661952700416.0}, -{0x5a93, 20688410788233216.0}, -{0x5ab0, 24769797950537728.0}, -{0x5ab6, 25614222880669696.0}, -{0x5ae3, 31947409856659456.0}, -{0x5af5, 34480684647055360.0}, -{0x5afd, 35606584553897984.0}, -{0x5bb6, 102456891522678784.0}, -{0x5c3d, 212795082393255936.0}, -{0x5d57, 968273919884656640.0}, -{0x5d76, 1107885508333142016.0}, -{0x5d86, 1206964700135292928.0}, -{0x5db2, 1603281467343896576.0}, -{0x5dc1, 1738389456165011456.0}, -{0x5dc5, 1774418253183975424.0}, -{0x5e5d, 3981182070595518464.0}, -{0x5fa4, 23634890844440363008.0}, -{0x5fa8, 24211351596743786496.0}, -{0x5ff8, 35740566642812256256.0}, -{0x6006, 38622870404329373696.0}, -{0x6051, 60240148615707754496.0}, -{0x60ed, 136621198295911366656.0}, -{0x610b, 160256089140351729664.0}, -{0x6114, 170632382681813352448.0}, -{0x613b, 215596321361480384512.0}, -{0x6148, 230584300921369395200.0}, -{0x61ad, 398910840593969053696.0}, -{0x61fd, 583378281331064569856.0}, -{0x629f, 1466516153859909353472.0}, -{0x62a4, 1512633014044183232512.0}, -{0x62fb, 2315066381250548727808.0}, -{0x634b, 3744689046963038978048.0}, -{0x635a, 4021390208068682252288.0}, -{0x635f, 4113623928437230010368.0}, -{0x637c, 4648579506574807007232.0}, -{0x638d, 5201981828786093555712.0}, -{0x63a9, 6234999496913828446208.0}, -{0x6469, 17192365476697302106112.0}, -{0x64c0, 28334198897217871282176.0}, -{0x64d1, 30842956091242370301952.0}, -{0x64dd, 32613843522318487257088.0}, -{0x64ee, 35122600716342986276864.0}, -{0x64ef, 35270174668932662689792.0}, -{0x64fb, 37041062100008779644928.0}, -{0x6510, 42501298345826806923264.0}, -{0x6581, 76148159536273029070848.0}, -{0x65d4, 125142711796045598162944.0}, -{0x6612, 172366376624742050299904.0}, -{0x661c, 184172292831916163334144.0}, -{0x66c6, 467514281804094876155904.0}, -{0x66ed, 559600428220052957822976.0}, -{0x66f9, 587934627117270829105152.0}, -{0x6703, 618630009255923522994176.0}, -{0x6752, 991696961402625494876160.0}, -{0x6797, 1426154677826632854536192.0}, -{0x679c, 1473378342655329306673152.0}, -{0x67e3, 2143954383222818927017984.0}, -{0x6862, 4269019300514159273181184.0}, -{0x692f, 13222626152035006598348800.0}, -{0x693d, 14280436244197807126216704.0}, -{0x6943, 14733783426553293066731520.0}, -{0x695e, 16773845747152979799048192.0}, -{0x69ec, 35663311678631560653832192.0}, -{0x69f4, 36872237498246189828538368.0}, -{0x6a5c, 66490920078804604608839680.0}, -{0x6a7a, 75557863725914323419136000.0}, -{0x6ac3, 117870267412426344533852160.0}, -{0x6ad8, 130563988518379950868267008.0}, -{0x6ae3, 137213080526260411329150976.0}, -{0x6b37, 221233424989477138971230208.0}, -{0x6b77, 298604677444813406152425472.0}, -{0x6bd7, 519838102434290545123655680.0}, -{0x6be7, 558523728661958678714253312.0}, -{0x6c15, 720519788490318988124880896.0}, -{0x6c33, 865590886844074489089622016.0}, -{0x6c43, 942962139299410756270817280.0}, -{0x6c45, 952633545856327789668466688.0}, -{0x6c48, 967140655691703339764940800.0}, -{0x6da6, 6421813953792910176039206912.0}, -{0x6dba, 7195526478346272847851159552.0}, -{0x6def, 9245864668412683928152834048.0}, -{0x6e24, 12688885402675147817716023296.0}, -{0x6e28, 12998370412496492886440804352.0}, -{0x6e3d, 14623166714058554497245904896.0}, -{0x6ea0, 24758800785707605497982484480.0}, -{0x6eef, 36983458673650735712611336192.0}, -{0x6ef9, 38530883722757461056235241472.0}, -{0x6f55, 65920307091946499638378364928.0}, -{0x6f5c, 68086702160695915119451832320.0}, -{0x6f65, 70872067249088020737974861824.0}, -{0x6f9e, 97797263103545041717030813696.0}, -{0x6fdc, 136173404321391830238903664640.0}, -{0x70ab, 423375493435600054015500484608.0}, -{0x70dc, 544693617285567320955614658560.0}, -{0x714a, 1000255551742587262118492372992.0}, -{0x71ba, 1842054778456645849049896845312.0}, -{0x71d3, 2089642786313721904029721690112.0}, -{0x71ee, 2357037834799364043407932522496.0}, -{0x71f6, 2436265997313628381001476472832.0}, -{0x7251, 4139671491370311639262671405056.0}, -{0x72b8, 7288990951312319058606043430912.0}, -{0x731f, 12597277839768029677373488103424.0}, -{0x7328, 13310331302396408715715383656448.0}, -{0x7356, 16954826778052568245018405371904.0}, -{0x7358, 17113283103081096920205493272576.0}, -{0x7375, 19410899815994762710418267832320.0}, -{0x737c, 19965496953594613073573075484672.0}, -{0x7467, 73206822163180247936434610110464.0}, -{0x74a4, 103947349218714810922729662840832.0}, -{0x74b1, 112187078120198302032458233675776.0}, -{0x7530, 223106505640168374663419764146176.0}, -{0x7563, 287756686251808074139751627620352.0}, -{0x756f, 302968493454546826957712066084864.0}, -{0x7571, 305503794655003285760705472495616.0}, -{0x7626, 841719998551544322593810928369664.0}, -{0x7660, 1135814937804493543741046072016896.0}, -{0x7675, 1242297588223664813466769141268480.0}, -{0x76b2, 1805134454724998667731305364455424.0}, -{0x772c, 3488574451828087312918927221194752.0}, -{0x77b2, 7220537818899994670925221457821696.0}, -{0x783a, 15090112745116842795416754956795904.0}, -{0x795d, 71718600358512306619077480547352576.0}, -{0x796e, 77235415770705560974391132897148928.0}, -{0x798c, 90865195024359483499283685761351680.0}, -{0x79af, 113581493780449354374104607201689600.0}, -{0x7aa5, 428364490829123279353765947160657920.0}, -{0x7acf, 537402724858354659552906370074279936.0}, -{0x7adc, 571152654438831039138354596214210560.0}, -{0x7b07, 700960075902201729851617004444712960.0}, -{0x7b0f, 742498450770480350879860975078473728.0}, -{0x7b12, 758075341346084833765452464066134016.0}, -{0x7b30, 913844247102129662621367353942736896.0}, -{0x7bc2, 2014611181111513119869832575737397248.0}, -{0x7bd1, 2170380086867557948725747465614000128.0}, -{0x7bd5, 2211918461735836569753991436247760896.0}, -{0x7cf1, 10010748343255147667806796922736345088.0}, -{0x7d2f, 14538431203897517359885389721816268800.0}, -{0x7da0, 26584559915698317458076141205606891520.0}, -{0x7e58, 71778311772385457136805581255138607104.0}, -{0x7e81, 85735205728127073802295555388082225152.0}, -{0x7f09, 182104235422533474587821567258407206912.0}, -{0x7f24, 217993391308726203156224357885976510464.0}, -{0x7f86, std::numeric_limits::quiet_NaN()}, -{0x7f88, std::numeric_limits::quiet_NaN()}, -{0x7f8f, std::numeric_limits::quiet_NaN()}, -{0x7fa0, std::numeric_limits::quiet_NaN()}, -{0x7fcd, std::numeric_limits::quiet_NaN()}, -{0x8023, -0.00000000000000000000000000000000000000321424236553}, -{0x8074, -0.00000000000000000000000000000000000001065291755433}, -{0x8080, -0.00000000000000000000000000000000000001175494350822}, -{0x80a5, -0.00000000000000000000000000000000000001515285686607}, -{0x80d2, -0.00000000000000000000000000000000000001928545419318}, -{0x80fd, -0.00000000000000000000000000000000000002323438052797}, -{0x810a, -0.00000000000000000000000000000000000002534659693961}, -{0x8124, -0.00000000000000000000000000000000000003012204273982}, -{0x81e3, -0.00000000000000000000000000000000000008338663051146}, -{0x81f1, -0.00000000000000000000000000000000000008852941829630}, -{0x8285, -0.00000000000000000000000000000000000019542593582421}, -{0x828b, -0.00000000000000000000000000000000000020424214345537}, -{0x829f, -0.00000000000000000000000000000000000023362950222593}, -{0x82bc, -0.00000000000000000000000000000000000027624117244324}, -{0x82ee, -0.00000000000000000000000000000000000034970956936963}, -{0x82f9, -0.00000000000000000000000000000000000036587261669344}, -{0x8393, -0.00000000000000000000000000000000000086398834785438}, -{0x8394, -0.00000000000000000000000000000000000086986581960849}, -{0x843e, -0.00000000000000000000000000000000000223343926656235}, -{0x8451, -0.00000000000000000000000000000000000245678319321858}, -{0x847f, -0.00000000000000000000000000000000000299751059459683}, -{0x8483, -0.00000000000000000000000000000000000307979519915439}, -{0x84a0, -0.00000000000000000000000000000000000376158192263132}, -{0x84aa, -0.00000000000000000000000000000000000399668079279578}, -{0x84ba, -0.00000000000000000000000000000000000437283898505891}, -{0x84e4, -0.00000000000000000000000000000000000536025423974963}, -{0x8510, -0.00000000000000000000000000000000000677084746073638}, -{0x854d, -0.00000000000000000000000000000000000963905367674276}, -{0x8557, -0.00000000000000000000000000000000001010925141707167}, -{0x8584, -0.00000000000000000000000000000000001241322034468336}, -{0x85b7, -0.00000000000000000000000000000000001720923729603829}, -{0x8656, -0.00000000000000000000000000000000004024892657215512}, -{0x87c7, -0.00000000000000000000000000000000029942192104145307}, -{0x88d9, -0.00000000000000000000000000000000130602124353759431}, -{0x896c, -0.00000000000000000000000000000000284074666797117288}, -{0x89a0, -0.00000000000000000000000000000000385185988877447171}, -{0x89b2, -0.00000000000000000000000000000000428519412626159977}, -{0x89fe, -0.00000000000000000000000000000000611482757342947383}, -{0x8a31, -0.00000000000000000000000000000000852224000391351865}, -{0x8a55, -0.00000000000000000000000000000001025557695386203092}, -{0x8a68, -0.00000000000000000000000000000001117039367744596795}, -{0x8b4a, -0.00000000000000000000000000000003890378487662216423}, -{0x8b4c, -0.00000000000000000000000000000003928897086549961140}, -{0x8b5b, -0.00000000000000000000000000000004217786578208046518}, -{0x8bbf, -0.00000000000000000000000000000007357052387559240959}, -{0x8bff, -0.00000000000000000000000000000009822242716374902851}, -{0x8c43, -0.00000000000000000000000000000015022253566220439654}, -{0x8c6b, -0.00000000000000000000000000000018103741477240017019}, -{0x8d1d, -0.00000000000000000000000000000048379360203007364629}, -{0x8d23, -0.00000000000000000000000000000050228252949619111048}, -{0x8d30, -0.00000000000000000000000000000054234187233944561622}, -{0x8dee, -0.00000000000000000000000000000146678824564531882569}, -{0x8e54, -0.00000000000000000000000000000261310174854460160543}, -{0x8e68, -0.00000000000000000000000000000285962078142616779462}, -{0x8eb0, -0.00000000000000000000000000000433873497871556492976}, -{0x8efe, -0.00000000000000000000000000000626158343519178120546}, -{0x8f3d, -0.00000000000000000000000000000931841944292320195143}, -{0x8f95, -0.00000000000000000000000000001469253435974134487579}, -{0x8fa3, -0.00000000000000000000000000001607304094387811553526}, -{0x8fbe, -0.00000000000000000000000000001873544649899903037853}, -{0x9009, -0.00000000000000000000000000002701848600381965433535}, -{0x9017, -0.00000000000000000000000000002977949917209319565429}, -{0x90a8, -0.00000000000000000000000000006626431603856499165459}, -{0x90d2, -0.00000000000000000000000000008283039504820623956823}, -{0x9260, -0.00000000000000000000000000070681937107802657764891}, -{0x92d0, -0.00000000000000000000000000131266454628776364420512}, -{0x92ed, -0.00000000000000000000000000149568027629903838306064}, -{0x9356, -0.00000000000000000000000000270105973947674442172976}, -{0x94af, -0.00000000000000000000000001767048427695066444122272}, -{0x9503, -0.00000000000000000000000002645523931749185190628773}, -{0x953c, -0.00000000000000000000000003796629764647685617085567}, -{0x9556, -0.00000000000000000000000004321695583162791074767614}, -{0x9598, -0.00000000000000000000000006139231108792002274436236}, -{0x9599, -0.00000000000000000000000006179620787139318078873317}, -{0x95cf, -0.00000000000000000000000008360663417894371518475664}, -{0x95df, -0.00000000000000000000000009006898271451424389468952}, -{0x95f4, -0.00000000000000000000000009855081516745056282647643}, -{0x960f, -0.00000000000000000000000011551448007332320069005024}, -{0x9615, -0.00000000000000000000000012036124147500109722249990}, -{0x966a, -0.00000000000000000000000018902369466543796476553675}, -{0x968c, -0.00000000000000000000000022618219874496850484765081}, -{0x96b3, -0.00000000000000000000000028919009696678115976949640}, -{0x96d7, -0.00000000000000000000000034735123378691591815889232}, -{0x9719, -0.00000000000000000000000049436966297114544630986535}, -{0x9761, -0.00000000000000000000000072701421025168447986744905}, -{0x97f0, -0.00000000000000000000000155096364853692689038389130}, -{0x97fd, -0.00000000000000000000000163497417949934376361301874}, -{0x983c, -0.00000000000000000000000242984304937451879493476303}, -{0x987d, -0.00000000000000000000000326994835899868752722603749}, -{0x9895, -0.00000000000000000000000385155972720003511111999672}, -{0x98b3, -0.00000000000000000000000462704155146849855631194237}, -{0x98fa, -0.00000000000000000000000646234853557052870993288041}, -{0x998f, -0.00000000000000000000001478585344938536968832643037}, -{0x999b, -0.00000000000000000000001602662436821491120063354341}, -{0x99e4, -0.00000000000000000000002357464745776128873383514772}, -{0x9a8b, -0.00000000000000000000005748905257243542340356290410}, -{0x9a95, -0.00000000000000000000006162495563520056177791994756}, -{0x9a9f, -0.00000000000000000000006576085869796570015227699102}, -{0x9bb2, -0.00000000000000000000029447629806887785225422149438}, -{0x9bc4, -0.00000000000000000000032425480012078684854959220729}, -{0x9c09, -0.00000000000000000000045329497567905916582953196325}, -{0x9c79, -0.00000000000000000000082387189010281556417192305730}, -{0x9cca, -0.00000000000000000000133672386988569272259219644639}, -{0x9d21, -0.00000000000000000000213081725793659929046874879077}, -{0x9d2d, -0.00000000000000000000228963593554678060404405925965}, -{0x9d53, -0.00000000000000000000279256174797902143036587574443}, -{0x9d59, -0.00000000000000000000287197108678411208715353097887}, -{0x9d9b, -0.00000000000000000000410281583826301726736218711267}, -{0x9dc9, -0.00000000000000000000532042569994107400477290070739}, -{0x9e3a, -0.00000000000000000000984675801183124144166924907040}, -{0x9eb4, -0.00000000000000000001905824131322175762903725626529}, -{0x9eb7, -0.00000000000000000001937587866844212025618787720305}, -{0x9ec3, -0.00000000000000000002064642808932357076479036095407}, -{0x9ee0, -0.00000000000000000002371692252312040949391303001903}, -{0x9f0a, -0.00000000000000000002922263668027336169785712627345}, -{0x9f5b, -0.00000000000000000004637505386217294356399065691221}, -{0x9fb7, -0.00000000000000000007750351467376848102475150881219}, -{0xa007, -0.00000000000000000011434944787933054577422353759175}, -{0xa06c, -0.00000000000000000019989977555201488002012411016040}, -{0xa07a, -0.00000000000000000021175823681357508476708062516991}, -{0xa0c0, -0.00000000000000000032526065174565133020223584026098}, -{0xa0e5, -0.00000000000000000038794108984246955529329170531128}, -{0xa108, -0.00000000000000000046078592330633938445316744036973}, -{0xa128, -0.00000000000000000056920614055488982785391272045672}, -{0xa178, -0.00000000000000000084025668367626593635577592067420}, -{0xa1f6, -0.00000000000000000166696084019646306728645868133754}, -{0xa305, -0.00000000000000000720994444702860448614956112578511}, -{0xa312, -0.00000000000000000791467585914418236825440544635057}, -{0xa3f2, -0.00000000000000002623769257414920730298035778105259}, -{0xa3f3, -0.00000000000000002634611279139775774638110306113958}, -{0xa40a, -0.00000000000000002992397996059992237860569730401039}, -{0xa412, -0.00000000000000003165870343657672947301762178540230}, -{0xa413, -0.00000000000000003187554387107383035981911234557629}, -{0xa421, -0.00000000000000003491130995403324277503998018801212}, -{0xa450, -0.00000000000000004510281037539698445471003651618958}, -{0xa456, -0.00000000000000004640385298237958977551897987723351}, -{0xa4a4, -0.00000000000000007112366251504909087088890373706818}, -{0xa4c9, -0.00000000000000008716985466783455649419920518994331}, -{0xa4ed, -0.00000000000000010278236595162582034390652552247047}, -{0xa522, -0.00000000000000014051260155412137464736588299274445}, -{0xa53a, -0.00000000000000016132928326584305978030897676944733}, -{0xa541, -0.0000000000000001674008154317618846107507124543190}, -{0xa6f7, -0.00000000000000171390679426508540927898138761520386}, -{0xa76c, -0.00000000000000327515792264421179424971342086791992}, -{0xa7a3, -0.00000000000000452415882534751290222629904747009277}, -{0xa7ae, -0.00000000000000482947015711943095084279775619506836}, -{0xa7bc, -0.00000000000000521804821573823573999106884002685547}, -{0xa837, -0.00000000000001015854067532018234487622976303100586}, -{0xa83e, -0.00000000000001054711873393898713402450084686279297}, -{0xa881, -0.00000000000001432187701766451937146484851837158203}, -{0xa8b9, -0.00000000000002053912595556539599783718585968017578}, -{0xa8c2, -0.00000000000002153832667772803688421845436096191406}, -{0xa8ca, -0.00000000000002242650509742816211655735969543457031}, -{0xa8d6, -0.00000000000002375877272697834996506571769714355469}, -{0xa8e4, -0.00000000000002531308496145356912165880203247070312}, -{0xa92d, -0.00000000000003841371665203041629865765571594238281}, -{0xa933, -0.00000000000003974598428158060414716601371765136719}, -{0xa937, -0.00000000000004063416270128072937950491905212402344}, -{0xa950, -0.0000000000000461852778244065120816230773925781250}, -{0xa956, -0.00000000000004751754545395669993013143539428710938}, -{0xa9b8, -0.0000000000000817124146124115213751792907714843750}, -{0xa9c6, -0.00000000000008792966355031239800155162811279296875}, -{0xa9f0, -0.000000000000106581410364015027880668640136718750}, -{0xaa2d, -0.00000000000015365486660812166519463062286376953125}, -{0xaae6, -0.0000000000004085620730620576068758964538574218750}, -{0xaaff, -0.00000000000045297099404706386849284172058105468750}, -{0xab12, -0.000000000000518696197104873135685920715332031250}, -{0xab42, -0.000000000000689226453687297180294990539550781250}, -{0xabfa, -0.00000000000177635683940025046467781066894531250}, -{0xac3a, -0.0000000000026432189770275726914405822753906250}, -{0xadbb, -0.00000000002125943865394219756126403808593750}, -{0xadc3, -0.00000000002216893335571512579917907714843750}, -{0xadda, -0.0000000000247837306233122944831848144531250}, -{0xaddf, -0.00000000002535216481192037463188171386718750}, -{0xae16, -0.000000000034106051316484808921813964843750}, -{0xae77, -0.0000000000561612978344783186912536621093750}, -{0xaee2, -0.00000000010277290130034089088439941406250}, -{0xb03e, -0.00000000069121597334742546081542968750}, -{0xb050, -0.00000000075669959187507629394531250}, -{0xb075, -0.000000000891304807737469673156738281250}, -{0xb11d, -0.0000000022846506908535957336425781250}, -{0xb125, -0.0000000024010660126805305480957031250}, -{0xb139, -0.0000000026921043172478675842285156250}, -{0xb155, -0.0000000030995579436421394348144531250}, -{0xb18d, -0.000000004103640094399452209472656250}, -{0xb23c, -0.000000010943040251731872558593750}, -{0xb2a8, -0.0000000195577740669250488281250}, -{0xb341, -0.000000044936314225196838378906250}, -{0xb369, -0.000000054249539971351623535156250}, -{0xb37b, -0.000000058440491557121276855468750}, -{0xb3c6, -0.0000000922009348869323730468750}, -{0xb3c9, -0.00000009359791874885559082031250}, -{0xb3dc, -0.000000102445483207702636718750}, -{0xb3e2, -0.0000001052394509315490722656250}, -{0xb404, -0.00000012293457984924316406250}, -{0xb42d, -0.0000001611188054084777832031250}, -{0xb487, -0.000000251457095146179199218750}, -{0xb499, -0.000000284984707832336425781250}, -{0xb49b, -0.000000288709998130798339843750}, -{0xb4be, -0.00000035390257835388183593750}, -{0xb599, -0.0000011399388313293457031250}, -{0xb5be, -0.000001415610313415527343750}, -{0xb661, -0.000003352761268615722656250}, -{0xb67f, -0.000003799796104431152343750}, -{0xb6f4, -0.000007271766662597656250}, -{0xb70f, -0.0000085234642028808593750}, -{0xb729, -0.0000100731849670410156250}, -{0xb731, -0.0000105500221252441406250}, -{0xb735, -0.0000107884407043457031250}, -{0xb76f, -0.0000142455101013183593750}, -{0xb770, -0.000014305114746093750}, -{0xb7a4, -0.0000195503234863281250}, -{0xb7b1, -0.000021100044250488281250}, -{0xb829, -0.00004029273986816406250}, -{0xb882, -0.000061988830566406250}, -{0xb9a6, -0.0003166198730468750}, -{0xb9c5, -0.00037574768066406250}, -{0xb9cc, -0.000389099121093750}, -{0xb9d3, -0.00040245056152343750}, -{0xb9dd, -0.00042152404785156250}, -{0xbb04, -0.002014160156250}, -{0xbb14, -0.002258300781250}, -{0xbb19, -0.00233459472656250}, -{0xbb33, -0.00273132324218750}, -{0xbb66, -0.0035095214843750}, -{0xbbc5, -0.0060119628906250}, -{0xbc0d, -0.008605957031250}, -{0xbcb0, -0.0214843750}, -{0xbcc8, -0.02441406250}, -{0xbce0, -0.027343750}, -{0xbce8, -0.02832031250}, -{0xbd06, -0.032714843750}, -{0xbd77, -0.0603027343750}, -{0xbe31, -0.17285156250}, -{0xbe3a, -0.1816406250}, -{0xbe5d, -0.21582031250}, -{0xbe85, -0.2597656250}, -{0xbe9a, -0.300781250}, -{0xbea5, -0.3222656250}, -{0xbeb0, -0.343750}, -{0xbebf, -0.3730468750}, -{0xbeee, -0.464843750}, -{0xbf2b, -0.667968750}, -{0xbfac, -1.343750}, -{0xc022, -2.531250}, -{0xc026, -2.593750}, -{0xc05e, -3.468750}, -{0xc07e, -3.968750}, -{0xc07f, -3.9843750}, -{0xc086, -4.18750}, -{0xc0ae, -5.43750}, -{0xc0c2, -6.06250}, -{0xc0e6, -7.18750}, -{0xc13e, -11.8750}, -{0xc198, -19.0}, -{0xc1be, -23.750}, -{0xc1c1, -24.1250}, -{0xc1eb, -29.3750}, -{0xc225, -41.250}, -{0xc276, -61.50}, -{0xc27f, -63.750}, -{0xc29f, -79.50}, -{0xc313, -147.0}, -{0xc31b, -155.0}, -{0xc324, -164.0}, -{0xc35b, -219.0}, -{0xc394, -296.0}, -{0xc39d, -314.0}, -{0xc3b5, -362.0}, -{0xc3be, -380.0}, -{0xc429, -676.0}, -{0xc444, -784.0}, -{0xc44b, -812.0}, -{0xc4b5, -1448.0}, -{0xc4eb, -1880.0}, -{0xc523, -2608.0}, -{0xc557, -3440.0}, -{0xc55e, -3552.0}, -{0xc56d, -3792.0}, -{0xc58b, -4448.0}, -{0xc64d, -13120.0}, -{0xc6b8, -23552.0}, -{0xc6ca, -25856.0}, -{0xc777, -63232.0}, -{0xc7d6, -109568.0}, -{0xc868, -237568.0}, -{0xc8ca, -413696.0}, -{0xc910, -589824.0}, -{0xc9c5, -1613824.0}, -{0xc9c8, -1638400.0}, -{0xc9df, -1826816.0}, -{0xca3a, -3047424.0}, -{0xca42, -3178496.0}, -{0xca6b, -3850240.0}, -{0xcaa0, -5242880.0}, -{0xcaa2, -5308416.0}, -{0xcaac, -5636096.0}, -{0xcb3a, -12189696.0}, -{0xcb84, -17301504.0}, -{0xcc50, -54525952.0}, -{0xcc89, -71827456.0}, -{0xcc94, -77594624.0}, -{0xccaf, -91750400.0}, -{0xcce0, -117440512.0}, -{0xcce1, -117964800.0}, -{0xcd6d, -248512512.0}, -{0xcda8, -352321536.0}, -{0xcdba, -390070272.0}, -{0xcdd0, -436207616.0}, -{0xcde5, -480247808.0}, -{0xcdf7, -517996544.0}, -{0xce30, -738197504.0}, -{0xcec2, -1627389952.0}, -{0xcf03, -2197815296.0}, -{0xcf25, -2768240640.0}, -{0xcf57, -3607101440.0}, -{0xd036, -12213813248.0}, -{0xd09e, -21206401024.0}, -{0xd103, -35165044736.0}, -{0xd104, -35433480192.0}, -{0xd11f, -42681237504.0}, -{0xd125, -44291850240.0}, -{0xd19c, -83751862272.0}, -{0xd1c7, -106837311488.0}, -{0xd1cf, -111132278784.0}, -{0xd1d8, -115964116992.0}, -{0xd231, -190052302848.0}, -{0xd28a, -296352743424.0}, -{0xd294, -317827579904.0}, -{0xd2be, -408021893120.0}, -{0xd2c1, -414464344064.0}, -{0xd2c6, -425201762304.0}, -{0xd2db, -470298918912.0}, -{0xd334, -773094113280.0}, -{0xd36f, -1026497183744.0}, -{0xd375, -1052266987520.0}, -{0xd3c3, -1675037245440.0}, -{0xd3d5, -1829656068096.0}, -{0xd3f2, -2078764171264.0}, -{0xd44c, -3504693313536.0}, -{0xd49b, -5325759447040.0}, -{0xd4cd, -7043746365440.0}, -{0xd4e8, -7971459301376.0}, -{0xd538, -12644383719424.0}, -{0xd54c, -14018773254144.0}, -{0xd554, -14568529068032.0}, -{0xd5a3, -22402549415936.0}, -{0xd5bf, -26250840113152.0}, -{0xd64a, -55525337202688.0}, -{0xd74f, -227598906949632.0}, -{0xd75f, -245191092994048.0}, -{0xd762, -248489627877376.0}, -{0xd7d6, -470590976688128.0}, -{0xd7db, -481586092965888.0}, -{0xd819, -672901116198912.0}, -{0xd82d, -760862046420992.0}, -{0xd85b, -963172185931776.0}, -{0xd936, -3201777860083712.0}, -{0xd967, -4063794976260096.0}, -{0xd976, -4327677766926336.0}, -{0xd985, -4679521487814656.0}, -{0xd98c, -4925812092436480.0}, -{0xd9c9, -7072058789855232.0}, -{0xda1b, -10907155347537920.0}, -{0xda5a, -15340386230730752.0}, -{0xdab6, -25614222880669696.0}, -{0xdacc, -28710447624486912.0}, -{0xdb00, -36028797018963968.0}, -{0xdb0d, -39687971716202496.0}, -{0xdb24, -46161896180547584.0}, -{0xdb4c, -57420895248973824.0}, -{0xdbbd, -106397541196627968.0}, -{0xdbbf, -107523441103470592.0}, -{0xdbcc, -114841790497947648.0}, -{0xdbf4, -137359788634800128.0}, -{0xdc88, -306244774661193728.0}, -{0xdc9c, -351280770934898688.0}, -{0xdd24, -738590338888761344.0}, -{0xdd71, -1085367510196289536.0}, -{0xdd86, -1206964700135292928.0}, -{0xdd8f, -1288029493427961856.0}, -{0xdea9, -6088866696204910592.0}, -{0xded6, -7710162562058289152.0}, -{0xdedf, -8034421735228964864.0}, -{0xdef6, -8863084066665136128.0}, -{0xdf62, -16285016252571713536.0}, -{0xdf6a, -16861477004875137024.0}, -{0xdf71, -17365880163140632576.0}, -{0xdfc9, -28967152803247030272.0}, -{0xdff0, -34587645138205409280.0}, -{0xdff5, -35308221078584688640.0}, -{0xe037, -52746158835763249152.0}, -{0xe07e, -73210515542534782976.0}, -{0xe09a, -88774955854727217152.0}, -{0xe09d, -90504338111637487616.0}, -{0xe0cc, -117597993469898391552.0}, -{0xe113, -169479461177206505472.0}, -{0xe18f, -329735550317558235136.0}, -{0xe1aa, -391993311566327971840.0}, -{0xe21a, -710199646837817737216.0}, -{0xe233, -825491797298502434816.0}, -{0xe238, -848550227390639374336.0}, -{0xe247, -917725517667050192896.0}, -{0xe262, -1042241040164589666304.0}, -{0xe26a, -1079134528312008769536.0}, -{0xe271, -1111416330441000484864.0}, -{0xe28b, -1282048713122813837312.0}, -{0xe290, -1328165573307087716352.0}, -{0xe2b2, -1641760222560150093824.0}, -{0xe2eb, -2167492428660872314880.0}, -{0xe2f5, -2259726149029420072960.0}, -{0xe34b, -3744689046963038978048.0}, -{0xe363, -4187410904732068216832.0}, -{0xe388, -5017514388048998039552.0}, -{0xe3a0, -5902958103587056517120.0}, -{0xe3bd, -6972869259862210510848.0}, -{0xe3d6, -7895206463547688091648.0}, -{0xe3e4, -8411715297611555536896.0}, -{0xe406, -9887454823508319666176.0}, -{0xe5a3, -96218217088469021229056.0}, -{0xe5ae, -102711471002414783397888.0}, -{0xe5d7, -126913599227121715118080.0}, -{0xe5d9, -128094190847839126421504.0}, -{0xe644, -231395957660612615471104.0}, -{0xe66e, -280980805730743890214912.0}, -{0xe6b8, -434457716424007359660032.0}, -{0xe7f4, -2304514843640386864283648.0}, -{0xe824, -3097872412762487260184576.0}, -{0xe827, -3154540810556923002748928.0}, -{0xe880, -4835703278458516698824704.0}, -{0xe8f2, -9142501510835633133715456.0}, -{0xe928, -12693721105953606334414848.0}, -{0xe980, -19342813113834066795298816.0}, -{0xe9d1, -31583187037432187189198848.0}, -{0xe9fa, -37778931862957161709568000.0}, -{0xea15, -45032486780644936757805056.0}, -{0xea77, -74651169361203351538106368.0}, -{0xeaca, -122101507781077546645323776.0}, -{0xeacd, -123914896510499490407383040.0}, -{0xead9, -131168451428187265455620096.0}, -{0xeada, -131772914337994580042973184.0}, -{0xeb79, -301022529084042664501837824.0}, -{0xeba3, -394109817194369110954213376.0}, -{0xebf3, -587537948332709778907201536.0}, -{0xec09, -662491349148816787738984448.0}, -{0xec13, -710848381933401954727231488.0}, -{0xec48, -967140655691703339764940800.0}, -{0xece9, -2253437727761668781652312064.0}, -{0xed1f, -3075507285099616620452511744.0}, -{0xed24, -3172221350668786954429005824.0}, -{0xed9f, -6151014570199233240905023488.0}, -{0xede6, -8897694032363670725837455360.0}, -{0xedfe, -9826149061827705932011798528.0}, -{0xeea3, -25223028300439623101069656064.0}, -{0xeea5, -25532513310260968169794437120.0}, -{0xeec4, -30329530962491816735028543488.0}, -{0xeee0, -34662321099990647697175478272.0}, -{0xef23, -50446056600879246202139312128.0}, -{0xefa0, -99035203142830421991929937920.0}, -{0xefab, -105843873358900013503875121152.0}, -{0xf020, -198070406285660843983859875840.0}, -{0xf099, -378809652021326364119132012544.0}, -{0xf0a9, -418423733278458532915903987712.0}, -{0xf0cc, -505079536028435152158842683392.0}, -{0xf0e6, -569452418071274926453597143040.0}, -{0xf16b, -1163663636928257458405176770560.0}, -{0xf19b, -1535045648713871540874914037760.0}, -{0xf1bc, -1861861819085211933448282832896.0}, -{0xf1da, -2158967428513703199424072646656.0}, -{0xf231, -3505846191256196938514319802368.0}, -{0xf253, -4179285572627443808059443380224.0}, -{0xf287, -5347900969712842787564216647680.0}, -{0xf296, -5942112188569825319515796275200.0}, -{0xf2f3, -9626221745483117017615589965824.0}, -{0xf339, -14657210065138902454805630812160.0}, -{0xf36e, -18856302678394912347263460179968.0}, -{0xf3b3, -28363682180106632858488734220288.0}, -{0xf3c0, -30423614405477505635920876929024.0}, -{0xf3da, -34543478856219251190785162346496.0}, -{0xf3eb, -37237236381704238668965656657920.0}, -{0xf407, -42783207757702742300513733181440.0}, -{0xf418, -48170722808672717256874721804288.0}, -{0xf425, -52290587259414462811739007221760.0}, -{0xf473, -77009773963864936140924719726592.0}, -{0xf515, -188879939434006180823008777601024.0}, -{0xf57a, -316912650057057350374175801344000.0}, -{0xf594, -375224577667555902843024148791296.0}, -{0xf61c, -791013974542415146533942800154624.0}, -{0xf634, -912708432164325169077626307870720.0}, -{0xf69f, -1612451563490307798703806477238272.0}, -{0xf6b2, -1805134454724998667731305364455424.0}, -{0xf6f0, -2433889152438200450873670154321920.0}, -{0xf71e, -3204620717376963926983665703190528.0}, -{0xf735, -3671116138260952346734452482768896.0}, -{0xf748, -4056481920730334084789450257203200.0}, -{0xf75f, -4522977341614322504540237036781568.0}, -{0xf796, -6084722881095501127184175385804800.0}, -{0xf8a3, -26448262123161778232827215676964864.0}, -{0xf8d0, -33749929580476379585448226139930624.0}, -{0xf8ef, -38779967162181993850587144458862592.0}, -{0xf9a3, -105793048492647112931308862707859456.0}, -{0xfa0d, -183028464263352673905699995605008384.0}, -{0xfa18, -197307280624323449884158860510363648.0}, -{0xfa31, -229759135990166122562474462567989248.0}, -{0xfaa9, -438749084546192934610826939819098112.0}, -{0xfab5, -469902865697401900382009917794418688.0}, -{0xfacd, -532210427999819831924375873745059840.0}, -{0xfb84, -1370766370653194493932051030914105344.0}, -{0xfba8, -1744611744467702083186246766617952256.0}, -{0xfbfa, -2596148429267413814265248164610048000.0}, -{0xfc20, -3323069989462289682259517650700861440.0}, -{0xfc76, -5109220108798270386474008387952574464.0}, -{0xfc93, -6106141105636957291151863683162832896.0}, -{0xfccf, -8598443597733674552846501921188478976.0}, -{0xfcdc, -9138442471021296626213673539427368960.0}, -{0xfcf0, -9969209968386869046778552952102584320.0}, -{0xfd5b, -18193808192306036010370859137587216384.0}, -{0xfda9, -28079941410956347815092924148422279168.0}, -{0xfdca, -33563006893569125790821128272078700544.0}, -{0xfe1d, -52172198834557948011474427116003524608.0}, -{0xfe24, -54498347827181550789056089471494127616.0}, -{0xfe4b, -67458320786084480549868208309227487232.0}, -{0xfe4f, -68787548781869396422772015369507831808.0}, -{0xfe64, -75765995759740204755517002435979640832.0}, -{0xfea2, -107667467658578185705208371882707910656.0}, -{0xfec2, -128935115591136839671669284847193423872.0}, -{0xfee3, -150867377521587951574582101341819109376.0}, -{0xfee9, -154855061508942699193293522522660143104.0}, -{0xff57, -285784019093756912674318517960274083840.0}, -{0xff60, -297747071055821155530452781502797185024.0}, -{0xff8e, std::numeric_limits::quiet_NaN()}, -{0xffb0, std::numeric_limits::quiet_NaN()}, -{0xfffa, std::numeric_limits::quiet_NaN()}, -}; +#include +#include +#include -TEST_CASE(check_bf16_values) -{ - for(auto [x, f] : bf16_lut) - { - - auto h = migraphx::bit_cast(x); - if(std::isnan(f)) - { - CHECK(std::isnan(h)); - } - else if(std::isinf(f)) - { - CHECK(std::isinf(h)); - CHECK((h < 0) == (f < 0)); - CHECK(bit_equal(x, migraphx::bf16(f))); - } - else - { - CHECK(bit_equal(x, migraphx::bf16(f))); - CHECK(migraphx::float_equal(float(h), f)); - } - } -} +namespace migraphx { +inline namespace MIGRAPHX_INLINE_NS { +using bf16 = migraphx::generic_float<7, 8>; -TEST_CASE(check_flows) -{ - // check positive underflow - CHECK(bit_equal(std::numeric_limits::min() * - std::numeric_limits::min(), - migraphx::bf16(0))); +template +using deduce = typename detail::deduce::type; - // check overflow - CHECK(bit_equal(std::numeric_limits::infinity() + - std::numeric_limits::infinity(), - std::numeric_limits::infinity())); - CHECK(bit_equal(std::numeric_limits::max() + - std::numeric_limits::max(), - std::numeric_limits::infinity())); - CHECK(bit_equal(std::numeric_limits::max() / - std::numeric_limits::epsilon(), - std::numeric_limits::infinity())); - CHECK(bit_equal(std::numeric_limits::max() + - std::numeric_limits::min(), - std::numeric_limits::max())); +} // namespace MIGRAPHX_INLINE_NS +} // namespace migraphx - // check negative underflow - CHECK(bit_equal(std::numeric_limits::lowest() + - std::numeric_limits::lowest(), - -std::numeric_limits::infinity())); - CHECK(bit_equal(-std::numeric_limits::infinity() - - std::numeric_limits::infinity(), - -std::numeric_limits::infinity())); - CHECK(bit_equal(std::numeric_limits::lowest() - - std::numeric_limits::min(), - std::numeric_limits::lowest())); -} +namespace std { -TEST_CASE(test_nan) +template +struct common_type : std::common_type // NOLINT { - float f_qnan = std::numeric_limits::quiet_NaN(); - migraphx::bf16 bf16_qnan(f_qnan); - EXPECT(bf16_qnan.is_nan()); - EXPECT(std::isnan(bf16_qnan)); - - float f_snan = std::numeric_limits::signaling_NaN(); - migraphx::bf16 bf16_snan(f_snan); - EXPECT(bf16_snan.is_nan()); - EXPECT(std::isnan(bf16_snan)); -} +}; -TEST_CASE(test_bool) +template +struct common_type : std::common_type // NOLINT { - float zero = 0.0; - float two = 2.0; - float other = -0.375; - migraphx::bf16 bf16_zero(zero); - migraphx::bf16 bf16_two(two); - migraphx::bf16 bf16_other(other); - EXPECT(not static_cast(bf16_zero)); - EXPECT(static_cast(bf16_two)); - EXPECT(static_cast(bf16_other)); -} +}; -TEST_CASE(test_pos_infinity) +template <> +struct common_type { - float finf = std::numeric_limits::infinity(); - migraphx::bf16 bf16_inf_1(finf); - CHECK(bit_equal(bf16_inf_1, std::numeric_limits::infinity())); -} + using type = float; +}; -TEST_CASE(test_neg_infinity) +template <> +struct common_type { - float finf = -1.0 * std::numeric_limits::infinity(); - migraphx::bf16 bf16_neginf_1(finf); - CHECK(bit_equal(bf16_neginf_1, -std::numeric_limits::infinity())); -} + using type = float; +}; -TEST_CASE(test_numeric_max_1) +template <> +struct common_type { - float fmax = std::numeric_limits::max(); // fp32 max is fp16 inf - migraphx::bf16 bf16_inf(fmax); - CHECK(bit_equal(bf16_inf, std::numeric_limits::max())); -} + using type = float; +}; -TEST_CASE(test_numeric_lowest_1) +template <> +struct common_type { - float flowest = std::numeric_limits::lowest(); - migraphx::bf16 bf16_neginf(flowest); - CHECK(bit_equal(bf16_neginf, std::numeric_limits::lowest())); -} + using type = float; +}; -TEST_CASE(test_max_eq_lowest) +template <> +struct common_type { - EXPECT(migraphx::float_equal(std::numeric_limits::lowest(), - -1 * std::numeric_limits::max())); -} + using type = float; +}; -TEST_CASE(test_isfinite) +template <> +struct common_type { - EXPECT(std::isfinite(migraphx::bf16(0.0))); - EXPECT(std::isfinite(migraphx::bf16(-0.0))); - EXPECT(not std::isfinite(migraphx::bf16(std::numeric_limits::quiet_NaN()))); -} + using type = float; +}; -TEST_CASE(test_binary_ops) +template <> +struct common_type { - auto a = migraphx::bf16(-1.0); - auto b = migraphx::bf16(1.0); - auto c = migraphx::bf16(0.0); - auto d = migraphx::bf16(-0.0); - EXPECT(migraphx::float_equal((c + d), c)); - EXPECT(migraphx::float_equal((c + d), d)); - EXPECT(migraphx::float_equal((a + b), c)); - EXPECT(migraphx::float_equal((a + b), d)); - - auto e = migraphx::bf16(10.0); - auto f = migraphx::bf16(-10.0); - EXPECT(e > f); - EXPECT(f < e); - EXPECT(f <= e); - EXPECT(e >= f); - EXPECT(e <= e); - EXPECT(f >= f); - EXPECT(not migraphx::float_equal(f, e)); -} + using type = migraphx::bf16; +}; -TEST_CASE(test_stream_op) -{ - auto a = migraphx::bf16(-1.0); - std::stringstream ss; - ss << a; - EXPECT(std::string("-1") == ss.str()); - ss = std::stringstream(); - auto b = std::numeric_limits::quiet_NaN(); - ss << b; - EXPECT(std::string("nan") == ss.str()); -} +} // namespace std -int main(int argc, const char* argv[]) { test::run(argc, argv); } +#endif diff --git a/test/bf16.cpp b/test/bf16.cpp index 5f9275c6220..a051f7ee743 100644 --- a/test/bf16.cpp +++ b/test/bf16.cpp @@ -44,1094 +44,1045 @@ bool bit_equal(const T& x, const U& y) TEST_CASE(check_numeric_limits) { - std::bitset<8> exponentBits(std::numeric_limits::quiet_NaN().exponent); - std::cout << "Exponent bits: " << exponentBits << std::endl; - - std::bitset<7> mantissaBits(std::numeric_limits::quiet_NaN().mantissa); - std::cout << "Mantissa bits: " << mantissaBits << std::endl; - - std::cout << std::numeric_limits::min() << std::endl; CHECK(bit_equal(std::numeric_limits::min(), uint16_t{0x0080})); CHECK(bit_equal(std::numeric_limits::lowest(), uint16_t{0xff7f})); CHECK(bit_equal(std::numeric_limits::max(), uint16_t{0x7f7f})); - CHECK(bit_equal(std::numeric_limits::epsilon(), uint16_t{0x3c0})); + CHECK(bit_equal(std::numeric_limits::epsilon(), uint16_t{0x3c00})); CHECK(bit_equal(std::numeric_limits::denorm_min(), uint16_t{0x0001})); CHECK(bit_equal(std::numeric_limits::infinity(), uint16_t{0x7f80})); CHECK(bit_equal(std::numeric_limits::quiet_NaN(), uint16_t{0x7fc0})); CHECK(bit_equal(std::numeric_limits::signaling_NaN(), uint16_t{0x7fa0})); } - - - -static const std::map half_lut = { -{0x0000, 0.0}, -{0x004d, 0.0000000000000000000000000000000000000071}, -{0x0078, 0.0000000000000000000000000000000000000110}, -{0x00e4, 0.0000000000000000000000000000000000000209}, -{0x016c, 0.0000000000000000000000000000000000000433}, -{0x01da, 0.0000000000000000000000000000000000000801}, -{0x01dd, 0.0000000000000000000000000000000000000812}, -{0x0345, 0.0000000000000000000000000000000000005789}, -{0x0406, 0.0000000000000000000000000000000000015752}, -{0x0426, 0.0000000000000000000000000000000000019513}, -{0x04c2, 0.0000000000000000000000000000000000045609}, -{0x052f, 0.0000000000000000000000000000000000082285}, -{0x053f, 0.0000000000000000000000000000000000089808}, -{0x054c, 0.0000000000000000000000000000000000095920}, -{0x0648, 0.0000000000000000000000000000000000376158}, -{0x0659, 0.0000000000000000000000000000000000408132}, -{0x0676, 0.0000000000000000000000000000000000462675}, -{0x0695, 0.0000000000000000000000000000000000560476}, -{0x069a, 0.0000000000000000000000000000000000579284}, -{0x06b3, 0.0000000000000000000000000000000000673323}, -{0x06b9, 0.0000000000000000000000000000000000695893}, -{0x06cf, 0.0000000000000000000000000000000000778647}, -{0x0751, 0.0000000000000000000000000000000001572341}, -{0x0768, 0.0000000000000000000000000000000001745374}, -{0x076a, 0.0000000000000000000000000000000001760420}, -{0x07ba, 0.0000000000000000000000000000000002798617}, -{0x07c2, 0.0000000000000000000000000000000002918988}, -{0x07fe, 0.0000000000000000000000000000000003821767}, -{0x0801, 0.0000000000000000000000000000000003881953}, -{0x0838, 0.0000000000000000000000000000000005537049}, -{0x08fd, 0.0000000000000000000000000000000015226884}, -{0x0909, 0.0000000000000000000000000000000016490775}, -{0x0917, 0.0000000000000000000000000000000018175964}, -{0x0931, 0.000000000000000000000000000000002130560}, -{0x0953, 0.0000000000000000000000000000000025398201}, -{0x099f, 0.0000000000000000000000000000000038277858}, -{0x09b3, 0.0000000000000000000000000000000043092683}, -{0x09ec, 0.0000000000000000000000000000000056814933}, -{0x0a6a, 0.0000000000000000000000000000000112666902}, -{0x0ad7, 0.0000000000000000000000000000000207037469}, -{0x0ae2, 0.0000000000000000000000000000000217630084}, -{0x0b4c, 0.0000000000000000000000000000000392889709}, -{0x0c5b, 0.0000000000000000000000000000001687114631}, -{0x0cde, 0.0000000000000000000000000000003420451581}, -{0x0ce8, 0.0000000000000000000000000000003574525977}, -{0x0d3b, 0.0000000000000000000000000000005762382394}, -{0x0da1, 0.0000000000000000000000000000009922391073}, -{0x0dcc, 0.0000000000000000000000000000012572470677}, -{0x0e4d, 0.0000000000000000000000000000025268200870}, -{0x0e58, 0.0000000000000000000000000000026624055551}, -{0x0e94, 0.0000000000000000000000000000036484816866}, -{0x0eb8, 0.0000000000000000000000000000045359502050}, -{0x0efe, 0.0000000000000000000000000000062615834352}, -{0x0f61, 0.0000000000000000000000000000110933564797}, -{0x0f7b, 0.0000000000000000000000000000123752554507}, -{0x0ff0, 0.0000000000000000000000000000236658271566}, -{0x10f0, 0.0000000000000000000000000000946633086265}, -{0x10fe, 0.0000000000000000000000000001001853349631}, -{0x1109, 0.0000000000000000000000000001080739440153}, -{0x118a, 0.0000000000000000000000000002177256098410}, -{0x11c1, 0.0000000000000000000000000003045003094153}, -{0x11c3, 0.0000000000000000000000000003076557530362}, -{0x11d2, 0.0000000000000000000000000003313215801928}, -{0x1224, 0.0000000000000000000000000005174927538250}, -{0x12d7, 0.0000000000000000000000000013568407569801}, -{0x1306, 0.0000000000000000000000000016913177807938}, -{0x1309, 0.0000000000000000000000000017291831042445}, -{0x1351, 0.0000000000000000000000000026379508670591}, -{0x1366, 0.0000000000000000000000000029030081312133}, -{0x136c, 0.0000000000000000000000000029787387781145}, -{0x139c, 0.0000000000000000000000000039379936388633}, -{0x13a4, 0.0000000000000000000000000041399420305999}, -{0x13cb, 0.0000000000000000000000000051244404403157}, -{0x13f6, 0.0000000000000000000000000062099130458998}, -{0x13fe, 0.0000000000000000000000000064118614376364}, -{0x1423, 0.0000000000000000000000000082293969632656}, -{0x1471, 0.0000000000000000000000000121673906021289}, -{0x1566, 0.0000000000000000000000000464481300994132}, -{0x1571, 0.0000000000000000000000000486695624085155}, -{0x15ad, 0.0000000000000000000000000698741435408563}, -{0x15bf, 0.0000000000000000000000000771442856433732}, -{0x15d0, 0.0000000000000000000000000840105309624169}, -{0x15ef, 0.0000000000000000000000000965313312500848}, -{0x1659, 0.0000000000000000000000001752912040273506}, -{0x16d0, 0.0000000000000000000000003360421238496675}, -{0x173d, 0.0000000000000000000000006106919366114150}, -{0x174c, 0.0000000000000000000000006591595506281939}, -{0x1769, 0.0000000000000000000000007528636043939666}, -{0x17c4, 0.0000000000000000000000012666203129718236}, -{0x1882, 0.0000000000000000000000033604212384966749}, -{0x18ae, 0.0000000000000000000000044977945807570880}, -{0x18c1, 0.0000000000000000000000049889330694604482}, -{0x18d1, 0.0000000000000000000000054025233757369620}, -{0x18d2, 0.0000000000000000000000054283727698792441}, -{0x18e5, 0.0000000000000000000000059195112585826043}, -{0x1947, 0.0000000000000000000000102880588686282817}, -{0x1998, 0.0000000000000000000000157164316385075258}, -{0x19e9, 0.0000000000000000000000240916353406069310}, -{0x1a1b, 0.0000000000000000000000320532487364298224}, -{0x1a8a, 0.0000000000000000000000570754622661589096}, -{0x1a8c, 0.0000000000000000000000579026428787119372}, -{0x1b70, 0.0000000000000000000001985233470127266420}, -{0x1b90, 0.0000000000000000000002382280164152719704}, -{0x1bea, 0.0000000000000000000003871205266748169518}, -{0x1c1d, 0.0000000000000000000005194694246833013798}, -{0x1c7e, 0.0000000000000000000008404155023538761177}, -{0x1c91, 0.0000000000000000000009595295105615121029}, -{0x1cab, 0.0000000000000000000011315830779725418592}, -{0x1d62, 0.0000000000000000000029910850949917480723}, -{0x1e7d, 0.0000000000000000000133937084784586241115}, -{0x1eca, 0.0000000000000000000213875819181710835615}, -{0x1efb, 0.0000000000000000000265756587201036731383}, -{0x1efc, 0.0000000000000000000266815378385104606807}, -{0x1f0f, 0.0000000000000000000302814278643412371217}, -{0x1f6b, 0.0000000000000000000497631856511901449203}, -{0x1f85, 0.0000000000000000000563276909924109725480}, -{0x1f8a, 0.0000000000000000000584452733605467233957}, -{0x1f9c, 0.0000000000000000000660685698858354264473}, -{0x1fdc, 0.0000000000000000000931736241979730372975}, -{0x1ffc, 0.0000000000000000001067261513540418427226}, -{0x2084, 0.0000000000000000002236166980751352895140}, -{0x20fb, 0.0000000000000000004252105395216587702123}, -{0x2153, 0.0000000000000000007148958074826294861737}, -{0x21bb, 0.0000000000000000012671612890924333072462}, -{0x2207, 0.0000000000000000018295911660692887323876}, -{0x220c, 0.0000000000000000018973538018496327595130}, -{0x2265, 0.0000000000000000031035287187397564423463}, -{0x2268, 0.0000000000000000031441863002079628586216}, -{0x2298, 0.0000000000000000041199682554449168492283}, -{0x22a1, 0.000000000000000004363913744254155346880}, -{0x2310, 0.0000000000000000078062556418956319248537}, -{0x2313, 0.0000000000000000079688859677684575899548}, -{0x232d, 0.0000000000000000093783487919996133541645}, -{0x23e5, 0.0000000000000000248282297499180515387707}, -{0x23f5, 0.0000000000000000265629532258948586331826}, -{0x2452, 0.0000000000000000455364912443911862283130}, -{0x2462, 0.0000000000000000490059381963448004171369}, -{0x2472, 0.0000000000000000524753851482984146059607}, -{0x24be, 0.0000000000000000823993651088983369845664}, -{0x24e3, 0.0000000000000000984455572616838026078767}, -{0x2509, 0.0000000000000001188285581044112859672168}, -{0x250b, 0.0000000000000001205632815803880930616288}, -{0x2546, 0.0000000000000001717376241217039023467805}, -{0x254a, 0.0000000000000001752070710736575165356044}, -{0x2550, 0.0000000000000001804112415015879378188401}, -{0x2585, 0.0000000000000002307182223049153435567860}, -{0x25d2, 0.0000000000000003642919299551294898265041}, -{0x2608, 0.0000000000000004718447854656915296800435}, -{0x261d, 0.0000000000000005447031714567174276453443}, -{0x2622, 0.0000000000000005620504062164854985894635}, -{0x26e1, 0.0000000000000015612511283791263849707320}, -{0x2726, 0.0000000000000023037127760971998213790357}, -{0x2731, 0.0000000000000024563684419831588456872851}, -{0x2737, 0.0000000000000025396351688300455862190574}, -{0x2750, 0.0000000000000028865798640254070051014423}, -{0x275c, 0.0000000000000030531133177191804861649871}, -{0x2776, 0.0000000000000034139358007223563618026674}, -{0x2781, 0.0000000000000035804692544161298428662121}, -{0x27c3, 0.0000000000000054123372450476381345652044}, -{0x27e3, 0.0000000000000063005156647477633669041097}, -{0x2804, 0.0000000000000073274719625260331667959690}, -{0x2838, 0.0000000000000102140518265514401718974113}, -{0x2887, 0.0000000000000149880108324396132957190275}, -{0x28e0, 0.0000000000000248689957516035065054893494}, -{0x28fe, 0.0000000000000281996648254789761267602444}, -{0x29b4, 0.0000000000000799360577730112709105014801}, -{0x29d6, 0.0000000000000950350909079133998602628708}, -{0x29f9, 0.0000000000001105782132526655914261937141}, -{0x2a58, 0.0000000000001918465386552270501852035522}, -{0x2aac, 0.0000000000003055333763768430799245834351}, -{0x2aea, 0.0000000000004156675004196586087346076965}, -{0x2b19, 0.0000000000005435651928564766421914100647}, -{0x2b80, 0.0000000000009094947017729282379150390625}, -{0x2bff, 0.0000000000018118839761882554739713668823}, -{0x2c4c, 0.0000000000028990143619012087583541870117}, -{0x2c8d, 0.0000000000040074610296869650483131408691}, -{0x2ccb, 0.0000000000057696070143720135092735290527}, -{0x2cfd, 0.0000000000071906924858922138810157775879}, -{0x2d31, 0.0000000000100612851383630186319351196289}, -{0x2d68, 0.0000000000131876731757074594497680664062}, -{0x2d77, 0.0000000000140403244586195796728134155273}, -{0x2dab, 0.0000000000194404492503963410854339599609}, -{0x2db1, 0.0000000000201225702767260372638702392578}, -{0x2de3, 0.0000000000258069121628068387508392333984}, -{0x2df1, 0.0000000000273985278909094631671905517578}, -{0x2e6a, 0.0000000000532054400537163019180297851562}, -{0x2eaa, 0.0000000000773070496506989002227783203125}, -{0x2ecf, 0.0000000000941327016334980726242065429688}, -{0x2f88, 0.0000000002473825588822364807128906250}, -{0x2fbb, 0.0000000003401510184630751609802246093750}, -{0x2fcd, 0.0000000003728928277269005775451660156250}, -{0x3035, 0.000000000658474164083600044250488281250}, -{0x3065, 0.000000000833097146824002265930175781250}, -{0x30ad, 0.00000000125874066725373268127441406250}, -{0x30ea, 0.0000000017025740817189216613769531250}, -{0x3143, 0.0000000028376234695315361022949218750}, -{0x317d, 0.0000000036816345527768135070800781250}, -{0x31eb, 0.000000006839400157332420349121093750}, -{0x31fa, 0.00000000727595761418342590332031250}, -{0x325b, 0.00000001274747774004936218261718750}, -{0x32da, 0.000000025378540158271789550781250}, -{0x332e, 0.00000004051253199577331542968750}, -{0x3333, 0.000000041676685214042663574218750}, -{0x336e, 0.00000005541369318962097167968750}, -{0x33aa, 0.0000000791624188423156738281250}, -{0x3446, 0.000000184401869773864746093750}, -{0x3456, 0.000000199303030967712402343750}, -{0x345c, 0.00000020489096641540527343750}, -{0x345d, 0.0000002058222889900207519531250}, -{0x350e, 0.0000005289912223815917968750}, -{0x3551, 0.00000077858567237854003906250}, -{0x357c, 0.000000938773155212402343750}, -{0x3684, 0.000003933906555175781250}, -{0x369f, 0.00000473856925964355468750}, -{0x36b2, 0.0000053048133850097656250}, -{0x37ab, 0.000020384788513183593750}, -{0x37c1, 0.000023007392883300781250}, -{0x37e4, 0.0000271797180175781250}, -{0x3814, 0.000035285949707031250}, -{0x3863, 0.00005412101745605468750}, -{0x3869, 0.00005555152893066406250}, -{0x388c, 0.00006675720214843750}, -{0x3895, 0.0000710487365722656250}, -{0x38ab, 0.0000815391540527343750}, -{0x38d0, 0.000099182128906250}, -{0x38e6, 0.000109672546386718750}, -{0x3930, 0.00016784667968750}, -{0x393a, 0.00017738342285156250}, -{0x395f, 0.000212669372558593750}, -{0x3978, 0.000236511230468750}, -{0x397a, 0.00023841857910156250}, -{0x3a1a, 0.000587463378906250}, -{0x3aac, 0.0013122558593750}, -{0x3af3, 0.001853942871093750}, -{0x3bcf, 0.0063171386718750}, -{0x3c1d, 0.009582519531250}, -{0x3c26, 0.01013183593750}, -{0x3c2a, 0.01037597656250}, -{0x3c71, 0.014709472656250}, -{0x3c7a, 0.01525878906250}, -{0x3cef, 0.02917480468750}, -{0x3d0c, 0.03417968750}, -{0x3d5e, 0.054199218750}, -{0x3d61, 0.0549316406250}, -{0x3e47, 0.19433593750}, -{0x3e96, 0.292968750}, -{0x3e9d, 0.3066406250}, -{0x3eb1, 0.3457031250}, -{0x3ef9, 0.4863281250}, -{0x3f7b, 0.980468750}, -{0x3f7d, 0.988281250}, -{0x3fb7, 1.42968750}, -{0x3ff0, 1.8750}, -{0x402d, 2.7031250}, -{0x4042, 3.031250}, -{0x405d, 3.4531250}, -{0x40a6, 5.18750}, -{0x40b1, 5.531250}, -{0x40b9, 5.781250}, -{0x40f2, 7.56250}, -{0x4128, 10.50}, -{0x416d, 14.81250}, -{0x41ef, 29.8750}, -{0x41f5, 30.6250}, -{0x4204, 33.0}, -{0x4237, 45.750}, -{0x429b, 77.50}, -{0x429d, 78.50}, -{0x42ee, 119.0}, -{0x43b4, 360.0}, -{0x43e7, 462.0}, -{0x43f7, 494.0}, -{0x4469, 932.0}, -{0x446d, 948.0}, -{0x447a, 1000.0}, -{0x447f, 1020.0}, -{0x44ca, 1616.0}, -{0x4525, 2640.0}, -{0x458b, 4448.0}, -{0x45a2, 5184.0}, -{0x464b, 12992.0}, -{0x47a0, 81920.0}, -{0x47a2, 82944.0}, -{0x480e, 145408.0}, -{0x4983, 1073152.0}, -{0x49bb, 1531904.0}, -{0x49f4, 1998848.0}, -{0x49fd, 2072576.0}, -{0x4a50, 3407872.0}, -{0x4a72, 3964928.0}, -{0x4aa4, 5373952.0}, -{0x4af1, 7897088.0}, -{0x4b04, 8650752.0}, -{0x4b12, 9568256.0}, -{0x4b13, 9633792.0}, -{0x4b6f, 15663104.0}, -{0x4c12, 38273024.0}, -{0x4c24, 42991616.0}, -{0x4c36, 47710208.0}, -{0x4c46, 51904512.0}, -{0x4c50, 54525952.0}, -{0x4cf0, 125829120.0}, -{0x4d8d, 295698432.0}, -{0x4dcb, 425721856.0}, -{0x4e25, 692060160.0}, -{0x4e91, 1216348160.0}, -{0x4ed0, 1744830464.0}, -{0x4ef3, 2038431744.0}, -{0x4efc, 2113929216.0}, -{0x4f43, 3271557120.0}, -{0x4fac, 5771362304.0}, -{0x4fc2, 6509559808.0}, -{0x4fea, 7851737088.0}, -{0x50a1, 21609054208.0}, -{0x50e1, 30198988800.0}, -{0x50f6, 33017561088.0}, -{0x51ae, 93415538688.0}, -{0x5205, 142807662592.0}, -{0x5218, 163208757248.0}, -{0x521c, 167503724544.0}, -{0x5362, 970662608896.0}, -{0x546f, 4105988734976.0}, -{0x5476, 4226247819264.0}, -{0x54d2, 7215545057280.0}, -{0x5511, 9964324126720.0}, -{0x569d, 86311662780416.0}, -{0x56f9, 136889197658112.0}, -{0x5702, 142936511610880.0}, -{0x570b, 152832116260864.0}, -{0x573a, 204509162766336.0}, -{0x578f, 314460325543936.0}, -{0x5812, 642114790621184.0}, -{0x584e, 905997581287424.0}, -{0x5851, 919191720820736.0}, -{0x5860, 985162418487296.0}, -{0x5907, 2374945115996160.0}, -{0x5938, 3236962232172544.0}, -{0x59e3, 7986852464164864.0}, -{0x5a27, 11751580277669888.0}, -{0x5a5b, 15410754974908416.0}, -{0x5aad, 24347585485471744.0}, -{0x5ab7, 25754960369025024.0}, -{0x5ada, 30680772461461504.0}, -{0x5aef, 33636259716923392.0}, -{0x5b09, 38562071809359872.0}, -{0x5c1f, 179018085187977216.0}, -{0x5d62, 1017813515785732096.0}, -{0x5d70, 1080863910568919040.0}, -{0x5dbb, 1684346260636565504.0}, -{0x5dea, 2107684625609392128.0}, -{0x5e0a, 2485986994308513792.0}, -{0x5e2e, 3134505340649865216.0}, -{0x5e3d, 3404721318292094976.0}, -{0x5ea7, 6016809102166982656.0}, -{0x5f1f, 11457157452030541824.0}, -{0x5f51, 15060037153926938624.0}, -{0x5f64, 16429131440647569408.0}, -{0x5f99, 22049623775605948416.0}, -{0x5fda, 31417111000536580096.0}, -{0x5ffc, 36317027395115679744.0}, -{0x604a, 58222535982645772288.0}, -{0x607f, 73498745918686494720.0}, -{0x608a, 79551583817872441344.0}, -{0x60c1, 111256925194560733184.0}, -{0x60eb, 135468276791304519680.0}, -{0x614b, 234043065435189936128.0}, -{0x616c, 272089475087215886336.0}, -{0x61cc, 470391973879593566208.0}, -{0x6270, 1106804644422573096960.0}, -{0x6291, 1337388945343942492160.0}, -{0x62bd, 1743217314965552627712.0}, -{0x630c, 2582544170319337226240.0}, -{0x6325, 3043712772162076016640.0}, -{0x633f, 3523328118078524358656.0}, -{0x63a0, 5902958103587056517120.0}, -{0x63b3, 6603934378388019478528.0}, -{0x63e0, 8264141345021879123968.0}, -{0x63eb, 8669969714643489259520.0}, -{0x63fc, 9297159013149614014464.0}, -{0x6427, 12322425041237980479488.0}, -{0x6469, 17192365476697302106112.0}, -{0x648c, 20660353362554697809920.0}, -{0x64b3, 26415737513552077914112.0}, -{0x64c3, 28776920754986900520960.0}, -{0x64ea, 34532304905984280625152.0}, -{0x64ed, 34975026763753309863936.0}, -{0x6503, 38664375578495220187136.0}, -{0x6531, 52241179216745450176512.0}, -{0x6566, 67884018191251149946880.0}, -{0x657b, 74082124200017559289856.0}, -{0x65af, 103301766812773489049600.0}, -{0x65b5, 106843541674925722959872.0}, -{0x65d9, 128094190847839126421504.0}, -{0x6611, 171185785004024638996480.0}, -{0x6613, 173546968245459461603328.0}, -{0x6635, 213687083349851445919744.0}, -{0x6699, 361261035939527858847744.0}, -{0x66c0, 453347182355485940514816.0}, -{0x6768, 1095589024025757689577472.0}, -{0x6798, 1435599410792372144963584.0}, -{0x67d3, 1992838655770990280179712.0}, -{0x67d6, 2021172854668208151461888.0}, -{0x681d, 2965646151242137194201088.0}, -{0x6854, 4004566777473459141214208.0}, -{0x6857, 4061235175267894883778560.0}, -{0x6876, 4646808619143730890276864.0}, -{0x689b, 5855734438758360064983040.0}, -{0x68ed, 8953606851520847325167616.0}, -{0x68fc, 9520290829465204750811136.0}, -{0x6908, 10275869466724347985002496.0}, -{0x6aaa, 102758694667243479850024960.0}, -{0x6ad0, 125728285239921434169442304.0}, -{0x6b26, 200681686056028443001225216.0}, -{0x6b60, 270799383593676935134183424.0}, -{0x6bd1, 505330992598914995027181568.0}, -{0x6c4b, 981647765527078889861414912.0}, -{0x6cb4, 1740853180245066011576893440.0}, -{0x6d68, 4487532642409503496509325312.0}, -{0x6d86, 5183873914507529901140082688.0}, -{0x6ead, 26770453349546348444693561344.0}, -{0x6f07, 41780476325881584277845442560.0}, -{0x6f1e, 48898631551772520858515406848.0}, -{0x6f69, 72110007288373401012873986048.0}, -{0x6fb5, 112033573555326914878370742272.0}, -{0x70a0, 396140812571321687967719751680.0}, -{0x713a, 921027389228322924524948422656.0}, -{0x713b, 925979149385464445624544919552.0}, -{0x715c, 1089387234571134641911229317120.0}, -{0x7178, 1228036518971097232699931230208.0}, -{0x719a, 1525142128399588498675721043968.0}, -{0x719e, 1564756209656720667472493019136.0}, -{0x71a5, 1634080851856701962866843975680.0}, -{0x71c4, 1941089981599476271041826783232.0}, -{0x71e0, 2218388550399401452619230609408.0}, -{0x721b, 3070091297427743081749828075520.0}, -{0x7333, 14181841090053316429244367110144.0}, -{0x734c, 16162545152909924869082965868544.0}, -{0x7354, 16796370453024039569831317471232.0}, -{0x7376, 19490127978509027048011811782656.0}, -{0x73fc, 39930993907189226147146150969344.0}, -{0x745d, 70037695662609674432692852097024.0}, -{0x74f1, 152751897327501642880352736247808.0}, -{0x7538, 233247710441994209875393389789184.0}, -{0x7539, 234515361042222439276890092994560.0}, -{0x7562, 286489035651579844738254924414976.0}, -{0x7563, 287756686251808074139751627620352.0}, -{0x759f, 403112890872576949675951619309568.0}, -{0x760d, 714954938528721382444140607832064.0}, -{0x768e, 1440051081859268600100254841307136.0}, -{0x7691, 1470474696264746105736175718236160.0}, -{0x770c, 2839537344511233859352615180042240.0}, -{0x771c, 3164055898169660586135771200618496.0}, -{0x776a, 4746083847254490879203656800927744.0}, -{0x7773, 4928625533687355913019182062501888.0}, -{0x7798, 6165852519510107808879964390948864.0}, -{0x77ca, 8194093479875274851274689519550464.0}, -{0x77db, 8883695406399431645688896063275008.0}, -{0x77eb, 9532732513716285099255208104427520.0}, -{0x7855, 17280612982311223201203058095685632.0}, -{0x788c, 22716298756089870874820921440337920.0}, -{0x789a, 24987928631698857962303013584371712.0}, -{0x789b, 25150187908528071325694591594659840.0}, -{0x78de, 36021559456085366672930318283964416.0}, -{0x7900, 41538374868278621028243970633760768.0}, -{0x7915, 48353264495105582290690247065862144.0}, -{0x791a, 49975857263397715924606027168743424.0}, -{0x7999, 99302677419478578395645742296334336.0}, -{0x79c6, 128509347248736983806129784148197376.0}, -{0x79d9, 140841052287757199423889712930095104.0}, -{0x7a28, 218076468058462760398280845827244032.0}, -{0x7a2d, 224566839131631294933943966238769152.0}, -{0x7a4f, 268701362429177329776453185037139968.0}, -{0x7aa2, 420576045541321037910970202666827776.0}, -{0x7aa9, 438749084546192934610826939819098112.0}, -{0x7b14, 768459935063154489022513456724574208.0}, -{0x7b2e, 903459653385060007364306361284296704.0}, -{0x7b4b, 1054036262282570008591690754831679488.0}, -{0x7b93, 1526535276409239322787965920790708224.0}, -{0x7b99, 1588842838711657254330331876741349376.0}, -{0x7bbe, 1973072806243234498841588605103636480.0}, -{0x7bc0, 1993841993677373809355710590420516864.0}, -{0x7c49, 4174606674262001413338519048692957184.0}, -{0x7c7f, 5296142795705524181101106255804497920.0}, -{0x7c98, 6313832979978350396293083536331636736.0}, -{0x7cda, 9055365721284739384157185598159847424.0}, -{0x7d06, 11132284464698670435569384129847885824.0}, -{0x7d1d, 13043049708639487002868606779000881152.0}, -{0x7d3d, 15701505700209318748676220899561570304.0}, -{0x7d4c, 16947656946257677379523540018574393344.0}, -{0x7d58, 17944577943096364284201395313784651776.0}, -{0x7d85, 22098415429924226387025792377160728576.0}, -{0x7da9, 28079941410956347815092924148422279168.0}, -{0x7db1, 29409169406741263687996731208702623744.0}, -{0x7db2, 29575322906214378172109707091237666816.0}, -{0x7dfc, 41870681867224849996469922398830854144.0}, -{0x7e0f, 47519900849310742456311102405022318592.0}, -{0x7e15, 49513742842988116265666812995442835456.0}, -{0x7e50, 69119855780815625390997967134577917952.0}, -{0x7e55, 70781390775546770232127725959928348672.0}, -{0x7e73, 80750600743933639278906278912030932992.0}, -{0x7f08, 180775007426748558714917760198126862336.0}, -{0x7f67, 307051667026315566640779430924759597056.0}, -{0x7f6a, 311039351013670314259490852105600630784.0}, -{0x7f7b, 333636226942013884098855572130366488576.0}, -{0x7f7e, 337623910929368631717566993311207522304.0}, -{0x7f9a, std::numeric_limits::quiet_NaN()}, -{0x8022, -0.0000000000000000000000000000000000000031}, -{0x8075, -0.0000000000000000000000000000000000000107}, -{0x807d, -0.0000000000000000000000000000000000000115}, -{0x8095, -0.0000000000000000000000000000000000000137}, -{0x80c6, -0.0000000000000000000000000000000000000182}, -{0x80fc, -0.0000000000000000000000000000000000000231}, -{0x814d, -0.0000000000000000000000000000000000000377}, -{0x8181, -0.0000000000000000000000000000000000000474}, -{0x818a, -0.0000000000000000000000000000000000000507}, -{0x819c, -0.0000000000000000000000000000000000000573}, -{0x81be, -0.0000000000000000000000000000000000000698}, -{0x8201, -0.0000000000000000000000000000000000000948}, -{0x8232, -0.0000000000000000000000000000000000001308}, -{0x8241, -0.0000000000000000000000000000000000001418}, -{0x82c3, -0.0000000000000000000000000000000000002865}, -{0x82f2, -0.0000000000000000000000000000000000003556}, -{0x82fd, -0.0000000000000000000000000000000000003718}, -{0x8340, -0.0000000000000000000000000000000000005642}, -{0x8349, -0.0000000000000000000000000000000000005907}, -{0x835b, -0.0000000000000000000000000000000000006436}, -{0x83a0, -0.0000000000000000000000000000000000009404}, -{0x83b6, -0.0000000000000000000000000000000000010697}, -{0x83ca, -0.0000000000000000000000000000000000011872}, -{0x842e, -0.0000000000000000000000000000000000020454}, -{0x8445, -0.0000000000000000000000000000000000023157}, -{0x847d, -0.0000000000000000000000000000000000029740}, -{0x8486, -0.0000000000000000000000000000000000031503}, -{0x84bc, -0.0000000000000000000000000000000000044199}, -{0x84da, -0.0000000000000000000000000000000000051252}, -{0x84e2, -0.0000000000000000000000000000000000053132}, -{0x84fd, -0.0000000000000000000000000000000000059480}, -{0x8546, -0.0000000000000000000000000000000000093099}, -{0x8594, -0.0000000000000000000000000000000000139179}, -{0x859a, -0.0000000000000000000000000000000000144821}, -{0x85e3, -0.0000000000000000000000000000000000213470}, -{0x85e5, -0.0000000000000000000000000000000000215351}, -{0x86ee, -0.0000000000000000000000000000000000895256}, -{0x86ef, -0.0000000000000000000000000000000000899018}, -{0x871d, -0.0000000000000000000000000000000001181137}, -{0x876b, -0.0000000000000000000000000000000001767944}, -{0x8783, -0.0000000000000000000000000000000001971069}, -{0x87a9, -0.0000000000000000000000000000000002542829}, -{0x87fb, -0.0000000000000000000000000000000003776628}, -{0x8822, -0.0000000000000000000000000000000004875010}, -{0x885e, -0.0000000000000000000000000000000006680569}, -{0x888a, -0.0000000000000000000000000000000008305573}, -{0x8891, -0.0000000000000000000000000000000008726870}, -{0x891c, -0.0000000000000000000000000000000018777817}, -{0x89a0, -0.0000000000000000000000000000000038518599}, -{0x89d0, -0.0000000000000000000000000000000050074179}, -{0x8a05, -0.0000000000000000000000000000000064037171}, -{0x8a3a, -0.0000000000000000000000000000000089555742}, -{0x8a3f, -0.0000000000000000000000000000000091963155}, -{0x8a7e, -0.0000000000000000000000000000000122296551}, -{0x8ae4, -0.0000000000000000000000000000000219556014}, -{0x8afb, -0.0000000000000000000000000000000241704208}, -{0x8b18, -0.0000000000000000000000000000000292741352}, -{0x8b86, -0.0000000000000000000000000000000516149225}, -{0x8ba2, -0.0000000000000000000000000000000624001302}, -{0x8be0, -0.0000000000000000000000000000000862816615}, -{0x8c00, -0.0000000000000000000000000000000986076132}, -{0x8c34, -0.0000000000000000000000000000001386669560}, -{0x8c9f, -0.0000000000000000000000000000002449782889}, -{0x8caa, -0.0000000000000000000000000000002619264724}, -{0x8cb3, -0.0000000000000000000000000000002757931680}, -{0x8d34, -0.0000000000000000000000000000005546678240}, -{0x8d48, -0.0000000000000000000000000000006162975822}, -{0x8d58, -0.0000000000000000000000000000006656013888}, -{0x8d5f, -0.0000000000000000000000000000006871718042}, -{0x8d6a, -0.0000000000000000000000000000007210681712}, -{0x8d7f, -0.0000000000000000000000000000007857794173}, -{0x8d91, -0.0000000000000000000000000000008936314942}, -{0x8df0, -0.0000000000000000000000000000014791141973}, -{0x8e06, -0.0000000000000000000000000000016516775203}, -{0x8e1a, -0.0000000000000000000000000000018981965532}, -{0x8e9f, -0.0000000000000000000000000000039196526228}, -{0x8ed1, -0.0000000000000000000000000000051522477872}, -{0x8f1d, -0.0000000000000000000000000000077406976325}, -{0x8f23, -0.0000000000000000000000000000080365204719}, -{0x8f4f, -0.0000000000000000000000000000102058879613}, -{0x901b, -0.0000000000000000000000000000305683600773}, -{0x9059, -0.0000000000000000000000000000427957041082}, -{0x90c1, -0.0000000000000000000000000000761250773538}, -{0x911c, -0.0000000000000000000000000001230623012145}, -{0x9131, -0.0000000000000000000000000001396283802241}, -{0x919d, -0.0000000000000000000000000002477023242394}, -{0x9243, -0.0000000000000000000000000006153115060724}, -{0x9268, -0.0000000000000000000000000007320629200451}, -{0x92b7, -0.0000000000000000000000000011548923652436}, -{0x9308, -0.0000000000000000000000000017165613297609}, -{0x9319, -0.0000000000000000000000000019311314959810}, -{0x9353, -0.0000000000000000000000000026631944160261}, -{0x9411, -0.0000000000000000000000000073206292004510}, -{0x941e, -0.0000000000000000000000000079769614735949}, -{0x943d, -0.0000000000000000000000000095420615095534}, -{0x9456, -0.0000000000000000000000000108042389579070}, -{0x947d, -0.0000000000000000000000000127732357773386}, -{0x94f8, -0.0000000000000000000000000250416005753358}, -{0x95b2, -0.0000000000000000000000000718936274582221}, -{0x9629, -0.0000000000000000000000001365171128139274}, -{0x965a, -0.0000000000000000000000001760989975942969}, -{0x966c, -0.0000000000000000000000001906392817993306}, -{0x971a, -0.0000000000000000000000004976008372389307}, -{0x9728, -0.0000000000000000000000005428372769879244}, -{0x977b, -0.0000000000000000000000008110247412141014}, -{0x97b9, -0.0000000000000000000000011955344790805478}, -{0x98f2, -0.0000000000000000000000062555533824322718}, -{0x9912, -0.0000000000000000000000075480230895463775}, -{0x9973, -0.0000000000000000000000125628055531491078}, -{0x9978, -0.0000000000000000000000128212994945719290}, -{0x9994, -0.0000000000000000000000153028413322310120}, -{0x9a97, -0.0000000000000000000000624521362477535895}, -{0x9aa0, -0.0000000000000000000000661744490042422140}, -{0x9aaf, -0.0000000000000000000000723783035983899216}, -{0x9ac4, -0.0000000000000000000000810637000301967121}, -{0x9ad9, -0.0000000000000000000000897490964620035027}, -{0x9b02, -0.0000000000000000000001075334796318935977}, -{0x9b19, -0.0000000000000000000001265586337206132343}, -{0x9b75, -0.0000000000000000000002026592500754917803}, -{0x9ba8, -0.0000000000000000000002779326858178172988}, -{0x9bb5, -0.0000000000000000000002994393817441960183}, -{0x9bc1, -0.0000000000000000000003192917164454686825}, -{0x9be2, -0.0000000000000000000003738856368739685090}, -{0x9c65, -0.0000000000000000000007576974410985733502}, -{0x9c76, -0.0000000000000000000008139457227521792321}, -{0x9cb0, -0.0000000000000000000011646703024746629662}, -{0x9cef, -0.0000000000000000000015815693312013889144}, -{0x9d01, -0.0000000000000000000017073007843094491209}, -{0x9d33, -0.0000000000000000000023690452743518712608}, -{0x9d91, -0.0000000000000000000038381180422460484114}, -{0x9db1, -0.0000000000000000000046851509895003487505}, -{0x9de7, -0.0000000000000000000061145190879919805726}, -{0x9dea, -0.0000000000000000000061939284267970712294}, -{0x9e48, -0.0000000000000000000105879118406787542384}, -{0x9fb7, -0.0000000000000000000775035146737684810248}, -{0x9ff7, -0.0000000000000000001046085689859060918749}, -{0xa009, -0.0000000000000000001160435137738391464524}, -{0xa0a4, -0.0000000000000000002778268066994105112144}, -{0xa217, -0.0000000000000000020464316005663896191891}, -{0xa225, -0.0000000000000000022361669807513528951404}, -{0xa22f, -0.0000000000000000023716922523120409493913}, -{0xa241, -0.0000000000000000026156377411212794470430}, -{0xa281, -0.0000000000000000034965520062657517996740}, -{0xa29a, -0.0000000000000000041741783640691920709287}, -{0xa2ce, -0.0000000000000000055836411883003478351384}, -{0xa2d4, -0.0000000000000000057462715141731735002395}, -{0xa2f6, -0.0000000000000000066678433607858522691458}, -{0xa394, -0.0000000000000000160461921527854656233103}, -{0xa3f3, -0.0000000000000000263461127913977577463811}, -{0xa403, -0.0000000000000000284060969191202161709953}, -{0xa416, -0.0000000000000000325260651745651330202236}, -{0xa432, -0.0000000000000000385975973404839578506653}, -{0xa46c, -0.0000000000000000511743425413158092851518}, -{0xa482, -0.0000000000000000563785129692462305683875}, -{0xa4b0, -0.0000000000000000763278329429795121541247}, -{0xa4d4, -0.0000000000000000919403442267707760038320}, -{0xa4dc, -0.0000000000000000954097911787243901926558}, -{0xa52c, -0.0000000000000001491862189340054101194255}, -{0xa595, -0.0000000000000002584737979205442570673767}, -{0xa604, -0.0000000000000004579669976578770729247481}, -{0xa607, -0.0000000000000004683753385137379154912196}, -{0xa62e, -0.0000000000000006036837696399288688553497}, -{0xa641, -0.0000000000000006696032617270475384430028}, -{0xa67b, -0.0000000000000008708311849403571613947861}, -{0xa708, -0.0000000000000018873791418627661187201738}, -{0xa72f, -0.0000000000000024286128663675299321766943}, -{0xa74c, -0.0000000000000028310687127941491780802608}, -{0xa779, -0.0000000000000034555691641457997320685536}, -{0xa7a0, -0.0000000000000044408920985006261616945267}, -{0xa81d, -0.0000000000000087152507433074788423255086}, -{0xa822, -0.0000000000000089928064994637679774314165}, -{0xa83e, -0.0000000000000105471187339389871340245008}, -{0xa8c6, -0.0000000000000219824158875780995003879070}, -{0xa8cd, -0.0000000000000227595720048157090786844492}, -{0xa8fc, -0.0000000000000279776202205539448186755180}, -{0xa909, -0.0000000000000304201108747292892076075077}, -{0xa911, -0.0000000000000321964677141295396722853184}, -{0xa934, -0.0000000000000399680288865056354552507401}, -{0xa9b5, -0.0000000000000803801469828613335266709328}, -{0xa9e9, -0.0000000000001034727858950645895674824715}, -{0xaa3f, -0.0000000000001696420781627239193767309189}, -{0xab0d, -0.0000000000005009326287108706310391426086}, -{0xab40, -0.0000000000006821210263296961784362792969}, -{0xab44, -0.0000000000006963318810448981821537017822}, -{0xab4a, -0.0000000000007176481631177011877298355103}, -{0xab69, -0.0000000000008277822871605167165398597717}, -{0xab6a, -0.0000000000008313350008393172174692153931}, -{0xab85, -0.0000000000009450218385609332472085952759}, -{0xabba, -0.0000000000013216094885137863457202911377}, -{0xac1f, -0.0000000000022595258997171185910701751709}, -{0xac94, -0.0000000000042064129956997931003570556641}, -{0xaca6, -0.0000000000047180037654470652341842651367}, -{0xacbf, -0.0000000000054285465012071654200553894043}, -{0xacf2, -0.0000000000068780536821577697992324829102}, -{0xad7a, -0.0000000000142108547152020037174224853516}, -{0xadaf, -0.0000000000198951966012828052043914794922}, -{0xadfd, -0.0000000000287627699435688555240631103516}, -{0xae3e, -0.0000000000432009983342140913009643554688}, -{0xae45, -0.0000000000447926140623167157173156738281}, -{0xae8a, -0.0000000000627551344223320484161376953125}, -{0xaeda, -0.0000000000991349224932491779327392578125}, -{0xafa2, -0.000000000294676283374428749084472656250}, -{0xaffc, -0.00000000045838532969355583190917968750}, -{0xb016, -0.00000000054569682106375694274902343750}, -{0xb086, -0.0000000009749783203005790710449218750}, -{0xb09d, -0.00000000114232534542679786682128906250}, -{0xb0bd, -0.00000000137515598908066749572753906250}, -{0xb0d1, -0.00000000152067514136433601379394531250}, -{0xb121, -0.0000000023428583517670631408691406250}, -{0xb13a, -0.000000002706656232476234436035156250}, -{0xb259, -0.00000001263106241822242736816406250}, -{0xb25c, -0.000000012805685400962829589843750}, -{0xb2fa, -0.000000029103830456733703613281250}, -{0xb3e2, -0.0000001052394509315490722656250}, -{0xb3ff, -0.00000011874362826347351074218750}, -{0xb44f, -0.0000001927837729454040527343750}, -{0xb4c9, -0.000000374391674995422363281250}, -{0xb4e9, -0.000000433996319770812988281250}, -{0xb4fa, -0.00000046566128730773925781250}, -{0xb5cc, -0.00000151991844177246093750}, -{0xb5df, -0.0000016614794731140136718750}, -{0xb630, -0.00000262260437011718750}, -{0xb648, -0.000002980232238769531250}, -{0xb717, -0.0000090003013610839843750}, -{0xb76f, -0.0000142455101013183593750}, -{0xb78a, -0.00001645088195800781250}, -{0xb7f7, -0.000029444694519042968750}, -{0xb86d, -0.00005650520324707031250}, -{0xb885, -0.0000634193420410156250}, -{0xb8cc, -0.00009727478027343750}, -{0xb8d5, -0.0001015663146972656250}, -{0xb95a, -0.00020790100097656250}, -{0xb967, -0.000220298767089843750}, -{0xb9fc, -0.000480651855468750}, -{0xba87, -0.001029968261718750}, -{0xbac9, -0.001533508300781250}, -{0xbb04, -0.002014160156250}, -{0xbb7b, -0.00382995605468750}, -{0xbbb1, -0.0054016113281250}, -{0xbc7c, -0.0153808593750}, -{0xbc8d, -0.01721191406250}, -{0xbcb7, -0.02233886718750}, -{0xbce7, -0.02819824218750}, -{0xbcfd, -0.03088378906250}, -{0xbd14, -0.03613281250}, -{0xbd44, -0.04785156250}, -{0xbd75, -0.0598144531250}, -{0xbd7e, -0.062011718750}, -{0xbe39, -0.18066406250}, -{0xbebd, -0.3691406250}, -{0xbec2, -0.378906250}, -{0xbee7, -0.4511718750}, -{0xbf16, -0.58593750}, -{0xbf74, -0.9531250}, -{0xbf86, -1.0468750}, -{0xbfab, -1.33593750}, -{0xbfc1, -1.50781250}, -{0xbfc2, -1.5156250}, -{0xbfe1, -1.75781250}, -{0xc01e, -2.468750}, -{0xc02d, -2.7031250}, -{0xc04a, -3.156250}, -{0xc090, -4.50}, -{0xc095, -4.656250}, -{0xc0ce, -6.43750}, -{0xc105, -8.31250}, -{0xc175, -15.31250}, -{0xc18f, -17.8750}, -{0xc1b3, -22.3750}, -{0xc1b6, -22.750}, -{0xc2a0, -80.0}, -{0xc327, -167.0}, -{0xc352, -210.0}, -{0xc380, -256.0}, -{0xc3bb, -374.0}, -{0xc3c4, -392.0}, -{0xc464, -912.0}, -{0xc4ad, -1384.0}, -{0xc4c5, -1576.0}, -{0xc4e7, -1848.0}, -{0xc540, -3072.0}, -{0xc569, -3728.0}, -{0xc56b, -3760.0}, -{0xc57a, -4000.0}, -{0xc5b4, -5760.0}, -{0xc5d0, -6656.0}, -{0xc5d2, -6720.0}, -{0xc5db, -7008.0}, -{0xc5f5, -7840.0}, -{0xc643, -12480.0}, -{0xc655, -13632.0}, -{0xc690, -18432.0}, -{0xc6bc, -24064.0}, -{0xc761, -57600.0}, -{0xc7b4, -92160.0}, -{0xc8a9, -346112.0}, -{0xc8d1, -428032.0}, -{0xc91b, -634880.0}, -{0xca23, -2670592.0}, -{0xca44, -3211264.0}, -{0xcabe, -6225920.0}, -{0xcac8, -6553600.0}, -{0xcb88, -17825792.0}, -{0xcbc4, -25690112.0}, -{0xcbf5, -32112640.0}, -{0xcbfc, -33030144.0}, -{0xcc6e, -62390272.0}, -{0xcc74, -63963136.0}, -{0xcce7, -121110528.0}, -{0xcceb, -123207680.0}, -{0xccee, -124780544.0}, -{0xcd4e, -216006656.0}, -{0xcd5c, -230686720.0}, -{0xcdfd, -530579456.0}, -{0xce03, -549453824.0}, -{0xce35, -759169024.0}, -{0xce6b, -985661440.0}, -{0xce94, -1241513984.0}, -{0xceab, -1434451968.0}, -{0xceb5, -1518338048.0}, -{0xcee0, -1879048192.0}, -{0xcf36, -3053453312.0}, -{0xcf4e, -3456106496.0}, -{0xcfe5, -7683964928.0}, -{0xd023, -10938744832.0}, -{0xd055, -14294188032.0}, -{0xd059, -14562623488.0}, -{0xd0ac, -23085449216.0}, -{0xd0b9, -24830279680.0}, -{0xd0bd, -25367150592.0}, -{0xd14a, -54223962112.0}, -{0xd204, -141733920768.0}, -{0xd216, -161061273600.0}, -{0xd26d, -254476812288.0}, -{0xd37b, -1078036791296.0}, -{0xd37c, -1082331758592.0}, -{0xd471, -4140348473344.0}, -{0xd4a6, -5703716569088.0}, -{0xd4d2, -7215545057280.0}, -{0xd4d3, -7249904795648.0}, -{0xd5a6, -22814866276352.0}, -{0xd5c2, -26663156973568.0}, -{0xd67b, -68994354642944.0}, -{0xd714, -162727720910848.0}, -{0xd754, -233096465088512.0}, -{0xd777, -271579372060672.0}, -{0xd7a5, -362838837166080.0}, -{0xd7bd, -415615395299328.0}, -{0xd809, -602532372021248.0}, -{0xd819, -672901116198912.0}, -{0xd827, -734473767354368.0}, -{0xd82e, -765260092932096.0}, -{0xd859, -954376092909568.0}, -{0xd8a6, -1460151441686528.0}, -{0xd8fc, -2216615441596416.0}, -{0xd93e, -3342515348439040.0}, -{0xd97e, -4468415255281664.0}, -{0xd9a7, -5875790138834944.0}, -{0xd9e0, -7881299347898368.0}, -{0xda46, -13933011347177472.0}, -{0xda4e, -14495961300598784.0}, -{0xda6e, -16747761114284032.0}, -{0xda83, -18436610974547968.0}, -{0xda8e, -19984723346456576.0}, -{0xdb78, -69805794224242688.0}, -{0xdb81, -72620543991349248.0}, -{0xdbaa, -95701492081623040.0}, -{0xdc01, -145241087982698496.0}, -{0xdc2a, -191402984163246080.0}, -{0xdc50, -234187180623265792.0}, -{0xdcf1, -542683755098144768.0}, -{0xdcf9, -560698153607626752.0}, -{0xde68, -4179340454199820288.0}, -{0xdf9c, -22481969339833516032.0}, -{0xdfa6, -23923121220592074752.0}, -{0xdff4, -35164105890508832768.0}, -{0xe018, -43811017175060185088.0}, -{0xe0b2, -102610013910009380864.0}, -{0xe0d9, -125091983249842896896.0}, -{0xe0ff, -146997491837372989440.0}, -{0xe113, -169479461177206505472.0}, -{0xe137, -210984635343052996608.0}, -{0xe1ae, -401216683603182747648.0}, -{0xe261, -1037629354146162278400.0}, -{0xe277, -1139086446551564812288.0}, -{0xe296, -1383505805528216371200.0}, -{0xe2a6, -1531079758117892784128.0}, -{0xe2d0, -1918461383665793368064.0}, -{0xe2dc, -2029141848108050677760.0}, -{0xe2e2, -2084482080329179332608.0}, -{0xe327, -3080606260309495119872.0}, -{0xe336, -3357307421415138394112.0}, -{0xe34d, -3781582535110458081280.0}, -{0xe3e5, -8448608785758974640128.0}, -{0xe457, -15864199903390214389760.0}, -{0xe496, -22136092888451461939200.0}, -{0xe498, -22431240793630814765056.0}, -{0xe51c, -46043073207979040833536.0}, -{0xe53d, -55782954078897684086784.0}, -{0xe547, -58734433130691212345344.0}, -{0xe59a, -90905554795240670363648.0}, -{0xe5ae, -102711471002414783397888.0}, -{0xe5e8, -136948628003219711197184.0}, -{0xe5ed, -139900107055013239455744.0}, -{0xe6f5, -578489894151531538677760.0}, -{0xe730, -831136500985057557610496.0}, -{0xe73c, -887804898779493300174848.0}, -{0xe743, -920861464159580816670720.0}, -{0xe792, -1378931012997936402399232.0}, -{0xe82c, -3248988140214315907022848.0}, -{0xe899, -5780176575032445741563904.0}, -{0xe89a, -5817955506895402903273472.0}, -{0xe8eb, -8878048987794933001748480.0}, -{0xe8ed, -8953606851520847325167616.0}, -{0xe90d, -10653658785353919602098176.0}, -{0xe953, -15942709246167922241437696.0}, -{0xe9a5, -24934095029551726728314880.0}, -{0xea47, -60144059525827801441632256.0}, -{0xeaa2, -97922991388784963151200256.0}, -{0xeae1, -136004154706645782154444800.0}, -{0xeb36, -220024499169862509796524032.0}, -{0xeb58, -261127977036759901736534016.0}, -{0xeb85, -321574268017491360471842816.0}, -{0xec33, -865590886844074489089622016.0}, -{0xec5e, -1073526127817790707139084288.0}, -{0xecc6, -1914938498269572612734582784.0}, -{0xecd2, -2030995376952577013506375680.0}, -{0xed02, -2514565704798428683388846080.0}, -{0xed5f, -4313447324384996895351635968.0}, -{0xed61, -4352132950612665028942233600.0}, -{0xedb2, -6886041468524927779126378496.0}, -{0xedda, -8433466517631653122750283776.0}, -{0xeded, -9168493415957347660971638784.0}, -{0xee2f, -13539969179683846756709171200.0}, -{0xef22, -50136571591057901133414531072.0}, -{0xef24, -50755541610700591270864093184.0}, -{0xef46, -61278031944626323607506649088.0}, -{0xef5a, -67467732141053224982002270208.0}, -{0xef67, -71491037268730710875424423936.0}, -{0xefc6, -122556063889252647215013298176.0}, -{0xf003, -162170145146384816011785273344.0}, -{0xf0a3, -403568452807033969617114497024.0}, -{0xf0b7, -453086054378449180613079465984.0}, -{0xf0e1, -557073017678421123704605900800.0}, -{0xf14d, -1015110832214011825417281863680.0}, -{0xf18c, -1386492843999625907887019130880.0}, -{0xf1c1, -1911379420656627144444247801856.0}, -{0xf21d, -3109705378684875250546600050688.0}, -{0xf22a, -3367196906856234347725617889280.0}, -{0xf22c, -3406810988113366516522389864448.0}, -{0xf239, -3664302516284725613701407703040.0}, -{0xf240, -3802951800684688204490109616128.0}, -{0xf267, -4575426385198765496027163131904.0}, -{0xf270, -4753689750855860255612637020160.0}, -{0xf27f, -5050795360284351521588426833920.0}, -{0xf2df, -8833940120340473641680150462464.0}, -{0xf2f8, -9824292151768777861599449841664.0}, -{0xf335, -14340297415081845104431455010816.0}, -{0xf368, -18380933703309326321702196477952.0}, -{0xf3ba, -29472876455306333584798349524992.0}, -{0xf3c1, -30582070730506034311107964829696.0}, -{0xf418, -48170722808672717256874721804288.0}, -{0xf435, -57361189660327380417725820043264.0}, -{0xf494, -93806144416888975710756037197824.0}, -{0xf49b, -98242921517687778615994498416640.0}, -{0xf4a0, -101412048018258352119736256430080.0}, -{0xf4ec, -149582770826931069376610978234368.0}, -{0xf50a, -174935782831495657406545042341888.0}, -{0xf563, -287756686251808074139751627620352.0}, -{0xf583, -332124457259796103192136239808512.0}, -{0xf5a0, -405648192073033408478945025720320.0}, -{0xf5f0, -608472288109550112718417538580480.0}, -{0xf60c, -709884336127808464838153795010560.0}, -{0xf614, -750449155335111805686048297582592.0}, -{0xf6d9, -2200641441996206240998276764532736.0}, -{0xf6f2, -2454171562041852121297617405607936.0}, -{0xf700, -2596148429267413814265248164610048.0}, -{0xf730, -3569704090242693994614716226338816.0}, -{0xf77b, -5090884810516569276410760072790016.0}, -{0xf7a0, -6490371073168534535663120411525120.0}, -{0xf7ae, -7058278542070781307533643447533568.0}, -{0xf7da, -8843130587192128304841001560702976.0}, -{0xf7f2, -9816686248167408485190469622431744.0}, -{0xf7f3, -9857251067374711826038364125003776.0}, -{0xf7fa, -10141204801825835211973625643008000.0}, -{0xf831, -14359945999385382660154653910499328.0}, -{0xf84d, -16631575874994369747636746054533120.0}, -{0xf85c, -17848520451213469973073581131694080.0}, -{0xf8ac, -27908595614624698503351417769558016.0}, -{0xf90e, -46081634619496595203208154921828352.0}, -{0xf93f, -61983043748759504815582799930064896.0}, -{0xf97c, -81778675521923535149355317185216512.0}, -{0xf98e, -92163269238993190406416309843656704.0}, -{0xf9dc, -142788163609707759784588649053552640.0}, -{0xf9e7, -149927571790193147773818081506230272.0}, -{0xfa00, -166153499473114484112975882535043072.0}, -{0xfa45, -255720620282840260705126944214089728.0}, -{0xfa78, -321922405229159312968890772411645952.0}, -{0xfae3, -589325693443702935838211333366480896.0}, -{0xfb2b, -887882762809455524478714872296636416.0}, -{0xfb59, -1126728418302057595391117703440760832.0}, -{0xfb82, -1349997183219055183417929045597224960.0}, -{0xfb94, -1536919870126308978045026913449148416.0}, -{0xfb96, -1557689057560448288559148898766028800.0}, -{0xfb9e, -1640765807297005530615636840033550336.0}, -{0xfbad, -1796534713053050359471551729910153216.0}, -{0xfbc2, -2014611181111513119869832575737397248.0}, -{0xfbde, -2305379805189463467067540370173722624.0}, -{0xfbfd, -2627302210418622780036431142585368576.0}, -{0xfc37, -3800761300447493824084323312989110272.0}, -{0xfd39, -15369198701263089780450269134491484160.0}, -{0xfd4a, -16781503446784562895410564136039350272.0}, -{0xfd84, -21932261930451111902912816494625685504.0}, -{0xfdcc, -33895313892515354759047080037148786688.0}, -{0xff1b, -206030339346661960300090094343453409280.0}, -{0xff45, -261857915169628426962049990875227881472.0}, -{0xff51, -277808651119047417436895675598592016384.0} +static const std::map bf16_lut = { + {0x0000, 0.0}, + {0x002d, 0.00000000000000000000000000000000000000413259732711}, + {0x004e, 0.00000000000000000000000000000000000000716316870032}, + {0x005b, 0.00000000000000000000000000000000000000835703015038}, + {0x00cd, 0.00000000000000000000000000000000000001882627671239}, + {0x00ce, 0.00000000000000000000000000000000000001891811220855}, + {0x0170, 0.00000000000000000000000000000000000004408103815584}, + {0x01be, 0.00000000000000000000000000000000000006979497708007}, + {0x01fe, 0.00000000000000000000000000000000000009330486409652}, + {0x0211, 0.00000000000000000000000000000000000010652917554327}, + {0x028f, 0.00000000000000000000000000000000000021011961520948}, + {0x02bc, 0.00000000000000000000000000000000000027624117244324}, + {0x02e8, 0.00000000000000000000000000000000000034089336173846}, + {0x039c, 0.00000000000000000000000000000000000091688559364138}, + {0x03a9, 0.00000000000000000000000000000000000099329272644483}, + {0x03cf, 0.00000000000000000000000000000000000121663665310107}, + {0x03da, 0.00000000000000000000000000000000000128128884239629}, + {0x03f3, 0.00000000000000000000000000000000000142822563624908}, + {0x0427, 0.00000000000000000000000000000000000196307556587322}, + {0x044c, 0.00000000000000000000000000000000000239800847567747}, + {0x0485, 0.00000000000000000000000000000000000312681497318728}, + {0x0498, 0.00000000000000000000000000000000000357350282649975}, + {0x04da, 0.00000000000000000000000000000000000512515536958517}, + {0x051b, 0.00000000000000000000000000000000000728806497509818}, + {0x0533, 0.00000000000000000000000000000000000841653955188758}, + {0x0536, 0.00000000000000000000000000000000000855759887398625}, + {0x0577, 0.00000000000000000000000000000000001161388418612420}, + {0x0587, 0.00000000000000000000000000000000001269533898888071}, + {0x065a, 0.00000000000000000000000000000000004100124295668139}, + {0x0735, 0.00000000000000000000000000000000013616926559925378}, + {0x075e, 0.00000000000000000000000000000000016701423736483061}, + {0x0765, 0.00000000000000000000000000000000017228045205651446}, + {0x076b, 0.00000000000000000000000000000000017679435036367204}, + {0x07ba, 0.00000000000000000000000000000000027986169504377021}, + {0x07d1, 0.00000000000000000000000000000000031446824873197835}, + {0x07db, 0.00000000000000000000000000000000032951457642250363}, + {0x07eb, 0.00000000000000000000000000000000035358870072734408}, + {0x080d, 0.00000000000000000000000000000000042430644087281290}, + {0x0841, 0.00000000000000000000000000000000058078824885427581}, + {0x08ff, 0.00000000000000000000000000000000153472542443357857}, + {0x09e1, 0.00000000000000000000000000000000541667796858910084}, + {0x0a0b, 0.00000000000000000000000000000000669260655674564459}, + {0x0a0f, 0.00000000000000000000000000000000688519955118436817}, + {0x0a12, 0.00000000000000000000000000000000702964429701341086}, + {0x0a1d, 0.00000000000000000000000000000000755927503171990072}, + {0x0aa2, 0.00000000000000000000000000000001560003254953661041}, + {0x0aaf, 0.00000000000000000000000000000001685188701338831371}, + {0x0ab4, 0.00000000000000000000000000000001733336949948512268}, + {0x0ade, 0.00000000000000000000000000000002137782238269831797}, + {0x0b6e, 0.00000000000000000000000000000004583713267641621330}, + {0x0bb6, 0.00000000000000000000000000000007010384997569538505}, + {0x0c8c, 0.00000000000000000000000000000021570415377137041554}, + {0x0cf7, 0.00000000000000000000000000000038056375701091780456}, + {0x0d06, 0.00000000000000000000000000000041291938007662336690}, + {0x0d20, 0.00000000000000000000000000000049303806576313237838}, + {0x0d5e, 0.00000000000000000000000000000068409031624634617501}, + {0x0d60, 0.00000000000000000000000000000069025329206838532974}, + {0x0d6a, 0.00000000000000000000000000000072106817117858110338}, + {0x0d76, 0.00000000000000000000000000000075804602611081603176}, + {0x0d7e, 0.00000000000000000000000000000078269792939897265068}, + {0x0dcc, 0.00000000000000000000000000000125724706769598756487}, + {0x0dfc, 0.00000000000000000000000000000155306990715386699190}, + {0x0e09, 0.00000000000000000000000000000168865537523872839596}, + {0x0e3c, 0.00000000000000000000000000000231727890908672217840}, + {0x0e69, 0.00000000000000000000000000000287194673307024610408}, + {0x0f42, 0.00000000000000000000000000000956493847580476814062}, + {0x0f8f, 0.00000000000000000000000000001410088868082558602173}, + {0x0fa2, 0.00000000000000000000000000001597443333072548905959}, + {0x1007, 0.00000000000000000000000000002662405555120914843265}, + {0x1015, 0.00000000000000000000000000002938506871948268975159}, + {0x1030, 0.00000000000000000000000000003470987982972451943812}, + {0x1042, 0.00000000000000000000000000003825975390321907256247}, + {0x1056, 0.00000000000000000000000000004220405842932413158953}, + {0x1166, 0.00000000000000000000000000018143800820083271524470}, + {0x1182, 0.00000000000000000000000000020510383535746306940705}, + {0x128a, 0.00000000000000000000000000087090243936399703317455}, + {0x1295, 0.00000000000000000000000000094032219902344607205078}, + {0x129e, 0.00000000000000000000000000099712018419935892204042}, + {0x12b0, 0.00000000000000000000000000111071615455118462201971}, + {0x12bf, 0.00000000000000000000000000120537946317770603866912}, + {0x1315, 0.00000000000000000000000000188064439804689214410156}, + {0x1343, 0.00000000000000000000000000246124602428955683288459}, + {0x13e2, 0.00000000000000000000000000570504206655835737673762}, + {0x13ee, 0.00000000000000000000000000600796465416322591001572}, + {0x1445, 0.00000000000000000000000000994595829302651684263107}, + {0x1469, 0.00000000000000000000000001176349381865572804229970}, + {0x14bd, 0.00000000000000000000000001908412301910671759652054}, + {0x1541, 0.00000000000000000000000003897603960515975128178268}, + {0x1546, 0.00000000000000000000000003998578156384264639270970}, + {0x1569, 0.00000000000000000000000004705397527462291216919879}, + {0x16a1, 0.00000000000000000000000026010952855671378057479844}, + {0x16b6, 0.00000000000000000000000029403685836845905630194606}, + {0x16f4, 0.00000000000000000000000039420326066980225130590570}, + {0x1703, 0.00000000000000000000000042328382907986963050060367}, + {0x1720, 0.00000000000000000000000051698788284564229679463043}, + {0x178e, 0.00000000000000000000000091765349205101507681046902}, + {0x17f6, 0.00000000000000000000000158973773975035006264348858}, + {0x18e8, 0.00000000000000000000000599705944100945064281771302}, + {0x18f1, 0.00000000000000000000000622970398828998967637529671}, + {0x1927, 0.00000000000000000000000863369764352222635647032822}, + {0x1a39, 0.00000000000000000000003825710333057752996280265201}, + {0x1a60, 0.00000000000000000000004632211430296954979279888676}, + {0x1a69, 0.00000000000000000000004818327068121386206125955631}, + {0x1b1f, 0.00000000000000000000013152171739593140030455398204}, + {0x1b43, 0.00000000000000000000016130021944784039659992469495}, + {0x1ba0, 0.00000000000000000000026469779601696885595885078146}, + {0x1bc0, 0.00000000000000000000031763735522036262715062093775}, + {0x1bea, 0.00000000000000000000038712052667481695183981926789}, + {0x1c25, 0.00000000000000000000054593920428499826541512973677}, + {0x1c32, 0.00000000000000000000058895259613775570450844298875}, + {0x1cbe, 0.00000000000000000000125731453108060206580454121195}, + {0x1ccd, 0.00000000000000000000135657620458696538678911025499}, + {0x1cd6, 0.00000000000000000000141613320869078337937985168082}, + {0x1d23, 0.00000000000000000000215728703753829617606463386892}, + {0x1d38, 0.00000000000000000000243521972335611347482142718945}, + {0x1dce, 0.00000000000000000000545277459794955843275232609813}, + {0x1e7c, 0.00000000000000000001334076891925523034032607938570}, + {0x1e9e, 0.00000000000000000001672890070827243169659936938842}, + {0x1eb1, 0.00000000000000000001874060395800139500188663532754}, + {0x1f33, 0.00000000000000000003790472438962994017330743190541}, + {0x1f56, 0.00000000000000000004531626267810506814015525378636}, + {0x1fa8, 0.00000000000000000007115076756936122848173909005709}, + {0x1fed, 0.00000000000000000010037340424963459017959621633054}, + {0x2001, 0.00000000000000000010926725019580474373981360258767}, + {0x213f, 0.00000000000000000064713317170228545904819839051925}, + {0x2154, 0.00000000000000000071828393927164668752993748057634}, + {0x216b, 0.00000000000000000079621097041904231872422315063886}, + {0x219f, 0.00000000000000000107742590890747003129490622086450}, + {0x2225, 0.00000000000000000223616698075135289514037140179425}, + {0x2229, 0.00000000000000000229037708937562811684074404183775}, + {0x2274, 0.00000000000000000330681662608078852372273104265332}, + {0x227b, 0.00000000000000000340168431617327016169838316272944}, + {0x2294, 0.00000000000000000401154803819636640582757536321878}, + {0x22b7, 0.00000000000000000496022493912118278558409656397998}, + {0x2379, 0.00000000000000001349831704744453020339278737083077}, + {0x2389, 0.00000000000000001485356976305141074590210337191820}, + {0x2464, 0.00000000000000004943961906533900219073984771966934}, + {0x2475, 0.00000000000000005312590645178971726636518724262714}, + {0x2491, 0.00000000000000006288372600415925717243226245045662}, + {0x24f6, 0.00000000000000010668549377257363630633335560560226}, + {0x2567, 0.00000000000000020036056147532121940457727760076523}, + {0x256a, 0.00000000000000020296264668928643004619516432285309}, + {0x257f, 0.00000000000000022117724318704290453752037137746811}, + {0x25f9, 0.00000000000000043194614551822496650856919586658478}, + {0x263b, 0.00000000000000064878658001532585331005975604057312}, + {0x270c, 0.00000000000000194289029309402394574135541915893555}, + {0x272c, 0.00000000000000238697950294408656191080808639526367}, + {0x2745, 0.00000000000000273392419813944798079319298267364502}, + {0x2791, 0.00000000000000402455846426619245903566479682922363}, + {0x2792, 0.00000000000000405231403988182137254625558853149414}, + {0x27a0, 0.00000000000000444089209850062616169452667236328125}, + {0x27a3, 0.00000000000000452415882534751290222629904747009277}, + {0x27d4, 0.00000000000000588418203051332966424524784088134766}, + {0x27dd, 0.00000000000000613398221105398988584056496620178223}, + {0x2821, 0.00000000000000893729534823251015041023492813110352}, + {0x28d9, 0.00000000000002409183963436589692719280719757080078}, + {0x2981, 0.00000000000005728750807065807748585939407348632812}, + {0x29ca, 0.00000000000008970602038971264846622943878173828125}, + {0x2a5b, 0.00000000000019451107391432742588222026824951171875}, + {0x2aa8, 0.00000000000029842794901924207806587219238281250}, + {0x2ac4, 0.000000000000348165940522449091076850891113281250}, + {0x2ae7, 0.00000000000041033842990145785734057426452636718750}, + {0x2af1, 0.00000000000042810199829546036198735237121582031250}, + {0x2afe, 0.0000000000004511946372076636180281639099121093750}, + {0x2b24, 0.00000000000058264504332328215241432189941406250}, + {0x2b4c, 0.00000000000072475359047530218958854675292968750}, + {0x2b85, 0.000000000000945021838560933247208595275878906250}, + {0x2bed, 0.000000000001683986283751437440514564514160156250}, + {0x2c18, 0.00000000000216004991671070456504821777343750}, + {0x2cdf, 0.0000000000063380412029800936579704284667968750}, + {0x2d6b, 0.000000000013358203432289883494377136230468750}, + {0x2d96, 0.0000000000170530256582424044609069824218750}, + {0x2da2, 0.0000000000184172677109017968177795410156250}, + {0x2db8, 0.00000000002091837814077734947204589843750}, + {0x2de1, 0.00000000002557953848736360669136047363281250}, + {0x2e90, 0.00000000006548361852765083312988281250}, + {0x2ea3, 0.000000000074123818194493651390075683593750}, + {0x2ef0, 0.00000000010913936421275138854980468750}, + {0x2f09, 0.00000000012460077414289116859436035156250}, + {0x2f6b, 0.00000000021373125491663813591003417968750}, + {0x303b, 0.000000000680302036926150321960449218750}, + {0x308f, 0.00000000104046193882822990417480468750}, + {0x309c, 0.000000001135049387812614440917968750}, + {0x30a9, 0.00000000122963683679699897766113281250}, + {0x312a, 0.000000002473825588822364807128906250}, + {0x313d, 0.0000000027503119781613349914550781250}, + {0x3159, 0.0000000031577656045556068420410156250}, + {0x31c6, 0.00000000576255843043327331542968750}, + {0x3212, 0.0000000084983184933662414550781250}, + {0x3245, 0.00000001146690919995307922363281250}, + {0x329b, 0.0000000180443748831748962402343750}, + {0x32ba, 0.000000021653249859809875488281250}, + {0x32cc, 0.00000002374872565269470214843750}, + {0x3332, 0.00000004144385457038879394531250}, + {0x33c4, 0.000000091269612312316894531250}, + {0x3424, 0.00000015273690223693847656250}, + {0x3589, 0.0000010207295417785644531250}, + {0x3594, 0.00000110268592834472656250}, + {0x368b, 0.00000414252281188964843750}, + {0x36a0, 0.000004768371582031250}, + {0x36e9, 0.00000694394111633300781250}, + {0x36ed, 0.00000706315040588378906250}, + {0x3750, 0.000012397766113281250}, + {0x375f, 0.0000132918357849121093750}, + {0x37ce, 0.00002455711364746093750}, + {0x37d2, 0.00002503395080566406250}, + {0x37f0, 0.00002861022949218750}, + {0x380e, 0.0000338554382324218750}, + {0x3826, 0.0000395774841308593750}, + {0x387f, 0.00006079673767089843750}, + {0x38e1, 0.0001072883605957031250}, + {0x38e9, 0.0001111030578613281250}, + {0x3964, 0.0002174377441406250}, + {0x3994, 0.000282287597656250}, + {0x3a26, 0.000633239746093750}, + {0x3a2c, 0.00065612792968750}, + {0x3a6a, 0.000892639160156250}, + {0x3a85, 0.001014709472656250}, + {0x3ab9, 0.001411437988281250}, + {0x3aba, 0.00141906738281250}, + {0x3af7, 0.001884460449218750}, + {0x3b03, 0.00199890136718750}, + {0x3bb3, 0.0054626464843750}, + {0x3bbf, 0.0058288574218750}, + {0x3be8, 0.0070800781250}, + {0x3c06, 0.00817871093750}, + {0x3c29, 0.010314941406250}, + {0x3c3f, 0.011657714843750}, + {0x3c73, 0.014831542968750}, + {0x3ce9, 0.02844238281250}, + {0x3cfa, 0.0305175781250}, + {0x3cfb, 0.03063964843750}, + {0x3d0f, 0.0349121093750}, + {0x3d2a, 0.041503906250}, + {0x3d43, 0.0476074218750}, + {0x3dd0, 0.10156250}, + {0x3dd9, 0.105957031250}, + {0x3de9, 0.113769531250}, + {0x3df9, 0.121582031250}, + {0x3e1e, 0.1542968750}, + {0x3e77, 0.24121093750}, + {0x3e95, 0.2910156250}, + {0x3f38, 0.718750}, + {0x3fb3, 1.39843750}, + {0x3fc5, 1.53906250}, + {0x3fd3, 1.64843750}, + {0x3fd7, 1.67968750}, + {0x400b, 2.1718750}, + {0x40bf, 5.968750}, + {0x40c7, 6.218750}, + {0x4123, 10.18750}, + {0x412b, 10.68750}, + {0x41bf, 23.8750}, + {0x41ca, 25.250}, + {0x421b, 38.750}, + {0x4226, 41.50}, + {0x42a7, 83.50}, + {0x42b7, 91.50}, + {0x4311, 145.0}, + {0x431f, 159.0}, + {0x4334, 180.0}, + {0x434f, 207.0}, + {0x43b1, 354.0}, + {0x43e5, 458.0}, + {0x4476, 984.0}, + {0x4496, 1200.0}, + {0x44a4, 1312.0}, + {0x458b, 4448.0}, + {0x45a9, 5408.0}, + {0x45df, 7136.0}, + {0x45f6, 7872.0}, + {0x45fa, 8000.0}, + {0x4602, 8320.0}, + {0x4640, 12288.0}, + {0x4648, 12800.0}, + {0x46a7, 21376.0}, + {0x46b1, 22656.0}, + {0x4742, 49664.0}, + {0x4744, 50176.0}, + {0x475e, 56832.0}, + {0x477a, 64000.0}, + {0x4837, 187392.0}, + {0x488a, 282624.0}, + {0x488f, 292864.0}, + {0x48ea, 479232.0}, + {0x495c, 901120.0}, + {0x49aa, 1392640.0}, + {0x49b9, 1515520.0}, + {0x4a1e, 2588672.0}, + {0x4a2b, 2801664.0}, + {0x4a4c, 3342336.0}, + {0x4ab6, 5963776.0}, + {0x4b34, 11796480.0}, + {0x4b73, 15925248.0}, + {0x4b7b, 16449536.0}, + {0x4bcd, 26869760.0}, + {0x4bd0, 27262976.0}, + {0x4c07, 35389440.0}, + {0x4c17, 39583744.0}, + {0x4c53, 55312384.0}, + {0x4cad, 90701824.0}, + {0x4d1c, 163577856.0}, + {0x4dc0, 402653184.0}, + {0x4dde, 465567744.0}, + {0x4eef, 2004877312.0}, + {0x4efc, 2113929216.0}, + {0x4f12, 2449473536.0}, + {0x4f2f, 2936012800.0}, + {0x4f92, 4898947072.0}, + {0x4fad, 5804916736.0}, + {0x4fdc, 7381975040.0}, + {0x4feb, 7885291520.0}, + {0x5076, 16508780544.0}, + {0x5083, 17582522368.0}, + {0x5215, 159987531776.0}, + {0x52a9, 362924736512.0}, + {0x5394, 1271310319616.0}, + {0x53a0, 1374389534720.0}, + {0x53b7, 1571958030336.0}, + {0x540e, 2439541424128.0}, + {0x542f, 3006477107200.0}, + {0x5465, 3934190043136.0}, + {0x5529, 11613591568384.0}, + {0x554c, 14018773254144.0}, + {0x5596, 20615843020800.0}, + {0x55ae, 23914377904128.0}, + {0x55be, 26113401159680.0}, + {0x55da, 29961691856896.0}, + {0x568d, 77515569758208.0}, + {0x5690, 79164837199872.0}, + {0x56ad, 95107755802624.0}, + {0x5718, 167125767421952.0}, + {0x571c, 171523813933056.0}, + {0x571d, 172623325560832.0}, + {0x5826, 730075720843264.0}, + {0x587c, 1108307720798208.0}, + {0x5890, 1266637395197952.0}, + {0x58a8, 1477743627730944.0}, + {0x58f6, 2163838883463168.0}, + {0x5966, 4046202790215680.0}, + {0x5985, 4679521487814656.0}, + {0x59ad, 6086896371367936.0}, + {0x59b0, 6192449487634432.0}, + {0x59bc, 6614661952700416.0}, + {0x5a93, 20688410788233216.0}, + {0x5ab0, 24769797950537728.0}, + {0x5ab6, 25614222880669696.0}, + {0x5ae3, 31947409856659456.0}, + {0x5af5, 34480684647055360.0}, + {0x5afd, 35606584553897984.0}, + {0x5bb6, 102456891522678784.0}, + {0x5c3d, 212795082393255936.0}, + {0x5d57, 968273919884656640.0}, + {0x5d76, 1107885508333142016.0}, + {0x5d86, 1206964700135292928.0}, + {0x5db2, 1603281467343896576.0}, + {0x5dc1, 1738389456165011456.0}, + {0x5dc5, 1774418253183975424.0}, + {0x5e5d, 3981182070595518464.0}, + {0x5fa4, 23634890844440363008.0}, + {0x5fa8, 24211351596743786496.0}, + {0x5ff8, 35740566642812256256.0}, + {0x6006, 38622870404329373696.0}, + {0x6051, 60240148615707754496.0}, + {0x60ed, 136621198295911366656.0}, + {0x610b, 160256089140351729664.0}, + {0x6114, 170632382681813352448.0}, + {0x613b, 215596321361480384512.0}, + {0x6148, 230584300921369395200.0}, + {0x61ad, 398910840593969053696.0}, + {0x61fd, 583378281331064569856.0}, + {0x629f, 1466516153859909353472.0}, + {0x62a4, 1512633014044183232512.0}, + {0x62fb, 2315066381250548727808.0}, + {0x634b, 3744689046963038978048.0}, + {0x635a, 4021390208068682252288.0}, + {0x635f, 4113623928437230010368.0}, + {0x637c, 4648579506574807007232.0}, + {0x638d, 5201981828786093555712.0}, + {0x63a9, 6234999496913828446208.0}, + {0x6469, 17192365476697302106112.0}, + {0x64c0, 28334198897217871282176.0}, + {0x64d1, 30842956091242370301952.0}, + {0x64dd, 32613843522318487257088.0}, + {0x64ee, 35122600716342986276864.0}, + {0x64ef, 35270174668932662689792.0}, + {0x64fb, 37041062100008779644928.0}, + {0x6510, 42501298345826806923264.0}, + {0x6581, 76148159536273029070848.0}, + {0x65d4, 125142711796045598162944.0}, + {0x6612, 172366376624742050299904.0}, + {0x661c, 184172292831916163334144.0}, + {0x66c6, 467514281804094876155904.0}, + {0x66ed, 559600428220052957822976.0}, + {0x66f9, 587934627117270829105152.0}, + {0x6703, 618630009255923522994176.0}, + {0x6752, 991696961402625494876160.0}, + {0x6797, 1426154677826632854536192.0}, + {0x679c, 1473378342655329306673152.0}, + {0x67e3, 2143954383222818927017984.0}, + {0x6862, 4269019300514159273181184.0}, + {0x692f, 13222626152035006598348800.0}, + {0x693d, 14280436244197807126216704.0}, + {0x6943, 14733783426553293066731520.0}, + {0x695e, 16773845747152979799048192.0}, + {0x69ec, 35663311678631560653832192.0}, + {0x69f4, 36872237498246189828538368.0}, + {0x6a5c, 66490920078804604608839680.0}, + {0x6a7a, 75557863725914323419136000.0}, + {0x6ac3, 117870267412426344533852160.0}, + {0x6ad8, 130563988518379950868267008.0}, + {0x6ae3, 137213080526260411329150976.0}, + {0x6b37, 221233424989477138971230208.0}, + {0x6b77, 298604677444813406152425472.0}, + {0x6bd7, 519838102434290545123655680.0}, + {0x6be7, 558523728661958678714253312.0}, + {0x6c15, 720519788490318988124880896.0}, + {0x6c33, 865590886844074489089622016.0}, + {0x6c43, 942962139299410756270817280.0}, + {0x6c45, 952633545856327789668466688.0}, + {0x6c48, 967140655691703339764940800.0}, + {0x6da6, 6421813953792910176039206912.0}, + {0x6dba, 7195526478346272847851159552.0}, + {0x6def, 9245864668412683928152834048.0}, + {0x6e24, 12688885402675147817716023296.0}, + {0x6e28, 12998370412496492886440804352.0}, + {0x6e3d, 14623166714058554497245904896.0}, + {0x6ea0, 24758800785707605497982484480.0}, + {0x6eef, 36983458673650735712611336192.0}, + {0x6ef9, 38530883722757461056235241472.0}, + {0x6f55, 65920307091946499638378364928.0}, + {0x6f5c, 68086702160695915119451832320.0}, + {0x6f65, 70872067249088020737974861824.0}, + {0x6f9e, 97797263103545041717030813696.0}, + {0x6fdc, 136173404321391830238903664640.0}, + {0x70ab, 423375493435600054015500484608.0}, + {0x70dc, 544693617285567320955614658560.0}, + {0x714a, 1000255551742587262118492372992.0}, + {0x71ba, 1842054778456645849049896845312.0}, + {0x71d3, 2089642786313721904029721690112.0}, + {0x71ee, 2357037834799364043407932522496.0}, + {0x71f6, 2436265997313628381001476472832.0}, + {0x7251, 4139671491370311639262671405056.0}, + {0x72b8, 7288990951312319058606043430912.0}, + {0x731f, 12597277839768029677373488103424.0}, + {0x7328, 13310331302396408715715383656448.0}, + {0x7356, 16954826778052568245018405371904.0}, + {0x7358, 17113283103081096920205493272576.0}, + {0x7375, 19410899815994762710418267832320.0}, + {0x737c, 19965496953594613073573075484672.0}, + {0x7467, 73206822163180247936434610110464.0}, + {0x74a4, 103947349218714810922729662840832.0}, + {0x74b1, 112187078120198302032458233675776.0}, + {0x7530, 223106505640168374663419764146176.0}, + {0x7563, 287756686251808074139751627620352.0}, + {0x756f, 302968493454546826957712066084864.0}, + {0x7571, 305503794655003285760705472495616.0}, + {0x7626, 841719998551544322593810928369664.0}, + {0x7660, 1135814937804493543741046072016896.0}, + {0x7675, 1242297588223664813466769141268480.0}, + {0x76b2, 1805134454724998667731305364455424.0}, + {0x772c, 3488574451828087312918927221194752.0}, + {0x77b2, 7220537818899994670925221457821696.0}, + {0x783a, 15090112745116842795416754956795904.0}, + {0x795d, 71718600358512306619077480547352576.0}, + {0x796e, 77235415770705560974391132897148928.0}, + {0x798c, 90865195024359483499283685761351680.0}, + {0x79af, 113581493780449354374104607201689600.0}, + {0x7aa5, 428364490829123279353765947160657920.0}, + {0x7acf, 537402724858354659552906370074279936.0}, + {0x7adc, 571152654438831039138354596214210560.0}, + {0x7b07, 700960075902201729851617004444712960.0}, + {0x7b0f, 742498450770480350879860975078473728.0}, + {0x7b12, 758075341346084833765452464066134016.0}, + {0x7b30, 913844247102129662621367353942736896.0}, + {0x7bc2, 2014611181111513119869832575737397248.0}, + {0x7bd1, 2170380086867557948725747465614000128.0}, + {0x7bd5, 2211918461735836569753991436247760896.0}, + {0x7cf1, 10010748343255147667806796922736345088.0}, + {0x7d2f, 14538431203897517359885389721816268800.0}, + {0x7da0, 26584559915698317458076141205606891520.0}, + {0x7e58, 71778311772385457136805581255138607104.0}, + {0x7e81, 85735205728127073802295555388082225152.0}, + {0x7f09, 182104235422533474587821567258407206912.0}, + {0x7f24, 217993391308726203156224357885976510464.0}, + {0x7f86, std::numeric_limits::quiet_NaN()}, + {0x7f88, std::numeric_limits::quiet_NaN()}, + {0x7f8f, std::numeric_limits::quiet_NaN()}, + {0x7fa0, std::numeric_limits::quiet_NaN()}, + {0x7fcd, std::numeric_limits::quiet_NaN()}, + {0x8023, -0.00000000000000000000000000000000000000321424236553}, + {0x8074, -0.00000000000000000000000000000000000001065291755433}, + {0x8080, -0.00000000000000000000000000000000000001175494350822}, + {0x80a5, -0.00000000000000000000000000000000000001515285686607}, + {0x80d2, -0.00000000000000000000000000000000000001928545419318}, + {0x80fd, -0.00000000000000000000000000000000000002323438052797}, + {0x810a, -0.00000000000000000000000000000000000002534659693961}, + {0x8124, -0.00000000000000000000000000000000000003012204273982}, + {0x81e3, -0.00000000000000000000000000000000000008338663051146}, + {0x81f1, -0.00000000000000000000000000000000000008852941829630}, + {0x8285, -0.00000000000000000000000000000000000019542593582421}, + {0x828b, -0.00000000000000000000000000000000000020424214345537}, + {0x829f, -0.00000000000000000000000000000000000023362950222593}, + {0x82bc, -0.00000000000000000000000000000000000027624117244324}, + {0x82ee, -0.00000000000000000000000000000000000034970956936963}, + {0x82f9, -0.00000000000000000000000000000000000036587261669344}, + {0x8393, -0.00000000000000000000000000000000000086398834785438}, + {0x8394, -0.00000000000000000000000000000000000086986581960849}, + {0x843e, -0.00000000000000000000000000000000000223343926656235}, + {0x8451, -0.00000000000000000000000000000000000245678319321858}, + {0x847f, -0.00000000000000000000000000000000000299751059459683}, + {0x8483, -0.00000000000000000000000000000000000307979519915439}, + {0x84a0, -0.00000000000000000000000000000000000376158192263132}, + {0x84aa, -0.00000000000000000000000000000000000399668079279578}, + {0x84ba, -0.00000000000000000000000000000000000437283898505891}, + {0x84e4, -0.00000000000000000000000000000000000536025423974963}, + {0x8510, -0.00000000000000000000000000000000000677084746073638}, + {0x854d, -0.00000000000000000000000000000000000963905367674276}, + {0x8557, -0.00000000000000000000000000000000001010925141707167}, + {0x8584, -0.00000000000000000000000000000000001241322034468336}, + {0x85b7, -0.00000000000000000000000000000000001720923729603829}, + {0x8656, -0.00000000000000000000000000000000004024892657215512}, + {0x87c7, -0.00000000000000000000000000000000029942192104145307}, + {0x88d9, -0.00000000000000000000000000000000130602124353759431}, + {0x896c, -0.00000000000000000000000000000000284074666797117288}, + {0x89a0, -0.00000000000000000000000000000000385185988877447171}, + {0x89b2, -0.00000000000000000000000000000000428519412626159977}, + {0x89fe, -0.00000000000000000000000000000000611482757342947383}, + {0x8a31, -0.00000000000000000000000000000000852224000391351865}, + {0x8a55, -0.00000000000000000000000000000001025557695386203092}, + {0x8a68, -0.00000000000000000000000000000001117039367744596795}, + {0x8b4a, -0.00000000000000000000000000000003890378487662216423}, + {0x8b4c, -0.00000000000000000000000000000003928897086549961140}, + {0x8b5b, -0.00000000000000000000000000000004217786578208046518}, + {0x8bbf, -0.00000000000000000000000000000007357052387559240959}, + {0x8bff, -0.00000000000000000000000000000009822242716374902851}, + {0x8c43, -0.00000000000000000000000000000015022253566220439654}, + {0x8c6b, -0.00000000000000000000000000000018103741477240017019}, + {0x8d1d, -0.00000000000000000000000000000048379360203007364629}, + {0x8d23, -0.00000000000000000000000000000050228252949619111048}, + {0x8d30, -0.00000000000000000000000000000054234187233944561622}, + {0x8dee, -0.00000000000000000000000000000146678824564531882569}, + {0x8e54, -0.00000000000000000000000000000261310174854460160543}, + {0x8e68, -0.00000000000000000000000000000285962078142616779462}, + {0x8eb0, -0.00000000000000000000000000000433873497871556492976}, + {0x8efe, -0.00000000000000000000000000000626158343519178120546}, + {0x8f3d, -0.00000000000000000000000000000931841944292320195143}, + {0x8f95, -0.00000000000000000000000000001469253435974134487579}, + {0x8fa3, -0.00000000000000000000000000001607304094387811553526}, + {0x8fbe, -0.00000000000000000000000000001873544649899903037853}, + {0x9009, -0.00000000000000000000000000002701848600381965433535}, + {0x9017, -0.00000000000000000000000000002977949917209319565429}, + {0x90a8, -0.00000000000000000000000000006626431603856499165459}, + {0x90d2, -0.00000000000000000000000000008283039504820623956823}, + {0x9260, -0.00000000000000000000000000070681937107802657764891}, + {0x92d0, -0.00000000000000000000000000131266454628776364420512}, + {0x92ed, -0.00000000000000000000000000149568027629903838306064}, + {0x9356, -0.00000000000000000000000000270105973947674442172976}, + {0x94af, -0.00000000000000000000000001767048427695066444122272}, + {0x9503, -0.00000000000000000000000002645523931749185190628773}, + {0x953c, -0.00000000000000000000000003796629764647685617085567}, + {0x9556, -0.00000000000000000000000004321695583162791074767614}, + {0x9598, -0.00000000000000000000000006139231108792002274436236}, + {0x9599, -0.00000000000000000000000006179620787139318078873317}, + {0x95cf, -0.00000000000000000000000008360663417894371518475664}, + {0x95df, -0.00000000000000000000000009006898271451424389468952}, + {0x95f4, -0.00000000000000000000000009855081516745056282647643}, + {0x960f, -0.00000000000000000000000011551448007332320069005024}, + {0x9615, -0.00000000000000000000000012036124147500109722249990}, + {0x966a, -0.00000000000000000000000018902369466543796476553675}, + {0x968c, -0.00000000000000000000000022618219874496850484765081}, + {0x96b3, -0.00000000000000000000000028919009696678115976949640}, + {0x96d7, -0.00000000000000000000000034735123378691591815889232}, + {0x9719, -0.00000000000000000000000049436966297114544630986535}, + {0x9761, -0.00000000000000000000000072701421025168447986744905}, + {0x97f0, -0.00000000000000000000000155096364853692689038389130}, + {0x97fd, -0.00000000000000000000000163497417949934376361301874}, + {0x983c, -0.00000000000000000000000242984304937451879493476303}, + {0x987d, -0.00000000000000000000000326994835899868752722603749}, + {0x9895, -0.00000000000000000000000385155972720003511111999672}, + {0x98b3, -0.00000000000000000000000462704155146849855631194237}, + {0x98fa, -0.00000000000000000000000646234853557052870993288041}, + {0x998f, -0.00000000000000000000001478585344938536968832643037}, + {0x999b, -0.00000000000000000000001602662436821491120063354341}, + {0x99e4, -0.00000000000000000000002357464745776128873383514772}, + {0x9a8b, -0.00000000000000000000005748905257243542340356290410}, + {0x9a95, -0.00000000000000000000006162495563520056177791994756}, + {0x9a9f, -0.00000000000000000000006576085869796570015227699102}, + {0x9bb2, -0.00000000000000000000029447629806887785225422149438}, + {0x9bc4, -0.00000000000000000000032425480012078684854959220729}, + {0x9c09, -0.00000000000000000000045329497567905916582953196325}, + {0x9c79, -0.00000000000000000000082387189010281556417192305730}, + {0x9cca, -0.00000000000000000000133672386988569272259219644639}, + {0x9d21, -0.00000000000000000000213081725793659929046874879077}, + {0x9d2d, -0.00000000000000000000228963593554678060404405925965}, + {0x9d53, -0.00000000000000000000279256174797902143036587574443}, + {0x9d59, -0.00000000000000000000287197108678411208715353097887}, + {0x9d9b, -0.00000000000000000000410281583826301726736218711267}, + {0x9dc9, -0.00000000000000000000532042569994107400477290070739}, + {0x9e3a, -0.00000000000000000000984675801183124144166924907040}, + {0x9eb4, -0.00000000000000000001905824131322175762903725626529}, + {0x9eb7, -0.00000000000000000001937587866844212025618787720305}, + {0x9ec3, -0.00000000000000000002064642808932357076479036095407}, + {0x9ee0, -0.00000000000000000002371692252312040949391303001903}, + {0x9f0a, -0.00000000000000000002922263668027336169785712627345}, + {0x9f5b, -0.00000000000000000004637505386217294356399065691221}, + {0x9fb7, -0.00000000000000000007750351467376848102475150881219}, + {0xa007, -0.00000000000000000011434944787933054577422353759175}, + {0xa06c, -0.00000000000000000019989977555201488002012411016040}, + {0xa07a, -0.00000000000000000021175823681357508476708062516991}, + {0xa0c0, -0.00000000000000000032526065174565133020223584026098}, + {0xa0e5, -0.00000000000000000038794108984246955529329170531128}, + {0xa108, -0.00000000000000000046078592330633938445316744036973}, + {0xa128, -0.00000000000000000056920614055488982785391272045672}, + {0xa178, -0.00000000000000000084025668367626593635577592067420}, + {0xa1f6, -0.00000000000000000166696084019646306728645868133754}, + {0xa305, -0.00000000000000000720994444702860448614956112578511}, + {0xa312, -0.00000000000000000791467585914418236825440544635057}, + {0xa3f2, -0.00000000000000002623769257414920730298035778105259}, + {0xa3f3, -0.00000000000000002634611279139775774638110306113958}, + {0xa40a, -0.00000000000000002992397996059992237860569730401039}, + {0xa412, -0.00000000000000003165870343657672947301762178540230}, + {0xa413, -0.00000000000000003187554387107383035981911234557629}, + {0xa421, -0.00000000000000003491130995403324277503998018801212}, + {0xa450, -0.00000000000000004510281037539698445471003651618958}, + {0xa456, -0.00000000000000004640385298237958977551897987723351}, + {0xa4a4, -0.00000000000000007112366251504909087088890373706818}, + {0xa4c9, -0.00000000000000008716985466783455649419920518994331}, + {0xa4ed, -0.00000000000000010278236595162582034390652552247047}, + {0xa522, -0.00000000000000014051260155412137464736588299274445}, + {0xa53a, -0.00000000000000016132928326584305978030897676944733}, + {0xa541, -0.0000000000000001674008154317618846107507124543190}, + {0xa6f7, -0.00000000000000171390679426508540927898138761520386}, + {0xa76c, -0.00000000000000327515792264421179424971342086791992}, + {0xa7a3, -0.00000000000000452415882534751290222629904747009277}, + {0xa7ae, -0.00000000000000482947015711943095084279775619506836}, + {0xa7bc, -0.00000000000000521804821573823573999106884002685547}, + {0xa837, -0.00000000000001015854067532018234487622976303100586}, + {0xa83e, -0.00000000000001054711873393898713402450084686279297}, + {0xa881, -0.00000000000001432187701766451937146484851837158203}, + {0xa8b9, -0.00000000000002053912595556539599783718585968017578}, + {0xa8c2, -0.00000000000002153832667772803688421845436096191406}, + {0xa8ca, -0.00000000000002242650509742816211655735969543457031}, + {0xa8d6, -0.00000000000002375877272697834996506571769714355469}, + {0xa8e4, -0.00000000000002531308496145356912165880203247070312}, + {0xa92d, -0.00000000000003841371665203041629865765571594238281}, + {0xa933, -0.00000000000003974598428158060414716601371765136719}, + {0xa937, -0.00000000000004063416270128072937950491905212402344}, + {0xa950, -0.0000000000000461852778244065120816230773925781250}, + {0xa956, -0.00000000000004751754545395669993013143539428710938}, + {0xa9b8, -0.0000000000000817124146124115213751792907714843750}, + {0xa9c6, -0.00000000000008792966355031239800155162811279296875}, + {0xa9f0, -0.000000000000106581410364015027880668640136718750}, + {0xaa2d, -0.00000000000015365486660812166519463062286376953125}, + {0xaae6, -0.0000000000004085620730620576068758964538574218750}, + {0xaaff, -0.00000000000045297099404706386849284172058105468750}, + {0xab12, -0.000000000000518696197104873135685920715332031250}, + {0xab42, -0.000000000000689226453687297180294990539550781250}, + {0xabfa, -0.00000000000177635683940025046467781066894531250}, + {0xac3a, -0.0000000000026432189770275726914405822753906250}, + {0xadbb, -0.00000000002125943865394219756126403808593750}, + {0xadc3, -0.00000000002216893335571512579917907714843750}, + {0xadda, -0.0000000000247837306233122944831848144531250}, + {0xaddf, -0.00000000002535216481192037463188171386718750}, + {0xae16, -0.000000000034106051316484808921813964843750}, + {0xae77, -0.0000000000561612978344783186912536621093750}, + {0xaee2, -0.00000000010277290130034089088439941406250}, + {0xb03e, -0.00000000069121597334742546081542968750}, + {0xb050, -0.00000000075669959187507629394531250}, + {0xb075, -0.000000000891304807737469673156738281250}, + {0xb11d, -0.0000000022846506908535957336425781250}, + {0xb125, -0.0000000024010660126805305480957031250}, + {0xb139, -0.0000000026921043172478675842285156250}, + {0xb155, -0.0000000030995579436421394348144531250}, + {0xb18d, -0.000000004103640094399452209472656250}, + {0xb23c, -0.000000010943040251731872558593750}, + {0xb2a8, -0.0000000195577740669250488281250}, + {0xb341, -0.000000044936314225196838378906250}, + {0xb369, -0.000000054249539971351623535156250}, + {0xb37b, -0.000000058440491557121276855468750}, + {0xb3c6, -0.0000000922009348869323730468750}, + {0xb3c9, -0.00000009359791874885559082031250}, + {0xb3dc, -0.000000102445483207702636718750}, + {0xb3e2, -0.0000001052394509315490722656250}, + {0xb404, -0.00000012293457984924316406250}, + {0xb42d, -0.0000001611188054084777832031250}, + {0xb487, -0.000000251457095146179199218750}, + {0xb499, -0.000000284984707832336425781250}, + {0xb49b, -0.000000288709998130798339843750}, + {0xb4be, -0.00000035390257835388183593750}, + {0xb599, -0.0000011399388313293457031250}, + {0xb5be, -0.000001415610313415527343750}, + {0xb661, -0.000003352761268615722656250}, + {0xb67f, -0.000003799796104431152343750}, + {0xb6f4, -0.000007271766662597656250}, + {0xb70f, -0.0000085234642028808593750}, + {0xb729, -0.0000100731849670410156250}, + {0xb731, -0.0000105500221252441406250}, + {0xb735, -0.0000107884407043457031250}, + {0xb76f, -0.0000142455101013183593750}, + {0xb770, -0.000014305114746093750}, + {0xb7a4, -0.0000195503234863281250}, + {0xb7b1, -0.000021100044250488281250}, + {0xb829, -0.00004029273986816406250}, + {0xb882, -0.000061988830566406250}, + {0xb9a6, -0.0003166198730468750}, + {0xb9c5, -0.00037574768066406250}, + {0xb9cc, -0.000389099121093750}, + {0xb9d3, -0.00040245056152343750}, + {0xb9dd, -0.00042152404785156250}, + {0xbb04, -0.002014160156250}, + {0xbb14, -0.002258300781250}, + {0xbb19, -0.00233459472656250}, + {0xbb33, -0.00273132324218750}, + {0xbb66, -0.0035095214843750}, + {0xbbc5, -0.0060119628906250}, + {0xbc0d, -0.008605957031250}, + {0xbcb0, -0.0214843750}, + {0xbcc8, -0.02441406250}, + {0xbce0, -0.027343750}, + {0xbce8, -0.02832031250}, + {0xbd06, -0.032714843750}, + {0xbd77, -0.0603027343750}, + {0xbe31, -0.17285156250}, + {0xbe3a, -0.1816406250}, + {0xbe5d, -0.21582031250}, + {0xbe85, -0.2597656250}, + {0xbe9a, -0.300781250}, + {0xbea5, -0.3222656250}, + {0xbeb0, -0.343750}, + {0xbebf, -0.3730468750}, + {0xbeee, -0.464843750}, + {0xbf2b, -0.667968750}, + {0xbfac, -1.343750}, + {0xc022, -2.531250}, + {0xc026, -2.593750}, + {0xc05e, -3.468750}, + {0xc07e, -3.968750}, + {0xc07f, -3.9843750}, + {0xc086, -4.18750}, + {0xc0ae, -5.43750}, + {0xc0c2, -6.06250}, + {0xc0e6, -7.18750}, + {0xc13e, -11.8750}, + {0xc198, -19.0}, + {0xc1be, -23.750}, + {0xc1c1, -24.1250}, + {0xc1eb, -29.3750}, + {0xc225, -41.250}, + {0xc276, -61.50}, + {0xc27f, -63.750}, + {0xc29f, -79.50}, + {0xc313, -147.0}, + {0xc31b, -155.0}, + {0xc324, -164.0}, + {0xc35b, -219.0}, + {0xc394, -296.0}, + {0xc39d, -314.0}, + {0xc3b5, -362.0}, + {0xc3be, -380.0}, + {0xc429, -676.0}, + {0xc444, -784.0}, + {0xc44b, -812.0}, + {0xc4b5, -1448.0}, + {0xc4eb, -1880.0}, + {0xc523, -2608.0}, + {0xc557, -3440.0}, + {0xc55e, -3552.0}, + {0xc56d, -3792.0}, + {0xc58b, -4448.0}, + {0xc64d, -13120.0}, + {0xc6b8, -23552.0}, + {0xc6ca, -25856.0}, + {0xc777, -63232.0}, + {0xc7d6, -109568.0}, + {0xc868, -237568.0}, + {0xc8ca, -413696.0}, + {0xc910, -589824.0}, + {0xc9c5, -1613824.0}, + {0xc9c8, -1638400.0}, + {0xc9df, -1826816.0}, + {0xca3a, -3047424.0}, + {0xca42, -3178496.0}, + {0xca6b, -3850240.0}, + {0xcaa0, -5242880.0}, + {0xcaa2, -5308416.0}, + {0xcaac, -5636096.0}, + {0xcb3a, -12189696.0}, + {0xcb84, -17301504.0}, + {0xcc50, -54525952.0}, + {0xcc89, -71827456.0}, + {0xcc94, -77594624.0}, + {0xccaf, -91750400.0}, + {0xcce0, -117440512.0}, + {0xcce1, -117964800.0}, + {0xcd6d, -248512512.0}, + {0xcda8, -352321536.0}, + {0xcdba, -390070272.0}, + {0xcdd0, -436207616.0}, + {0xcde5, -480247808.0}, + {0xcdf7, -517996544.0}, + {0xce30, -738197504.0}, + {0xcec2, -1627389952.0}, + {0xcf03, -2197815296.0}, + {0xcf25, -2768240640.0}, + {0xcf57, -3607101440.0}, + {0xd036, -12213813248.0}, + {0xd09e, -21206401024.0}, + {0xd103, -35165044736.0}, + {0xd104, -35433480192.0}, + {0xd11f, -42681237504.0}, + {0xd125, -44291850240.0}, + {0xd19c, -83751862272.0}, + {0xd1c7, -106837311488.0}, + {0xd1cf, -111132278784.0}, + {0xd1d8, -115964116992.0}, + {0xd231, -190052302848.0}, + {0xd28a, -296352743424.0}, + {0xd294, -317827579904.0}, + {0xd2be, -408021893120.0}, + {0xd2c1, -414464344064.0}, + {0xd2c6, -425201762304.0}, + {0xd2db, -470298918912.0}, + {0xd334, -773094113280.0}, + {0xd36f, -1026497183744.0}, + {0xd375, -1052266987520.0}, + {0xd3c3, -1675037245440.0}, + {0xd3d5, -1829656068096.0}, + {0xd3f2, -2078764171264.0}, + {0xd44c, -3504693313536.0}, + {0xd49b, -5325759447040.0}, + {0xd4cd, -7043746365440.0}, + {0xd4e8, -7971459301376.0}, + {0xd538, -12644383719424.0}, + {0xd54c, -14018773254144.0}, + {0xd554, -14568529068032.0}, + {0xd5a3, -22402549415936.0}, + {0xd5bf, -26250840113152.0}, + {0xd64a, -55525337202688.0}, + {0xd74f, -227598906949632.0}, + {0xd75f, -245191092994048.0}, + {0xd762, -248489627877376.0}, + {0xd7d6, -470590976688128.0}, + {0xd7db, -481586092965888.0}, + {0xd819, -672901116198912.0}, + {0xd82d, -760862046420992.0}, + {0xd85b, -963172185931776.0}, + {0xd936, -3201777860083712.0}, + {0xd967, -4063794976260096.0}, + {0xd976, -4327677766926336.0}, + {0xd985, -4679521487814656.0}, + {0xd98c, -4925812092436480.0}, + {0xd9c9, -7072058789855232.0}, + {0xda1b, -10907155347537920.0}, + {0xda5a, -15340386230730752.0}, + {0xdab6, -25614222880669696.0}, + {0xdacc, -28710447624486912.0}, + {0xdb00, -36028797018963968.0}, + {0xdb0d, -39687971716202496.0}, + {0xdb24, -46161896180547584.0}, + {0xdb4c, -57420895248973824.0}, + {0xdbbd, -106397541196627968.0}, + {0xdbbf, -107523441103470592.0}, + {0xdbcc, -114841790497947648.0}, + {0xdbf4, -137359788634800128.0}, + {0xdc88, -306244774661193728.0}, + {0xdc9c, -351280770934898688.0}, + {0xdd24, -738590338888761344.0}, + {0xdd71, -1085367510196289536.0}, + {0xdd86, -1206964700135292928.0}, + {0xdd8f, -1288029493427961856.0}, + {0xdea9, -6088866696204910592.0}, + {0xded6, -7710162562058289152.0}, + {0xdedf, -8034421735228964864.0}, + {0xdef6, -8863084066665136128.0}, + {0xdf62, -16285016252571713536.0}, + {0xdf6a, -16861477004875137024.0}, + {0xdf71, -17365880163140632576.0}, + {0xdfc9, -28967152803247030272.0}, + {0xdff0, -34587645138205409280.0}, + {0xdff5, -35308221078584688640.0}, + {0xe037, -52746158835763249152.0}, + {0xe07e, -73210515542534782976.0}, + {0xe09a, -88774955854727217152.0}, + {0xe09d, -90504338111637487616.0}, + {0xe0cc, -117597993469898391552.0}, + {0xe113, -169479461177206505472.0}, + {0xe18f, -329735550317558235136.0}, + {0xe1aa, -391993311566327971840.0}, + {0xe21a, -710199646837817737216.0}, + {0xe233, -825491797298502434816.0}, + {0xe238, -848550227390639374336.0}, + {0xe247, -917725517667050192896.0}, + {0xe262, -1042241040164589666304.0}, + {0xe26a, -1079134528312008769536.0}, + {0xe271, -1111416330441000484864.0}, + {0xe28b, -1282048713122813837312.0}, + {0xe290, -1328165573307087716352.0}, + {0xe2b2, -1641760222560150093824.0}, + {0xe2eb, -2167492428660872314880.0}, + {0xe2f5, -2259726149029420072960.0}, + {0xe34b, -3744689046963038978048.0}, + {0xe363, -4187410904732068216832.0}, + {0xe388, -5017514388048998039552.0}, + {0xe3a0, -5902958103587056517120.0}, + {0xe3bd, -6972869259862210510848.0}, + {0xe3d6, -7895206463547688091648.0}, + {0xe3e4, -8411715297611555536896.0}, + {0xe406, -9887454823508319666176.0}, + {0xe5a3, -96218217088469021229056.0}, + {0xe5ae, -102711471002414783397888.0}, + {0xe5d7, -126913599227121715118080.0}, + {0xe5d9, -128094190847839126421504.0}, + {0xe644, -231395957660612615471104.0}, + {0xe66e, -280980805730743890214912.0}, + {0xe6b8, -434457716424007359660032.0}, + {0xe7f4, -2304514843640386864283648.0}, + {0xe824, -3097872412762487260184576.0}, + {0xe827, -3154540810556923002748928.0}, + {0xe880, -4835703278458516698824704.0}, + {0xe8f2, -9142501510835633133715456.0}, + {0xe928, -12693721105953606334414848.0}, + {0xe980, -19342813113834066795298816.0}, + {0xe9d1, -31583187037432187189198848.0}, + {0xe9fa, -37778931862957161709568000.0}, + {0xea15, -45032486780644936757805056.0}, + {0xea77, -74651169361203351538106368.0}, + {0xeaca, -122101507781077546645323776.0}, + {0xeacd, -123914896510499490407383040.0}, + {0xead9, -131168451428187265455620096.0}, + {0xeada, -131772914337994580042973184.0}, + {0xeb79, -301022529084042664501837824.0}, + {0xeba3, -394109817194369110954213376.0}, + {0xebf3, -587537948332709778907201536.0}, + {0xec09, -662491349148816787738984448.0}, + {0xec13, -710848381933401954727231488.0}, + {0xec48, -967140655691703339764940800.0}, + {0xece9, -2253437727761668781652312064.0}, + {0xed1f, -3075507285099616620452511744.0}, + {0xed24, -3172221350668786954429005824.0}, + {0xed9f, -6151014570199233240905023488.0}, + {0xede6, -8897694032363670725837455360.0}, + {0xedfe, -9826149061827705932011798528.0}, + {0xeea3, -25223028300439623101069656064.0}, + {0xeea5, -25532513310260968169794437120.0}, + {0xeec4, -30329530962491816735028543488.0}, + {0xeee0, -34662321099990647697175478272.0}, + {0xef23, -50446056600879246202139312128.0}, + {0xefa0, -99035203142830421991929937920.0}, + {0xefab, -105843873358900013503875121152.0}, + {0xf020, -198070406285660843983859875840.0}, + {0xf099, -378809652021326364119132012544.0}, + {0xf0a9, -418423733278458532915903987712.0}, + {0xf0cc, -505079536028435152158842683392.0}, + {0xf0e6, -569452418071274926453597143040.0}, + {0xf16b, -1163663636928257458405176770560.0}, + {0xf19b, -1535045648713871540874914037760.0}, + {0xf1bc, -1861861819085211933448282832896.0}, + {0xf1da, -2158967428513703199424072646656.0}, + {0xf231, -3505846191256196938514319802368.0}, + {0xf253, -4179285572627443808059443380224.0}, + {0xf287, -5347900969712842787564216647680.0}, + {0xf296, -5942112188569825319515796275200.0}, + {0xf2f3, -9626221745483117017615589965824.0}, + {0xf339, -14657210065138902454805630812160.0}, + {0xf36e, -18856302678394912347263460179968.0}, + {0xf3b3, -28363682180106632858488734220288.0}, + {0xf3c0, -30423614405477505635920876929024.0}, + {0xf3da, -34543478856219251190785162346496.0}, + {0xf3eb, -37237236381704238668965656657920.0}, + {0xf407, -42783207757702742300513733181440.0}, + {0xf418, -48170722808672717256874721804288.0}, + {0xf425, -52290587259414462811739007221760.0}, + {0xf473, -77009773963864936140924719726592.0}, + {0xf515, -188879939434006180823008777601024.0}, + {0xf57a, -316912650057057350374175801344000.0}, + {0xf594, -375224577667555902843024148791296.0}, + {0xf61c, -791013974542415146533942800154624.0}, + {0xf634, -912708432164325169077626307870720.0}, + {0xf69f, -1612451563490307798703806477238272.0}, + {0xf6b2, -1805134454724998667731305364455424.0}, + {0xf6f0, -2433889152438200450873670154321920.0}, + {0xf71e, -3204620717376963926983665703190528.0}, + {0xf735, -3671116138260952346734452482768896.0}, + {0xf748, -4056481920730334084789450257203200.0}, + {0xf75f, -4522977341614322504540237036781568.0}, + {0xf796, -6084722881095501127184175385804800.0}, + {0xf8a3, -26448262123161778232827215676964864.0}, + {0xf8d0, -33749929580476379585448226139930624.0}, + {0xf8ef, -38779967162181993850587144458862592.0}, + {0xf9a3, -105793048492647112931308862707859456.0}, + {0xfa0d, -183028464263352673905699995605008384.0}, + {0xfa18, -197307280624323449884158860510363648.0}, + {0xfa31, -229759135990166122562474462567989248.0}, + {0xfaa9, -438749084546192934610826939819098112.0}, + {0xfab5, -469902865697401900382009917794418688.0}, + {0xfacd, -532210427999819831924375873745059840.0}, + {0xfb84, -1370766370653194493932051030914105344.0}, + {0xfba8, -1744611744467702083186246766617952256.0}, + {0xfbfa, -2596148429267413814265248164610048000.0}, + {0xfc20, -3323069989462289682259517650700861440.0}, + {0xfc76, -5109220108798270386474008387952574464.0}, + {0xfc93, -6106141105636957291151863683162832896.0}, + {0xfccf, -8598443597733674552846501921188478976.0}, + {0xfcdc, -9138442471021296626213673539427368960.0}, + {0xfcf0, -9969209968386869046778552952102584320.0}, + {0xfd5b, -18193808192306036010370859137587216384.0}, + {0xfda9, -28079941410956347815092924148422279168.0}, + {0xfdca, -33563006893569125790821128272078700544.0}, + {0xfe1d, -52172198834557948011474427116003524608.0}, + {0xfe24, -54498347827181550789056089471494127616.0}, + {0xfe4b, -67458320786084480549868208309227487232.0}, + {0xfe4f, -68787548781869396422772015369507831808.0}, + {0xfe64, -75765995759740204755517002435979640832.0}, + {0xfea2, -107667467658578185705208371882707910656.0}, + {0xfec2, -128935115591136839671669284847193423872.0}, + {0xfee3, -150867377521587951574582101341819109376.0}, + {0xfee9, -154855061508942699193293522522660143104.0}, + {0xff57, -285784019093756912674318517960274083840.0}, + {0xff60, -297747071055821155530452781502797185024.0}, + {0xff8e, std::numeric_limits::quiet_NaN()}, + {0xffb0, std::numeric_limits::quiet_NaN()}, + {0xfffa, std::numeric_limits::quiet_NaN()}, }; -// TEST_CASE(clang_bf16) { - -// std::set samples = {0}; -// auto ns = migraphx::range(1, 65535); -// std::sample(ns.begin(), -// ns.end(), -// std::inserter(samples, samples.begin()), -// 1022, -// std::mt19937{std::random_device{}()}); -// samples.insert(65536); - - -// for(uint16_t i : samples) -// { - -// float f = migraphx::bit_cast<__bf16>(i); - -// std::cout << "{0x" << std::hex << std::setw(4) << std::setfill('0') << i << ", "; - -// if(std::isfinite(f)) -// { -// std::cout << std::fixed << std::setprecision(40) << static_cast(f); -// } -// else if(std::isinf(f)) -// { -// if(f < 0) -// std::cout << "-"; -// std::cout << "std::numeric_limits::infinity()"; -// } -// else if(std::isnan(f)) -// { -// std::cout << "std::numeric_limits::quiet_NaN()"; -// } -// std::cout << "},\n"; -// } - -// } - - -TEST_CASE(check_half_values) +TEST_CASE(check_bf16_values) { - for(auto [x, f] : half_lut) + for(auto [x, f] : bf16_lut) { auto h = migraphx::bit_cast(x); @@ -1261,7 +1212,7 @@ TEST_CASE(test_binary_ops) auto c = migraphx::bf16(0.0); auto d = migraphx::bf16(-0.0); EXPECT(migraphx::float_equal((c + d), c)); - // EXPECT(migraphx::float_equal((c + d), d)); + EXPECT(migraphx::float_equal((c + d), d)); EXPECT(migraphx::float_equal((a + b), c)); EXPECT(migraphx::float_equal((a + b), d)); From b9d204efdcb157d49ee0edea72fe9f073dc8289b Mon Sep 17 00:00:00 2001 From: Richa Gadgil Date: Mon, 4 Nov 2024 10:20:24 -0800 Subject: [PATCH 52/72] Update bf16.cpp --- test/bf16.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/test/bf16.cpp b/test/bf16.cpp index a051f7ee743..1e918a69643 100644 --- a/test/bf16.cpp +++ b/test/bf16.cpp @@ -1104,7 +1104,6 @@ TEST_CASE(check_bf16_values) } } - TEST_CASE(check_flows) { // check positive underflow From fb6df2dcfe5b86878677048eb58b1442c405f847 Mon Sep 17 00:00:00 2001 From: Richa Gadgil Date: Mon, 4 Nov 2024 13:34:01 -0800 Subject: [PATCH 53/72] Update generic_float.hpp --- src/include/migraphx/generic_float.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/include/migraphx/generic_float.hpp b/src/include/migraphx/generic_float.hpp index 6526a1943b9..1ac940e4999 100644 --- a/src/include/migraphx/generic_float.hpp +++ b/src/include/migraphx/generic_float.hpp @@ -386,12 +386,12 @@ class numeric_limits> // NOLINT(cert-dcl58-cpp) }; template -struct common_type, T> : std::common_type // NOLINT +struct common_type, T> : std::common_type // NOLINT(cert-dcl58-cpp) { }; template -struct common_type> : std::common_type // NOLINT +struct common_type> : std::common_type // NOLINT(cert-dcl58-cpp) { }; @@ -416,7 +416,7 @@ struct common_type> : std::common_type -struct common_type, migraphx::generic_float> +struct common_type, migraphx::generic_float> // NOLINT(cert-dcl58-cpp) { using type = migraphx::generic_float; }; From 8e1f99eda2399b7127f90514ca69ae55a5cf69a2 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Fri, 8 Nov 2024 20:04:26 +0000 Subject: [PATCH 54/72] add extra common type --- src/include/migraphx/bf16.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/include/migraphx/bf16.hpp b/src/include/migraphx/bf16.hpp index 8c9ed6fd9f3..d39703a9ace 100644 --- a/src/include/migraphx/bf16.hpp +++ b/src/include/migraphx/bf16.hpp @@ -94,6 +94,12 @@ struct common_type using type = migraphx::bf16; }; +template <> +struct common_type +{ + using type = float; +}; + } // namespace std #endif From 61929709ebc1ee3ce5607d562885402432f98550 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Fri, 8 Nov 2024 21:53:55 +0000 Subject: [PATCH 55/72] tidy --- test/bf16.cpp | 2056 +++++++++++++++++++++++++------------------------ 1 file changed, 1030 insertions(+), 1026 deletions(-) diff --git a/test/bf16.cpp b/test/bf16.cpp index 1e918a69643..9ba04d083a2 100644 --- a/test/bf16.cpp +++ b/test/bf16.cpp @@ -54,1035 +54,1039 @@ TEST_CASE(check_numeric_limits) CHECK(bit_equal(std::numeric_limits::signaling_NaN(), uint16_t{0x7fa0})); } -static const std::map bf16_lut = { - {0x0000, 0.0}, - {0x002d, 0.00000000000000000000000000000000000000413259732711}, - {0x004e, 0.00000000000000000000000000000000000000716316870032}, - {0x005b, 0.00000000000000000000000000000000000000835703015038}, - {0x00cd, 0.00000000000000000000000000000000000001882627671239}, - {0x00ce, 0.00000000000000000000000000000000000001891811220855}, - {0x0170, 0.00000000000000000000000000000000000004408103815584}, - {0x01be, 0.00000000000000000000000000000000000006979497708007}, - {0x01fe, 0.00000000000000000000000000000000000009330486409652}, - {0x0211, 0.00000000000000000000000000000000000010652917554327}, - {0x028f, 0.00000000000000000000000000000000000021011961520948}, - {0x02bc, 0.00000000000000000000000000000000000027624117244324}, - {0x02e8, 0.00000000000000000000000000000000000034089336173846}, - {0x039c, 0.00000000000000000000000000000000000091688559364138}, - {0x03a9, 0.00000000000000000000000000000000000099329272644483}, - {0x03cf, 0.00000000000000000000000000000000000121663665310107}, - {0x03da, 0.00000000000000000000000000000000000128128884239629}, - {0x03f3, 0.00000000000000000000000000000000000142822563624908}, - {0x0427, 0.00000000000000000000000000000000000196307556587322}, - {0x044c, 0.00000000000000000000000000000000000239800847567747}, - {0x0485, 0.00000000000000000000000000000000000312681497318728}, - {0x0498, 0.00000000000000000000000000000000000357350282649975}, - {0x04da, 0.00000000000000000000000000000000000512515536958517}, - {0x051b, 0.00000000000000000000000000000000000728806497509818}, - {0x0533, 0.00000000000000000000000000000000000841653955188758}, - {0x0536, 0.00000000000000000000000000000000000855759887398625}, - {0x0577, 0.00000000000000000000000000000000001161388418612420}, - {0x0587, 0.00000000000000000000000000000000001269533898888071}, - {0x065a, 0.00000000000000000000000000000000004100124295668139}, - {0x0735, 0.00000000000000000000000000000000013616926559925378}, - {0x075e, 0.00000000000000000000000000000000016701423736483061}, - {0x0765, 0.00000000000000000000000000000000017228045205651446}, - {0x076b, 0.00000000000000000000000000000000017679435036367204}, - {0x07ba, 0.00000000000000000000000000000000027986169504377021}, - {0x07d1, 0.00000000000000000000000000000000031446824873197835}, - {0x07db, 0.00000000000000000000000000000000032951457642250363}, - {0x07eb, 0.00000000000000000000000000000000035358870072734408}, - {0x080d, 0.00000000000000000000000000000000042430644087281290}, - {0x0841, 0.00000000000000000000000000000000058078824885427581}, - {0x08ff, 0.00000000000000000000000000000000153472542443357857}, - {0x09e1, 0.00000000000000000000000000000000541667796858910084}, - {0x0a0b, 0.00000000000000000000000000000000669260655674564459}, - {0x0a0f, 0.00000000000000000000000000000000688519955118436817}, - {0x0a12, 0.00000000000000000000000000000000702964429701341086}, - {0x0a1d, 0.00000000000000000000000000000000755927503171990072}, - {0x0aa2, 0.00000000000000000000000000000001560003254953661041}, - {0x0aaf, 0.00000000000000000000000000000001685188701338831371}, - {0x0ab4, 0.00000000000000000000000000000001733336949948512268}, - {0x0ade, 0.00000000000000000000000000000002137782238269831797}, - {0x0b6e, 0.00000000000000000000000000000004583713267641621330}, - {0x0bb6, 0.00000000000000000000000000000007010384997569538505}, - {0x0c8c, 0.00000000000000000000000000000021570415377137041554}, - {0x0cf7, 0.00000000000000000000000000000038056375701091780456}, - {0x0d06, 0.00000000000000000000000000000041291938007662336690}, - {0x0d20, 0.00000000000000000000000000000049303806576313237838}, - {0x0d5e, 0.00000000000000000000000000000068409031624634617501}, - {0x0d60, 0.00000000000000000000000000000069025329206838532974}, - {0x0d6a, 0.00000000000000000000000000000072106817117858110338}, - {0x0d76, 0.00000000000000000000000000000075804602611081603176}, - {0x0d7e, 0.00000000000000000000000000000078269792939897265068}, - {0x0dcc, 0.00000000000000000000000000000125724706769598756487}, - {0x0dfc, 0.00000000000000000000000000000155306990715386699190}, - {0x0e09, 0.00000000000000000000000000000168865537523872839596}, - {0x0e3c, 0.00000000000000000000000000000231727890908672217840}, - {0x0e69, 0.00000000000000000000000000000287194673307024610408}, - {0x0f42, 0.00000000000000000000000000000956493847580476814062}, - {0x0f8f, 0.00000000000000000000000000001410088868082558602173}, - {0x0fa2, 0.00000000000000000000000000001597443333072548905959}, - {0x1007, 0.00000000000000000000000000002662405555120914843265}, - {0x1015, 0.00000000000000000000000000002938506871948268975159}, - {0x1030, 0.00000000000000000000000000003470987982972451943812}, - {0x1042, 0.00000000000000000000000000003825975390321907256247}, - {0x1056, 0.00000000000000000000000000004220405842932413158953}, - {0x1166, 0.00000000000000000000000000018143800820083271524470}, - {0x1182, 0.00000000000000000000000000020510383535746306940705}, - {0x128a, 0.00000000000000000000000000087090243936399703317455}, - {0x1295, 0.00000000000000000000000000094032219902344607205078}, - {0x129e, 0.00000000000000000000000000099712018419935892204042}, - {0x12b0, 0.00000000000000000000000000111071615455118462201971}, - {0x12bf, 0.00000000000000000000000000120537946317770603866912}, - {0x1315, 0.00000000000000000000000000188064439804689214410156}, - {0x1343, 0.00000000000000000000000000246124602428955683288459}, - {0x13e2, 0.00000000000000000000000000570504206655835737673762}, - {0x13ee, 0.00000000000000000000000000600796465416322591001572}, - {0x1445, 0.00000000000000000000000000994595829302651684263107}, - {0x1469, 0.00000000000000000000000001176349381865572804229970}, - {0x14bd, 0.00000000000000000000000001908412301910671759652054}, - {0x1541, 0.00000000000000000000000003897603960515975128178268}, - {0x1546, 0.00000000000000000000000003998578156384264639270970}, - {0x1569, 0.00000000000000000000000004705397527462291216919879}, - {0x16a1, 0.00000000000000000000000026010952855671378057479844}, - {0x16b6, 0.00000000000000000000000029403685836845905630194606}, - {0x16f4, 0.00000000000000000000000039420326066980225130590570}, - {0x1703, 0.00000000000000000000000042328382907986963050060367}, - {0x1720, 0.00000000000000000000000051698788284564229679463043}, - {0x178e, 0.00000000000000000000000091765349205101507681046902}, - {0x17f6, 0.00000000000000000000000158973773975035006264348858}, - {0x18e8, 0.00000000000000000000000599705944100945064281771302}, - {0x18f1, 0.00000000000000000000000622970398828998967637529671}, - {0x1927, 0.00000000000000000000000863369764352222635647032822}, - {0x1a39, 0.00000000000000000000003825710333057752996280265201}, - {0x1a60, 0.00000000000000000000004632211430296954979279888676}, - {0x1a69, 0.00000000000000000000004818327068121386206125955631}, - {0x1b1f, 0.00000000000000000000013152171739593140030455398204}, - {0x1b43, 0.00000000000000000000016130021944784039659992469495}, - {0x1ba0, 0.00000000000000000000026469779601696885595885078146}, - {0x1bc0, 0.00000000000000000000031763735522036262715062093775}, - {0x1bea, 0.00000000000000000000038712052667481695183981926789}, - {0x1c25, 0.00000000000000000000054593920428499826541512973677}, - {0x1c32, 0.00000000000000000000058895259613775570450844298875}, - {0x1cbe, 0.00000000000000000000125731453108060206580454121195}, - {0x1ccd, 0.00000000000000000000135657620458696538678911025499}, - {0x1cd6, 0.00000000000000000000141613320869078337937985168082}, - {0x1d23, 0.00000000000000000000215728703753829617606463386892}, - {0x1d38, 0.00000000000000000000243521972335611347482142718945}, - {0x1dce, 0.00000000000000000000545277459794955843275232609813}, - {0x1e7c, 0.00000000000000000001334076891925523034032607938570}, - {0x1e9e, 0.00000000000000000001672890070827243169659936938842}, - {0x1eb1, 0.00000000000000000001874060395800139500188663532754}, - {0x1f33, 0.00000000000000000003790472438962994017330743190541}, - {0x1f56, 0.00000000000000000004531626267810506814015525378636}, - {0x1fa8, 0.00000000000000000007115076756936122848173909005709}, - {0x1fed, 0.00000000000000000010037340424963459017959621633054}, - {0x2001, 0.00000000000000000010926725019580474373981360258767}, - {0x213f, 0.00000000000000000064713317170228545904819839051925}, - {0x2154, 0.00000000000000000071828393927164668752993748057634}, - {0x216b, 0.00000000000000000079621097041904231872422315063886}, - {0x219f, 0.00000000000000000107742590890747003129490622086450}, - {0x2225, 0.00000000000000000223616698075135289514037140179425}, - {0x2229, 0.00000000000000000229037708937562811684074404183775}, - {0x2274, 0.00000000000000000330681662608078852372273104265332}, - {0x227b, 0.00000000000000000340168431617327016169838316272944}, - {0x2294, 0.00000000000000000401154803819636640582757536321878}, - {0x22b7, 0.00000000000000000496022493912118278558409656397998}, - {0x2379, 0.00000000000000001349831704744453020339278737083077}, - {0x2389, 0.00000000000000001485356976305141074590210337191820}, - {0x2464, 0.00000000000000004943961906533900219073984771966934}, - {0x2475, 0.00000000000000005312590645178971726636518724262714}, - {0x2491, 0.00000000000000006288372600415925717243226245045662}, - {0x24f6, 0.00000000000000010668549377257363630633335560560226}, - {0x2567, 0.00000000000000020036056147532121940457727760076523}, - {0x256a, 0.00000000000000020296264668928643004619516432285309}, - {0x257f, 0.00000000000000022117724318704290453752037137746811}, - {0x25f9, 0.00000000000000043194614551822496650856919586658478}, - {0x263b, 0.00000000000000064878658001532585331005975604057312}, - {0x270c, 0.00000000000000194289029309402394574135541915893555}, - {0x272c, 0.00000000000000238697950294408656191080808639526367}, - {0x2745, 0.00000000000000273392419813944798079319298267364502}, - {0x2791, 0.00000000000000402455846426619245903566479682922363}, - {0x2792, 0.00000000000000405231403988182137254625558853149414}, - {0x27a0, 0.00000000000000444089209850062616169452667236328125}, - {0x27a3, 0.00000000000000452415882534751290222629904747009277}, - {0x27d4, 0.00000000000000588418203051332966424524784088134766}, - {0x27dd, 0.00000000000000613398221105398988584056496620178223}, - {0x2821, 0.00000000000000893729534823251015041023492813110352}, - {0x28d9, 0.00000000000002409183963436589692719280719757080078}, - {0x2981, 0.00000000000005728750807065807748585939407348632812}, - {0x29ca, 0.00000000000008970602038971264846622943878173828125}, - {0x2a5b, 0.00000000000019451107391432742588222026824951171875}, - {0x2aa8, 0.00000000000029842794901924207806587219238281250}, - {0x2ac4, 0.000000000000348165940522449091076850891113281250}, - {0x2ae7, 0.00000000000041033842990145785734057426452636718750}, - {0x2af1, 0.00000000000042810199829546036198735237121582031250}, - {0x2afe, 0.0000000000004511946372076636180281639099121093750}, - {0x2b24, 0.00000000000058264504332328215241432189941406250}, - {0x2b4c, 0.00000000000072475359047530218958854675292968750}, - {0x2b85, 0.000000000000945021838560933247208595275878906250}, - {0x2bed, 0.000000000001683986283751437440514564514160156250}, - {0x2c18, 0.00000000000216004991671070456504821777343750}, - {0x2cdf, 0.0000000000063380412029800936579704284667968750}, - {0x2d6b, 0.000000000013358203432289883494377136230468750}, - {0x2d96, 0.0000000000170530256582424044609069824218750}, - {0x2da2, 0.0000000000184172677109017968177795410156250}, - {0x2db8, 0.00000000002091837814077734947204589843750}, - {0x2de1, 0.00000000002557953848736360669136047363281250}, - {0x2e90, 0.00000000006548361852765083312988281250}, - {0x2ea3, 0.000000000074123818194493651390075683593750}, - {0x2ef0, 0.00000000010913936421275138854980468750}, - {0x2f09, 0.00000000012460077414289116859436035156250}, - {0x2f6b, 0.00000000021373125491663813591003417968750}, - {0x303b, 0.000000000680302036926150321960449218750}, - {0x308f, 0.00000000104046193882822990417480468750}, - {0x309c, 0.000000001135049387812614440917968750}, - {0x30a9, 0.00000000122963683679699897766113281250}, - {0x312a, 0.000000002473825588822364807128906250}, - {0x313d, 0.0000000027503119781613349914550781250}, - {0x3159, 0.0000000031577656045556068420410156250}, - {0x31c6, 0.00000000576255843043327331542968750}, - {0x3212, 0.0000000084983184933662414550781250}, - {0x3245, 0.00000001146690919995307922363281250}, - {0x329b, 0.0000000180443748831748962402343750}, - {0x32ba, 0.000000021653249859809875488281250}, - {0x32cc, 0.00000002374872565269470214843750}, - {0x3332, 0.00000004144385457038879394531250}, - {0x33c4, 0.000000091269612312316894531250}, - {0x3424, 0.00000015273690223693847656250}, - {0x3589, 0.0000010207295417785644531250}, - {0x3594, 0.00000110268592834472656250}, - {0x368b, 0.00000414252281188964843750}, - {0x36a0, 0.000004768371582031250}, - {0x36e9, 0.00000694394111633300781250}, - {0x36ed, 0.00000706315040588378906250}, - {0x3750, 0.000012397766113281250}, - {0x375f, 0.0000132918357849121093750}, - {0x37ce, 0.00002455711364746093750}, - {0x37d2, 0.00002503395080566406250}, - {0x37f0, 0.00002861022949218750}, - {0x380e, 0.0000338554382324218750}, - {0x3826, 0.0000395774841308593750}, - {0x387f, 0.00006079673767089843750}, - {0x38e1, 0.0001072883605957031250}, - {0x38e9, 0.0001111030578613281250}, - {0x3964, 0.0002174377441406250}, - {0x3994, 0.000282287597656250}, - {0x3a26, 0.000633239746093750}, - {0x3a2c, 0.00065612792968750}, - {0x3a6a, 0.000892639160156250}, - {0x3a85, 0.001014709472656250}, - {0x3ab9, 0.001411437988281250}, - {0x3aba, 0.00141906738281250}, - {0x3af7, 0.001884460449218750}, - {0x3b03, 0.00199890136718750}, - {0x3bb3, 0.0054626464843750}, - {0x3bbf, 0.0058288574218750}, - {0x3be8, 0.0070800781250}, - {0x3c06, 0.00817871093750}, - {0x3c29, 0.010314941406250}, - {0x3c3f, 0.011657714843750}, - {0x3c73, 0.014831542968750}, - {0x3ce9, 0.02844238281250}, - {0x3cfa, 0.0305175781250}, - {0x3cfb, 0.03063964843750}, - {0x3d0f, 0.0349121093750}, - {0x3d2a, 0.041503906250}, - {0x3d43, 0.0476074218750}, - {0x3dd0, 0.10156250}, - {0x3dd9, 0.105957031250}, - {0x3de9, 0.113769531250}, - {0x3df9, 0.121582031250}, - {0x3e1e, 0.1542968750}, - {0x3e77, 0.24121093750}, - {0x3e95, 0.2910156250}, - {0x3f38, 0.718750}, - {0x3fb3, 1.39843750}, - {0x3fc5, 1.53906250}, - {0x3fd3, 1.64843750}, - {0x3fd7, 1.67968750}, - {0x400b, 2.1718750}, - {0x40bf, 5.968750}, - {0x40c7, 6.218750}, - {0x4123, 10.18750}, - {0x412b, 10.68750}, - {0x41bf, 23.8750}, - {0x41ca, 25.250}, - {0x421b, 38.750}, - {0x4226, 41.50}, - {0x42a7, 83.50}, - {0x42b7, 91.50}, - {0x4311, 145.0}, - {0x431f, 159.0}, - {0x4334, 180.0}, - {0x434f, 207.0}, - {0x43b1, 354.0}, - {0x43e5, 458.0}, - {0x4476, 984.0}, - {0x4496, 1200.0}, - {0x44a4, 1312.0}, - {0x458b, 4448.0}, - {0x45a9, 5408.0}, - {0x45df, 7136.0}, - {0x45f6, 7872.0}, - {0x45fa, 8000.0}, - {0x4602, 8320.0}, - {0x4640, 12288.0}, - {0x4648, 12800.0}, - {0x46a7, 21376.0}, - {0x46b1, 22656.0}, - {0x4742, 49664.0}, - {0x4744, 50176.0}, - {0x475e, 56832.0}, - {0x477a, 64000.0}, - {0x4837, 187392.0}, - {0x488a, 282624.0}, - {0x488f, 292864.0}, - {0x48ea, 479232.0}, - {0x495c, 901120.0}, - {0x49aa, 1392640.0}, - {0x49b9, 1515520.0}, - {0x4a1e, 2588672.0}, - {0x4a2b, 2801664.0}, - {0x4a4c, 3342336.0}, - {0x4ab6, 5963776.0}, - {0x4b34, 11796480.0}, - {0x4b73, 15925248.0}, - {0x4b7b, 16449536.0}, - {0x4bcd, 26869760.0}, - {0x4bd0, 27262976.0}, - {0x4c07, 35389440.0}, - {0x4c17, 39583744.0}, - {0x4c53, 55312384.0}, - {0x4cad, 90701824.0}, - {0x4d1c, 163577856.0}, - {0x4dc0, 402653184.0}, - {0x4dde, 465567744.0}, - {0x4eef, 2004877312.0}, - {0x4efc, 2113929216.0}, - {0x4f12, 2449473536.0}, - {0x4f2f, 2936012800.0}, - {0x4f92, 4898947072.0}, - {0x4fad, 5804916736.0}, - {0x4fdc, 7381975040.0}, - {0x4feb, 7885291520.0}, - {0x5076, 16508780544.0}, - {0x5083, 17582522368.0}, - {0x5215, 159987531776.0}, - {0x52a9, 362924736512.0}, - {0x5394, 1271310319616.0}, - {0x53a0, 1374389534720.0}, - {0x53b7, 1571958030336.0}, - {0x540e, 2439541424128.0}, - {0x542f, 3006477107200.0}, - {0x5465, 3934190043136.0}, - {0x5529, 11613591568384.0}, - {0x554c, 14018773254144.0}, - {0x5596, 20615843020800.0}, - {0x55ae, 23914377904128.0}, - {0x55be, 26113401159680.0}, - {0x55da, 29961691856896.0}, - {0x568d, 77515569758208.0}, - {0x5690, 79164837199872.0}, - {0x56ad, 95107755802624.0}, - {0x5718, 167125767421952.0}, - {0x571c, 171523813933056.0}, - {0x571d, 172623325560832.0}, - {0x5826, 730075720843264.0}, - {0x587c, 1108307720798208.0}, - {0x5890, 1266637395197952.0}, - {0x58a8, 1477743627730944.0}, - {0x58f6, 2163838883463168.0}, - {0x5966, 4046202790215680.0}, - {0x5985, 4679521487814656.0}, - {0x59ad, 6086896371367936.0}, - {0x59b0, 6192449487634432.0}, - {0x59bc, 6614661952700416.0}, - {0x5a93, 20688410788233216.0}, - {0x5ab0, 24769797950537728.0}, - {0x5ab6, 25614222880669696.0}, - {0x5ae3, 31947409856659456.0}, - {0x5af5, 34480684647055360.0}, - {0x5afd, 35606584553897984.0}, - {0x5bb6, 102456891522678784.0}, - {0x5c3d, 212795082393255936.0}, - {0x5d57, 968273919884656640.0}, - {0x5d76, 1107885508333142016.0}, - {0x5d86, 1206964700135292928.0}, - {0x5db2, 1603281467343896576.0}, - {0x5dc1, 1738389456165011456.0}, - {0x5dc5, 1774418253183975424.0}, - {0x5e5d, 3981182070595518464.0}, - {0x5fa4, 23634890844440363008.0}, - {0x5fa8, 24211351596743786496.0}, - {0x5ff8, 35740566642812256256.0}, - {0x6006, 38622870404329373696.0}, - {0x6051, 60240148615707754496.0}, - {0x60ed, 136621198295911366656.0}, - {0x610b, 160256089140351729664.0}, - {0x6114, 170632382681813352448.0}, - {0x613b, 215596321361480384512.0}, - {0x6148, 230584300921369395200.0}, - {0x61ad, 398910840593969053696.0}, - {0x61fd, 583378281331064569856.0}, - {0x629f, 1466516153859909353472.0}, - {0x62a4, 1512633014044183232512.0}, - {0x62fb, 2315066381250548727808.0}, - {0x634b, 3744689046963038978048.0}, - {0x635a, 4021390208068682252288.0}, - {0x635f, 4113623928437230010368.0}, - {0x637c, 4648579506574807007232.0}, - {0x638d, 5201981828786093555712.0}, - {0x63a9, 6234999496913828446208.0}, - {0x6469, 17192365476697302106112.0}, - {0x64c0, 28334198897217871282176.0}, - {0x64d1, 30842956091242370301952.0}, - {0x64dd, 32613843522318487257088.0}, - {0x64ee, 35122600716342986276864.0}, - {0x64ef, 35270174668932662689792.0}, - {0x64fb, 37041062100008779644928.0}, - {0x6510, 42501298345826806923264.0}, - {0x6581, 76148159536273029070848.0}, - {0x65d4, 125142711796045598162944.0}, - {0x6612, 172366376624742050299904.0}, - {0x661c, 184172292831916163334144.0}, - {0x66c6, 467514281804094876155904.0}, - {0x66ed, 559600428220052957822976.0}, - {0x66f9, 587934627117270829105152.0}, - {0x6703, 618630009255923522994176.0}, - {0x6752, 991696961402625494876160.0}, - {0x6797, 1426154677826632854536192.0}, - {0x679c, 1473378342655329306673152.0}, - {0x67e3, 2143954383222818927017984.0}, - {0x6862, 4269019300514159273181184.0}, - {0x692f, 13222626152035006598348800.0}, - {0x693d, 14280436244197807126216704.0}, - {0x6943, 14733783426553293066731520.0}, - {0x695e, 16773845747152979799048192.0}, - {0x69ec, 35663311678631560653832192.0}, - {0x69f4, 36872237498246189828538368.0}, - {0x6a5c, 66490920078804604608839680.0}, - {0x6a7a, 75557863725914323419136000.0}, - {0x6ac3, 117870267412426344533852160.0}, - {0x6ad8, 130563988518379950868267008.0}, - {0x6ae3, 137213080526260411329150976.0}, - {0x6b37, 221233424989477138971230208.0}, - {0x6b77, 298604677444813406152425472.0}, - {0x6bd7, 519838102434290545123655680.0}, - {0x6be7, 558523728661958678714253312.0}, - {0x6c15, 720519788490318988124880896.0}, - {0x6c33, 865590886844074489089622016.0}, - {0x6c43, 942962139299410756270817280.0}, - {0x6c45, 952633545856327789668466688.0}, - {0x6c48, 967140655691703339764940800.0}, - {0x6da6, 6421813953792910176039206912.0}, - {0x6dba, 7195526478346272847851159552.0}, - {0x6def, 9245864668412683928152834048.0}, - {0x6e24, 12688885402675147817716023296.0}, - {0x6e28, 12998370412496492886440804352.0}, - {0x6e3d, 14623166714058554497245904896.0}, - {0x6ea0, 24758800785707605497982484480.0}, - {0x6eef, 36983458673650735712611336192.0}, - {0x6ef9, 38530883722757461056235241472.0}, - {0x6f55, 65920307091946499638378364928.0}, - {0x6f5c, 68086702160695915119451832320.0}, - {0x6f65, 70872067249088020737974861824.0}, - {0x6f9e, 97797263103545041717030813696.0}, - {0x6fdc, 136173404321391830238903664640.0}, - {0x70ab, 423375493435600054015500484608.0}, - {0x70dc, 544693617285567320955614658560.0}, - {0x714a, 1000255551742587262118492372992.0}, - {0x71ba, 1842054778456645849049896845312.0}, - {0x71d3, 2089642786313721904029721690112.0}, - {0x71ee, 2357037834799364043407932522496.0}, - {0x71f6, 2436265997313628381001476472832.0}, - {0x7251, 4139671491370311639262671405056.0}, - {0x72b8, 7288990951312319058606043430912.0}, - {0x731f, 12597277839768029677373488103424.0}, - {0x7328, 13310331302396408715715383656448.0}, - {0x7356, 16954826778052568245018405371904.0}, - {0x7358, 17113283103081096920205493272576.0}, - {0x7375, 19410899815994762710418267832320.0}, - {0x737c, 19965496953594613073573075484672.0}, - {0x7467, 73206822163180247936434610110464.0}, - {0x74a4, 103947349218714810922729662840832.0}, - {0x74b1, 112187078120198302032458233675776.0}, - {0x7530, 223106505640168374663419764146176.0}, - {0x7563, 287756686251808074139751627620352.0}, - {0x756f, 302968493454546826957712066084864.0}, - {0x7571, 305503794655003285760705472495616.0}, - {0x7626, 841719998551544322593810928369664.0}, - {0x7660, 1135814937804493543741046072016896.0}, - {0x7675, 1242297588223664813466769141268480.0}, - {0x76b2, 1805134454724998667731305364455424.0}, - {0x772c, 3488574451828087312918927221194752.0}, - {0x77b2, 7220537818899994670925221457821696.0}, - {0x783a, 15090112745116842795416754956795904.0}, - {0x795d, 71718600358512306619077480547352576.0}, - {0x796e, 77235415770705560974391132897148928.0}, - {0x798c, 90865195024359483499283685761351680.0}, - {0x79af, 113581493780449354374104607201689600.0}, - {0x7aa5, 428364490829123279353765947160657920.0}, - {0x7acf, 537402724858354659552906370074279936.0}, - {0x7adc, 571152654438831039138354596214210560.0}, - {0x7b07, 700960075902201729851617004444712960.0}, - {0x7b0f, 742498450770480350879860975078473728.0}, - {0x7b12, 758075341346084833765452464066134016.0}, - {0x7b30, 913844247102129662621367353942736896.0}, - {0x7bc2, 2014611181111513119869832575737397248.0}, - {0x7bd1, 2170380086867557948725747465614000128.0}, - {0x7bd5, 2211918461735836569753991436247760896.0}, - {0x7cf1, 10010748343255147667806796922736345088.0}, - {0x7d2f, 14538431203897517359885389721816268800.0}, - {0x7da0, 26584559915698317458076141205606891520.0}, - {0x7e58, 71778311772385457136805581255138607104.0}, - {0x7e81, 85735205728127073802295555388082225152.0}, - {0x7f09, 182104235422533474587821567258407206912.0}, - {0x7f24, 217993391308726203156224357885976510464.0}, - {0x7f86, std::numeric_limits::quiet_NaN()}, - {0x7f88, std::numeric_limits::quiet_NaN()}, - {0x7f8f, std::numeric_limits::quiet_NaN()}, - {0x7fa0, std::numeric_limits::quiet_NaN()}, - {0x7fcd, std::numeric_limits::quiet_NaN()}, - {0x8023, -0.00000000000000000000000000000000000000321424236553}, - {0x8074, -0.00000000000000000000000000000000000001065291755433}, - {0x8080, -0.00000000000000000000000000000000000001175494350822}, - {0x80a5, -0.00000000000000000000000000000000000001515285686607}, - {0x80d2, -0.00000000000000000000000000000000000001928545419318}, - {0x80fd, -0.00000000000000000000000000000000000002323438052797}, - {0x810a, -0.00000000000000000000000000000000000002534659693961}, - {0x8124, -0.00000000000000000000000000000000000003012204273982}, - {0x81e3, -0.00000000000000000000000000000000000008338663051146}, - {0x81f1, -0.00000000000000000000000000000000000008852941829630}, - {0x8285, -0.00000000000000000000000000000000000019542593582421}, - {0x828b, -0.00000000000000000000000000000000000020424214345537}, - {0x829f, -0.00000000000000000000000000000000000023362950222593}, - {0x82bc, -0.00000000000000000000000000000000000027624117244324}, - {0x82ee, -0.00000000000000000000000000000000000034970956936963}, - {0x82f9, -0.00000000000000000000000000000000000036587261669344}, - {0x8393, -0.00000000000000000000000000000000000086398834785438}, - {0x8394, -0.00000000000000000000000000000000000086986581960849}, - {0x843e, -0.00000000000000000000000000000000000223343926656235}, - {0x8451, -0.00000000000000000000000000000000000245678319321858}, - {0x847f, -0.00000000000000000000000000000000000299751059459683}, - {0x8483, -0.00000000000000000000000000000000000307979519915439}, - {0x84a0, -0.00000000000000000000000000000000000376158192263132}, - {0x84aa, -0.00000000000000000000000000000000000399668079279578}, - {0x84ba, -0.00000000000000000000000000000000000437283898505891}, - {0x84e4, -0.00000000000000000000000000000000000536025423974963}, - {0x8510, -0.00000000000000000000000000000000000677084746073638}, - {0x854d, -0.00000000000000000000000000000000000963905367674276}, - {0x8557, -0.00000000000000000000000000000000001010925141707167}, - {0x8584, -0.00000000000000000000000000000000001241322034468336}, - {0x85b7, -0.00000000000000000000000000000000001720923729603829}, - {0x8656, -0.00000000000000000000000000000000004024892657215512}, - {0x87c7, -0.00000000000000000000000000000000029942192104145307}, - {0x88d9, -0.00000000000000000000000000000000130602124353759431}, - {0x896c, -0.00000000000000000000000000000000284074666797117288}, - {0x89a0, -0.00000000000000000000000000000000385185988877447171}, - {0x89b2, -0.00000000000000000000000000000000428519412626159977}, - {0x89fe, -0.00000000000000000000000000000000611482757342947383}, - {0x8a31, -0.00000000000000000000000000000000852224000391351865}, - {0x8a55, -0.00000000000000000000000000000001025557695386203092}, - {0x8a68, -0.00000000000000000000000000000001117039367744596795}, - {0x8b4a, -0.00000000000000000000000000000003890378487662216423}, - {0x8b4c, -0.00000000000000000000000000000003928897086549961140}, - {0x8b5b, -0.00000000000000000000000000000004217786578208046518}, - {0x8bbf, -0.00000000000000000000000000000007357052387559240959}, - {0x8bff, -0.00000000000000000000000000000009822242716374902851}, - {0x8c43, -0.00000000000000000000000000000015022253566220439654}, - {0x8c6b, -0.00000000000000000000000000000018103741477240017019}, - {0x8d1d, -0.00000000000000000000000000000048379360203007364629}, - {0x8d23, -0.00000000000000000000000000000050228252949619111048}, - {0x8d30, -0.00000000000000000000000000000054234187233944561622}, - {0x8dee, -0.00000000000000000000000000000146678824564531882569}, - {0x8e54, -0.00000000000000000000000000000261310174854460160543}, - {0x8e68, -0.00000000000000000000000000000285962078142616779462}, - {0x8eb0, -0.00000000000000000000000000000433873497871556492976}, - {0x8efe, -0.00000000000000000000000000000626158343519178120546}, - {0x8f3d, -0.00000000000000000000000000000931841944292320195143}, - {0x8f95, -0.00000000000000000000000000001469253435974134487579}, - {0x8fa3, -0.00000000000000000000000000001607304094387811553526}, - {0x8fbe, -0.00000000000000000000000000001873544649899903037853}, - {0x9009, -0.00000000000000000000000000002701848600381965433535}, - {0x9017, -0.00000000000000000000000000002977949917209319565429}, - {0x90a8, -0.00000000000000000000000000006626431603856499165459}, - {0x90d2, -0.00000000000000000000000000008283039504820623956823}, - {0x9260, -0.00000000000000000000000000070681937107802657764891}, - {0x92d0, -0.00000000000000000000000000131266454628776364420512}, - {0x92ed, -0.00000000000000000000000000149568027629903838306064}, - {0x9356, -0.00000000000000000000000000270105973947674442172976}, - {0x94af, -0.00000000000000000000000001767048427695066444122272}, - {0x9503, -0.00000000000000000000000002645523931749185190628773}, - {0x953c, -0.00000000000000000000000003796629764647685617085567}, - {0x9556, -0.00000000000000000000000004321695583162791074767614}, - {0x9598, -0.00000000000000000000000006139231108792002274436236}, - {0x9599, -0.00000000000000000000000006179620787139318078873317}, - {0x95cf, -0.00000000000000000000000008360663417894371518475664}, - {0x95df, -0.00000000000000000000000009006898271451424389468952}, - {0x95f4, -0.00000000000000000000000009855081516745056282647643}, - {0x960f, -0.00000000000000000000000011551448007332320069005024}, - {0x9615, -0.00000000000000000000000012036124147500109722249990}, - {0x966a, -0.00000000000000000000000018902369466543796476553675}, - {0x968c, -0.00000000000000000000000022618219874496850484765081}, - {0x96b3, -0.00000000000000000000000028919009696678115976949640}, - {0x96d7, -0.00000000000000000000000034735123378691591815889232}, - {0x9719, -0.00000000000000000000000049436966297114544630986535}, - {0x9761, -0.00000000000000000000000072701421025168447986744905}, - {0x97f0, -0.00000000000000000000000155096364853692689038389130}, - {0x97fd, -0.00000000000000000000000163497417949934376361301874}, - {0x983c, -0.00000000000000000000000242984304937451879493476303}, - {0x987d, -0.00000000000000000000000326994835899868752722603749}, - {0x9895, -0.00000000000000000000000385155972720003511111999672}, - {0x98b3, -0.00000000000000000000000462704155146849855631194237}, - {0x98fa, -0.00000000000000000000000646234853557052870993288041}, - {0x998f, -0.00000000000000000000001478585344938536968832643037}, - {0x999b, -0.00000000000000000000001602662436821491120063354341}, - {0x99e4, -0.00000000000000000000002357464745776128873383514772}, - {0x9a8b, -0.00000000000000000000005748905257243542340356290410}, - {0x9a95, -0.00000000000000000000006162495563520056177791994756}, - {0x9a9f, -0.00000000000000000000006576085869796570015227699102}, - {0x9bb2, -0.00000000000000000000029447629806887785225422149438}, - {0x9bc4, -0.00000000000000000000032425480012078684854959220729}, - {0x9c09, -0.00000000000000000000045329497567905916582953196325}, - {0x9c79, -0.00000000000000000000082387189010281556417192305730}, - {0x9cca, -0.00000000000000000000133672386988569272259219644639}, - {0x9d21, -0.00000000000000000000213081725793659929046874879077}, - {0x9d2d, -0.00000000000000000000228963593554678060404405925965}, - {0x9d53, -0.00000000000000000000279256174797902143036587574443}, - {0x9d59, -0.00000000000000000000287197108678411208715353097887}, - {0x9d9b, -0.00000000000000000000410281583826301726736218711267}, - {0x9dc9, -0.00000000000000000000532042569994107400477290070739}, - {0x9e3a, -0.00000000000000000000984675801183124144166924907040}, - {0x9eb4, -0.00000000000000000001905824131322175762903725626529}, - {0x9eb7, -0.00000000000000000001937587866844212025618787720305}, - {0x9ec3, -0.00000000000000000002064642808932357076479036095407}, - {0x9ee0, -0.00000000000000000002371692252312040949391303001903}, - {0x9f0a, -0.00000000000000000002922263668027336169785712627345}, - {0x9f5b, -0.00000000000000000004637505386217294356399065691221}, - {0x9fb7, -0.00000000000000000007750351467376848102475150881219}, - {0xa007, -0.00000000000000000011434944787933054577422353759175}, - {0xa06c, -0.00000000000000000019989977555201488002012411016040}, - {0xa07a, -0.00000000000000000021175823681357508476708062516991}, - {0xa0c0, -0.00000000000000000032526065174565133020223584026098}, - {0xa0e5, -0.00000000000000000038794108984246955529329170531128}, - {0xa108, -0.00000000000000000046078592330633938445316744036973}, - {0xa128, -0.00000000000000000056920614055488982785391272045672}, - {0xa178, -0.00000000000000000084025668367626593635577592067420}, - {0xa1f6, -0.00000000000000000166696084019646306728645868133754}, - {0xa305, -0.00000000000000000720994444702860448614956112578511}, - {0xa312, -0.00000000000000000791467585914418236825440544635057}, - {0xa3f2, -0.00000000000000002623769257414920730298035778105259}, - {0xa3f3, -0.00000000000000002634611279139775774638110306113958}, - {0xa40a, -0.00000000000000002992397996059992237860569730401039}, - {0xa412, -0.00000000000000003165870343657672947301762178540230}, - {0xa413, -0.00000000000000003187554387107383035981911234557629}, - {0xa421, -0.00000000000000003491130995403324277503998018801212}, - {0xa450, -0.00000000000000004510281037539698445471003651618958}, - {0xa456, -0.00000000000000004640385298237958977551897987723351}, - {0xa4a4, -0.00000000000000007112366251504909087088890373706818}, - {0xa4c9, -0.00000000000000008716985466783455649419920518994331}, - {0xa4ed, -0.00000000000000010278236595162582034390652552247047}, - {0xa522, -0.00000000000000014051260155412137464736588299274445}, - {0xa53a, -0.00000000000000016132928326584305978030897676944733}, - {0xa541, -0.0000000000000001674008154317618846107507124543190}, - {0xa6f7, -0.00000000000000171390679426508540927898138761520386}, - {0xa76c, -0.00000000000000327515792264421179424971342086791992}, - {0xa7a3, -0.00000000000000452415882534751290222629904747009277}, - {0xa7ae, -0.00000000000000482947015711943095084279775619506836}, - {0xa7bc, -0.00000000000000521804821573823573999106884002685547}, - {0xa837, -0.00000000000001015854067532018234487622976303100586}, - {0xa83e, -0.00000000000001054711873393898713402450084686279297}, - {0xa881, -0.00000000000001432187701766451937146484851837158203}, - {0xa8b9, -0.00000000000002053912595556539599783718585968017578}, - {0xa8c2, -0.00000000000002153832667772803688421845436096191406}, - {0xa8ca, -0.00000000000002242650509742816211655735969543457031}, - {0xa8d6, -0.00000000000002375877272697834996506571769714355469}, - {0xa8e4, -0.00000000000002531308496145356912165880203247070312}, - {0xa92d, -0.00000000000003841371665203041629865765571594238281}, - {0xa933, -0.00000000000003974598428158060414716601371765136719}, - {0xa937, -0.00000000000004063416270128072937950491905212402344}, - {0xa950, -0.0000000000000461852778244065120816230773925781250}, - {0xa956, -0.00000000000004751754545395669993013143539428710938}, - {0xa9b8, -0.0000000000000817124146124115213751792907714843750}, - {0xa9c6, -0.00000000000008792966355031239800155162811279296875}, - {0xa9f0, -0.000000000000106581410364015027880668640136718750}, - {0xaa2d, -0.00000000000015365486660812166519463062286376953125}, - {0xaae6, -0.0000000000004085620730620576068758964538574218750}, - {0xaaff, -0.00000000000045297099404706386849284172058105468750}, - {0xab12, -0.000000000000518696197104873135685920715332031250}, - {0xab42, -0.000000000000689226453687297180294990539550781250}, - {0xabfa, -0.00000000000177635683940025046467781066894531250}, - {0xac3a, -0.0000000000026432189770275726914405822753906250}, - {0xadbb, -0.00000000002125943865394219756126403808593750}, - {0xadc3, -0.00000000002216893335571512579917907714843750}, - {0xadda, -0.0000000000247837306233122944831848144531250}, - {0xaddf, -0.00000000002535216481192037463188171386718750}, - {0xae16, -0.000000000034106051316484808921813964843750}, - {0xae77, -0.0000000000561612978344783186912536621093750}, - {0xaee2, -0.00000000010277290130034089088439941406250}, - {0xb03e, -0.00000000069121597334742546081542968750}, - {0xb050, -0.00000000075669959187507629394531250}, - {0xb075, -0.000000000891304807737469673156738281250}, - {0xb11d, -0.0000000022846506908535957336425781250}, - {0xb125, -0.0000000024010660126805305480957031250}, - {0xb139, -0.0000000026921043172478675842285156250}, - {0xb155, -0.0000000030995579436421394348144531250}, - {0xb18d, -0.000000004103640094399452209472656250}, - {0xb23c, -0.000000010943040251731872558593750}, - {0xb2a8, -0.0000000195577740669250488281250}, - {0xb341, -0.000000044936314225196838378906250}, - {0xb369, -0.000000054249539971351623535156250}, - {0xb37b, -0.000000058440491557121276855468750}, - {0xb3c6, -0.0000000922009348869323730468750}, - {0xb3c9, -0.00000009359791874885559082031250}, - {0xb3dc, -0.000000102445483207702636718750}, - {0xb3e2, -0.0000001052394509315490722656250}, - {0xb404, -0.00000012293457984924316406250}, - {0xb42d, -0.0000001611188054084777832031250}, - {0xb487, -0.000000251457095146179199218750}, - {0xb499, -0.000000284984707832336425781250}, - {0xb49b, -0.000000288709998130798339843750}, - {0xb4be, -0.00000035390257835388183593750}, - {0xb599, -0.0000011399388313293457031250}, - {0xb5be, -0.000001415610313415527343750}, - {0xb661, -0.000003352761268615722656250}, - {0xb67f, -0.000003799796104431152343750}, - {0xb6f4, -0.000007271766662597656250}, - {0xb70f, -0.0000085234642028808593750}, - {0xb729, -0.0000100731849670410156250}, - {0xb731, -0.0000105500221252441406250}, - {0xb735, -0.0000107884407043457031250}, - {0xb76f, -0.0000142455101013183593750}, - {0xb770, -0.000014305114746093750}, - {0xb7a4, -0.0000195503234863281250}, - {0xb7b1, -0.000021100044250488281250}, - {0xb829, -0.00004029273986816406250}, - {0xb882, -0.000061988830566406250}, - {0xb9a6, -0.0003166198730468750}, - {0xb9c5, -0.00037574768066406250}, - {0xb9cc, -0.000389099121093750}, - {0xb9d3, -0.00040245056152343750}, - {0xb9dd, -0.00042152404785156250}, - {0xbb04, -0.002014160156250}, - {0xbb14, -0.002258300781250}, - {0xbb19, -0.00233459472656250}, - {0xbb33, -0.00273132324218750}, - {0xbb66, -0.0035095214843750}, - {0xbbc5, -0.0060119628906250}, - {0xbc0d, -0.008605957031250}, - {0xbcb0, -0.0214843750}, - {0xbcc8, -0.02441406250}, - {0xbce0, -0.027343750}, - {0xbce8, -0.02832031250}, - {0xbd06, -0.032714843750}, - {0xbd77, -0.0603027343750}, - {0xbe31, -0.17285156250}, - {0xbe3a, -0.1816406250}, - {0xbe5d, -0.21582031250}, - {0xbe85, -0.2597656250}, - {0xbe9a, -0.300781250}, - {0xbea5, -0.3222656250}, - {0xbeb0, -0.343750}, - {0xbebf, -0.3730468750}, - {0xbeee, -0.464843750}, - {0xbf2b, -0.667968750}, - {0xbfac, -1.343750}, - {0xc022, -2.531250}, - {0xc026, -2.593750}, - {0xc05e, -3.468750}, - {0xc07e, -3.968750}, - {0xc07f, -3.9843750}, - {0xc086, -4.18750}, - {0xc0ae, -5.43750}, - {0xc0c2, -6.06250}, - {0xc0e6, -7.18750}, - {0xc13e, -11.8750}, - {0xc198, -19.0}, - {0xc1be, -23.750}, - {0xc1c1, -24.1250}, - {0xc1eb, -29.3750}, - {0xc225, -41.250}, - {0xc276, -61.50}, - {0xc27f, -63.750}, - {0xc29f, -79.50}, - {0xc313, -147.0}, - {0xc31b, -155.0}, - {0xc324, -164.0}, - {0xc35b, -219.0}, - {0xc394, -296.0}, - {0xc39d, -314.0}, - {0xc3b5, -362.0}, - {0xc3be, -380.0}, - {0xc429, -676.0}, - {0xc444, -784.0}, - {0xc44b, -812.0}, - {0xc4b5, -1448.0}, - {0xc4eb, -1880.0}, - {0xc523, -2608.0}, - {0xc557, -3440.0}, - {0xc55e, -3552.0}, - {0xc56d, -3792.0}, - {0xc58b, -4448.0}, - {0xc64d, -13120.0}, - {0xc6b8, -23552.0}, - {0xc6ca, -25856.0}, - {0xc777, -63232.0}, - {0xc7d6, -109568.0}, - {0xc868, -237568.0}, - {0xc8ca, -413696.0}, - {0xc910, -589824.0}, - {0xc9c5, -1613824.0}, - {0xc9c8, -1638400.0}, - {0xc9df, -1826816.0}, - {0xca3a, -3047424.0}, - {0xca42, -3178496.0}, - {0xca6b, -3850240.0}, - {0xcaa0, -5242880.0}, - {0xcaa2, -5308416.0}, - {0xcaac, -5636096.0}, - {0xcb3a, -12189696.0}, - {0xcb84, -17301504.0}, - {0xcc50, -54525952.0}, - {0xcc89, -71827456.0}, - {0xcc94, -77594624.0}, - {0xccaf, -91750400.0}, - {0xcce0, -117440512.0}, - {0xcce1, -117964800.0}, - {0xcd6d, -248512512.0}, - {0xcda8, -352321536.0}, - {0xcdba, -390070272.0}, - {0xcdd0, -436207616.0}, - {0xcde5, -480247808.0}, - {0xcdf7, -517996544.0}, - {0xce30, -738197504.0}, - {0xcec2, -1627389952.0}, - {0xcf03, -2197815296.0}, - {0xcf25, -2768240640.0}, - {0xcf57, -3607101440.0}, - {0xd036, -12213813248.0}, - {0xd09e, -21206401024.0}, - {0xd103, -35165044736.0}, - {0xd104, -35433480192.0}, - {0xd11f, -42681237504.0}, - {0xd125, -44291850240.0}, - {0xd19c, -83751862272.0}, - {0xd1c7, -106837311488.0}, - {0xd1cf, -111132278784.0}, - {0xd1d8, -115964116992.0}, - {0xd231, -190052302848.0}, - {0xd28a, -296352743424.0}, - {0xd294, -317827579904.0}, - {0xd2be, -408021893120.0}, - {0xd2c1, -414464344064.0}, - {0xd2c6, -425201762304.0}, - {0xd2db, -470298918912.0}, - {0xd334, -773094113280.0}, - {0xd36f, -1026497183744.0}, - {0xd375, -1052266987520.0}, - {0xd3c3, -1675037245440.0}, - {0xd3d5, -1829656068096.0}, - {0xd3f2, -2078764171264.0}, - {0xd44c, -3504693313536.0}, - {0xd49b, -5325759447040.0}, - {0xd4cd, -7043746365440.0}, - {0xd4e8, -7971459301376.0}, - {0xd538, -12644383719424.0}, - {0xd54c, -14018773254144.0}, - {0xd554, -14568529068032.0}, - {0xd5a3, -22402549415936.0}, - {0xd5bf, -26250840113152.0}, - {0xd64a, -55525337202688.0}, - {0xd74f, -227598906949632.0}, - {0xd75f, -245191092994048.0}, - {0xd762, -248489627877376.0}, - {0xd7d6, -470590976688128.0}, - {0xd7db, -481586092965888.0}, - {0xd819, -672901116198912.0}, - {0xd82d, -760862046420992.0}, - {0xd85b, -963172185931776.0}, - {0xd936, -3201777860083712.0}, - {0xd967, -4063794976260096.0}, - {0xd976, -4327677766926336.0}, - {0xd985, -4679521487814656.0}, - {0xd98c, -4925812092436480.0}, - {0xd9c9, -7072058789855232.0}, - {0xda1b, -10907155347537920.0}, - {0xda5a, -15340386230730752.0}, - {0xdab6, -25614222880669696.0}, - {0xdacc, -28710447624486912.0}, - {0xdb00, -36028797018963968.0}, - {0xdb0d, -39687971716202496.0}, - {0xdb24, -46161896180547584.0}, - {0xdb4c, -57420895248973824.0}, - {0xdbbd, -106397541196627968.0}, - {0xdbbf, -107523441103470592.0}, - {0xdbcc, -114841790497947648.0}, - {0xdbf4, -137359788634800128.0}, - {0xdc88, -306244774661193728.0}, - {0xdc9c, -351280770934898688.0}, - {0xdd24, -738590338888761344.0}, - {0xdd71, -1085367510196289536.0}, - {0xdd86, -1206964700135292928.0}, - {0xdd8f, -1288029493427961856.0}, - {0xdea9, -6088866696204910592.0}, - {0xded6, -7710162562058289152.0}, - {0xdedf, -8034421735228964864.0}, - {0xdef6, -8863084066665136128.0}, - {0xdf62, -16285016252571713536.0}, - {0xdf6a, -16861477004875137024.0}, - {0xdf71, -17365880163140632576.0}, - {0xdfc9, -28967152803247030272.0}, - {0xdff0, -34587645138205409280.0}, - {0xdff5, -35308221078584688640.0}, - {0xe037, -52746158835763249152.0}, - {0xe07e, -73210515542534782976.0}, - {0xe09a, -88774955854727217152.0}, - {0xe09d, -90504338111637487616.0}, - {0xe0cc, -117597993469898391552.0}, - {0xe113, -169479461177206505472.0}, - {0xe18f, -329735550317558235136.0}, - {0xe1aa, -391993311566327971840.0}, - {0xe21a, -710199646837817737216.0}, - {0xe233, -825491797298502434816.0}, - {0xe238, -848550227390639374336.0}, - {0xe247, -917725517667050192896.0}, - {0xe262, -1042241040164589666304.0}, - {0xe26a, -1079134528312008769536.0}, - {0xe271, -1111416330441000484864.0}, - {0xe28b, -1282048713122813837312.0}, - {0xe290, -1328165573307087716352.0}, - {0xe2b2, -1641760222560150093824.0}, - {0xe2eb, -2167492428660872314880.0}, - {0xe2f5, -2259726149029420072960.0}, - {0xe34b, -3744689046963038978048.0}, - {0xe363, -4187410904732068216832.0}, - {0xe388, -5017514388048998039552.0}, - {0xe3a0, -5902958103587056517120.0}, - {0xe3bd, -6972869259862210510848.0}, - {0xe3d6, -7895206463547688091648.0}, - {0xe3e4, -8411715297611555536896.0}, - {0xe406, -9887454823508319666176.0}, - {0xe5a3, -96218217088469021229056.0}, - {0xe5ae, -102711471002414783397888.0}, - {0xe5d7, -126913599227121715118080.0}, - {0xe5d9, -128094190847839126421504.0}, - {0xe644, -231395957660612615471104.0}, - {0xe66e, -280980805730743890214912.0}, - {0xe6b8, -434457716424007359660032.0}, - {0xe7f4, -2304514843640386864283648.0}, - {0xe824, -3097872412762487260184576.0}, - {0xe827, -3154540810556923002748928.0}, - {0xe880, -4835703278458516698824704.0}, - {0xe8f2, -9142501510835633133715456.0}, - {0xe928, -12693721105953606334414848.0}, - {0xe980, -19342813113834066795298816.0}, - {0xe9d1, -31583187037432187189198848.0}, - {0xe9fa, -37778931862957161709568000.0}, - {0xea15, -45032486780644936757805056.0}, - {0xea77, -74651169361203351538106368.0}, - {0xeaca, -122101507781077546645323776.0}, - {0xeacd, -123914896510499490407383040.0}, - {0xead9, -131168451428187265455620096.0}, - {0xeada, -131772914337994580042973184.0}, - {0xeb79, -301022529084042664501837824.0}, - {0xeba3, -394109817194369110954213376.0}, - {0xebf3, -587537948332709778907201536.0}, - {0xec09, -662491349148816787738984448.0}, - {0xec13, -710848381933401954727231488.0}, - {0xec48, -967140655691703339764940800.0}, - {0xece9, -2253437727761668781652312064.0}, - {0xed1f, -3075507285099616620452511744.0}, - {0xed24, -3172221350668786954429005824.0}, - {0xed9f, -6151014570199233240905023488.0}, - {0xede6, -8897694032363670725837455360.0}, - {0xedfe, -9826149061827705932011798528.0}, - {0xeea3, -25223028300439623101069656064.0}, - {0xeea5, -25532513310260968169794437120.0}, - {0xeec4, -30329530962491816735028543488.0}, - {0xeee0, -34662321099990647697175478272.0}, - {0xef23, -50446056600879246202139312128.0}, - {0xefa0, -99035203142830421991929937920.0}, - {0xefab, -105843873358900013503875121152.0}, - {0xf020, -198070406285660843983859875840.0}, - {0xf099, -378809652021326364119132012544.0}, - {0xf0a9, -418423733278458532915903987712.0}, - {0xf0cc, -505079536028435152158842683392.0}, - {0xf0e6, -569452418071274926453597143040.0}, - {0xf16b, -1163663636928257458405176770560.0}, - {0xf19b, -1535045648713871540874914037760.0}, - {0xf1bc, -1861861819085211933448282832896.0}, - {0xf1da, -2158967428513703199424072646656.0}, - {0xf231, -3505846191256196938514319802368.0}, - {0xf253, -4179285572627443808059443380224.0}, - {0xf287, -5347900969712842787564216647680.0}, - {0xf296, -5942112188569825319515796275200.0}, - {0xf2f3, -9626221745483117017615589965824.0}, - {0xf339, -14657210065138902454805630812160.0}, - {0xf36e, -18856302678394912347263460179968.0}, - {0xf3b3, -28363682180106632858488734220288.0}, - {0xf3c0, -30423614405477505635920876929024.0}, - {0xf3da, -34543478856219251190785162346496.0}, - {0xf3eb, -37237236381704238668965656657920.0}, - {0xf407, -42783207757702742300513733181440.0}, - {0xf418, -48170722808672717256874721804288.0}, - {0xf425, -52290587259414462811739007221760.0}, - {0xf473, -77009773963864936140924719726592.0}, - {0xf515, -188879939434006180823008777601024.0}, - {0xf57a, -316912650057057350374175801344000.0}, - {0xf594, -375224577667555902843024148791296.0}, - {0xf61c, -791013974542415146533942800154624.0}, - {0xf634, -912708432164325169077626307870720.0}, - {0xf69f, -1612451563490307798703806477238272.0}, - {0xf6b2, -1805134454724998667731305364455424.0}, - {0xf6f0, -2433889152438200450873670154321920.0}, - {0xf71e, -3204620717376963926983665703190528.0}, - {0xf735, -3671116138260952346734452482768896.0}, - {0xf748, -4056481920730334084789450257203200.0}, - {0xf75f, -4522977341614322504540237036781568.0}, - {0xf796, -6084722881095501127184175385804800.0}, - {0xf8a3, -26448262123161778232827215676964864.0}, - {0xf8d0, -33749929580476379585448226139930624.0}, - {0xf8ef, -38779967162181993850587144458862592.0}, - {0xf9a3, -105793048492647112931308862707859456.0}, - {0xfa0d, -183028464263352673905699995605008384.0}, - {0xfa18, -197307280624323449884158860510363648.0}, - {0xfa31, -229759135990166122562474462567989248.0}, - {0xfaa9, -438749084546192934610826939819098112.0}, - {0xfab5, -469902865697401900382009917794418688.0}, - {0xfacd, -532210427999819831924375873745059840.0}, - {0xfb84, -1370766370653194493932051030914105344.0}, - {0xfba8, -1744611744467702083186246766617952256.0}, - {0xfbfa, -2596148429267413814265248164610048000.0}, - {0xfc20, -3323069989462289682259517650700861440.0}, - {0xfc76, -5109220108798270386474008387952574464.0}, - {0xfc93, -6106141105636957291151863683162832896.0}, - {0xfccf, -8598443597733674552846501921188478976.0}, - {0xfcdc, -9138442471021296626213673539427368960.0}, - {0xfcf0, -9969209968386869046778552952102584320.0}, - {0xfd5b, -18193808192306036010370859137587216384.0}, - {0xfda9, -28079941410956347815092924148422279168.0}, - {0xfdca, -33563006893569125790821128272078700544.0}, - {0xfe1d, -52172198834557948011474427116003524608.0}, - {0xfe24, -54498347827181550789056089471494127616.0}, - {0xfe4b, -67458320786084480549868208309227487232.0}, - {0xfe4f, -68787548781869396422772015369507831808.0}, - {0xfe64, -75765995759740204755517002435979640832.0}, - {0xfea2, -107667467658578185705208371882707910656.0}, - {0xfec2, -128935115591136839671669284847193423872.0}, - {0xfee3, -150867377521587951574582101341819109376.0}, - {0xfee9, -154855061508942699193293522522660143104.0}, - {0xff57, -285784019093756912674318517960274083840.0}, - {0xff60, -297747071055821155530452781502797185024.0}, - {0xff8e, std::numeric_limits::quiet_NaN()}, - {0xffb0, std::numeric_limits::quiet_NaN()}, - {0xfffa, std::numeric_limits::quiet_NaN()}, -}; +const std::map& bf16_lut() // NOLINT(readability-function-size) +{ + static const std::map result = { + {0x0000, 0.0}, + {0x002d, 0.00000000000000000000000000000000000000413259732711}, + {0x004e, 0.00000000000000000000000000000000000000716316870032}, + {0x005b, 0.00000000000000000000000000000000000000835703015038}, + {0x00cd, 0.00000000000000000000000000000000000001882627671239}, + {0x00ce, 0.00000000000000000000000000000000000001891811220855}, + {0x0170, 0.00000000000000000000000000000000000004408103815584}, + {0x01be, 0.00000000000000000000000000000000000006979497708007}, + {0x01fe, 0.00000000000000000000000000000000000009330486409652}, + {0x0211, 0.00000000000000000000000000000000000010652917554327}, + {0x028f, 0.00000000000000000000000000000000000021011961520948}, + {0x02bc, 0.00000000000000000000000000000000000027624117244324}, + {0x02e8, 0.00000000000000000000000000000000000034089336173846}, + {0x039c, 0.00000000000000000000000000000000000091688559364138}, + {0x03a9, 0.00000000000000000000000000000000000099329272644483}, + {0x03cf, 0.00000000000000000000000000000000000121663665310107}, + {0x03da, 0.00000000000000000000000000000000000128128884239629}, + {0x03f3, 0.00000000000000000000000000000000000142822563624908}, + {0x0427, 0.00000000000000000000000000000000000196307556587322}, + {0x044c, 0.00000000000000000000000000000000000239800847567747}, + {0x0485, 0.00000000000000000000000000000000000312681497318728}, + {0x0498, 0.00000000000000000000000000000000000357350282649975}, + {0x04da, 0.00000000000000000000000000000000000512515536958517}, + {0x051b, 0.00000000000000000000000000000000000728806497509818}, + {0x0533, 0.00000000000000000000000000000000000841653955188758}, + {0x0536, 0.00000000000000000000000000000000000855759887398625}, + {0x0577, 0.00000000000000000000000000000000001161388418612420}, + {0x0587, 0.00000000000000000000000000000000001269533898888071}, + {0x065a, 0.00000000000000000000000000000000004100124295668139}, + {0x0735, 0.00000000000000000000000000000000013616926559925378}, + {0x075e, 0.00000000000000000000000000000000016701423736483061}, + {0x0765, 0.00000000000000000000000000000000017228045205651446}, + {0x076b, 0.00000000000000000000000000000000017679435036367204}, + {0x07ba, 0.00000000000000000000000000000000027986169504377021}, + {0x07d1, 0.00000000000000000000000000000000031446824873197835}, + {0x07db, 0.00000000000000000000000000000000032951457642250363}, + {0x07eb, 0.00000000000000000000000000000000035358870072734408}, + {0x080d, 0.00000000000000000000000000000000042430644087281290}, + {0x0841, 0.00000000000000000000000000000000058078824885427581}, + {0x08ff, 0.00000000000000000000000000000000153472542443357857}, + {0x09e1, 0.00000000000000000000000000000000541667796858910084}, + {0x0a0b, 0.00000000000000000000000000000000669260655674564459}, + {0x0a0f, 0.00000000000000000000000000000000688519955118436817}, + {0x0a12, 0.00000000000000000000000000000000702964429701341086}, + {0x0a1d, 0.00000000000000000000000000000000755927503171990072}, + {0x0aa2, 0.00000000000000000000000000000001560003254953661041}, + {0x0aaf, 0.00000000000000000000000000000001685188701338831371}, + {0x0ab4, 0.00000000000000000000000000000001733336949948512268}, + {0x0ade, 0.00000000000000000000000000000002137782238269831797}, + {0x0b6e, 0.00000000000000000000000000000004583713267641621330}, + {0x0bb6, 0.00000000000000000000000000000007010384997569538505}, + {0x0c8c, 0.00000000000000000000000000000021570415377137041554}, + {0x0cf7, 0.00000000000000000000000000000038056375701091780456}, + {0x0d06, 0.00000000000000000000000000000041291938007662336690}, + {0x0d20, 0.00000000000000000000000000000049303806576313237838}, + {0x0d5e, 0.00000000000000000000000000000068409031624634617501}, + {0x0d60, 0.00000000000000000000000000000069025329206838532974}, + {0x0d6a, 0.00000000000000000000000000000072106817117858110338}, + {0x0d76, 0.00000000000000000000000000000075804602611081603176}, + {0x0d7e, 0.00000000000000000000000000000078269792939897265068}, + {0x0dcc, 0.00000000000000000000000000000125724706769598756487}, + {0x0dfc, 0.00000000000000000000000000000155306990715386699190}, + {0x0e09, 0.00000000000000000000000000000168865537523872839596}, + {0x0e3c, 0.00000000000000000000000000000231727890908672217840}, + {0x0e69, 0.00000000000000000000000000000287194673307024610408}, + {0x0f42, 0.00000000000000000000000000000956493847580476814062}, + {0x0f8f, 0.00000000000000000000000000001410088868082558602173}, + {0x0fa2, 0.00000000000000000000000000001597443333072548905959}, + {0x1007, 0.00000000000000000000000000002662405555120914843265}, + {0x1015, 0.00000000000000000000000000002938506871948268975159}, + {0x1030, 0.00000000000000000000000000003470987982972451943812}, + {0x1042, 0.00000000000000000000000000003825975390321907256247}, + {0x1056, 0.00000000000000000000000000004220405842932413158953}, + {0x1166, 0.00000000000000000000000000018143800820083271524470}, + {0x1182, 0.00000000000000000000000000020510383535746306940705}, + {0x128a, 0.00000000000000000000000000087090243936399703317455}, + {0x1295, 0.00000000000000000000000000094032219902344607205078}, + {0x129e, 0.00000000000000000000000000099712018419935892204042}, + {0x12b0, 0.00000000000000000000000000111071615455118462201971}, + {0x12bf, 0.00000000000000000000000000120537946317770603866912}, + {0x1315, 0.00000000000000000000000000188064439804689214410156}, + {0x1343, 0.00000000000000000000000000246124602428955683288459}, + {0x13e2, 0.00000000000000000000000000570504206655835737673762}, + {0x13ee, 0.00000000000000000000000000600796465416322591001572}, + {0x1445, 0.00000000000000000000000000994595829302651684263107}, + {0x1469, 0.00000000000000000000000001176349381865572804229970}, + {0x14bd, 0.00000000000000000000000001908412301910671759652054}, + {0x1541, 0.00000000000000000000000003897603960515975128178268}, + {0x1546, 0.00000000000000000000000003998578156384264639270970}, + {0x1569, 0.00000000000000000000000004705397527462291216919879}, + {0x16a1, 0.00000000000000000000000026010952855671378057479844}, + {0x16b6, 0.00000000000000000000000029403685836845905630194606}, + {0x16f4, 0.00000000000000000000000039420326066980225130590570}, + {0x1703, 0.00000000000000000000000042328382907986963050060367}, + {0x1720, 0.00000000000000000000000051698788284564229679463043}, + {0x178e, 0.00000000000000000000000091765349205101507681046902}, + {0x17f6, 0.00000000000000000000000158973773975035006264348858}, + {0x18e8, 0.00000000000000000000000599705944100945064281771302}, + {0x18f1, 0.00000000000000000000000622970398828998967637529671}, + {0x1927, 0.00000000000000000000000863369764352222635647032822}, + {0x1a39, 0.00000000000000000000003825710333057752996280265201}, + {0x1a60, 0.00000000000000000000004632211430296954979279888676}, + {0x1a69, 0.00000000000000000000004818327068121386206125955631}, + {0x1b1f, 0.00000000000000000000013152171739593140030455398204}, + {0x1b43, 0.00000000000000000000016130021944784039659992469495}, + {0x1ba0, 0.00000000000000000000026469779601696885595885078146}, + {0x1bc0, 0.00000000000000000000031763735522036262715062093775}, + {0x1bea, 0.00000000000000000000038712052667481695183981926789}, + {0x1c25, 0.00000000000000000000054593920428499826541512973677}, + {0x1c32, 0.00000000000000000000058895259613775570450844298875}, + {0x1cbe, 0.00000000000000000000125731453108060206580454121195}, + {0x1ccd, 0.00000000000000000000135657620458696538678911025499}, + {0x1cd6, 0.00000000000000000000141613320869078337937985168082}, + {0x1d23, 0.00000000000000000000215728703753829617606463386892}, + {0x1d38, 0.00000000000000000000243521972335611347482142718945}, + {0x1dce, 0.00000000000000000000545277459794955843275232609813}, + {0x1e7c, 0.00000000000000000001334076891925523034032607938570}, + {0x1e9e, 0.00000000000000000001672890070827243169659936938842}, + {0x1eb1, 0.00000000000000000001874060395800139500188663532754}, + {0x1f33, 0.00000000000000000003790472438962994017330743190541}, + {0x1f56, 0.00000000000000000004531626267810506814015525378636}, + {0x1fa8, 0.00000000000000000007115076756936122848173909005709}, + {0x1fed, 0.00000000000000000010037340424963459017959621633054}, + {0x2001, 0.00000000000000000010926725019580474373981360258767}, + {0x213f, 0.00000000000000000064713317170228545904819839051925}, + {0x2154, 0.00000000000000000071828393927164668752993748057634}, + {0x216b, 0.00000000000000000079621097041904231872422315063886}, + {0x219f, 0.00000000000000000107742590890747003129490622086450}, + {0x2225, 0.00000000000000000223616698075135289514037140179425}, + {0x2229, 0.00000000000000000229037708937562811684074404183775}, + {0x2274, 0.00000000000000000330681662608078852372273104265332}, + {0x227b, 0.00000000000000000340168431617327016169838316272944}, + {0x2294, 0.00000000000000000401154803819636640582757536321878}, + {0x22b7, 0.00000000000000000496022493912118278558409656397998}, + {0x2379, 0.00000000000000001349831704744453020339278737083077}, + {0x2389, 0.00000000000000001485356976305141074590210337191820}, + {0x2464, 0.00000000000000004943961906533900219073984771966934}, + {0x2475, 0.00000000000000005312590645178971726636518724262714}, + {0x2491, 0.00000000000000006288372600415925717243226245045662}, + {0x24f6, 0.00000000000000010668549377257363630633335560560226}, + {0x2567, 0.00000000000000020036056147532121940457727760076523}, + {0x256a, 0.00000000000000020296264668928643004619516432285309}, + {0x257f, 0.00000000000000022117724318704290453752037137746811}, + {0x25f9, 0.00000000000000043194614551822496650856919586658478}, + {0x263b, 0.00000000000000064878658001532585331005975604057312}, + {0x270c, 0.00000000000000194289029309402394574135541915893555}, + {0x272c, 0.00000000000000238697950294408656191080808639526367}, + {0x2745, 0.00000000000000273392419813944798079319298267364502}, + {0x2791, 0.00000000000000402455846426619245903566479682922363}, + {0x2792, 0.00000000000000405231403988182137254625558853149414}, + {0x27a0, 0.00000000000000444089209850062616169452667236328125}, + {0x27a3, 0.00000000000000452415882534751290222629904747009277}, + {0x27d4, 0.00000000000000588418203051332966424524784088134766}, + {0x27dd, 0.00000000000000613398221105398988584056496620178223}, + {0x2821, 0.00000000000000893729534823251015041023492813110352}, + {0x28d9, 0.00000000000002409183963436589692719280719757080078}, + {0x2981, 0.00000000000005728750807065807748585939407348632812}, + {0x29ca, 0.00000000000008970602038971264846622943878173828125}, + {0x2a5b, 0.00000000000019451107391432742588222026824951171875}, + {0x2aa8, 0.00000000000029842794901924207806587219238281250}, + {0x2ac4, 0.000000000000348165940522449091076850891113281250}, + {0x2ae7, 0.00000000000041033842990145785734057426452636718750}, + {0x2af1, 0.00000000000042810199829546036198735237121582031250}, + {0x2afe, 0.0000000000004511946372076636180281639099121093750}, + {0x2b24, 0.00000000000058264504332328215241432189941406250}, + {0x2b4c, 0.00000000000072475359047530218958854675292968750}, + {0x2b85, 0.000000000000945021838560933247208595275878906250}, + {0x2bed, 0.000000000001683986283751437440514564514160156250}, + {0x2c18, 0.00000000000216004991671070456504821777343750}, + {0x2cdf, 0.0000000000063380412029800936579704284667968750}, + {0x2d6b, 0.000000000013358203432289883494377136230468750}, + {0x2d96, 0.0000000000170530256582424044609069824218750}, + {0x2da2, 0.0000000000184172677109017968177795410156250}, + {0x2db8, 0.00000000002091837814077734947204589843750}, + {0x2de1, 0.00000000002557953848736360669136047363281250}, + {0x2e90, 0.00000000006548361852765083312988281250}, + {0x2ea3, 0.000000000074123818194493651390075683593750}, + {0x2ef0, 0.00000000010913936421275138854980468750}, + {0x2f09, 0.00000000012460077414289116859436035156250}, + {0x2f6b, 0.00000000021373125491663813591003417968750}, + {0x303b, 0.000000000680302036926150321960449218750}, + {0x308f, 0.00000000104046193882822990417480468750}, + {0x309c, 0.000000001135049387812614440917968750}, + {0x30a9, 0.00000000122963683679699897766113281250}, + {0x312a, 0.000000002473825588822364807128906250}, + {0x313d, 0.0000000027503119781613349914550781250}, + {0x3159, 0.0000000031577656045556068420410156250}, + {0x31c6, 0.00000000576255843043327331542968750}, + {0x3212, 0.0000000084983184933662414550781250}, + {0x3245, 0.00000001146690919995307922363281250}, + {0x329b, 0.0000000180443748831748962402343750}, + {0x32ba, 0.000000021653249859809875488281250}, + {0x32cc, 0.00000002374872565269470214843750}, + {0x3332, 0.00000004144385457038879394531250}, + {0x33c4, 0.000000091269612312316894531250}, + {0x3424, 0.00000015273690223693847656250}, + {0x3589, 0.0000010207295417785644531250}, + {0x3594, 0.00000110268592834472656250}, + {0x368b, 0.00000414252281188964843750}, + {0x36a0, 0.000004768371582031250}, + {0x36e9, 0.00000694394111633300781250}, + {0x36ed, 0.00000706315040588378906250}, + {0x3750, 0.000012397766113281250}, + {0x375f, 0.0000132918357849121093750}, + {0x37ce, 0.00002455711364746093750}, + {0x37d2, 0.00002503395080566406250}, + {0x37f0, 0.00002861022949218750}, + {0x380e, 0.0000338554382324218750}, + {0x3826, 0.0000395774841308593750}, + {0x387f, 0.00006079673767089843750}, + {0x38e1, 0.0001072883605957031250}, + {0x38e9, 0.0001111030578613281250}, + {0x3964, 0.0002174377441406250}, + {0x3994, 0.000282287597656250}, + {0x3a26, 0.000633239746093750}, + {0x3a2c, 0.00065612792968750}, + {0x3a6a, 0.000892639160156250}, + {0x3a85, 0.001014709472656250}, + {0x3ab9, 0.001411437988281250}, + {0x3aba, 0.00141906738281250}, + {0x3af7, 0.001884460449218750}, + {0x3b03, 0.00199890136718750}, + {0x3bb3, 0.0054626464843750}, + {0x3bbf, 0.0058288574218750}, + {0x3be8, 0.0070800781250}, + {0x3c06, 0.00817871093750}, + {0x3c29, 0.010314941406250}, + {0x3c3f, 0.011657714843750}, + {0x3c73, 0.014831542968750}, + {0x3ce9, 0.02844238281250}, + {0x3cfa, 0.0305175781250}, + {0x3cfb, 0.03063964843750}, + {0x3d0f, 0.0349121093750}, + {0x3d2a, 0.041503906250}, + {0x3d43, 0.0476074218750}, + {0x3dd0, 0.10156250}, + {0x3dd9, 0.105957031250}, + {0x3de9, 0.113769531250}, + {0x3df9, 0.121582031250}, + {0x3e1e, 0.1542968750}, + {0x3e77, 0.24121093750}, + {0x3e95, 0.2910156250}, + {0x3f38, 0.718750}, + {0x3fb3, 1.39843750}, + {0x3fc5, 1.53906250}, + {0x3fd3, 1.64843750}, + {0x3fd7, 1.67968750}, + {0x400b, 2.1718750}, + {0x40bf, 5.968750}, + {0x40c7, 6.218750}, + {0x4123, 10.18750}, + {0x412b, 10.68750}, + {0x41bf, 23.8750}, + {0x41ca, 25.250}, + {0x421b, 38.750}, + {0x4226, 41.50}, + {0x42a7, 83.50}, + {0x42b7, 91.50}, + {0x4311, 145.0}, + {0x431f, 159.0}, + {0x4334, 180.0}, + {0x434f, 207.0}, + {0x43b1, 354.0}, + {0x43e5, 458.0}, + {0x4476, 984.0}, + {0x4496, 1200.0}, + {0x44a4, 1312.0}, + {0x458b, 4448.0}, + {0x45a9, 5408.0}, + {0x45df, 7136.0}, + {0x45f6, 7872.0}, + {0x45fa, 8000.0}, + {0x4602, 8320.0}, + {0x4640, 12288.0}, + {0x4648, 12800.0}, + {0x46a7, 21376.0}, + {0x46b1, 22656.0}, + {0x4742, 49664.0}, + {0x4744, 50176.0}, + {0x475e, 56832.0}, + {0x477a, 64000.0}, + {0x4837, 187392.0}, + {0x488a, 282624.0}, + {0x488f, 292864.0}, + {0x48ea, 479232.0}, + {0x495c, 901120.0}, + {0x49aa, 1392640.0}, + {0x49b9, 1515520.0}, + {0x4a1e, 2588672.0}, + {0x4a2b, 2801664.0}, + {0x4a4c, 3342336.0}, + {0x4ab6, 5963776.0}, + {0x4b34, 11796480.0}, + {0x4b73, 15925248.0}, + {0x4b7b, 16449536.0}, + {0x4bcd, 26869760.0}, + {0x4bd0, 27262976.0}, + {0x4c07, 35389440.0}, + {0x4c17, 39583744.0}, + {0x4c53, 55312384.0}, + {0x4cad, 90701824.0}, + {0x4d1c, 163577856.0}, + {0x4dc0, 402653184.0}, + {0x4dde, 465567744.0}, + {0x4eef, 2004877312.0}, + {0x4efc, 2113929216.0}, + {0x4f12, 2449473536.0}, + {0x4f2f, 2936012800.0}, + {0x4f92, 4898947072.0}, + {0x4fad, 5804916736.0}, + {0x4fdc, 7381975040.0}, + {0x4feb, 7885291520.0}, + {0x5076, 16508780544.0}, + {0x5083, 17582522368.0}, + {0x5215, 159987531776.0}, + {0x52a9, 362924736512.0}, + {0x5394, 1271310319616.0}, + {0x53a0, 1374389534720.0}, + {0x53b7, 1571958030336.0}, + {0x540e, 2439541424128.0}, + {0x542f, 3006477107200.0}, + {0x5465, 3934190043136.0}, + {0x5529, 11613591568384.0}, + {0x554c, 14018773254144.0}, + {0x5596, 20615843020800.0}, + {0x55ae, 23914377904128.0}, + {0x55be, 26113401159680.0}, + {0x55da, 29961691856896.0}, + {0x568d, 77515569758208.0}, + {0x5690, 79164837199872.0}, + {0x56ad, 95107755802624.0}, + {0x5718, 167125767421952.0}, + {0x571c, 171523813933056.0}, + {0x571d, 172623325560832.0}, + {0x5826, 730075720843264.0}, + {0x587c, 1108307720798208.0}, + {0x5890, 1266637395197952.0}, + {0x58a8, 1477743627730944.0}, + {0x58f6, 2163838883463168.0}, + {0x5966, 4046202790215680.0}, + {0x5985, 4679521487814656.0}, + {0x59ad, 6086896371367936.0}, + {0x59b0, 6192449487634432.0}, + {0x59bc, 6614661952700416.0}, + {0x5a93, 20688410788233216.0}, + {0x5ab0, 24769797950537728.0}, + {0x5ab6, 25614222880669696.0}, + {0x5ae3, 31947409856659456.0}, + {0x5af5, 34480684647055360.0}, + {0x5afd, 35606584553897984.0}, + {0x5bb6, 102456891522678784.0}, + {0x5c3d, 212795082393255936.0}, + {0x5d57, 968273919884656640.0}, + {0x5d76, 1107885508333142016.0}, + {0x5d86, 1206964700135292928.0}, + {0x5db2, 1603281467343896576.0}, + {0x5dc1, 1738389456165011456.0}, + {0x5dc5, 1774418253183975424.0}, + {0x5e5d, 3981182070595518464.0}, + {0x5fa4, 23634890844440363008.0}, + {0x5fa8, 24211351596743786496.0}, + {0x5ff8, 35740566642812256256.0}, + {0x6006, 38622870404329373696.0}, + {0x6051, 60240148615707754496.0}, + {0x60ed, 136621198295911366656.0}, + {0x610b, 160256089140351729664.0}, + {0x6114, 170632382681813352448.0}, + {0x613b, 215596321361480384512.0}, + {0x6148, 230584300921369395200.0}, + {0x61ad, 398910840593969053696.0}, + {0x61fd, 583378281331064569856.0}, + {0x629f, 1466516153859909353472.0}, + {0x62a4, 1512633014044183232512.0}, + {0x62fb, 2315066381250548727808.0}, + {0x634b, 3744689046963038978048.0}, + {0x635a, 4021390208068682252288.0}, + {0x635f, 4113623928437230010368.0}, + {0x637c, 4648579506574807007232.0}, + {0x638d, 5201981828786093555712.0}, + {0x63a9, 6234999496913828446208.0}, + {0x6469, 17192365476697302106112.0}, + {0x64c0, 28334198897217871282176.0}, + {0x64d1, 30842956091242370301952.0}, + {0x64dd, 32613843522318487257088.0}, + {0x64ee, 35122600716342986276864.0}, + {0x64ef, 35270174668932662689792.0}, + {0x64fb, 37041062100008779644928.0}, + {0x6510, 42501298345826806923264.0}, + {0x6581, 76148159536273029070848.0}, + {0x65d4, 125142711796045598162944.0}, + {0x6612, 172366376624742050299904.0}, + {0x661c, 184172292831916163334144.0}, + {0x66c6, 467514281804094876155904.0}, + {0x66ed, 559600428220052957822976.0}, + {0x66f9, 587934627117270829105152.0}, + {0x6703, 618630009255923522994176.0}, + {0x6752, 991696961402625494876160.0}, + {0x6797, 1426154677826632854536192.0}, + {0x679c, 1473378342655329306673152.0}, + {0x67e3, 2143954383222818927017984.0}, + {0x6862, 4269019300514159273181184.0}, + {0x692f, 13222626152035006598348800.0}, + {0x693d, 14280436244197807126216704.0}, + {0x6943, 14733783426553293066731520.0}, + {0x695e, 16773845747152979799048192.0}, + {0x69ec, 35663311678631560653832192.0}, + {0x69f4, 36872237498246189828538368.0}, + {0x6a5c, 66490920078804604608839680.0}, + {0x6a7a, 75557863725914323419136000.0}, + {0x6ac3, 117870267412426344533852160.0}, + {0x6ad8, 130563988518379950868267008.0}, + {0x6ae3, 137213080526260411329150976.0}, + {0x6b37, 221233424989477138971230208.0}, + {0x6b77, 298604677444813406152425472.0}, + {0x6bd7, 519838102434290545123655680.0}, + {0x6be7, 558523728661958678714253312.0}, + {0x6c15, 720519788490318988124880896.0}, + {0x6c33, 865590886844074489089622016.0}, + {0x6c43, 942962139299410756270817280.0}, + {0x6c45, 952633545856327789668466688.0}, + {0x6c48, 967140655691703339764940800.0}, + {0x6da6, 6421813953792910176039206912.0}, + {0x6dba, 7195526478346272847851159552.0}, + {0x6def, 9245864668412683928152834048.0}, + {0x6e24, 12688885402675147817716023296.0}, + {0x6e28, 12998370412496492886440804352.0}, + {0x6e3d, 14623166714058554497245904896.0}, + {0x6ea0, 24758800785707605497982484480.0}, + {0x6eef, 36983458673650735712611336192.0}, + {0x6ef9, 38530883722757461056235241472.0}, + {0x6f55, 65920307091946499638378364928.0}, + {0x6f5c, 68086702160695915119451832320.0}, + {0x6f65, 70872067249088020737974861824.0}, + {0x6f9e, 97797263103545041717030813696.0}, + {0x6fdc, 136173404321391830238903664640.0}, + {0x70ab, 423375493435600054015500484608.0}, + {0x70dc, 544693617285567320955614658560.0}, + {0x714a, 1000255551742587262118492372992.0}, + {0x71ba, 1842054778456645849049896845312.0}, + {0x71d3, 2089642786313721904029721690112.0}, + {0x71ee, 2357037834799364043407932522496.0}, + {0x71f6, 2436265997313628381001476472832.0}, + {0x7251, 4139671491370311639262671405056.0}, + {0x72b8, 7288990951312319058606043430912.0}, + {0x731f, 12597277839768029677373488103424.0}, + {0x7328, 13310331302396408715715383656448.0}, + {0x7356, 16954826778052568245018405371904.0}, + {0x7358, 17113283103081096920205493272576.0}, + {0x7375, 19410899815994762710418267832320.0}, + {0x737c, 19965496953594613073573075484672.0}, + {0x7467, 73206822163180247936434610110464.0}, + {0x74a4, 103947349218714810922729662840832.0}, + {0x74b1, 112187078120198302032458233675776.0}, + {0x7530, 223106505640168374663419764146176.0}, + {0x7563, 287756686251808074139751627620352.0}, + {0x756f, 302968493454546826957712066084864.0}, + {0x7571, 305503794655003285760705472495616.0}, + {0x7626, 841719998551544322593810928369664.0}, + {0x7660, 1135814937804493543741046072016896.0}, + {0x7675, 1242297588223664813466769141268480.0}, + {0x76b2, 1805134454724998667731305364455424.0}, + {0x772c, 3488574451828087312918927221194752.0}, + {0x77b2, 7220537818899994670925221457821696.0}, + {0x783a, 15090112745116842795416754956795904.0}, + {0x795d, 71718600358512306619077480547352576.0}, + {0x796e, 77235415770705560974391132897148928.0}, + {0x798c, 90865195024359483499283685761351680.0}, + {0x79af, 113581493780449354374104607201689600.0}, + {0x7aa5, 428364490829123279353765947160657920.0}, + {0x7acf, 537402724858354659552906370074279936.0}, + {0x7adc, 571152654438831039138354596214210560.0}, + {0x7b07, 700960075902201729851617004444712960.0}, + {0x7b0f, 742498450770480350879860975078473728.0}, + {0x7b12, 758075341346084833765452464066134016.0}, + {0x7b30, 913844247102129662621367353942736896.0}, + {0x7bc2, 2014611181111513119869832575737397248.0}, + {0x7bd1, 2170380086867557948725747465614000128.0}, + {0x7bd5, 2211918461735836569753991436247760896.0}, + {0x7cf1, 10010748343255147667806796922736345088.0}, + {0x7d2f, 14538431203897517359885389721816268800.0}, + {0x7da0, 26584559915698317458076141205606891520.0}, + {0x7e58, 71778311772385457136805581255138607104.0}, + {0x7e81, 85735205728127073802295555388082225152.0}, + {0x7f09, 182104235422533474587821567258407206912.0}, + {0x7f24, 217993391308726203156224357885976510464.0}, + {0x7f86, std::numeric_limits::quiet_NaN()}, + {0x7f88, std::numeric_limits::quiet_NaN()}, + {0x7f8f, std::numeric_limits::quiet_NaN()}, + {0x7fa0, std::numeric_limits::quiet_NaN()}, + {0x7fcd, std::numeric_limits::quiet_NaN()}, + {0x8023, -0.00000000000000000000000000000000000000321424236553}, + {0x8074, -0.00000000000000000000000000000000000001065291755433}, + {0x8080, -0.00000000000000000000000000000000000001175494350822}, + {0x80a5, -0.00000000000000000000000000000000000001515285686607}, + {0x80d2, -0.00000000000000000000000000000000000001928545419318}, + {0x80fd, -0.00000000000000000000000000000000000002323438052797}, + {0x810a, -0.00000000000000000000000000000000000002534659693961}, + {0x8124, -0.00000000000000000000000000000000000003012204273982}, + {0x81e3, -0.00000000000000000000000000000000000008338663051146}, + {0x81f1, -0.00000000000000000000000000000000000008852941829630}, + {0x8285, -0.00000000000000000000000000000000000019542593582421}, + {0x828b, -0.00000000000000000000000000000000000020424214345537}, + {0x829f, -0.00000000000000000000000000000000000023362950222593}, + {0x82bc, -0.00000000000000000000000000000000000027624117244324}, + {0x82ee, -0.00000000000000000000000000000000000034970956936963}, + {0x82f9, -0.00000000000000000000000000000000000036587261669344}, + {0x8393, -0.00000000000000000000000000000000000086398834785438}, + {0x8394, -0.00000000000000000000000000000000000086986581960849}, + {0x843e, -0.00000000000000000000000000000000000223343926656235}, + {0x8451, -0.00000000000000000000000000000000000245678319321858}, + {0x847f, -0.00000000000000000000000000000000000299751059459683}, + {0x8483, -0.00000000000000000000000000000000000307979519915439}, + {0x84a0, -0.00000000000000000000000000000000000376158192263132}, + {0x84aa, -0.00000000000000000000000000000000000399668079279578}, + {0x84ba, -0.00000000000000000000000000000000000437283898505891}, + {0x84e4, -0.00000000000000000000000000000000000536025423974963}, + {0x8510, -0.00000000000000000000000000000000000677084746073638}, + {0x854d, -0.00000000000000000000000000000000000963905367674276}, + {0x8557, -0.00000000000000000000000000000000001010925141707167}, + {0x8584, -0.00000000000000000000000000000000001241322034468336}, + {0x85b7, -0.00000000000000000000000000000000001720923729603829}, + {0x8656, -0.00000000000000000000000000000000004024892657215512}, + {0x87c7, -0.00000000000000000000000000000000029942192104145307}, + {0x88d9, -0.00000000000000000000000000000000130602124353759431}, + {0x896c, -0.00000000000000000000000000000000284074666797117288}, + {0x89a0, -0.00000000000000000000000000000000385185988877447171}, + {0x89b2, -0.00000000000000000000000000000000428519412626159977}, + {0x89fe, -0.00000000000000000000000000000000611482757342947383}, + {0x8a31, -0.00000000000000000000000000000000852224000391351865}, + {0x8a55, -0.00000000000000000000000000000001025557695386203092}, + {0x8a68, -0.00000000000000000000000000000001117039367744596795}, + {0x8b4a, -0.00000000000000000000000000000003890378487662216423}, + {0x8b4c, -0.00000000000000000000000000000003928897086549961140}, + {0x8b5b, -0.00000000000000000000000000000004217786578208046518}, + {0x8bbf, -0.00000000000000000000000000000007357052387559240959}, + {0x8bff, -0.00000000000000000000000000000009822242716374902851}, + {0x8c43, -0.00000000000000000000000000000015022253566220439654}, + {0x8c6b, -0.00000000000000000000000000000018103741477240017019}, + {0x8d1d, -0.00000000000000000000000000000048379360203007364629}, + {0x8d23, -0.00000000000000000000000000000050228252949619111048}, + {0x8d30, -0.00000000000000000000000000000054234187233944561622}, + {0x8dee, -0.00000000000000000000000000000146678824564531882569}, + {0x8e54, -0.00000000000000000000000000000261310174854460160543}, + {0x8e68, -0.00000000000000000000000000000285962078142616779462}, + {0x8eb0, -0.00000000000000000000000000000433873497871556492976}, + {0x8efe, -0.00000000000000000000000000000626158343519178120546}, + {0x8f3d, -0.00000000000000000000000000000931841944292320195143}, + {0x8f95, -0.00000000000000000000000000001469253435974134487579}, + {0x8fa3, -0.00000000000000000000000000001607304094387811553526}, + {0x8fbe, -0.00000000000000000000000000001873544649899903037853}, + {0x9009, -0.00000000000000000000000000002701848600381965433535}, + {0x9017, -0.00000000000000000000000000002977949917209319565429}, + {0x90a8, -0.00000000000000000000000000006626431603856499165459}, + {0x90d2, -0.00000000000000000000000000008283039504820623956823}, + {0x9260, -0.00000000000000000000000000070681937107802657764891}, + {0x92d0, -0.00000000000000000000000000131266454628776364420512}, + {0x92ed, -0.00000000000000000000000000149568027629903838306064}, + {0x9356, -0.00000000000000000000000000270105973947674442172976}, + {0x94af, -0.00000000000000000000000001767048427695066444122272}, + {0x9503, -0.00000000000000000000000002645523931749185190628773}, + {0x953c, -0.00000000000000000000000003796629764647685617085567}, + {0x9556, -0.00000000000000000000000004321695583162791074767614}, + {0x9598, -0.00000000000000000000000006139231108792002274436236}, + {0x9599, -0.00000000000000000000000006179620787139318078873317}, + {0x95cf, -0.00000000000000000000000008360663417894371518475664}, + {0x95df, -0.00000000000000000000000009006898271451424389468952}, + {0x95f4, -0.00000000000000000000000009855081516745056282647643}, + {0x960f, -0.00000000000000000000000011551448007332320069005024}, + {0x9615, -0.00000000000000000000000012036124147500109722249990}, + {0x966a, -0.00000000000000000000000018902369466543796476553675}, + {0x968c, -0.00000000000000000000000022618219874496850484765081}, + {0x96b3, -0.00000000000000000000000028919009696678115976949640}, + {0x96d7, -0.00000000000000000000000034735123378691591815889232}, + {0x9719, -0.00000000000000000000000049436966297114544630986535}, + {0x9761, -0.00000000000000000000000072701421025168447986744905}, + {0x97f0, -0.00000000000000000000000155096364853692689038389130}, + {0x97fd, -0.00000000000000000000000163497417949934376361301874}, + {0x983c, -0.00000000000000000000000242984304937451879493476303}, + {0x987d, -0.00000000000000000000000326994835899868752722603749}, + {0x9895, -0.00000000000000000000000385155972720003511111999672}, + {0x98b3, -0.00000000000000000000000462704155146849855631194237}, + {0x98fa, -0.00000000000000000000000646234853557052870993288041}, + {0x998f, -0.00000000000000000000001478585344938536968832643037}, + {0x999b, -0.00000000000000000000001602662436821491120063354341}, + {0x99e4, -0.00000000000000000000002357464745776128873383514772}, + {0x9a8b, -0.00000000000000000000005748905257243542340356290410}, + {0x9a95, -0.00000000000000000000006162495563520056177791994756}, + {0x9a9f, -0.00000000000000000000006576085869796570015227699102}, + {0x9bb2, -0.00000000000000000000029447629806887785225422149438}, + {0x9bc4, -0.00000000000000000000032425480012078684854959220729}, + {0x9c09, -0.00000000000000000000045329497567905916582953196325}, + {0x9c79, -0.00000000000000000000082387189010281556417192305730}, + {0x9cca, -0.00000000000000000000133672386988569272259219644639}, + {0x9d21, -0.00000000000000000000213081725793659929046874879077}, + {0x9d2d, -0.00000000000000000000228963593554678060404405925965}, + {0x9d53, -0.00000000000000000000279256174797902143036587574443}, + {0x9d59, -0.00000000000000000000287197108678411208715353097887}, + {0x9d9b, -0.00000000000000000000410281583826301726736218711267}, + {0x9dc9, -0.00000000000000000000532042569994107400477290070739}, + {0x9e3a, -0.00000000000000000000984675801183124144166924907040}, + {0x9eb4, -0.00000000000000000001905824131322175762903725626529}, + {0x9eb7, -0.00000000000000000001937587866844212025618787720305}, + {0x9ec3, -0.00000000000000000002064642808932357076479036095407}, + {0x9ee0, -0.00000000000000000002371692252312040949391303001903}, + {0x9f0a, -0.00000000000000000002922263668027336169785712627345}, + {0x9f5b, -0.00000000000000000004637505386217294356399065691221}, + {0x9fb7, -0.00000000000000000007750351467376848102475150881219}, + {0xa007, -0.00000000000000000011434944787933054577422353759175}, + {0xa06c, -0.00000000000000000019989977555201488002012411016040}, + {0xa07a, -0.00000000000000000021175823681357508476708062516991}, + {0xa0c0, -0.00000000000000000032526065174565133020223584026098}, + {0xa0e5, -0.00000000000000000038794108984246955529329170531128}, + {0xa108, -0.00000000000000000046078592330633938445316744036973}, + {0xa128, -0.00000000000000000056920614055488982785391272045672}, + {0xa178, -0.00000000000000000084025668367626593635577592067420}, + {0xa1f6, -0.00000000000000000166696084019646306728645868133754}, + {0xa305, -0.00000000000000000720994444702860448614956112578511}, + {0xa312, -0.00000000000000000791467585914418236825440544635057}, + {0xa3f2, -0.00000000000000002623769257414920730298035778105259}, + {0xa3f3, -0.00000000000000002634611279139775774638110306113958}, + {0xa40a, -0.00000000000000002992397996059992237860569730401039}, + {0xa412, -0.00000000000000003165870343657672947301762178540230}, + {0xa413, -0.00000000000000003187554387107383035981911234557629}, + {0xa421, -0.00000000000000003491130995403324277503998018801212}, + {0xa450, -0.00000000000000004510281037539698445471003651618958}, + {0xa456, -0.00000000000000004640385298237958977551897987723351}, + {0xa4a4, -0.00000000000000007112366251504909087088890373706818}, + {0xa4c9, -0.00000000000000008716985466783455649419920518994331}, + {0xa4ed, -0.00000000000000010278236595162582034390652552247047}, + {0xa522, -0.00000000000000014051260155412137464736588299274445}, + {0xa53a, -0.00000000000000016132928326584305978030897676944733}, + {0xa541, -0.0000000000000001674008154317618846107507124543190}, + {0xa6f7, -0.00000000000000171390679426508540927898138761520386}, + {0xa76c, -0.00000000000000327515792264421179424971342086791992}, + {0xa7a3, -0.00000000000000452415882534751290222629904747009277}, + {0xa7ae, -0.00000000000000482947015711943095084279775619506836}, + {0xa7bc, -0.00000000000000521804821573823573999106884002685547}, + {0xa837, -0.00000000000001015854067532018234487622976303100586}, + {0xa83e, -0.00000000000001054711873393898713402450084686279297}, + {0xa881, -0.00000000000001432187701766451937146484851837158203}, + {0xa8b9, -0.00000000000002053912595556539599783718585968017578}, + {0xa8c2, -0.00000000000002153832667772803688421845436096191406}, + {0xa8ca, -0.00000000000002242650509742816211655735969543457031}, + {0xa8d6, -0.00000000000002375877272697834996506571769714355469}, + {0xa8e4, -0.00000000000002531308496145356912165880203247070312}, + {0xa92d, -0.00000000000003841371665203041629865765571594238281}, + {0xa933, -0.00000000000003974598428158060414716601371765136719}, + {0xa937, -0.00000000000004063416270128072937950491905212402344}, + {0xa950, -0.0000000000000461852778244065120816230773925781250}, + {0xa956, -0.00000000000004751754545395669993013143539428710938}, + {0xa9b8, -0.0000000000000817124146124115213751792907714843750}, + {0xa9c6, -0.00000000000008792966355031239800155162811279296875}, + {0xa9f0, -0.000000000000106581410364015027880668640136718750}, + {0xaa2d, -0.00000000000015365486660812166519463062286376953125}, + {0xaae6, -0.0000000000004085620730620576068758964538574218750}, + {0xaaff, -0.00000000000045297099404706386849284172058105468750}, + {0xab12, -0.000000000000518696197104873135685920715332031250}, + {0xab42, -0.000000000000689226453687297180294990539550781250}, + {0xabfa, -0.00000000000177635683940025046467781066894531250}, + {0xac3a, -0.0000000000026432189770275726914405822753906250}, + {0xadbb, -0.00000000002125943865394219756126403808593750}, + {0xadc3, -0.00000000002216893335571512579917907714843750}, + {0xadda, -0.0000000000247837306233122944831848144531250}, + {0xaddf, -0.00000000002535216481192037463188171386718750}, + {0xae16, -0.000000000034106051316484808921813964843750}, + {0xae77, -0.0000000000561612978344783186912536621093750}, + {0xaee2, -0.00000000010277290130034089088439941406250}, + {0xb03e, -0.00000000069121597334742546081542968750}, + {0xb050, -0.00000000075669959187507629394531250}, + {0xb075, -0.000000000891304807737469673156738281250}, + {0xb11d, -0.0000000022846506908535957336425781250}, + {0xb125, -0.0000000024010660126805305480957031250}, + {0xb139, -0.0000000026921043172478675842285156250}, + {0xb155, -0.0000000030995579436421394348144531250}, + {0xb18d, -0.000000004103640094399452209472656250}, + {0xb23c, -0.000000010943040251731872558593750}, + {0xb2a8, -0.0000000195577740669250488281250}, + {0xb341, -0.000000044936314225196838378906250}, + {0xb369, -0.000000054249539971351623535156250}, + {0xb37b, -0.000000058440491557121276855468750}, + {0xb3c6, -0.0000000922009348869323730468750}, + {0xb3c9, -0.00000009359791874885559082031250}, + {0xb3dc, -0.000000102445483207702636718750}, + {0xb3e2, -0.0000001052394509315490722656250}, + {0xb404, -0.00000012293457984924316406250}, + {0xb42d, -0.0000001611188054084777832031250}, + {0xb487, -0.000000251457095146179199218750}, + {0xb499, -0.000000284984707832336425781250}, + {0xb49b, -0.000000288709998130798339843750}, + {0xb4be, -0.00000035390257835388183593750}, + {0xb599, -0.0000011399388313293457031250}, + {0xb5be, -0.000001415610313415527343750}, + {0xb661, -0.000003352761268615722656250}, + {0xb67f, -0.000003799796104431152343750}, + {0xb6f4, -0.000007271766662597656250}, + {0xb70f, -0.0000085234642028808593750}, + {0xb729, -0.0000100731849670410156250}, + {0xb731, -0.0000105500221252441406250}, + {0xb735, -0.0000107884407043457031250}, + {0xb76f, -0.0000142455101013183593750}, + {0xb770, -0.000014305114746093750}, + {0xb7a4, -0.0000195503234863281250}, + {0xb7b1, -0.000021100044250488281250}, + {0xb829, -0.00004029273986816406250}, + {0xb882, -0.000061988830566406250}, + {0xb9a6, -0.0003166198730468750}, + {0xb9c5, -0.00037574768066406250}, + {0xb9cc, -0.000389099121093750}, + {0xb9d3, -0.00040245056152343750}, + {0xb9dd, -0.00042152404785156250}, + {0xbb04, -0.002014160156250}, + {0xbb14, -0.002258300781250}, + {0xbb19, -0.00233459472656250}, + {0xbb33, -0.00273132324218750}, + {0xbb66, -0.0035095214843750}, + {0xbbc5, -0.0060119628906250}, + {0xbc0d, -0.008605957031250}, + {0xbcb0, -0.0214843750}, + {0xbcc8, -0.02441406250}, + {0xbce0, -0.027343750}, + {0xbce8, -0.02832031250}, + {0xbd06, -0.032714843750}, + {0xbd77, -0.0603027343750}, + {0xbe31, -0.17285156250}, + {0xbe3a, -0.1816406250}, + {0xbe5d, -0.21582031250}, + {0xbe85, -0.2597656250}, + {0xbe9a, -0.300781250}, + {0xbea5, -0.3222656250}, + {0xbeb0, -0.343750}, + {0xbebf, -0.3730468750}, + {0xbeee, -0.464843750}, + {0xbf2b, -0.667968750}, + {0xbfac, -1.343750}, + {0xc022, -2.531250}, + {0xc026, -2.593750}, + {0xc05e, -3.468750}, + {0xc07e, -3.968750}, + {0xc07f, -3.9843750}, + {0xc086, -4.18750}, + {0xc0ae, -5.43750}, + {0xc0c2, -6.06250}, + {0xc0e6, -7.18750}, + {0xc13e, -11.8750}, + {0xc198, -19.0}, + {0xc1be, -23.750}, + {0xc1c1, -24.1250}, + {0xc1eb, -29.3750}, + {0xc225, -41.250}, + {0xc276, -61.50}, + {0xc27f, -63.750}, + {0xc29f, -79.50}, + {0xc313, -147.0}, + {0xc31b, -155.0}, + {0xc324, -164.0}, + {0xc35b, -219.0}, + {0xc394, -296.0}, + {0xc39d, -314.0}, + {0xc3b5, -362.0}, + {0xc3be, -380.0}, + {0xc429, -676.0}, + {0xc444, -784.0}, + {0xc44b, -812.0}, + {0xc4b5, -1448.0}, + {0xc4eb, -1880.0}, + {0xc523, -2608.0}, + {0xc557, -3440.0}, + {0xc55e, -3552.0}, + {0xc56d, -3792.0}, + {0xc58b, -4448.0}, + {0xc64d, -13120.0}, + {0xc6b8, -23552.0}, + {0xc6ca, -25856.0}, + {0xc777, -63232.0}, + {0xc7d6, -109568.0}, + {0xc868, -237568.0}, + {0xc8ca, -413696.0}, + {0xc910, -589824.0}, + {0xc9c5, -1613824.0}, + {0xc9c8, -1638400.0}, + {0xc9df, -1826816.0}, + {0xca3a, -3047424.0}, + {0xca42, -3178496.0}, + {0xca6b, -3850240.0}, + {0xcaa0, -5242880.0}, + {0xcaa2, -5308416.0}, + {0xcaac, -5636096.0}, + {0xcb3a, -12189696.0}, + {0xcb84, -17301504.0}, + {0xcc50, -54525952.0}, + {0xcc89, -71827456.0}, + {0xcc94, -77594624.0}, + {0xccaf, -91750400.0}, + {0xcce0, -117440512.0}, + {0xcce1, -117964800.0}, + {0xcd6d, -248512512.0}, + {0xcda8, -352321536.0}, + {0xcdba, -390070272.0}, + {0xcdd0, -436207616.0}, + {0xcde5, -480247808.0}, + {0xcdf7, -517996544.0}, + {0xce30, -738197504.0}, + {0xcec2, -1627389952.0}, + {0xcf03, -2197815296.0}, + {0xcf25, -2768240640.0}, + {0xcf57, -3607101440.0}, + {0xd036, -12213813248.0}, + {0xd09e, -21206401024.0}, + {0xd103, -35165044736.0}, + {0xd104, -35433480192.0}, + {0xd11f, -42681237504.0}, + {0xd125, -44291850240.0}, + {0xd19c, -83751862272.0}, + {0xd1c7, -106837311488.0}, + {0xd1cf, -111132278784.0}, + {0xd1d8, -115964116992.0}, + {0xd231, -190052302848.0}, + {0xd28a, -296352743424.0}, + {0xd294, -317827579904.0}, + {0xd2be, -408021893120.0}, + {0xd2c1, -414464344064.0}, + {0xd2c6, -425201762304.0}, + {0xd2db, -470298918912.0}, + {0xd334, -773094113280.0}, + {0xd36f, -1026497183744.0}, + {0xd375, -1052266987520.0}, + {0xd3c3, -1675037245440.0}, + {0xd3d5, -1829656068096.0}, + {0xd3f2, -2078764171264.0}, + {0xd44c, -3504693313536.0}, + {0xd49b, -5325759447040.0}, + {0xd4cd, -7043746365440.0}, + {0xd4e8, -7971459301376.0}, + {0xd538, -12644383719424.0}, + {0xd54c, -14018773254144.0}, + {0xd554, -14568529068032.0}, + {0xd5a3, -22402549415936.0}, + {0xd5bf, -26250840113152.0}, + {0xd64a, -55525337202688.0}, + {0xd74f, -227598906949632.0}, + {0xd75f, -245191092994048.0}, + {0xd762, -248489627877376.0}, + {0xd7d6, -470590976688128.0}, + {0xd7db, -481586092965888.0}, + {0xd819, -672901116198912.0}, + {0xd82d, -760862046420992.0}, + {0xd85b, -963172185931776.0}, + {0xd936, -3201777860083712.0}, + {0xd967, -4063794976260096.0}, + {0xd976, -4327677766926336.0}, + {0xd985, -4679521487814656.0}, + {0xd98c, -4925812092436480.0}, + {0xd9c9, -7072058789855232.0}, + {0xda1b, -10907155347537920.0}, + {0xda5a, -15340386230730752.0}, + {0xdab6, -25614222880669696.0}, + {0xdacc, -28710447624486912.0}, + {0xdb00, -36028797018963968.0}, + {0xdb0d, -39687971716202496.0}, + {0xdb24, -46161896180547584.0}, + {0xdb4c, -57420895248973824.0}, + {0xdbbd, -106397541196627968.0}, + {0xdbbf, -107523441103470592.0}, + {0xdbcc, -114841790497947648.0}, + {0xdbf4, -137359788634800128.0}, + {0xdc88, -306244774661193728.0}, + {0xdc9c, -351280770934898688.0}, + {0xdd24, -738590338888761344.0}, + {0xdd71, -1085367510196289536.0}, + {0xdd86, -1206964700135292928.0}, + {0xdd8f, -1288029493427961856.0}, + {0xdea9, -6088866696204910592.0}, + {0xded6, -7710162562058289152.0}, + {0xdedf, -8034421735228964864.0}, + {0xdef6, -8863084066665136128.0}, + {0xdf62, -16285016252571713536.0}, + {0xdf6a, -16861477004875137024.0}, + {0xdf71, -17365880163140632576.0}, + {0xdfc9, -28967152803247030272.0}, + {0xdff0, -34587645138205409280.0}, + {0xdff5, -35308221078584688640.0}, + {0xe037, -52746158835763249152.0}, + {0xe07e, -73210515542534782976.0}, + {0xe09a, -88774955854727217152.0}, + {0xe09d, -90504338111637487616.0}, + {0xe0cc, -117597993469898391552.0}, + {0xe113, -169479461177206505472.0}, + {0xe18f, -329735550317558235136.0}, + {0xe1aa, -391993311566327971840.0}, + {0xe21a, -710199646837817737216.0}, + {0xe233, -825491797298502434816.0}, + {0xe238, -848550227390639374336.0}, + {0xe247, -917725517667050192896.0}, + {0xe262, -1042241040164589666304.0}, + {0xe26a, -1079134528312008769536.0}, + {0xe271, -1111416330441000484864.0}, + {0xe28b, -1282048713122813837312.0}, + {0xe290, -1328165573307087716352.0}, + {0xe2b2, -1641760222560150093824.0}, + {0xe2eb, -2167492428660872314880.0}, + {0xe2f5, -2259726149029420072960.0}, + {0xe34b, -3744689046963038978048.0}, + {0xe363, -4187410904732068216832.0}, + {0xe388, -5017514388048998039552.0}, + {0xe3a0, -5902958103587056517120.0}, + {0xe3bd, -6972869259862210510848.0}, + {0xe3d6, -7895206463547688091648.0}, + {0xe3e4, -8411715297611555536896.0}, + {0xe406, -9887454823508319666176.0}, + {0xe5a3, -96218217088469021229056.0}, + {0xe5ae, -102711471002414783397888.0}, + {0xe5d7, -126913599227121715118080.0}, + {0xe5d9, -128094190847839126421504.0}, + {0xe644, -231395957660612615471104.0}, + {0xe66e, -280980805730743890214912.0}, + {0xe6b8, -434457716424007359660032.0}, + {0xe7f4, -2304514843640386864283648.0}, + {0xe824, -3097872412762487260184576.0}, + {0xe827, -3154540810556923002748928.0}, + {0xe880, -4835703278458516698824704.0}, + {0xe8f2, -9142501510835633133715456.0}, + {0xe928, -12693721105953606334414848.0}, + {0xe980, -19342813113834066795298816.0}, + {0xe9d1, -31583187037432187189198848.0}, + {0xe9fa, -37778931862957161709568000.0}, + {0xea15, -45032486780644936757805056.0}, + {0xea77, -74651169361203351538106368.0}, + {0xeaca, -122101507781077546645323776.0}, + {0xeacd, -123914896510499490407383040.0}, + {0xead9, -131168451428187265455620096.0}, + {0xeada, -131772914337994580042973184.0}, + {0xeb79, -301022529084042664501837824.0}, + {0xeba3, -394109817194369110954213376.0}, + {0xebf3, -587537948332709778907201536.0}, + {0xec09, -662491349148816787738984448.0}, + {0xec13, -710848381933401954727231488.0}, + {0xec48, -967140655691703339764940800.0}, + {0xece9, -2253437727761668781652312064.0}, + {0xed1f, -3075507285099616620452511744.0}, + {0xed24, -3172221350668786954429005824.0}, + {0xed9f, -6151014570199233240905023488.0}, + {0xede6, -8897694032363670725837455360.0}, + {0xedfe, -9826149061827705932011798528.0}, + {0xeea3, -25223028300439623101069656064.0}, + {0xeea5, -25532513310260968169794437120.0}, + {0xeec4, -30329530962491816735028543488.0}, + {0xeee0, -34662321099990647697175478272.0}, + {0xef23, -50446056600879246202139312128.0}, + {0xefa0, -99035203142830421991929937920.0}, + {0xefab, -105843873358900013503875121152.0}, + {0xf020, -198070406285660843983859875840.0}, + {0xf099, -378809652021326364119132012544.0}, + {0xf0a9, -418423733278458532915903987712.0}, + {0xf0cc, -505079536028435152158842683392.0}, + {0xf0e6, -569452418071274926453597143040.0}, + {0xf16b, -1163663636928257458405176770560.0}, + {0xf19b, -1535045648713871540874914037760.0}, + {0xf1bc, -1861861819085211933448282832896.0}, + {0xf1da, -2158967428513703199424072646656.0}, + {0xf231, -3505846191256196938514319802368.0}, + {0xf253, -4179285572627443808059443380224.0}, + {0xf287, -5347900969712842787564216647680.0}, + {0xf296, -5942112188569825319515796275200.0}, + {0xf2f3, -9626221745483117017615589965824.0}, + {0xf339, -14657210065138902454805630812160.0}, + {0xf36e, -18856302678394912347263460179968.0}, + {0xf3b3, -28363682180106632858488734220288.0}, + {0xf3c0, -30423614405477505635920876929024.0}, + {0xf3da, -34543478856219251190785162346496.0}, + {0xf3eb, -37237236381704238668965656657920.0}, + {0xf407, -42783207757702742300513733181440.0}, + {0xf418, -48170722808672717256874721804288.0}, + {0xf425, -52290587259414462811739007221760.0}, + {0xf473, -77009773963864936140924719726592.0}, + {0xf515, -188879939434006180823008777601024.0}, + {0xf57a, -316912650057057350374175801344000.0}, + {0xf594, -375224577667555902843024148791296.0}, + {0xf61c, -791013974542415146533942800154624.0}, + {0xf634, -912708432164325169077626307870720.0}, + {0xf69f, -1612451563490307798703806477238272.0}, + {0xf6b2, -1805134454724998667731305364455424.0}, + {0xf6f0, -2433889152438200450873670154321920.0}, + {0xf71e, -3204620717376963926983665703190528.0}, + {0xf735, -3671116138260952346734452482768896.0}, + {0xf748, -4056481920730334084789450257203200.0}, + {0xf75f, -4522977341614322504540237036781568.0}, + {0xf796, -6084722881095501127184175385804800.0}, + {0xf8a3, -26448262123161778232827215676964864.0}, + {0xf8d0, -33749929580476379585448226139930624.0}, + {0xf8ef, -38779967162181993850587144458862592.0}, + {0xf9a3, -105793048492647112931308862707859456.0}, + {0xfa0d, -183028464263352673905699995605008384.0}, + {0xfa18, -197307280624323449884158860510363648.0}, + {0xfa31, -229759135990166122562474462567989248.0}, + {0xfaa9, -438749084546192934610826939819098112.0}, + {0xfab5, -469902865697401900382009917794418688.0}, + {0xfacd, -532210427999819831924375873745059840.0}, + {0xfb84, -1370766370653194493932051030914105344.0}, + {0xfba8, -1744611744467702083186246766617952256.0}, + {0xfbfa, -2596148429267413814265248164610048000.0}, + {0xfc20, -3323069989462289682259517650700861440.0}, + {0xfc76, -5109220108798270386474008387952574464.0}, + {0xfc93, -6106141105636957291151863683162832896.0}, + {0xfccf, -8598443597733674552846501921188478976.0}, + {0xfcdc, -9138442471021296626213673539427368960.0}, + {0xfcf0, -9969209968386869046778552952102584320.0}, + {0xfd5b, -18193808192306036010370859137587216384.0}, + {0xfda9, -28079941410956347815092924148422279168.0}, + {0xfdca, -33563006893569125790821128272078700544.0}, + {0xfe1d, -52172198834557948011474427116003524608.0}, + {0xfe24, -54498347827181550789056089471494127616.0}, + {0xfe4b, -67458320786084480549868208309227487232.0}, + {0xfe4f, -68787548781869396422772015369507831808.0}, + {0xfe64, -75765995759740204755517002435979640832.0}, + {0xfea2, -107667467658578185705208371882707910656.0}, + {0xfec2, -128935115591136839671669284847193423872.0}, + {0xfee3, -150867377521587951574582101341819109376.0}, + {0xfee9, -154855061508942699193293522522660143104.0}, + {0xff57, -285784019093756912674318517960274083840.0}, + {0xff60, -297747071055821155530452781502797185024.0}, + {0xff8e, std::numeric_limits::quiet_NaN()}, + {0xffb0, std::numeric_limits::quiet_NaN()}, + {0xfffa, std::numeric_limits::quiet_NaN()}, + }; + return result; +} TEST_CASE(check_bf16_values) { - for(auto [x, f] : bf16_lut) + for(auto [x, f] : bf16_lut()) { auto h = migraphx::bit_cast(x); From c0d6bc49facfc46f0fc9f2c4257fe2763b78e36e Mon Sep 17 00:00:00 2001 From: Richa Gadgil Date: Mon, 11 Nov 2024 09:45:00 -0800 Subject: [PATCH 56/72] Update bf16.hpp --- src/include/migraphx/bf16.hpp | 62 ----------------------------------- 1 file changed, 62 deletions(-) diff --git a/src/include/migraphx/bf16.hpp b/src/include/migraphx/bf16.hpp index d39703a9ace..f7139547354 100644 --- a/src/include/migraphx/bf16.hpp +++ b/src/include/migraphx/bf16.hpp @@ -40,66 +40,4 @@ using deduce = typename detail::deduce::type; } // namespace MIGRAPHX_INLINE_NS } // namespace migraphx -namespace std { - -template -struct common_type : std::common_type // NOLINT -{ -}; - -template -struct common_type : std::common_type // NOLINT -{ -}; - -template <> -struct common_type -{ - using type = float; -}; - -template <> -struct common_type -{ - using type = float; -}; - -template <> -struct common_type -{ - using type = float; -}; - -template <> -struct common_type -{ - using type = float; -}; - -template <> -struct common_type -{ - using type = float; -}; - -template <> -struct common_type -{ - using type = float; -}; - -template <> -struct common_type -{ - using type = migraphx::bf16; -}; - -template <> -struct common_type -{ - using type = float; -}; - -} // namespace std - #endif From 7bfc4079713446782a3495b1d145a579c0356cb9 Mon Sep 17 00:00:00 2001 From: Richa Gadgil Date: Mon, 11 Nov 2024 09:47:47 -0800 Subject: [PATCH 57/72] Update generic_float.hpp --- src/include/migraphx/generic_float.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/include/migraphx/generic_float.hpp b/src/include/migraphx/generic_float.hpp index 99dc276cdd9..fd2cc3bc01b 100644 --- a/src/include/migraphx/generic_float.hpp +++ b/src/include/migraphx/generic_float.hpp @@ -53,6 +53,8 @@ struct float32_parts unsigned int exponent : 8; unsigned int sign : 1; + static constexpr unsigned int exponent_width() { return 8; } + static constexpr unsigned int mantissa_width() { return 23; } static constexpr unsigned int max_exponent() { return all_ones<8>(); } @@ -98,7 +100,7 @@ struct __attribute__((packed, may_alias)) generic_float float32_parts f{}; f.sign = sign; - if(exponent == 0 and ExponentSize != 8) // subnormal fps + if(exponent == 0 and ExponentSize != float32_parts::exponent_width()) // subnormal fps { if(mantissa == 0) From ffd4ba2920017ff94aed266001debd017cac4b50 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Mon, 11 Nov 2024 18:17:35 -0600 Subject: [PATCH 58/72] remove imports --- src/include/migraphx/bf16.hpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/include/migraphx/bf16.hpp b/src/include/migraphx/bf16.hpp index f7139547354..26ecdd7c996 100644 --- a/src/include/migraphx/bf16.hpp +++ b/src/include/migraphx/bf16.hpp @@ -25,18 +25,14 @@ #ifndef MIGRAPHX_GUARD_RTGLIB_BF16_HPP #define MIGRAPHX_GUARD_RTGLIB_BF16_HPP -#include +#include #include -#include namespace migraphx { inline namespace MIGRAPHX_INLINE_NS { using bf16 = migraphx::generic_float<7, 8>; -template -using deduce = typename detail::deduce::type; - } // namespace MIGRAPHX_INLINE_NS } // namespace migraphx From 1565a0ee199b4553a1c8eb150ba4a92ae24f0279 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Wed, 13 Nov 2024 00:01:42 +0000 Subject: [PATCH 59/72] ref tests --- src/api/include/migraphx/migraphx.h | 1 + src/include/migraphx/shape.hpp | 4 +++- src/include/migraphx/type_traits.hpp | 5 +++++ test/ref/add.cpp | 19 +++++++++++++++++++ test/ref/isinf.cpp | 19 +++++++++++++++++++ tools/api/migraphx.h | 1 + 6 files changed, 48 insertions(+), 1 deletion(-) diff --git a/src/api/include/migraphx/migraphx.h b/src/api/include/migraphx/migraphx.h index 90ba7c3e017..9d3fddd5a6d 100644 --- a/src/api/include/migraphx/migraphx.h +++ b/src/api/include/migraphx/migraphx.h @@ -35,6 +35,7 @@ #define MIGRAPHX_SHAPE_VISIT_TYPES(m) \ m(bool_type, bool) \ m(half_type, half) \ + m(bf16_type, bf16) \ m(float_type, float) \ m(double_type, double) \ m(uint8_type, uint8_t) \ diff --git a/src/include/migraphx/shape.hpp b/src/include/migraphx/shape.hpp index e15c4dece44..5f7f5abbef2 100644 --- a/src/include/migraphx/shape.hpp +++ b/src/include/migraphx/shape.hpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -52,6 +53,7 @@ struct MIGRAPHX_EXPORT shape #define MIGRAPHX_SHAPE_VISIT_TYPES(m) \ m(bool_type, bool) \ m(half_type, half) \ + m(bf16_type, bf16) \ m(float_type, float) \ m(double_type, double) \ m(uint8_type, uint8_t) \ @@ -65,7 +67,7 @@ struct MIGRAPHX_EXPORT shape m(fp8e4m3fnuz_type, migraphx::fp8::fp8e4m3fnuz) \ m(fp8e4m3fn_type, migraphx::fp8::fp8e4m3fn) \ m(fp8e5m2_type, migraphx::fp8::fp8e5m2) -// clang-format on + // clang-format on #define MIGRAPHX_SHAPE_GENERATE_ENUM_TYPES(x, t) x, enum type_t diff --git a/src/include/migraphx/type_traits.hpp b/src/include/migraphx/type_traits.hpp index 908f67d9f14..ff6f9225d6a 100644 --- a/src/include/migraphx/type_traits.hpp +++ b/src/include/migraphx/type_traits.hpp @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -53,6 +54,10 @@ MIGRAPHX_DETAIL_EXTEND_TRAIT_FOR(is_floating_point, half) MIGRAPHX_DETAIL_EXTEND_TRAIT_FOR(is_signed, half) MIGRAPHX_DETAIL_EXTEND_TRAIT_FOR(is_arithmetic, half) +MIGRAPHX_DETAIL_EXTEND_TRAIT_FOR(is_floating_point, bf16) +MIGRAPHX_DETAIL_EXTEND_TRAIT_FOR(is_signed, bf16) +MIGRAPHX_DETAIL_EXTEND_TRAIT_FOR(is_arithmetic, bf16) + MIGRAPHX_DETAIL_EXTEND_TRAIT_FOR(is_floating_point, migraphx::fp8::fp8e4m3fnuz) MIGRAPHX_DETAIL_EXTEND_TRAIT_FOR(is_signed, migraphx::fp8::fp8e4m3fnuz) MIGRAPHX_DETAIL_EXTEND_TRAIT_FOR(is_arithmetic, migraphx::fp8::fp8e4m3fnuz) diff --git a/test/ref/add.cpp b/test/ref/add.cpp index ec9b7a2c40e..525e74dfa11 100644 --- a/test/ref/add.cpp +++ b/test/ref/add.cpp @@ -137,6 +137,25 @@ TEST_CASE(fp16_test) EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } +TEST_CASE(bf16_test) +{ + migraphx::program p; + auto* mm = p.get_main_module(); + migraphx::shape s{migraphx::shape::bf16_type, {1}}; + migraphx::bf16 a{1.5}; + migraphx::bf16 b{2.5}; + migraphx::bf16 c{4.0}; + auto l0 = mm->add_literal(migraphx::literal{s, {a}}); + auto l1 = mm->add_literal(migraphx::literal{s, {b}}); + mm->add_instruction(migraphx::make_op("add"), l0, l1); + p.compile(migraphx::make_target("ref")); + auto result = p.eval({}).back(); + std::vector results_vector(1); + result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); + std::vector gold{c}; + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); +} + TEST_CASE(fp32_fp16_test) { auto create_program = [] { diff --git a/test/ref/isinf.cpp b/test/ref/isinf.cpp index 900ebc13fda..4d86e7f1b27 100644 --- a/test/ref/isinf.cpp +++ b/test/ref/isinf.cpp @@ -83,6 +83,25 @@ TEST_CASE(isinf_half_test) EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } +TEST_CASE(isinf_bf16_test) +{ + migraphx::program p; + auto* mm = p.get_main_module(); + migraphx::shape s{migraphx::shape::bf16_type, {2, 3}}; + auto inf_val = std::numeric_limits::infinity(); + migraphx::bf16 a{1.2}; + migraphx::bf16 b{5.2}; + std::vector data0 = {a, b, inf_val, -inf_val, b, a}; + auto l1 = mm->add_literal(migraphx::literal{s, data0}); + mm->add_instruction(migraphx::make_op("isinf"), l1); + p.compile(migraphx::make_target("ref")); + auto result = p.eval({}).back(); + std::vector results_vector; + result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); + std::vector gold = {0, 0, 1, 1, 0, 0}; + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); +} + TEST_CASE(isinf_dyn_test) { migraphx::program p; diff --git a/tools/api/migraphx.h b/tools/api/migraphx.h index 4ce7ea1d07b..b87cbc303cf 100644 --- a/tools/api/migraphx.h +++ b/tools/api/migraphx.h @@ -35,6 +35,7 @@ #define MIGRAPHX_SHAPE_VISIT_TYPES(m) \ m(bool_type, bool) \ m(half_type, half) \ + m(bf16_type, bf16) \ m(float_type, float) \ m(double_type, double) \ m(uint8_type, uint8_t) \ From e6d1155766c5c249567c068b9dfb4f8825a7dcf9 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Wed, 13 Nov 2024 18:49:21 +0000 Subject: [PATCH 60/72] migraphx_py fix --- src/py/migraphx_py.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/py/migraphx_py.cpp b/src/py/migraphx_py.cpp index 9d05e32e67d..3384aecce89 100644 --- a/src/py/migraphx_py.cpp +++ b/src/py/migraphx_py.cpp @@ -180,6 +180,17 @@ struct npy_format_descriptor static constexpr auto name() { return _("fp8e5m2"); } }; +template <> +struct npy_format_descriptor +{ + static std::string format() + { + // TODO: no standard format in numpy for bf16 + return "z"; + } + static constexpr auto name() { return _("bf16"); } +}; + } // namespace detail } // namespace pybind11 From 867e9605a3f46d09925aa1b7a3ddf5b800757d08 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Wed, 13 Nov 2024 19:49:10 +0000 Subject: [PATCH 61/72] fix test cae by index --- test/op_shape_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/op_shape_test.cpp b/test/op_shape_test.cpp index 8d08455d814..96cc884ae7c 100644 --- a/test/op_shape_test.cpp +++ b/test/op_shape_test.cpp @@ -2166,7 +2166,7 @@ TEST_CASE(multinomial) migraphx::shape s1{migraphx::shape::float_type, {1, 2}}; migraphx::shape s2{migraphx::shape::float_type, {3, 4}}; migraphx::shape s3{migraphx::shape::float_type, {1, 4}}; - int dtype = 2; + int dtype = 3; expect_shape(s3, migraphx::make_op("multinomial", {{"dtype", dtype}}), s1, s2); } @@ -2175,7 +2175,7 @@ TEST_CASE(multinomial_0size_input) { migraphx::shape s1{migraphx::shape::float_type, {1, 2}}; migraphx::shape s2{migraphx::shape::float_type, {}}; - int dtype = 2; + int dtype = 3; throws_shape(migraphx::make_op("multinomial", {{"dtype", dtype}}), s1, s2); } From 9852da5f1667c8395496acf62a464c77fe84e69e Mon Sep 17 00:00:00 2001 From: richagadgil Date: Wed, 13 Nov 2024 20:31:20 +0000 Subject: [PATCH 62/72] add rocblas type --- src/targets/gpu/gemm_impl.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/targets/gpu/gemm_impl.cpp b/src/targets/gpu/gemm_impl.cpp index 19d4f056deb..a1b624e2c36 100644 --- a/src/targets/gpu/gemm_impl.cpp +++ b/src/targets/gpu/gemm_impl.cpp @@ -59,6 +59,7 @@ rocblas_datatype get_type(shape::type_t type) case shape::double_type: return rocblas_datatype_f64_r; case shape::float_type: return rocblas_datatype_f32_r; case shape::half_type: return rocblas_datatype_f16_r; + case shape::bf16_type: return rocblas_datatype_bf16_r; case shape::int8_type: return rocblas_datatype_i8_r; case shape::uint8_type: return rocblas_datatype_u8_r; case shape::int32_type: return rocblas_datatype_i32_r; From bf50653547e8d3e425e1fa4e20aa98e986a2ac97 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Wed, 13 Nov 2024 21:21:14 +0000 Subject: [PATCH 63/72] fix tgts err --- src/targets/gpu/hip_gemm_impl.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/targets/gpu/hip_gemm_impl.cpp b/src/targets/gpu/hip_gemm_impl.cpp index f5ec898d8d5..c37051837ac 100644 --- a/src/targets/gpu/hip_gemm_impl.cpp +++ b/src/targets/gpu/hip_gemm_impl.cpp @@ -65,6 +65,7 @@ hipDataType get_type_hipblas(shape::type_t type) case shape::double_type: return HIP_R_64F; case shape::float_type: return HIP_R_32F; case shape::half_type: return HIP_R_16F; + case shape::bf16_type: return HIP_R_16BF; case shape::int8_type: return HIP_R_8I; case shape::uint8_type: return HIP_R_8U; case shape::int32_type: return HIP_R_32I; From 0ebd22044b2734a2f16fe29b7dde7d05626e964b Mon Sep 17 00:00:00 2001 From: richagadgil Date: Mon, 18 Nov 2024 17:47:26 +0000 Subject: [PATCH 64/72] address changes --- src/api/include/migraphx/migraphx.h | 4 ++-- src/include/migraphx/shape.hpp | 4 ++-- src/targets/gpu/gemm_impl.cpp | 2 +- src/targets/gpu/hip_gemm_impl.cpp | 2 +- test/op_shape_test.cpp | 4 ++-- tools/api/migraphx.h | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/api/include/migraphx/migraphx.h b/src/api/include/migraphx/migraphx.h index 9d3fddd5a6d..cdc5bf3e9a5 100644 --- a/src/api/include/migraphx/migraphx.h +++ b/src/api/include/migraphx/migraphx.h @@ -35,7 +35,6 @@ #define MIGRAPHX_SHAPE_VISIT_TYPES(m) \ m(bool_type, bool) \ m(half_type, half) \ - m(bf16_type, bf16) \ m(float_type, float) \ m(double_type, double) \ m(uint8_type, uint8_t) \ @@ -48,7 +47,8 @@ m(uint64_type, uint64_t) \ m(fp8e4m3fnuz_type, migraphx::fp8::fp8e4m3fnuz) \ m(fp8e4m3fn_type, migraphx::fp8::fp8e4m3fn) \ - m(fp8e5m2_type, migraphx::fp8::fp8e5m2) + m(fp8e5m2_type, migraphx::fp8::fp8e5m2) \ + m(bf16_type, bf16) // clang-format on #ifdef __cplusplus diff --git a/src/include/migraphx/shape.hpp b/src/include/migraphx/shape.hpp index 5f7f5abbef2..d5004f63bc9 100644 --- a/src/include/migraphx/shape.hpp +++ b/src/include/migraphx/shape.hpp @@ -53,7 +53,6 @@ struct MIGRAPHX_EXPORT shape #define MIGRAPHX_SHAPE_VISIT_TYPES(m) \ m(bool_type, bool) \ m(half_type, half) \ - m(bf16_type, bf16) \ m(float_type, float) \ m(double_type, double) \ m(uint8_type, uint8_t) \ @@ -66,7 +65,8 @@ struct MIGRAPHX_EXPORT shape m(uint64_type, uint64_t) \ m(fp8e4m3fnuz_type, migraphx::fp8::fp8e4m3fnuz) \ m(fp8e4m3fn_type, migraphx::fp8::fp8e4m3fn) \ - m(fp8e5m2_type, migraphx::fp8::fp8e5m2) + m(fp8e5m2_type, migraphx::fp8::fp8e5m2) \ + m(bf16_type, bf16) // clang-format on #define MIGRAPHX_SHAPE_GENERATE_ENUM_TYPES(x, t) x, diff --git a/src/targets/gpu/gemm_impl.cpp b/src/targets/gpu/gemm_impl.cpp index a1b624e2c36..1ec27925fc8 100644 --- a/src/targets/gpu/gemm_impl.cpp +++ b/src/targets/gpu/gemm_impl.cpp @@ -59,7 +59,6 @@ rocblas_datatype get_type(shape::type_t type) case shape::double_type: return rocblas_datatype_f64_r; case shape::float_type: return rocblas_datatype_f32_r; case shape::half_type: return rocblas_datatype_f16_r; - case shape::bf16_type: return rocblas_datatype_bf16_r; case shape::int8_type: return rocblas_datatype_i8_r; case shape::uint8_type: return rocblas_datatype_u8_r; case shape::int32_type: return rocblas_datatype_i32_r; @@ -73,6 +72,7 @@ rocblas_datatype get_type(shape::type_t type) case shape::int16_type: case shape::int64_type: case shape::uint64_type: MIGRAPHX_THROW("ROCBLAS_GEMM: data type not supported!"); + case shape::bf16_type: return rocblas_datatype_bf16_r; } MIGRAPHX_THROW("ROCBLAS_GEMM: data type not supported!"); diff --git a/src/targets/gpu/hip_gemm_impl.cpp b/src/targets/gpu/hip_gemm_impl.cpp index c37051837ac..2361d3cc609 100644 --- a/src/targets/gpu/hip_gemm_impl.cpp +++ b/src/targets/gpu/hip_gemm_impl.cpp @@ -65,7 +65,6 @@ hipDataType get_type_hipblas(shape::type_t type) case shape::double_type: return HIP_R_64F; case shape::float_type: return HIP_R_32F; case shape::half_type: return HIP_R_16F; - case shape::bf16_type: return HIP_R_16BF; case shape::int8_type: return HIP_R_8I; case shape::uint8_type: return HIP_R_8U; case shape::int32_type: return HIP_R_32I; @@ -79,6 +78,7 @@ hipDataType get_type_hipblas(shape::type_t type) case shape::int16_type: case shape::int64_type: case shape::uint64_type: MIGRAPHX_THROW("HIPBLAS_GEMM: data type not supported!"); + case shape::bf16_type: return HIP_R_16BF; } MIGRAPHX_THROW("HIPBLAS_GEMM: data type not supported!"); diff --git a/test/op_shape_test.cpp b/test/op_shape_test.cpp index 96cc884ae7c..8d08455d814 100644 --- a/test/op_shape_test.cpp +++ b/test/op_shape_test.cpp @@ -2166,7 +2166,7 @@ TEST_CASE(multinomial) migraphx::shape s1{migraphx::shape::float_type, {1, 2}}; migraphx::shape s2{migraphx::shape::float_type, {3, 4}}; migraphx::shape s3{migraphx::shape::float_type, {1, 4}}; - int dtype = 3; + int dtype = 2; expect_shape(s3, migraphx::make_op("multinomial", {{"dtype", dtype}}), s1, s2); } @@ -2175,7 +2175,7 @@ TEST_CASE(multinomial_0size_input) { migraphx::shape s1{migraphx::shape::float_type, {1, 2}}; migraphx::shape s2{migraphx::shape::float_type, {}}; - int dtype = 3; + int dtype = 2; throws_shape(migraphx::make_op("multinomial", {{"dtype", dtype}}), s1, s2); } diff --git a/tools/api/migraphx.h b/tools/api/migraphx.h index b87cbc303cf..df89fee6c37 100644 --- a/tools/api/migraphx.h +++ b/tools/api/migraphx.h @@ -35,7 +35,6 @@ #define MIGRAPHX_SHAPE_VISIT_TYPES(m) \ m(bool_type, bool) \ m(half_type, half) \ - m(bf16_type, bf16) \ m(float_type, float) \ m(double_type, double) \ m(uint8_type, uint8_t) \ @@ -48,7 +47,8 @@ m(uint64_type, uint64_t) \ m(fp8e4m3fnuz_type, migraphx::fp8::fp8e4m3fnuz) \ m(fp8e4m3fn_type, migraphx::fp8::fp8e4m3fn) \ - m(fp8e5m2_type, migraphx::fp8::fp8e5m2) + m(fp8e5m2_type, migraphx::fp8::fp8e5m2) \ + m(bf16_type, bf16) // clang-format on #ifdef __cplusplus From 1aae73f42f558f8ab3e6529abfad3f1b78617928 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Mon, 18 Nov 2024 13:11:50 -0600 Subject: [PATCH 65/72] start onnx verify test support --- src/onnx/onnx_parser.cpp | 2 +- test/onnx/add_bf16_test.onnx | 16 ++++++++++ test/onnx/gen_onnx.py | 14 +++++++++ test/onnx/verify/add_bf16_test.cpp | 49 ++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 test/onnx/add_bf16_test.onnx create mode 100644 test/onnx/verify/add_bf16_test.cpp diff --git a/src/onnx/onnx_parser.cpp b/src/onnx/onnx_parser.cpp index d7fd8367f2f..450461b6724 100644 --- a/src/onnx/onnx_parser.cpp +++ b/src/onnx/onnx_parser.cpp @@ -687,7 +687,7 @@ shape::type_t get_type(int dtype) case 22: return shape::int8_type; case 14: case 15: - case 16: + case 16: return shape::bf16_type; case 17: case 19: case 20: diff --git a/test/onnx/add_bf16_test.onnx b/test/onnx/add_bf16_test.onnx new file mode 100644 index 00000000000..36e4efefd46 --- /dev/null +++ b/test/onnx/add_bf16_test.onnx @@ -0,0 +1,16 @@ +  add_bf16_test:R + +0 +12"Add add_bf16_testZ +0 + + +Z +1 + + +b +2 + + +B \ No newline at end of file diff --git a/test/onnx/gen_onnx.py b/test/onnx/gen_onnx.py index 05713398294..4b73b518e74 100644 --- a/test/onnx/gen_onnx.py +++ b/test/onnx/gen_onnx.py @@ -138,6 +138,20 @@ def add_fp8_test(): return ([node], [x, y], [z]) +@onnx_test() +def add_bf16_test(): + x = helper.make_tensor_value_info('0', TensorProto.BFLOAT16, [1]) + y = helper.make_tensor_value_info('1', TensorProto.BFLOAT16, [1]) + z = helper.make_tensor_value_info('2', TensorProto.BFLOAT16, [1]) + + node = onnx.helper.make_node( + 'Add', + inputs=['0', '1'], + outputs=['2'], + ) + + return ([node], [x, y], [z]) + @onnx_test() def add_scalar_test(): diff --git a/test/onnx/verify/add_bf16_test.cpp b/test/onnx/verify/add_bf16_test.cpp new file mode 100644 index 00000000000..705358415b3 --- /dev/null +++ b/test/onnx/verify/add_bf16_test.cpp @@ -0,0 +1,49 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include +#include +#include + +TEST_CASE(add_bf16_test) +{ + auto p = optimize_onnx("add_bf16_test.onnx"); + p.compile(migraphx::make_target("ref")); + + migraphx::shape s{migraphx::shape::bf16_type, {1}}; + + migraphx::parameter_map pp; + migraphx::literal l1{s, {3.25}}; + migraphx::literal l2{s, {2.25}}; + pp["0"] = l1.get_argument(); + pp["1"] = l2.get_argument(); + + auto result = p.eval(pp).back(); + std::vector result_vector; + result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); }); + std::vector gold{static_cast(5.5)}; + + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); +} From cb3f77f4fcf9bb2be1fa7a801e82de1136ab6b72 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Mon, 18 Nov 2024 13:52:53 -0600 Subject: [PATCH 66/72] add parse --- test/onnx/parse/add_bf16_test.cpp | 39 +++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 test/onnx/parse/add_bf16_test.cpp diff --git a/test/onnx/parse/add_bf16_test.cpp b/test/onnx/parse/add_bf16_test.cpp new file mode 100644 index 00000000000..79bf5e2c4b3 --- /dev/null +++ b/test/onnx/parse/add_bf16_test.cpp @@ -0,0 +1,39 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +TEST_CASE(add_bf16_test) +{ + migraphx::program p; + auto* mm = p.get_main_module(); + auto p0 = mm->add_parameter("0", migraphx::shape{migraphx::shape::bf16_type, {1}}); + auto p1 = mm->add_parameter("1", migraphx::shape{migraphx::shape::bf16_type, {1}}); + + mm->add_instruction(migraphx::make_op("add"), p0, p1); + + auto prog = optimize_onnx("add_bf16_test.onnx"); + + EXPECT(p == prog); +} From b775dee544ac7bbd75d208e2b76e9ffc7e86efb0 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Fri, 22 Nov 2024 12:02:50 -0600 Subject: [PATCH 67/72] add mean test --- test/onnx/gen_onnx.py | 16 +++++++++++ test/onnx/mean_bf16_test.onnx | 25 ++++++++++++++++ test/onnx/parse/mean_bf16_test.cpp | 46 ++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 test/onnx/mean_bf16_test.onnx create mode 100644 test/onnx/parse/mean_bf16_test.cpp diff --git a/test/onnx/gen_onnx.py b/test/onnx/gen_onnx.py index 4b73b518e74..3e72fdf6bb3 100644 --- a/test/onnx/gen_onnx.py +++ b/test/onnx/gen_onnx.py @@ -7576,6 +7576,22 @@ def mean_fp16_test(): return ([node], [data_0, data_1, data_2], [mean]) +@onnx_test() +def mean_bf16_test(): + data_0 = helper.make_tensor_value_info('0', TensorProto.BFLOAT16, [1, 2, 3]) + data_1 = helper.make_tensor_value_info('1', TensorProto.BFLOAT16, [1, 2, 3]) + data_2 = helper.make_tensor_value_info('2', TensorProto.BFLOAT16, [1, 2, 3]) + + mean = helper.make_tensor_value_info('mean', TensorProto.BFLOAT16, + [1, 2, 3]) + + node = onnx.helper.make_node("Mean", + inputs=["0", "1", "2"], + outputs=["mean"]) + + return ([node], [data_0, data_1, data_2], [mean]) + + @onnx_test() def mean_invalid_broadcast_test(): data_0 = helper.make_tensor_value_info('0', TensorProto.FLOAT, [1, 2, 3]) diff --git a/test/onnx/mean_bf16_test.onnx b/test/onnx/mean_bf16_test.onnx new file mode 100644 index 00000000000..7bb6a71dc16 --- /dev/null +++ b/test/onnx/mean_bf16_test.onnx @@ -0,0 +1,25 @@ + mean_bf16_test:Ž + +0 +1 +2mean"Meanmean_bf16_testZ +0 + + + +Z +1 + + + +Z +2 + + + +b +mean + + + +B \ No newline at end of file diff --git a/test/onnx/parse/mean_bf16_test.cpp b/test/onnx/parse/mean_bf16_test.cpp new file mode 100644 index 00000000000..b87f69c7b61 --- /dev/null +++ b/test/onnx/parse/mean_bf16_test.cpp @@ -0,0 +1,46 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +TEST_CASE(mean_bf16_test) +{ + const std::size_t num_data = 3; + migraphx::program p; + auto* mm = p.get_main_module(); + migraphx::shape s{migraphx::shape::bf16_type, {1, 2, 3}}; + auto data0 = mm->add_parameter("0", s); + auto data1 = mm->add_parameter("1", s); + auto data2 = mm->add_parameter("2", s); + auto add1 = mm->add_instruction(migraphx::make_op("add"), data0, data1); + auto mean = mm->add_instruction(migraphx::make_op("add"), add1, data2); + auto div_lit = mm->add_literal(migraphx::literal{migraphx::shape{s.type()}, {num_data}}); + auto divisor = + mm->add_instruction(migraphx::make_op("multibroadcast", {{"out_lens", s.lens()}}), div_lit); + mean = mm->add_instruction(migraphx::make_op("div"), mean, divisor); + + auto prog = optimize_onnx("mean_bf16_test.onnx"); + + EXPECT(p == prog); +} From dc4c38d661d7c6fda1358666d37e91d8f9b25e30 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Fri, 22 Nov 2024 12:09:47 -0600 Subject: [PATCH 68/72] mmvn_default_axes_bf16_test --- test/onnx/gen_onnx.py | 3 ++ test/onnx/mvn_default_axes_bf16_test.onnx | 15 ++++++ .../verify/mvn_default_axes_bf16_test.cpp | 51 +++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 test/onnx/mvn_default_axes_bf16_test.onnx create mode 100644 test/onnx/verify/mvn_default_axes_bf16_test.cpp diff --git a/test/onnx/gen_onnx.py b/test/onnx/gen_onnx.py index 3e72fdf6bb3..ef3b2092a84 100644 --- a/test/onnx/gen_onnx.py +++ b/test/onnx/gen_onnx.py @@ -7664,6 +7664,9 @@ def mvn_default_axes_test(): def mvn_default_axes_fp16_test(): return mvn_default_axes_test_base([2, 2, 2, 2], TensorProto.FLOAT16) +@onnx_test() +def mvn_default_axes_bf16_test(): + return mvn_default_axes_test_base([2, 2, 2, 2], TensorProto.BFLOAT16) @onnx_test() def mvn_default_axes_rank_too_small_test(): diff --git a/test/onnx/mvn_default_axes_bf16_test.onnx b/test/onnx/mvn_default_axes_bf16_test.onnx new file mode 100644 index 00000000000..3f590bf2e65 --- /dev/null +++ b/test/onnx/mvn_default_axes_bf16_test.onnx @@ -0,0 +1,15 @@ + mvn_default_axes_bf16_test:ƒ +& +dataout"MeanVarianceNormalizationmvn_default_axes_bf16_testZ +data + + + + +b +out + + + + +B \ No newline at end of file diff --git a/test/onnx/verify/mvn_default_axes_bf16_test.cpp b/test/onnx/verify/mvn_default_axes_bf16_test.cpp new file mode 100644 index 00000000000..2a76a81a6ba --- /dev/null +++ b/test/onnx/verify/mvn_default_axes_bf16_test.cpp @@ -0,0 +1,51 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include +#include +#include + +TEST_CASE(mvn_default_axes_bf16_test) +{ + using migraphx::bf16; + auto result = mvn_test({2, 2, 2, 2}, read_onnx("mvn_default_axes_bf16_test.onnx")); + std::vector gold{bf16{-1.324}, + bf16{-1.084}, + bf16{-0.843}, + bf16{-0.602}, + bf16{-1.324}, + bf16{-1.084}, + bf16{-0.843}, + bf16{-0.602}, + bf16{0.602}, + bf16{0.843}, + bf16{1.084}, + bf16{1.324}, + bf16{0.602}, + bf16{0.843}, + bf16{1.084}, + bf16{1.324}}; + EXPECT(migraphx::verify::verify_rms_range(result, gold)); +} From e7935e0339e8b90d18a684d43a6f2a6720d7a2d3 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Fri, 22 Nov 2024 12:29:38 -0600 Subject: [PATCH 69/72] mvn tests --- test/onnx/gen_onnx.py | 6 +++ test/onnx/mvn_rank_2_bf16_test.onnx | 12 ++++++ test/onnx/mvn_rank_3_bf16_test.onnx | Bin 0 -> 163 bytes test/onnx/verify/mvn_rank_2_bf16_test.cpp | 36 ++++++++++++++++++ test/onnx/verify/mvn_rank_3_bf16_test.cpp | 43 ++++++++++++++++++++++ 5 files changed, 97 insertions(+) create mode 100644 test/onnx/mvn_rank_2_bf16_test.onnx create mode 100644 test/onnx/mvn_rank_3_bf16_test.onnx create mode 100644 test/onnx/verify/mvn_rank_2_bf16_test.cpp create mode 100644 test/onnx/verify/mvn_rank_3_bf16_test.cpp diff --git a/test/onnx/gen_onnx.py b/test/onnx/gen_onnx.py index ef3b2092a84..a1a077172f5 100644 --- a/test/onnx/gen_onnx.py +++ b/test/onnx/gen_onnx.py @@ -7698,6 +7698,9 @@ def mvn_rank_2_test(): def mvn_rank_2_fp16_test(): return mvn_n_rank_test_base([1], [2, 2], TensorProto.FLOAT16) +@onnx_test() +def mvn_rank_2_bf16_test(): + return mvn_n_rank_test_base([1], [2, 2], TensorProto.BFLOAT16) @onnx_test() def mvn_rank_3_test(): @@ -7708,6 +7711,9 @@ def mvn_rank_3_test(): def mvn_rank_3_fp16_test(): return mvn_n_rank_test_base([0, 1], [2, 2, 2], TensorProto.FLOAT16) +@onnx_test() +def mvn_rank_3_bf16_test(): + return mvn_n_rank_test_base([0, 1], [2, 2, 2], TensorProto.BFLOAT16) @onnx_test() def mvn_axes_rank_too_small_test(): diff --git a/test/onnx/mvn_rank_2_bf16_test.onnx b/test/onnx/mvn_rank_2_bf16_test.onnx new file mode 100644 index 00000000000..e39c31cc56a --- /dev/null +++ b/test/onnx/mvn_rank_2_bf16_test.onnx @@ -0,0 +1,12 @@ + mvn_rank_2_bf16_test:z +3 +dataout"MeanVarianceNormalization* +axes@ mvn_rank_2_bf16_testZ +data +  + +b +out +  + +B \ No newline at end of file diff --git a/test/onnx/mvn_rank_3_bf16_test.onnx b/test/onnx/mvn_rank_3_bf16_test.onnx new file mode 100644 index 0000000000000000000000000000000000000000..f2df467ccbf26010b46c29841a19e35792c05226 GIT binary patch literal 163 zcmdb1uEiSQYVdOI9Vo6CXNfctvFD+4$^i5673rj4@ zOw3D8^~*2HP0Y!xN-W9D&(q@NVo9t>Ep}jVU|hh+j@`T{DX3vWTml>dLOfhd9855r QB*_J`LI{hL6O({2020h5;Q#;t literal 0 HcmV?d00001 diff --git a/test/onnx/verify/mvn_rank_2_bf16_test.cpp b/test/onnx/verify/mvn_rank_2_bf16_test.cpp new file mode 100644 index 00000000000..fca3312a810 --- /dev/null +++ b/test/onnx/verify/mvn_rank_2_bf16_test.cpp @@ -0,0 +1,36 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include +#include +#include + +TEST_CASE(mvn_rank_2_bf16_test) +{ + using migraphx::bf16; + auto result = mvn_test({2, 2}, read_onnx("mvn_rank_2_bf16_test.onnx")); + std::vector gold{bf16{-1}, bf16{1}, bf16{-1}, bf16{1}}; + EXPECT(migraphx::verify::verify_rms_range(result, gold)); +} diff --git a/test/onnx/verify/mvn_rank_3_bf16_test.cpp b/test/onnx/verify/mvn_rank_3_bf16_test.cpp new file mode 100644 index 00000000000..a785e40fff8 --- /dev/null +++ b/test/onnx/verify/mvn_rank_3_bf16_test.cpp @@ -0,0 +1,43 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include +#include +#include + +TEST_CASE(mvn_rank_3_bf16_test) +{ + using migraphx::bf16; + auto result = mvn_test({2, 2, 2}, read_onnx("mvn_rank_3_bf16_test.onnx")); + std::vector gold{bf16{-1.342}, + bf16{-1.342}, + bf16{-0.4473}, + bf16{-0.4473}, + bf16{0.4473}, + bf16{0.4473}, + bf16{1.342}, + bf16{1.342}}; + EXPECT(migraphx::verify::verify_rms_range(result, gold)); +} From 02e381785ca26d0f9701de365aee5e7a0504ca12 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Fri, 22 Nov 2024 18:38:56 -0600 Subject: [PATCH 70/72] working tests --- src/onnx/onnx_parser.cpp | 2 +- src/onnx/parse_instancenorm.cpp | 2 +- test/onnx/eyelike_bf16_test.onnx | 11 + test/onnx/gemm_bf16_test.onnx | Bin 0 -> 193 bytes test/onnx/gen_onnx.py | 392 ++++++++++++++++++ test/onnx/gridsample_bf16_test.onnx | Bin 0 -> 236 bytes test/onnx/group_norm_3d_bf16_test.onnx | 26 ++ test/onnx/group_norm_4d_bf16_test.onnx | 28 ++ test/onnx/group_norm_5d_bf16_test.onnx | 30 ++ test/onnx/group_norm_small_eps_bf16_test.onnx | 26 ++ test/onnx/hardsigmoid_bf16_test.onnx | 15 + test/onnx/imagescaler_bf16_test.onnx | Bin 0 -> 177 bytes test/onnx/instance_norm_bf16_test.onnx | 25 ++ .../instance_norm_dyn_batch_bf16_test.onnx | Bin 0 -> 204 bytes test/onnx/isinf_bf16_test.onnx | 11 + test/onnx/isnan_bf16_test.onnx | 11 + test/onnx/layer_norm_3d_bf16_test.onnx | 24 ++ test/onnx/layer_norm_4d_bf16_test.onnx | 26 ++ test/onnx/layer_norm_small_eps_bf16_test.onnx | 17 + test/onnx/mod_test_fmod_bf16.onnx | 20 + ..._kd_mean_reduction_bf16_weighted_test.onnx | 25 ++ ...kd_mean_reduction_bf16_weighted_test2.onnx | 23 + test/onnx/parse/eyelike_bf16_test.cpp | 46 ++ test/onnx/parse/group_norm_4d_bf16_test.cpp | 34 ++ test/onnx/parse/group_norm_5d_bf16_test.cpp | 39 ++ .../parse/group_norm_small_eps_bf16_test.cpp | 34 ++ test/onnx/parse/hardsigmoid_bf16_test.cpp | 58 +++ test/onnx/parse/imagescaler_bf16_test.cpp | 47 +++ test/onnx/parse/instance_norm_bf16_test.cpp | 63 +++ .../instance_norm_dyn_batch_bf16_test.cpp | 64 +++ test/onnx/parse/isinf_bf16_test.cpp | 38 ++ test/onnx/parse/isnan_bf16_test.cpp | 38 ++ test/onnx/parse/layer_norm_3d_bf16_test.cpp | 35 ++ test/onnx/parse/layer_norm_4d_bf16_test.cpp | 35 ++ .../parse/layer_norm_small_eps_bf16_test.cpp | 35 ++ test/onnx/parse/mod_test_fmod_bf16.cpp | 38 ++ test/onnx/parse/size_bf16_test.cpp | 36 ++ test/onnx/round_bf16_test.onnx | 11 + test/onnx/size_bf16_test.onnx | 11 + ...tropyloss_2d_mean_reduction_bf16_test.onnx | 17 + ..._2d_mean_reduction_bf16_weighted_test.onnx | 22 + ...entropyloss_2d_no_reduction_bf16_test.onnx | 17 + ...ss_2d_no_reduction_bf16_weighted_test.onnx | 22 + ...ntropyloss_2d_sum_reduction_bf16_test.onnx | 17 + ...s_2d_sum_reduction_bf16_weighted_test.onnx | 22 + ..._kd_mean_reduction_bf16_weighted_test.onnx | 25 ++ test/onnx/verify/gemm_bf16_test.cpp | 71 ++++ test/onnx/verify/gridsample_bf16_test.cpp | 61 +++ test/onnx/verify/group_norm_3d_bf16_test.cpp | 46 ++ test/onnx/verify/isinf_bf16_test.cpp | 50 +++ test/onnx/verify/layer_norm_3d_bf16_test.cpp | 46 ++ test/onnx/verify/round_bf16_test.cpp | 64 +++ 52 files changed, 1854 insertions(+), 2 deletions(-) create mode 100644 test/onnx/eyelike_bf16_test.onnx create mode 100644 test/onnx/gemm_bf16_test.onnx create mode 100644 test/onnx/gridsample_bf16_test.onnx create mode 100644 test/onnx/group_norm_3d_bf16_test.onnx create mode 100644 test/onnx/group_norm_4d_bf16_test.onnx create mode 100644 test/onnx/group_norm_5d_bf16_test.onnx create mode 100644 test/onnx/group_norm_small_eps_bf16_test.onnx create mode 100644 test/onnx/hardsigmoid_bf16_test.onnx create mode 100644 test/onnx/imagescaler_bf16_test.onnx create mode 100644 test/onnx/instance_norm_bf16_test.onnx create mode 100644 test/onnx/instance_norm_dyn_batch_bf16_test.onnx create mode 100644 test/onnx/isinf_bf16_test.onnx create mode 100644 test/onnx/isnan_bf16_test.onnx create mode 100644 test/onnx/layer_norm_3d_bf16_test.onnx create mode 100644 test/onnx/layer_norm_4d_bf16_test.onnx create mode 100644 test/onnx/layer_norm_small_eps_bf16_test.onnx create mode 100644 test/onnx/mod_test_fmod_bf16.onnx create mode 100644 test/onnx/negativeloglikelihoodloss_kd_mean_reduction_bf16_weighted_test.onnx create mode 100644 test/onnx/negativeloglikelihoodloss_kd_mean_reduction_bf16_weighted_test2.onnx create mode 100644 test/onnx/parse/eyelike_bf16_test.cpp create mode 100644 test/onnx/parse/group_norm_4d_bf16_test.cpp create mode 100644 test/onnx/parse/group_norm_5d_bf16_test.cpp create mode 100644 test/onnx/parse/group_norm_small_eps_bf16_test.cpp create mode 100644 test/onnx/parse/hardsigmoid_bf16_test.cpp create mode 100644 test/onnx/parse/imagescaler_bf16_test.cpp create mode 100644 test/onnx/parse/instance_norm_bf16_test.cpp create mode 100644 test/onnx/parse/instance_norm_dyn_batch_bf16_test.cpp create mode 100644 test/onnx/parse/isinf_bf16_test.cpp create mode 100644 test/onnx/parse/isnan_bf16_test.cpp create mode 100644 test/onnx/parse/layer_norm_3d_bf16_test.cpp create mode 100644 test/onnx/parse/layer_norm_4d_bf16_test.cpp create mode 100644 test/onnx/parse/layer_norm_small_eps_bf16_test.cpp create mode 100644 test/onnx/parse/mod_test_fmod_bf16.cpp create mode 100644 test/onnx/parse/size_bf16_test.cpp create mode 100644 test/onnx/round_bf16_test.onnx create mode 100644 test/onnx/size_bf16_test.onnx create mode 100644 test/onnx/softmaxcrossentropyloss_2d_mean_reduction_bf16_test.onnx create mode 100644 test/onnx/softmaxcrossentropyloss_2d_mean_reduction_bf16_weighted_test.onnx create mode 100644 test/onnx/softmaxcrossentropyloss_2d_no_reduction_bf16_test.onnx create mode 100644 test/onnx/softmaxcrossentropyloss_2d_no_reduction_bf16_weighted_test.onnx create mode 100644 test/onnx/softmaxcrossentropyloss_2d_sum_reduction_bf16_test.onnx create mode 100644 test/onnx/softmaxcrossentropyloss_2d_sum_reduction_bf16_weighted_test.onnx create mode 100644 test/onnx/softmaxcrossentropyloss_kd_mean_reduction_bf16_weighted_test.onnx create mode 100644 test/onnx/verify/gemm_bf16_test.cpp create mode 100644 test/onnx/verify/gridsample_bf16_test.cpp create mode 100644 test/onnx/verify/group_norm_3d_bf16_test.cpp create mode 100644 test/onnx/verify/isinf_bf16_test.cpp create mode 100644 test/onnx/verify/layer_norm_3d_bf16_test.cpp create mode 100644 test/onnx/verify/round_bf16_test.cpp diff --git a/src/onnx/onnx_parser.cpp b/src/onnx/onnx_parser.cpp index 450461b6724..cd01b76e7ed 100644 --- a/src/onnx/onnx_parser.cpp +++ b/src/onnx/onnx_parser.cpp @@ -700,7 +700,7 @@ shape::type_t get_type(int dtype) bool is_type_float(shape::type_t dtype) { bool r = false; - if(dtype == shape::float_type or dtype == shape::double_type or dtype == shape::half_type) + if(dtype == shape::float_type or dtype == shape::double_type or dtype == shape::half_type or dtype == shape::bf16_type) { r = true; } diff --git a/src/onnx/parse_instancenorm.cpp b/src/onnx/parse_instancenorm.cpp index 6c2f79134e0..d1c7156aeb1 100644 --- a/src/onnx/parse_instancenorm.cpp +++ b/src/onnx/parse_instancenorm.cpp @@ -36,7 +36,7 @@ namespace onnx { struct parse_instancenorm : op_parser { - std::set valid_types = {shape::float_type, shape::half_type, shape::double_type}; + std::set valid_types = {shape::float_type, shape::half_type, shape::double_type, shape::bf16_type}; std::vector operators() const { return {{"InstanceNormalization"}}; } diff --git a/test/onnx/eyelike_bf16_test.onnx b/test/onnx/eyelike_bf16_test.onnx new file mode 100644 index 00000000000..9cdef15cb63 --- /dev/null +++ b/test/onnx/eyelike_bf16_test.onnx @@ -0,0 +1,11 @@ + eyelike_bf16_test:R + +T1T2"EyeLikeeyelike_bf16_testZ +T1 +  + +b +T2 +  + +B \ No newline at end of file diff --git a/test/onnx/gemm_bf16_test.onnx b/test/onnx/gemm_bf16_test.onnx new file mode 100644 index 0000000000000000000000000000000000000000..83e839eeec542b3a427254eb062be50214487346 GIT binary patch literal 193 zcmdvuB^K!A36eZ>rJ4!GvU}Qo!HcA+1rVt+&4~Kvd2Nx3u g2(y6%ozMi?L4wXmf^0yQj7dPjNHjrqCnf=50Azb1uEiSP-%g7bY#aO|`0+JPCtW@H12Qq@e%Ctnd zcoTCn)AQn!^NaFQi;5)}7BDht339RI=BK18vE^jur6v|FU}V;k;NmGrOi9ViOOFRj zu~wxPnegativeloglikelihoodloss_kd_mean_reduction_bf16_weighted_test:× += +0 +1 +23"NegativeLogLikelihoodLoss* + reduction"mean >negativeloglikelihoodloss_kd_mean_reduction_bf16_weighted_testZ +0 + + + + +Z +1 + + + +Z +2 + + +b +3 + + +B \ No newline at end of file diff --git a/test/onnx/negativeloglikelihoodloss_kd_mean_reduction_bf16_weighted_test2.onnx b/test/onnx/negativeloglikelihoodloss_kd_mean_reduction_bf16_weighted_test2.onnx new file mode 100644 index 00000000000..7e5cffccc16 --- /dev/null +++ b/test/onnx/negativeloglikelihoodloss_kd_mean_reduction_bf16_weighted_test2.onnx @@ -0,0 +1,23 @@ + ?negativeloglikelihoodloss_kd_mean_reduction_bf16_weighted_test2:Ð += +0 +1 +23"NegativeLogLikelihoodLoss* + reduction"mean ?negativeloglikelihoodloss_kd_mean_reduction_bf16_weighted_test2Z +0 + + + +Z +1 +  + +Z +2 + + +b +3 + + +B \ No newline at end of file diff --git a/test/onnx/parse/eyelike_bf16_test.cpp b/test/onnx/parse/eyelike_bf16_test.cpp new file mode 100644 index 00000000000..fb0b1c99158 --- /dev/null +++ b/test/onnx/parse/eyelike_bf16_test.cpp @@ -0,0 +1,46 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include + +TEST_CASE(eyelike_bf16_test) +{ + migraphx::program p; + auto* mm = p.get_main_module(); + std::vector input_lens{8, 8}; + const size_t k = 0; + auto num_rows = input_lens.front(); + auto num_cols = input_lens.back(); + auto input_type = migraphx::shape::bf16_type; + auto output_type = migraphx::shape::bf16_type; + migraphx::shape s{input_type, input_lens}; + mm->add_parameter("T1", s); + + auto eyelike_mat = make_r_eyelike(num_rows, num_cols, k); + mm->add_literal(migraphx::literal{migraphx::shape{output_type, input_lens}, eyelike_mat}); + + auto prog = optimize_onnx("eyelike_bf16_test.onnx"); + EXPECT(p == prog); +} diff --git a/test/onnx/parse/group_norm_4d_bf16_test.cpp b/test/onnx/parse/group_norm_4d_bf16_test.cpp new file mode 100644 index 00000000000..2ba0124d7ff --- /dev/null +++ b/test/onnx/parse/group_norm_4d_bf16_test.cpp @@ -0,0 +1,34 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include + +TEST_CASE(group_norm_4d_bf16_test) +{ + migraphx::program p = make_group_norm( + {1, 4, 3, 3}, {2}, {2}, {1, 2, 2, 3, 3}, {2, 3, 4}, 1e-5f, migraphx::shape::bf16_type); + auto prog = optimize_onnx("group_norm_4d_bf16_test.onnx"); + EXPECT(p == prog); +} diff --git a/test/onnx/parse/group_norm_5d_bf16_test.cpp b/test/onnx/parse/group_norm_5d_bf16_test.cpp new file mode 100644 index 00000000000..c7ec4c8632a --- /dev/null +++ b/test/onnx/parse/group_norm_5d_bf16_test.cpp @@ -0,0 +1,39 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include + +TEST_CASE(group_norm_5d_bf16_test) +{ + migraphx::program p = make_group_norm({3, 3, 3, 3, 3}, + {1}, + {1}, + {3, 1, 3, 3, 3, 3}, + {2, 3, 4, 5}, + 1e-5f, + migraphx::shape::bf16_type); + auto prog = optimize_onnx("group_norm_5d_bf16_test.onnx"); + EXPECT(p == prog); +} diff --git a/test/onnx/parse/group_norm_small_eps_bf16_test.cpp b/test/onnx/parse/group_norm_small_eps_bf16_test.cpp new file mode 100644 index 00000000000..fa871a7d237 --- /dev/null +++ b/test/onnx/parse/group_norm_small_eps_bf16_test.cpp @@ -0,0 +1,34 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include + +TEST_CASE(group_norm_small_eps_bf16_test) +{ + migraphx::program p = make_group_norm( + {1, 4, 2}, {2}, {2}, {1, 2, 2, 2}, {2, 3}, 1e-7f, migraphx::shape::bf16_type); + auto prog = optimize_onnx("group_norm_small_eps_bf16_test.onnx"); + EXPECT(p == prog); +} diff --git a/test/onnx/parse/hardsigmoid_bf16_test.cpp b/test/onnx/parse/hardsigmoid_bf16_test.cpp new file mode 100644 index 00000000000..23f8ac9a550 --- /dev/null +++ b/test/onnx/parse/hardsigmoid_bf16_test.cpp @@ -0,0 +1,58 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +TEST_CASE(hardsigmoid_bf16_test) +{ + migraphx::program p; + auto* mm = p.get_main_module(); + std::vector input_lens{1, 3, 4, 5}; + auto input_type = migraphx::shape::bf16_type; + migraphx::shape s{input_type, input_lens}; + auto x = mm->add_parameter("x", s); + + float alpha = 0.2; + float beta = 0.5; + + auto mb_alpha = mm->add_instruction( + migraphx::make_op("multibroadcast", {{"out_lens", input_lens}}), + mm->add_literal(migraphx::literal{migraphx::shape{input_type}, {alpha}})); + auto mb_beta = mm->add_instruction( + migraphx::make_op("multibroadcast", {{"out_lens", input_lens}}), + mm->add_literal(migraphx::literal{migraphx::shape{input_type}, {beta}})); + auto mb_zero = + mm->add_instruction(migraphx::make_op("multibroadcast", {{"out_lens", input_lens}}), + mm->add_literal(migraphx::literal{migraphx::shape{input_type}, {0}})); + auto mb_one = + mm->add_instruction(migraphx::make_op("multibroadcast", {{"out_lens", input_lens}}), + mm->add_literal(migraphx::literal{migraphx::shape{input_type}, {1}})); + + auto mul = mm->add_instruction(migraphx::make_op("mul"), mb_alpha, x); + auto add = mm->add_instruction(migraphx::make_op("add"), mb_beta, mul); + mm->add_instruction(migraphx::make_op("clip"), add, mb_zero, mb_one); + + auto prog = optimize_onnx("hardsigmoid_bf16_test.onnx"); + EXPECT(p == prog); +} diff --git a/test/onnx/parse/imagescaler_bf16_test.cpp b/test/onnx/parse/imagescaler_bf16_test.cpp new file mode 100644 index 00000000000..8a7b34d77d0 --- /dev/null +++ b/test/onnx/parse/imagescaler_bf16_test.cpp @@ -0,0 +1,47 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +TEST_CASE(imagescaler_bf16_test) +{ + migraphx::program p; + auto* mm = p.get_main_module(); + migraphx::shape s{migraphx::shape::bf16_type, {1, 3, 16, 16}}; + auto l0 = mm->add_parameter("0", s); + auto scale_val = + mm->add_literal(migraphx::literal{migraphx::shape{migraphx::shape::bf16_type}, {0.5f}}); + auto bias_vals = mm->add_literal( + migraphx::literal{migraphx::shape{migraphx::shape::bf16_type, {3}}, {0.01, 0.02, 0.03}}); + auto scaled_tensor = mm->add_instruction( + migraphx::make_op("scalar", {{"scalar_bcst_dims", s.lens()}}), scale_val); + auto img_scaled = mm->add_instruction(migraphx::make_op("mul"), l0, scaled_tensor); + auto bias_bcast = mm->add_instruction( + migraphx::make_op("broadcast", {{"axis", 1}, {"out_lens", s.lens()}}), bias_vals); + mm->add_instruction(migraphx::make_op("add"), img_scaled, bias_bcast); + + auto prog = optimize_onnx("imagescaler_bf16_test.onnx"); + + EXPECT(p == prog); +} diff --git a/test/onnx/parse/instance_norm_bf16_test.cpp b/test/onnx/parse/instance_norm_bf16_test.cpp new file mode 100644 index 00000000000..7d5aa9e4119 --- /dev/null +++ b/test/onnx/parse/instance_norm_bf16_test.cpp @@ -0,0 +1,63 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +TEST_CASE(instance_norm_bf16_test) +{ + std::vector dims{1, 2, 3, 3}; + migraphx::shape s1{migraphx::shape::bf16_type, dims}; + migraphx::shape s2{migraphx::shape::bf16_type, {2}}; + + migraphx::program p; + auto* mm = p.get_main_module(); + auto x = mm->add_parameter("0", s1); + auto scale = mm->add_parameter("1", s2); + auto bias = mm->add_parameter("2", s2); + + auto mean = mm->add_instruction(migraphx::make_op("reduce_mean", {{"axes", {2, 3}}}), x); + auto l0 = add_common_op(*mm, migraphx::make_op("sub"), {x, mean}); + auto l1 = add_common_op(*mm, migraphx::make_op("sqdiff"), {x, mean}); + + auto variance = mm->add_instruction(migraphx::make_op("reduce_mean", {{"axes", {2, 3}}}), l1); + // type of epsilon_literal is same as 0'th input; convert instruction will be added by + // add_common_op + auto epsilon_literal = + mm->add_literal(migraphx::literal{migraphx::shape{migraphx::shape::bf16_type}, {1e-5}}); + auto l2 = add_common_op(*mm, migraphx::make_op("add"), {variance, epsilon_literal}); + + auto l3 = mm->add_instruction(migraphx::make_op("rsqrt"), l2); + auto l4 = add_common_op(*mm, migraphx::make_op("mul"), {l0, l3}); + + auto scale_bcast = mm->add_instruction( + migraphx::make_op("broadcast", {{"axis", 1}, {"out_lens", dims}}), scale); + auto bias_bcast = mm->add_instruction( + migraphx::make_op("broadcast", {{"axis", 1}, {"out_lens", dims}}), bias); + auto l5 = mm->add_instruction(migraphx::make_op("mul"), l4, scale_bcast); + mm->add_instruction(migraphx::make_op("add"), l5, bias_bcast); + + auto prog = optimize_onnx("instance_norm_bf16_test.onnx"); + + EXPECT(p == prog); +} diff --git a/test/onnx/parse/instance_norm_dyn_batch_bf16_test.cpp b/test/onnx/parse/instance_norm_dyn_batch_bf16_test.cpp new file mode 100644 index 00000000000..50e1085d2e5 --- /dev/null +++ b/test/onnx/parse/instance_norm_dyn_batch_bf16_test.cpp @@ -0,0 +1,64 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +TEST_CASE(instance_norm_dyn_batch_bf16_test) +{ + // instancenorm with bf16 type, dynamic input in the 0'th (batch) dimension + migraphx::shape s1{migraphx::shape::bf16_type, {{1, 2, {2}}, {2, 2}, {3, 3}, {3, 3}}}; + migraphx::shape s2{migraphx::shape::bf16_type, {2}}; + + migraphx::program p; + auto* mm = p.get_main_module(); + auto x = mm->add_parameter("0", s1); + auto scale = mm->add_parameter("1", s2); + auto bias = mm->add_parameter("2", s2); + + auto mean = mm->add_instruction(migraphx::make_op("reduce_mean", {{"axes", {2, 3}}}), x); + auto l0 = add_common_op(*mm, migraphx::make_op("sub"), {x, mean}); + auto l1 = add_common_op(*mm, migraphx::make_op("sqdiff"), {x, mean}); + + auto variance = mm->add_instruction(migraphx::make_op("reduce_mean", {{"axes", {2, 3}}}), l1); + // type of epsilon_literal is same as 0'th input; convert instruction will be added by + // add_common_op + auto epsilon_literal = + mm->add_literal(migraphx::literal{migraphx::shape{migraphx::shape::bf16_type}, {1e-5}}); + auto l2 = add_common_op(*mm, migraphx::make_op("add"), {variance, epsilon_literal}); + + auto l3 = mm->add_instruction(migraphx::make_op("rsqrt"), l2); + auto l4 = add_common_op(*mm, migraphx::make_op("mul"), {l0, l3}); + + auto scale_bcast = mm->add_instruction(migraphx::make_op("broadcast", {{"axis", 1}}), scale, x); + auto bias_bcast = mm->add_instruction(migraphx::make_op("broadcast", {{"axis", 1}}), bias, x); + auto l5 = mm->add_instruction(migraphx::make_op("mul"), l4, scale_bcast); + auto instance_norm_bf16 = mm->add_instruction(migraphx::make_op("add"), l5, bias_bcast); + + mm->add_return({instance_norm_bf16}); + + migraphx::onnx_options options; + options.default_dyn_dim_value = {1, 2, {2}}; + auto prog = read_onnx("instance_norm_dyn_batch_bf16_test.onnx", options); + EXPECT(p == prog); +} diff --git a/test/onnx/parse/isinf_bf16_test.cpp b/test/onnx/parse/isinf_bf16_test.cpp new file mode 100644 index 00000000000..e8c2104312e --- /dev/null +++ b/test/onnx/parse/isinf_bf16_test.cpp @@ -0,0 +1,38 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +TEST_CASE(isinf_bf16_test) +{ + migraphx::program p; + auto* mm = p.get_main_module(); + migraphx::shape s{migraphx::shape::bf16_type, {2, 3}}; + auto t1 = mm->add_parameter("t1", s); + auto ret = mm->add_instruction(migraphx::make_op("isinf"), t1); + mm->add_return({ret}); + + auto prog = read_onnx("isinf_bf16_test.onnx"); + EXPECT(p == prog); +} diff --git a/test/onnx/parse/isnan_bf16_test.cpp b/test/onnx/parse/isnan_bf16_test.cpp new file mode 100644 index 00000000000..b60dc4aefb5 --- /dev/null +++ b/test/onnx/parse/isnan_bf16_test.cpp @@ -0,0 +1,38 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +TEST_CASE(isnan_bf16_test) +{ + migraphx::program p; + auto* mm = p.get_main_module(); + migraphx::shape s{migraphx::shape::bf16_type, {2, 3}}; + auto t1 = mm->add_parameter("t1", s); + auto ret = mm->add_instruction(migraphx::make_op("isnan"), t1); + mm->add_return({ret}); + + auto prog = read_onnx("isnan_bf16_test.onnx"); + EXPECT(p == prog); +} diff --git a/test/onnx/parse/layer_norm_3d_bf16_test.cpp b/test/onnx/parse/layer_norm_3d_bf16_test.cpp new file mode 100644 index 00000000000..ac54419b3a2 --- /dev/null +++ b/test/onnx/parse/layer_norm_3d_bf16_test.cpp @@ -0,0 +1,35 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include + +TEST_CASE(layer_norm_3d_bf16_test) +{ + migraphx::program p = + make_layer_norm({1, 4, 2}, {2}, {2}, 2, false, 1e-5f, migraphx::shape::bf16_type); + + auto prog = optimize_onnx("layer_norm_3d_bf16_test.onnx"); + EXPECT(p == prog); +} diff --git a/test/onnx/parse/layer_norm_4d_bf16_test.cpp b/test/onnx/parse/layer_norm_4d_bf16_test.cpp new file mode 100644 index 00000000000..c1e18a4f3f2 --- /dev/null +++ b/test/onnx/parse/layer_norm_4d_bf16_test.cpp @@ -0,0 +1,35 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include + +TEST_CASE(layer_norm_4d_bf16_test) +{ + migraphx::program p = + make_layer_norm({3, 3, 3, 3}, {3}, {3}, 3, false, 1e-5f, migraphx::shape::bf16_type); + + auto prog = optimize_onnx("layer_norm_4d_bf16_test.onnx"); + EXPECT(p == prog); +} diff --git a/test/onnx/parse/layer_norm_small_eps_bf16_test.cpp b/test/onnx/parse/layer_norm_small_eps_bf16_test.cpp new file mode 100644 index 00000000000..b43551f5a16 --- /dev/null +++ b/test/onnx/parse/layer_norm_small_eps_bf16_test.cpp @@ -0,0 +1,35 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include + +TEST_CASE(layer_norm_small_eps_bf16_test) +{ + migraphx::program p = + make_layer_norm({1, 2}, {2}, {1}, 1, true, 1e-7, migraphx::shape::bf16_type); + + auto prog = optimize_onnx("layer_norm_small_eps_bf16_test.onnx"); + EXPECT(p == prog); +} diff --git a/test/onnx/parse/mod_test_fmod_bf16.cpp b/test/onnx/parse/mod_test_fmod_bf16.cpp new file mode 100644 index 00000000000..e18cf45e6b5 --- /dev/null +++ b/test/onnx/parse/mod_test_fmod_bf16.cpp @@ -0,0 +1,38 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +TEST_CASE(mod_test_fmod_bf16) +{ + migraphx::program p; + auto* mm = p.get_main_module(); + auto input0 = mm->add_parameter("0", migraphx::shape{migraphx::shape::bf16_type, {3, 3, 3}}); + auto input1 = mm->add_parameter("1", migraphx::shape{migraphx::shape::bf16_type, {3, 3, 3}}); + mm->add_instruction(migraphx::make_op("fmod"), input0, input1); + + auto prog = optimize_onnx("mod_test_fmod_bf16.onnx"); + + EXPECT(p == prog); +} diff --git a/test/onnx/parse/size_bf16_test.cpp b/test/onnx/parse/size_bf16_test.cpp new file mode 100644 index 00000000000..83056e8686f --- /dev/null +++ b/test/onnx/parse/size_bf16_test.cpp @@ -0,0 +1,36 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +TEST_CASE(size_bf16_test) +{ + migraphx::program p; + auto* mm = p.get_main_module(); + auto s = migraphx::shape{migraphx::shape::bf16_type, {3, 1}}; + mm->add_parameter("x", s); + mm->add_literal(migraphx::literal{migraphx::shape::int64_type, {s.elements()}}); + auto prog = optimize_onnx("size_bf16_test.onnx"); + EXPECT(p == prog); +} diff --git a/test/onnx/round_bf16_test.onnx b/test/onnx/round_bf16_test.onnx new file mode 100644 index 00000000000..d5f5bcad121 --- /dev/null +++ b/test/onnx/round_bf16_test.onnx @@ -0,0 +1,11 @@ + round_bf16_test:J + +xy"Roundround_bf16_testZ +x +  + +b +y +  + +B \ No newline at end of file diff --git a/test/onnx/size_bf16_test.onnx b/test/onnx/size_bf16_test.onnx new file mode 100644 index 00000000000..85c42208cf3 --- /dev/null +++ b/test/onnx/size_bf16_test.onnx @@ -0,0 +1,11 @@ + size_bf16_test:D + +xy"Sizesize_bf16_testZ +x +  + +b +y + + +B \ No newline at end of file diff --git a/test/onnx/softmaxcrossentropyloss_2d_mean_reduction_bf16_test.onnx b/test/onnx/softmaxcrossentropyloss_2d_mean_reduction_bf16_test.onnx new file mode 100644 index 00000000000..3c9a4b6ebd2 --- /dev/null +++ b/test/onnx/softmaxcrossentropyloss_2d_mean_reduction_bf16_test.onnx @@ -0,0 +1,17 @@ + 3softmaxcrossentropyloss_2d_mean_reduction_bf16_test:¦ +8 +0 +12"SoftmaxCrossEntropyLoss* + reduction"mean 3softmaxcrossentropyloss_2d_mean_reduction_bf16_testZ +0 +  + +Z +1 + + +b +2 + + +B \ No newline at end of file diff --git a/test/onnx/softmaxcrossentropyloss_2d_mean_reduction_bf16_weighted_test.onnx b/test/onnx/softmaxcrossentropyloss_2d_mean_reduction_bf16_weighted_test.onnx new file mode 100644 index 00000000000..d50caae01ae --- /dev/null +++ b/test/onnx/softmaxcrossentropyloss_2d_mean_reduction_bf16_weighted_test.onnx @@ -0,0 +1,22 @@ +  +#include +#include + +TEST_CASE(gemm_bf16_test) +{ + migraphx::program p = read_onnx("gemm_bf16_test.onnx"); + p.compile(migraphx::make_target("ref")); + + migraphx::shape a_shape{migraphx::shape::bf16_type, {8, 6}}; + std::vector tmp = {0.2646, 0.8525, 0.4192, 0.1415, 0.4321, 0.675, 0.4248, 0.8203, + 0.978, 0.5796, 0.6626, 0.479, 0.924, 0.734, 0.674, 0.8716, + 0.3733, 0.3328, 0.4272, 0.0247, 0.7583, 0.4873, 0.5835, 0.694, + 0.4375, 0.2406, 0.269, 0.6763, 0.542, 0.8994, 0.657, 0.5425, + 0.1412, 0.8994, 0.2183, 0.812, 0.937, 0.3438, 0.712, 0.9033, + 0.266, 0.8013, 0.803, 0.4993, 0.07196, 0.635, 0.7344, 0.3213}; + std::vector a_data{tmp.cbegin(), tmp.cend()}; + + migraphx::shape b_shape{migraphx::shape::bf16_type, {8, 7}}; + tmp = {0.7095, 0.612, 0.741, 0.02121, 0.3872, 0.4482, 0.6235, 0.02249, 0.2332, 0.7656, + 0.8955, 0.8154, 0.2239, 0.9277, 0.4622, 0.708, 0.566, 0.0736, 0.138, 0.8574, + 0.4055, 0.382, 0.6206, 0.424, 0.3674, 0.435, 0.998, 0.3594, 0.701, 0.6216, + 0.01826, 0.6313, 0.514, 0.1095, 0.3203, 0.01636, 0.537, 0.01952, 0.4502, 0.8965, + 0.5415, 0.7456, 0.793, 0.756, 0.9, 0.5264, 0.05368, 0.4214, 0.276, 0.1517, + 0.08453, 0.83, 0.417, 0.1682, 0.845, 0.1729}; + std::vector b_data{tmp.cbegin(), tmp.cend()}; + + migraphx::shape c_shape{migraphx::shape::bf16_type, {6, 1}}; + tmp = {0.10846, 0.672, 0.527, 0.94, 0.429, 0.2291}; + std::vector c_data{tmp.cbegin(), tmp.cend()}; + + migraphx::parameter_map params; + params["A"] = migraphx::argument(a_shape, a_data.data()); + params["B"] = migraphx::argument(b_shape, b_data.data()); + params["C"] = migraphx::argument(c_shape, c_data.data()); + + auto result = p.eval(params).back(); + std::vector result_vector; + result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); }); + + tmp = {1.071, 1.378, 1.465, 1.093, 0.968, 1.542, 1.145, 1.287, 1.533, 1.75, 1.338, + 1.449, 1.592, 1.668, 1.265, 1.531, 1.656, 1.348, 1.2705, 1.525, 1.479, 1.754, + 2.143, 2.062, 1.921, 1.836, 2.203, 1.952, 1.055, 1.225, 1.418, 1.209, 1.155, + 1.42, 1.234, 1.302, 1.593, 1.368, 1.289, 1.327, 1.451, 1.394}; + std::vector gold{tmp.cbegin(), tmp.cend()}; + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); +} diff --git a/test/onnx/verify/gridsample_bf16_test.cpp b/test/onnx/verify/gridsample_bf16_test.cpp new file mode 100644 index 00000000000..d9c4f455844 --- /dev/null +++ b/test/onnx/verify/gridsample_bf16_test.cpp @@ -0,0 +1,61 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include +#include + +TEST_CASE(gridsample_bf16_test) +{ + migraphx::program p = read_onnx("gridsample_bf16_test.onnx"); + migraphx::compile_options options; + p.compile(migraphx::make_target("ref")); + + migraphx::shape data_shape{migraphx::shape::bf16_type, {1, 1, 4, 4}}; + migraphx::shape grid_shape{migraphx::shape::float_type, {1, 6, 6, 2}}; + std::vector tmp = {0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15.}; + std::vector data = {tmp.begin(), tmp.end()}; + std::vector grid = {-1., -1., -0.6, -1., -0.2, -1., 0.2, -1., 0.6, -1., 1., -1., + -1., -0.6, -0.6, -0.6, -0.2, -0.6, 0.2, -0.6, 0.6, -0.6, 1., -0.6, + -1., -0.2, -0.6, -0.2, -0.2, -0.2, 0.2, -0.2, 0.6, -0.2, 1., -0.2, + -1., 0.2, -0.6, 0.2, -0.2, 0.2, 0.2, 0.2, 0.6, 0.2, 1., 0.2, + -1., 0.6, -0.6, 0.6, -0.2, 0.6, 0.2, 0.6, 0.6, 0.6, 1., 0.6, + -1., 1., -0.6, 1., -0.2, 1., 0.2, 1., 0.6, 1., 1., 1.}; + + migraphx::parameter_map pp; + pp["x"] = migraphx::argument(data_shape, data.data()); + pp["grid"] = migraphx::argument(grid_shape, grid.data()); + + auto result = p.eval(pp).back(); + std::vector result_vector; + result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); }); + + tmp = {0., 0.15, 0.55, 0.95, 1.35, 0.75, 0.6, 1.5, 2.3, 3.1, 3.9, 2.1, + 2.2, 4.7, 5.5, 6.3, 7.1, 3.7, 3.8, 7.9, 8.7, 9.5, 10.3, 5.3, + 5.4, 11.1, 11.9, 12.7, 13.5, 6.9, 3., 6.15, 6.55, 6.95, 7.35, 3.75}; + + std::vector gold = {tmp.begin(), tmp.end()}; + + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); +} diff --git a/test/onnx/verify/group_norm_3d_bf16_test.cpp b/test/onnx/verify/group_norm_3d_bf16_test.cpp new file mode 100644 index 00000000000..4cd3b750d9d --- /dev/null +++ b/test/onnx/verify/group_norm_3d_bf16_test.cpp @@ -0,0 +1,46 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include +#include +#include + +TEST_CASE(group_norm_bf16_test) +{ + using migraphx::bf16; + std::vector scale{bf16{1.2}, bf16{0.8}}; + std::vector bias{bf16{0.5}, bf16{0.2}}; + std::vector result_vector = + norm_test({1, 4, 2}, scale, bias, read_onnx("group_norm_3d_bf16_test.onnx")); + std::vector gold = {bf16{-1.10996256}, + bf16{-0.0366542}, + bf16{1.0366542}, + bf16{2.10996256}, + bf16{-0.87330837}, + bf16{-0.15776947}, + bf16{0.55776947}, + bf16{1.27330837}}; + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); +} diff --git a/test/onnx/verify/isinf_bf16_test.cpp b/test/onnx/verify/isinf_bf16_test.cpp new file mode 100644 index 00000000000..8d8f99458c7 --- /dev/null +++ b/test/onnx/verify/isinf_bf16_test.cpp @@ -0,0 +1,50 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include +#include + +TEST_CASE(isinf_bf16_test) +{ + migraphx::program p = read_onnx("isinf_bf16_test.onnx"); + p.compile(migraphx::make_target("ref")); + + migraphx::shape s{migraphx::shape::bf16_type, {2, 3}}; + migraphx::parameter_map pp; + migraphx::bf16 nan = std::numeric_limits::quiet_NaN(); + migraphx::bf16 infinity = std::numeric_limits::infinity(); + migraphx::bf16 max = std::numeric_limits::max(); + migraphx::bf16 min = std::numeric_limits::min(); + migraphx::bf16 val = migraphx::bf16(3.6); + std::vector data = {-infinity, nan, min, val, max, infinity}; + pp["t1"] = migraphx::argument(s, data.data()); + + auto result = p.eval(pp).back(); + std::vector result_vector; + result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); }); + + std::vector gold = {1, 0, 0, 0, 0, 1}; + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); +} diff --git a/test/onnx/verify/layer_norm_3d_bf16_test.cpp b/test/onnx/verify/layer_norm_3d_bf16_test.cpp new file mode 100644 index 00000000000..1a45e393809 --- /dev/null +++ b/test/onnx/verify/layer_norm_3d_bf16_test.cpp @@ -0,0 +1,46 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include +#include +#include + +TEST_CASE(layer_norm_bf16_test) +{ + using migraphx::bf16; + std::vector scale{bf16{1.2}, bf16{0.8}}; + std::vector bias{bf16{0.5}, bf16{0.2}}; + std::vector result_vector = + norm_test({1, 4, 2}, scale, bias, read_onnx("layer_norm_3d_bf16_test.onnx")); + std::vector gold = {bf16{-0.69997597}, + bf16{0.99998398}, + bf16{-0.69997597}, + bf16{0.99998398}, + bf16{-0.69997597}, + bf16{0.99998398}, + bf16{-0.69997597}, + bf16{0.99998398}}; + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); +} diff --git a/test/onnx/verify/round_bf16_test.cpp b/test/onnx/verify/round_bf16_test.cpp new file mode 100644 index 00000000000..a426bd2790e --- /dev/null +++ b/test/onnx/verify/round_bf16_test.cpp @@ -0,0 +1,64 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include +#include + +TEST_CASE(round_bf16_test) +{ + migraphx::program p = read_onnx("round_bf16_test.onnx"); + p.compile(migraphx::make_target("ref")); + + migraphx::shape xs{migraphx::shape::bf16_type, {4, 4}}; + std::vector tmp = {-3.51, + -3.5, + -3.49, + -2.51, + -2.50, + -2.49, + -1.6, + -1.5, + -0.51, + -0.5, + 0.5, + 0.6, + 2.4, + 2.5, + 3.5, + 4.5}; + std::vector data{tmp.cbegin(), tmp.cend()}; + migraphx::parameter_map param_map; + param_map["x"] = migraphx::argument(xs, data.data()); + + auto result = p.eval(param_map).back(); + + std::vector result_vector; + result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); }); + + tmp = {-4.0, -4.0, -3.0, -3.0, -2.0, -2.0, -2.0, -2.0, -1.0, 0.0, 0.0, 1.0, 2.0, 2.0, 4.0, 4.0}; + std::vector gold{tmp.cbegin(), tmp.cend()}; + + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); +} From 6e87c991b4136b736bc229c9d443bfd4063fa765 Mon Sep 17 00:00:00 2001 From: richagadgil Date: Fri, 22 Nov 2024 18:59:06 -0600 Subject: [PATCH 71/72] fix softmax --- test/onnx/gen_onnx.py | 64 +------------- ...rossentropyloss_2d_mean_reduction_test.cpp | 44 ++++++++++ ...xcrossentropyloss_2d_no_reduction_test.cpp | 43 ++++++++++ ...crossentropyloss_2d_sum_reduction_test.cpp | 44 ++++++++++ ...opyloss_kd_all_reduction_weighted_test.cpp | 86 +++++++++++++++++++ ..._2d_mean_reduction_bf16_weighted_test.onnx | 22 ----- ...ss_2d_no_reduction_bf16_weighted_test.onnx | 22 ----- ...s_2d_sum_reduction_bf16_weighted_test.onnx | 22 ----- 8 files changed, 218 insertions(+), 129 deletions(-) delete mode 100644 test/onnx/softmaxcrossentropyloss_2d_mean_reduction_bf16_weighted_test.onnx delete mode 100644 test/onnx/softmaxcrossentropyloss_2d_no_reduction_bf16_weighted_test.onnx delete mode 100644 test/onnx/softmaxcrossentropyloss_2d_sum_reduction_bf16_weighted_test.onnx diff --git a/test/onnx/gen_onnx.py b/test/onnx/gen_onnx.py index 1831e8d39d9..0a5452d1440 100644 --- a/test/onnx/gen_onnx.py +++ b/test/onnx/gen_onnx.py @@ -12979,28 +12979,6 @@ def softmaxcrossentropyloss_2d_no_reduction_half_weighted_test(): return ([node], [scores, labels, weights], [loss]) -@onnx_test() -def softmaxcrossentropyloss_2d_no_reduction_bf16_weighted_test(): - scores = helper.make_tensor_value_info('0', TensorProto.BFLOAT16, [4, 4]) - labels = helper.make_tensor_value_info('1', TensorProto.INT32, [4]) - weights = helper.make_tensor_value_info('2', TensorProto.BFLOAT16, [4]) - loss = helper.make_tensor_value_info('3', TensorProto.BFLOAT16, [4]) - - node = onnx.helper.make_node( - "SoftmaxCrossEntropyLoss", - inputs=[ - "0", - "1", - "2", - ], - outputs=["3"], - reduction="none", - ) - - return ([node], [scores, labels, weights], [loss]) - - - @onnx_test() def softmaxcrossentropyloss_2d_sum_reduction_weighted_test(): scores = helper.make_tensor_value_info('0', TensorProto.FLOAT, [4, 4]) @@ -13044,7 +13022,7 @@ def softmaxcrossentropyloss_2d_sum_reduction_double_weighted_test(): @onnx_test() -def softmaxcrossentropyloss_2d_sum_reduction_half_weighted_test(): +def softmaxcrossentropyloss_2d_sum_reduction_bf16_weighted_tes(): scores = helper.make_tensor_value_info('0', TensorProto.FLOAT16, [4, 4]) labels = helper.make_tensor_value_info('1', TensorProto.INT32, [4]) weights = helper.make_tensor_value_info('2', TensorProto.FLOAT16, [4]) @@ -13063,26 +13041,6 @@ def softmaxcrossentropyloss_2d_sum_reduction_half_weighted_test(): return ([node], [scores, labels, weights], [loss]) -@onnx_test() -def softmaxcrossentropyloss_2d_sum_reduction_bf16_weighted_test(): - scores = helper.make_tensor_value_info('0', TensorProto.BFLOAT16, [4, 4]) - labels = helper.make_tensor_value_info('1', TensorProto.INT32, [4]) - weights = helper.make_tensor_value_info('2', TensorProto.BFLOAT16, [4]) - loss = helper.make_tensor_value_info('3', TensorProto.BFLOAT16, [4]) - - node = onnx.helper.make_node( - "SoftmaxCrossEntropyLoss", - inputs=[ - "0", - "1", - "2", - ], - outputs=["3"], - reduction="sum", - ) - - return ([node], [scores, labels, weights], [loss]) - @onnx_test() def softmaxcrossentropyloss_2d_mean_reduction_weighted_test(): @@ -13146,26 +13104,6 @@ def softmaxcrossentropyloss_2d_mean_reduction_half_weighted_test(): return ([node], [scores, labels, weights], [loss]) -@onnx_test() -def softmaxcrossentropyloss_2d_mean_reduction_bf16_weighted_test(): - scores = helper.make_tensor_value_info('0', TensorProto.BFLOAT16, [4, 4]) - labels = helper.make_tensor_value_info('1', TensorProto.INT32, [4]) - weights = helper.make_tensor_value_info('2', TensorProto.BFLOAT16, [4]) - loss = helper.make_tensor_value_info('3', TensorProto.BFLOAT16, [4]) - - node = onnx.helper.make_node( - "SoftmaxCrossEntropyLoss", - inputs=[ - "0", - "1", - "2", - ], - outputs=["3"], - reduction="mean", - ) - - return ([node], [scores, labels, weights], [loss]) - @onnx_test() def softmaxcrossentropyloss_kdim_not_equal_test(): diff --git a/test/onnx/parse/softmaxcrossentropyloss_2d_mean_reduction_test.cpp b/test/onnx/parse/softmaxcrossentropyloss_2d_mean_reduction_test.cpp index e7abca8b0c6..c7a3204946d 100644 --- a/test/onnx/parse/softmaxcrossentropyloss_2d_mean_reduction_test.cpp +++ b/test/onnx/parse/softmaxcrossentropyloss_2d_mean_reduction_test.cpp @@ -158,3 +158,47 @@ TEST_CASE(softmaxcrossentropyloss_2d_mean_reduction_half_test) EXPECT(p == prog); } + +TEST_CASE(softmaxcrossentropyloss_2d_mean_reduction_bf16_test) +{ + migraphx::program p; + auto* mm = p.get_main_module(); + + auto scores = mm->add_parameter("0", migraphx::shape{migraphx::shape::bf16_type, {4, 4}}); + auto labels = mm->add_parameter("1", migraphx::shape{migraphx::shape::int32_type, {4}}); + auto weights = mm->add_literal( + migraphx::literal(migraphx::shape(migraphx::shape::bf16_type, {1}, {0}), {1})); + auto labels_idx = mm->add_literal( + migraphx::literal(migraphx::shape(migraphx::shape::int32_type, {4}, {1}), {0, 1, 2, 3})); + + auto mb_weights = mm->add_instruction( + migraphx::make_op("multibroadcast", {{"out_lens", labels->get_shape().lens()}}), weights); + + mb_weights = mm->add_instruction(migraphx::make_op("neg"), mb_weights); + + auto softmax = mm->add_instruction(migraphx::make_op("softmax"), scores); + auto unsq_labels = + mm->add_instruction(migraphx::make_op("unsqueeze", {{"axes", {-1}}}), labels); + auto unsq_labels_idx = + mm->add_instruction(migraphx::make_op("unsqueeze", {{"axes", {1}}}), labels_idx); + auto bc_unsq_labels_idx = mm->add_instruction( + migraphx::make_op("multibroadcast", {{"out_lens", unsq_labels->get_shape().lens()}}), + unsq_labels_idx); + auto concat = mm->add_instruction( + migraphx::make_op("concat", {{"axis", -1}}), bc_unsq_labels_idx, unsq_labels); + auto gathernd = mm->add_instruction(migraphx::make_op("gathernd"), softmax, concat); + auto unsq_mb_weights = + mm->add_instruction(migraphx::make_op("unsqueeze", {{"axes", {0}}}), mb_weights); + auto unsq_mb = mm->add_instruction( + migraphx::make_op("multibroadcast", {{"out_lens", scores->get_shape().lens()}}), + unsq_mb_weights); + auto gathernd2 = mm->add_instruction(migraphx::make_op("gathernd"), unsq_mb, concat); + + auto logsoftmax = mm->add_instruction(migraphx::make_op("log"), gathernd); + auto weighted_loss = mm->add_instruction(migraphx::make_op("mul"), logsoftmax, gathernd2); + mm->add_instruction(migraphx::make_op("reduce_mean", {{"axes", {0}}}), weighted_loss); + + auto prog = optimize_onnx("softmaxcrossentropyloss_2d_mean_reduction_bf16_test.onnx"); + + EXPECT(p == prog); +} diff --git a/test/onnx/parse/softmaxcrossentropyloss_2d_no_reduction_test.cpp b/test/onnx/parse/softmaxcrossentropyloss_2d_no_reduction_test.cpp index f1da5e0d0e8..1ed0f5272da 100644 --- a/test/onnx/parse/softmaxcrossentropyloss_2d_no_reduction_test.cpp +++ b/test/onnx/parse/softmaxcrossentropyloss_2d_no_reduction_test.cpp @@ -216,3 +216,46 @@ TEST_CASE(softmaxcrossentropyloss_2d_no_reduction_half_test) EXPECT(p == prog); } + +TEST_CASE(softmaxcrossentropyloss_2d_no_reduction_bf16_test) +{ + migraphx::program p; + auto* mm = p.get_main_module(); + + auto scores = mm->add_parameter("0", migraphx::shape{migraphx::shape::bf16_type, {4, 4}}); + auto labels = mm->add_parameter("1", migraphx::shape{migraphx::shape::int32_type, {4}}); + auto weights = mm->add_literal( + migraphx::literal(migraphx::shape(migraphx::shape::bf16_type, {1}, {0}), {1})); + auto labels_idx = mm->add_literal( + migraphx::literal(migraphx::shape(migraphx::shape::int32_type, {4}, {1}), {0, 1, 2, 3})); + + auto mb_weights = mm->add_instruction( + migraphx::make_op("multibroadcast", {{"out_lens", labels->get_shape().lens()}}), weights); + mb_weights = mm->add_instruction(migraphx::make_op("neg"), mb_weights); + + auto softmax = mm->add_instruction(migraphx::make_op("softmax"), scores); + auto unsq_labels = + mm->add_instruction(migraphx::make_op("unsqueeze", {{"axes", {-1}}}), labels); + auto unsq_labels_idx = + mm->add_instruction(migraphx::make_op("unsqueeze", {{"axes", {1}}}), labels_idx); + auto bc_unsq_labels_idx = mm->add_instruction( + migraphx::make_op("multibroadcast", {{"out_lens", unsq_labels->get_shape().lens()}}), + unsq_labels_idx); + auto concat = mm->add_instruction( + migraphx::make_op("concat", {{"axis", -1}}), bc_unsq_labels_idx, unsq_labels); + auto gathernd = mm->add_instruction(migraphx::make_op("gathernd"), softmax, concat); + auto unsq_mb_weights = + mm->add_instruction(migraphx::make_op("unsqueeze", {{"axes", {0}}}), mb_weights); + auto unsq_mb = mm->add_instruction( + migraphx::make_op("multibroadcast", {{"out_lens", scores->get_shape().lens()}}), + unsq_mb_weights); + auto gathernd2 = mm->add_instruction(migraphx::make_op("gathernd"), unsq_mb, concat); + + auto logsoftmax = mm->add_instruction(migraphx::make_op("log"), gathernd); + + mm->add_instruction(migraphx::make_op("mul"), logsoftmax, gathernd2); + + auto prog = optimize_onnx("softmaxcrossentropyloss_2d_no_reduction_bf16_test.onnx"); + + EXPECT(p == prog); +} diff --git a/test/onnx/parse/softmaxcrossentropyloss_2d_sum_reduction_test.cpp b/test/onnx/parse/softmaxcrossentropyloss_2d_sum_reduction_test.cpp index 3fe7df558a7..092c4fe09ef 100644 --- a/test/onnx/parse/softmaxcrossentropyloss_2d_sum_reduction_test.cpp +++ b/test/onnx/parse/softmaxcrossentropyloss_2d_sum_reduction_test.cpp @@ -157,3 +157,47 @@ TEST_CASE(softmaxcrossentropyloss_2d_sum_reduction_half_test) EXPECT(p == prog); } + +TEST_CASE(softmaxcrossentropyloss_2d_sum_reduction_bf16_test) +{ + migraphx::program p; + auto* mm = p.get_main_module(); + + auto scores = mm->add_parameter("0", migraphx::shape{migraphx::shape::bf16_type, {4, 4}}); + auto labels = mm->add_parameter("1", migraphx::shape{migraphx::shape::int32_type, {4}}); + auto weights = mm->add_literal( + migraphx::literal(migraphx::shape(migraphx::shape::bf16_type, {1}, {0}), {1})); + auto labels_idx = mm->add_literal( + migraphx::literal(migraphx::shape(migraphx::shape::int32_type, {4}, {1}), {0, 1, 2, 3})); + + auto mb_weights = mm->add_instruction( + migraphx::make_op("multibroadcast", {{"out_lens", labels->get_shape().lens()}}), weights); + mb_weights = mm->add_instruction(migraphx::make_op("neg"), mb_weights); + + auto softmax = mm->add_instruction(migraphx::make_op("softmax"), scores); + auto unsq_labels = + mm->add_instruction(migraphx::make_op("unsqueeze", {{"axes", {-1}}}), labels); + auto unsq_labels_idx = + mm->add_instruction(migraphx::make_op("unsqueeze", {{"axes", {1}}}), labels_idx); + auto bc_unsq_labels_idx = mm->add_instruction( + migraphx::make_op("multibroadcast", {{"out_lens", unsq_labels->get_shape().lens()}}), + unsq_labels_idx); + auto concat = mm->add_instruction( + migraphx::make_op("concat", {{"axis", -1}}), bc_unsq_labels_idx, unsq_labels); + auto gathernd = mm->add_instruction(migraphx::make_op("gathernd"), softmax, concat); + auto unsq_mb_weights = + mm->add_instruction(migraphx::make_op("unsqueeze", {{"axes", {0}}}), mb_weights); + auto unsq_mb = mm->add_instruction( + migraphx::make_op("multibroadcast", {{"out_lens", scores->get_shape().lens()}}), + unsq_mb_weights); + auto gathernd2 = mm->add_instruction(migraphx::make_op("gathernd"), unsq_mb, concat); + + auto logsoftmax = mm->add_instruction(migraphx::make_op("log"), gathernd); + + auto weighted_loss = mm->add_instruction(migraphx::make_op("mul"), logsoftmax, gathernd2); + mm->add_instruction(migraphx::make_op("reduce_sum", {{"axes", {0}}}), weighted_loss); + + auto prog = optimize_onnx("softmaxcrossentropyloss_2d_sum_reduction_bf16_test.onnx"); + + EXPECT(p == prog); +} diff --git a/test/onnx/parse/softmaxcrossentropyloss_kd_all_reduction_weighted_test.cpp b/test/onnx/parse/softmaxcrossentropyloss_kd_all_reduction_weighted_test.cpp index 42b9f341336..2ad877797b7 100644 --- a/test/onnx/parse/softmaxcrossentropyloss_kd_all_reduction_weighted_test.cpp +++ b/test/onnx/parse/softmaxcrossentropyloss_kd_all_reduction_weighted_test.cpp @@ -266,3 +266,89 @@ TEST_CASE(softmaxcrossentropyloss_kd_mean_reduction_half_weighted_test) auto prog = optimize_onnx("softmaxcrossentropyloss_kd_mean_reduction_half_weighted_test.onnx"); EXPECT(p == prog); } + +TEST_CASE(softmaxcrossentropyloss_kd_mean_reduction_bf16_weighted_test) +{ + migraphx::program p; + auto* mm = p.get_main_module(); + size_t batch_size = 4; + size_t class_size = 4; + + auto scores = mm->add_parameter( + "0", migraphx::shape{migraphx::shape::bf16_type, {batch_size, class_size, 2, 2}}); + auto labels = + mm->add_parameter("1", migraphx::shape{migraphx::shape::int32_type, {class_size, 2, 2}}); + auto weights = + mm->add_parameter("2", migraphx::shape{migraphx::shape::bf16_type, {class_size}}); + + auto weights_dflt = mm->add_literal( + migraphx::literal(migraphx::shape(migraphx::shape::bf16_type, {1}, {0}), {1})); + auto labels_idx = mm->add_literal(migraphx::literal( + migraphx::shape(migraphx::shape::int32_type, {class_size}, {1}), {0, 1, 2, 3})); + + // Index variables used for gather on k dimensions that span their dimension + auto kd_1 = mm->add_literal( + migraphx::literal(migraphx::shape(migraphx::shape::int32_type, {2}, {1}), {0, 1})); + auto kd_2 = mm->add_literal( + migraphx::literal(migraphx::shape(migraphx::shape::int32_type, {2}, {1}), {0, 1})); + + mm->add_instruction(migraphx::make_op("multibroadcast", {{"out_lens", {class_size}}}), + weights_dflt); + weights = mm->add_instruction(migraphx::make_op("neg"), weights); + + auto softmax = mm->add_instruction(migraphx::make_op("softmax"), scores); + auto unsq_labels = + mm->add_instruction(migraphx::make_op("unsqueeze", {{"axes", {-1}}}), labels); + + auto unsq_labels_idx = + mm->add_instruction(migraphx::make_op("unsqueeze", {{"axes", {1, 2, 3}}}), labels_idx); + auto bc_unsq_labels_idx = mm->add_instruction( + migraphx::make_op("multibroadcast", {{"out_lens", unsq_labels->get_shape().lens()}}), + unsq_labels_idx); + + auto unsq_labels_idx2 = + mm->add_instruction(migraphx::make_op("unsqueeze", {{"axes", {0, 2, 3}}}), kd_1); + auto bc_unsq_labels_idx2 = mm->add_instruction( + migraphx::make_op("multibroadcast", {{"out_lens", unsq_labels->get_shape().lens()}}), + unsq_labels_idx2); + + auto unsq_labels_idx3 = + mm->add_instruction(migraphx::make_op("unsqueeze", {{"axes", {0, 1, 3}}}), kd_2); + auto bc_unsq_labels_idx3 = mm->add_instruction( + migraphx::make_op("multibroadcast", {{"out_lens", unsq_labels->get_shape().lens()}}), + unsq_labels_idx3); + + auto concat = mm->add_instruction(migraphx::make_op("concat", {{"axis", -1}}), + bc_unsq_labels_idx, + bc_unsq_labels_idx2, + bc_unsq_labels_idx3, + unsq_labels); + + auto transpose = mm->add_instruction( + migraphx::make_op("transpose", {{"permutation", {0, 2, 3, 1}}}), softmax); + + auto gathernd = mm->add_instruction(migraphx::make_op("gathernd"), transpose, concat); + auto unsq_mb_weights = + mm->add_instruction(migraphx::make_op("unsqueeze", {{"axes", {0, 2, 3}}}), weights); + auto unsq_mb = mm->add_instruction( + migraphx::make_op("multibroadcast", {{"out_lens", scores->get_shape().lens()}}), + unsq_mb_weights); + auto transpose2 = mm->add_instruction( + migraphx::make_op("transpose", {{"permutation", {0, 2, 3, 1}}}), unsq_mb); + auto gathernd2 = mm->add_instruction(migraphx::make_op("gathernd"), transpose2, concat); + + auto logsoftmax = mm->add_instruction(migraphx::make_op("log"), gathernd); + + auto weighted_loss = mm->add_instruction(migraphx::make_op("mul"), logsoftmax, gathernd2); + + auto loss_x = + mm->add_instruction(migraphx::make_op("reduce_sum", {{"axes", {0, 1, 2}}}), weighted_loss); + auto loss_w = + mm->add_instruction(migraphx::make_op("reduce_sum", {{"axes", {0, 1, 2}}}), gathernd2); + loss_w = mm->add_instruction(migraphx::make_op("neg"), loss_w); + + mm->add_instruction(migraphx::make_op("div"), loss_x, loss_w); + + auto prog = optimize_onnx("softmaxcrossentropyloss_kd_mean_reduction_bf16_weighted_test.onnx"); + EXPECT(p == prog); +} diff --git a/test/onnx/softmaxcrossentropyloss_2d_mean_reduction_bf16_weighted_test.onnx b/test/onnx/softmaxcrossentropyloss_2d_mean_reduction_bf16_weighted_test.onnx deleted file mode 100644 index d50caae01ae..00000000000 --- a/test/onnx/softmaxcrossentropyloss_2d_mean_reduction_bf16_weighted_test.onnx +++ /dev/null @@ -1,22 +0,0 @@ -  Date: Fri, 22 Nov 2024 19:35:15 -0600 Subject: [PATCH 72/72] remaining tests --- test/onnx/parse/gemm_bf16_test.cpp | 56 ++++++++++++ test/onnx/parse/group_norm_3d_bf16_test.cpp | 34 ++++++++ ...oodloss_kd_all_reduction_weighted_test.cpp | 85 +++++++++++++++++++ 3 files changed, 175 insertions(+) create mode 100644 test/onnx/parse/gemm_bf16_test.cpp create mode 100644 test/onnx/parse/group_norm_3d_bf16_test.cpp diff --git a/test/onnx/parse/gemm_bf16_test.cpp b/test/onnx/parse/gemm_bf16_test.cpp new file mode 100644 index 00000000000..23afe5b7936 --- /dev/null +++ b/test/onnx/parse/gemm_bf16_test.cpp @@ -0,0 +1,56 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include + +TEST_CASE(gemm_bf16_test) +{ + migraphx::program p; + auto* mm = p.get_main_module(); + auto l0 = mm->add_parameter("A", migraphx::shape{migraphx::shape::bf16_type, {8, 6}}); + auto l1 = mm->add_parameter("B", migraphx::shape{migraphx::shape::bf16_type, {8, 7}}); + auto l2 = mm->add_parameter("C", migraphx::shape{migraphx::shape::bf16_type, {6, 1}}); + auto alpha = 0.5f; + auto beta = 0.8f; + auto a_l = mm->add_literal(alpha); + auto t_a = add_common_op(*mm, migraphx::make_op("mul"), {a_l, l0}); + t_a = mm->add_instruction( + migraphx::make_op("convert", {{"target_type", migraphx::shape::bf16_type}}), t_a); + t_a = mm->add_instruction(migraphx::make_op("transpose", {{"permutation", {1, 0}}}), t_a); + std::vector lens = {6, 7}; + auto dot = migraphx::add_apply_alpha_beta(*mm, {t_a, l1}, migraphx::make_op("dot"), 1.0f, 0.0f); + l2 = mm->add_instruction(migraphx::make_op("multibroadcast", {{"out_lens", lens}}), l2); + l2 = mm->add_instruction( + migraphx::make_op("convert", {{"target_type", migraphx::shape::float_type}}), l2); + auto b_l = mm->add_literal(beta); + auto b_b = mm->add_instruction(migraphx::make_op("multibroadcast", {{"out_lens", lens}}), b_l); + auto l2_b = mm->add_instruction(migraphx::make_op("mul"), l2, b_b); + l2_b = mm->add_instruction( + migraphx::make_op("convert", {{"target_type", migraphx::shape::bf16_type}}), l2_b); + mm->add_instruction(migraphx::make_op("add"), dot, l2_b); + + auto prog = optimize_onnx("gemm_bf16_test.onnx"); + EXPECT(p == prog); +} diff --git a/test/onnx/parse/group_norm_3d_bf16_test.cpp b/test/onnx/parse/group_norm_3d_bf16_test.cpp new file mode 100644 index 00000000000..3d4d7579814 --- /dev/null +++ b/test/onnx/parse/group_norm_3d_bf16_test.cpp @@ -0,0 +1,34 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include + +TEST_CASE(group_norm_3d_bf16_test) +{ + migraphx::program p = make_group_norm( + {1, 4, 2}, {2}, {2}, {1, 2, 2, 2}, {2, 3}, 1e-5f, migraphx::shape::bf16_type); + auto prog = optimize_onnx("group_norm_3d_bf16_test.onnx"); + EXPECT(p == prog); +} diff --git a/test/onnx/parse/negativeloglikelihoodloss_kd_all_reduction_weighted_test.cpp b/test/onnx/parse/negativeloglikelihoodloss_kd_all_reduction_weighted_test.cpp index 0bbf82dae9e..a8510d40e1b 100644 --- a/test/onnx/parse/negativeloglikelihoodloss_kd_all_reduction_weighted_test.cpp +++ b/test/onnx/parse/negativeloglikelihoodloss_kd_all_reduction_weighted_test.cpp @@ -263,3 +263,88 @@ TEST_CASE(negativeloglikelihoodloss_kd_mean_reduction_half_weighted_test) optimize_onnx("negativeloglikelihoodloss_kd_mean_reduction_half_weighted_test.onnx"); EXPECT(p == prog); } + +TEST_CASE(negativeloglikelihoodloss_kd_mean_reduction_bf16_weighted_test) +{ + migraphx::program p; + auto* mm = p.get_main_module(); + size_t batch_size = 4; + size_t class_size = 4; + + auto scores = mm->add_parameter( + "0", migraphx::shape{migraphx::shape::bf16_type, {batch_size, class_size, 2, 2}}); + auto labels = + mm->add_parameter("1", migraphx::shape{migraphx::shape::int32_type, {class_size, 2, 2}}); + auto weights = + mm->add_parameter("2", migraphx::shape{migraphx::shape::bf16_type, {class_size}}); + + auto weights_dflt = mm->add_literal( + migraphx::literal(migraphx::shape(migraphx::shape::bf16_type, {1}, {0}), {1})); + auto labels_idx = mm->add_literal(migraphx::literal( + migraphx::shape(migraphx::shape::int32_type, {class_size}, {1}), {0, 1, 2, 3})); + + // Index variables used for gather on k dimensions that span their dimension + auto kd_1 = mm->add_literal( + migraphx::literal(migraphx::shape(migraphx::shape::int32_type, {2}, {1}), {0, 1})); + auto kd_2 = mm->add_literal( + migraphx::literal(migraphx::shape(migraphx::shape::int32_type, {2}, {1}), {0, 1})); + + mm->add_instruction(migraphx::make_op("multibroadcast", {{"out_lens", {class_size}}}), + weights_dflt); + + weights = mm->add_instruction(migraphx::make_op("neg"), weights); + auto unsq_labels = + mm->add_instruction(migraphx::make_op("unsqueeze", {{"axes", {-1}}}), labels); + + auto unsq_labels_idx = + mm->add_instruction(migraphx::make_op("unsqueeze", {{"axes", {1, 2, 3}}}), labels_idx); + auto bc_unsq_labels_idx = mm->add_instruction( + migraphx::make_op("multibroadcast", {{"out_lens", unsq_labels->get_shape().lens()}}), + unsq_labels_idx); + + auto unsq_labels_idx2 = + mm->add_instruction(migraphx::make_op("unsqueeze", {{"axes", {0, 2, 3}}}), kd_1); + auto bc_unsq_labels_idx2 = mm->add_instruction( + migraphx::make_op("multibroadcast", {{"out_lens", unsq_labels->get_shape().lens()}}), + unsq_labels_idx2); + + auto unsq_labels_idx3 = + mm->add_instruction(migraphx::make_op("unsqueeze", {{"axes", {0, 1, 3}}}), kd_2); + auto bc_unsq_labels_idx3 = mm->add_instruction( + migraphx::make_op("multibroadcast", {{"out_lens", unsq_labels->get_shape().lens()}}), + unsq_labels_idx3); + + auto concat = mm->add_instruction(migraphx::make_op("concat", {{"axis", -1}}), + bc_unsq_labels_idx, + bc_unsq_labels_idx2, + bc_unsq_labels_idx3, + unsq_labels); + + auto transpose = mm->add_instruction( + migraphx::make_op("transpose", {{"permutation", {0, 2, 3, 1}}}), scores); + + auto gathernd = mm->add_instruction(migraphx::make_op("gathernd"), transpose, concat); + auto unsq_mb_weights = + mm->add_instruction(migraphx::make_op("unsqueeze", {{"axes", {0, 2, 3}}}), weights); + auto unsq_mb = mm->add_instruction( + migraphx::make_op("multibroadcast", {{"out_lens", scores->get_shape().lens()}}), + unsq_mb_weights); + auto transpose2 = mm->add_instruction( + migraphx::make_op("transpose", {{"permutation", {0, 2, 3, 1}}}), unsq_mb); + auto gathernd2 = mm->add_instruction(migraphx::make_op("gathernd"), transpose2, concat); + + auto weighted_loss = mm->add_instruction(migraphx::make_op("mul"), gathernd, gathernd2); + + auto loss_x = + mm->add_instruction(migraphx::make_op("reduce_sum", {{"axes", {0, 1, 2}}}), weighted_loss); + auto loss_w = + mm->add_instruction(migraphx::make_op("reduce_sum", {{"axes", {0, 1, 2}}}), gathernd2); + + loss_w = mm->add_instruction(migraphx::make_op("neg"), loss_w); + + mm->add_instruction(migraphx::make_op("div"), loss_x, loss_w); + + auto prog = + optimize_onnx("negativeloglikelihoodloss_kd_mean_reduction_bf16_weighted_test.onnx"); + EXPECT(p == prog); +} \ No newline at end of file