From 7a646f1b2fc77cedda6789190363c8ce4a16050d Mon Sep 17 00:00:00 2001 From: richagadgil Date: Fri, 11 Oct 2024 14:53:09 -0500 Subject: [PATCH] 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 baad2c900a..6599ab0df9 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 0a93d6a237..013bc6c639 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