Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
richagadgil committed Oct 11, 2024
1 parent 0b60841 commit 7a646f1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 36 deletions.
6 changes: 6 additions & 0 deletions src/include/migraphx/generic_float.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
* THE SOFTWARE.
*/

namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {

template<unsigned int N>
constexpr unsigned int all_ones() noexcept
{
Expand Down Expand Up @@ -260,3 +263,6 @@ struct generic_float
return not(x == y);
}
};

}

Check warning on line 267 in src/include/migraphx/generic_float.hpp

View workflow job for this annotation

GitHub Actions / tidy

namespace 'MIGRAPHX_INLINE_NS' not terminated with a closing comment [llvm-namespace-comment,-warnings-as-errors]
}

Check warning on line 268 in src/include/migraphx/generic_float.hpp

View workflow job for this annotation

GitHub Actions / tidy

namespace 'migraphx' not terminated with a closing comment [llvm-namespace-comment,-warnings-as-errors]
61 changes: 25 additions & 36 deletions src/include/migraphx/half.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <class T>
Expand All @@ -59,56 +59,45 @@ using deduce = typename detail::deduce<T>::type;

namespace std {

template <class T>
struct common_type<migraphx::half, T> : std::common_type<float, T> // NOLINT
template<unsigned int E, unsigned int M, unsigned int F>
class numeric_limits<migraphx::generic_float<E, M, F>>

Check warning on line 63 in src/include/migraphx/half.hpp

View workflow job for this annotation

GitHub Actions / tidy

modification of 'std' namespace can result in undefined behavior [cert-dcl58-cpp,-warnings-as-errors]
{
};
public:
static constexpr bool has_infinity = false;
static constexpr migraphx::generic_float<E, M, F> epsilon() { return migraphx::generic_float<E, M, F>::epsilon(); }

template <class T>
struct common_type<T, migraphx::half> : std::common_type<float, T> // NOLINT
{
};
static constexpr migraphx::generic_float<E, M, F> quiet_NaN() { return migraphx::generic_float<E, M, F>::quiet_NaN(); }

Check warning on line 69 in src/include/migraphx/half.hpp

View workflow job for this annotation

GitHub Actions / tidy

invalid case style for constexpr method 'quiet_NaN' [readability-identifier-naming,-warnings-as-errors]

template <>
struct common_type<migraphx::fp8::fp8e4m3fnuz, migraphx::half>
{
using type = float;
};
static constexpr migraphx::generic_float<E, M, F> max() { return migraphx::generic_float<E, M, F>::max(); }

template <>
struct common_type<migraphx::half, migraphx::fp8::fp8e4m3fnuz>
{
using type = float;
};
static constexpr migraphx::generic_float<E, M, F> min() { return migraphx::generic_float<E, M, F>::min(); }

template <>
struct common_type<migraphx::fp8::fp8e4m3fn, migraphx::half>
{
using type = float;
};
static constexpr migraphx::generic_float<E, M, F> lowest() { return migraphx::generic_float<E, M, F>::lowest(); }

template <>
struct common_type<migraphx::half, migraphx::fp8::fp8e4m3fn>
{
using type = float;
};

template <>
struct common_type<migraphx::fp8::fp8e5m2, migraphx::half>
template<unsigned int E, unsigned int M, unsigned int F, class T>
struct common_type<migraphx::generic_float<E, M, F>, T> : std::common_type<float, T> // NOLINT
{
using type = float;
};

template <>
struct common_type<migraphx::half, migraphx::fp8::fp8e5m2>
template<unsigned int E, unsigned int M, unsigned int F, class T>
struct common_type<T, migraphx::generic_float<E, M, F>> : std::common_type<float, T> // NOLINT
{
using type = float;
};

template <>
struct common_type<migraphx::half, migraphx::half>
template<unsigned int E, unsigned int M, unsigned int F, migraphx::fp8::f8_type T, bool FNUZ>
struct common_type<migraphx::generic_float<E, M, F>, migraphx::fp8::float8<T, FNUZ>> : std::common_type<float, float>

Check warning on line 90 in src/include/migraphx/half.hpp

View workflow job for this annotation

GitHub Actions / tidy

modification of 'std' namespace can result in undefined behavior [cert-dcl58-cpp,-warnings-as-errors]
{};

template<unsigned int E, unsigned int M, unsigned int F, migraphx::fp8::f8_type T, bool FNUZ>
struct common_type<migraphx::fp8::float8<T, FNUZ>, migraphx::generic_float<E, M, F>> : std::common_type<float, float>

Check warning on line 94 in src/include/migraphx/half.hpp

View workflow job for this annotation

GitHub Actions / tidy

modification of 'std' namespace can result in undefined behavior [cert-dcl58-cpp,-warnings-as-errors]
{};

template<unsigned int E, unsigned int M, unsigned int F>
struct common_type<migraphx::generic_float<E, M, F>, migraphx::generic_float<E, M, F>>

Check warning on line 98 in src/include/migraphx/half.hpp

View workflow job for this annotation

GitHub Actions / tidy

modification of 'std' namespace can result in undefined behavior [cert-dcl58-cpp,-warnings-as-errors]
{
using type = migraphx::half;
using type = migraphx::generic_float<E, M, F>;
};

} // namespace std
Expand Down

0 comments on commit 7a646f1

Please sign in to comment.