#ifndef MIGRAPH_GUARD_MIGRAPHLIB_FLOAT_EQUAL_HPP #define MIGRAPH_GUARD_MIGRAPHLIB_FLOAT_EQUAL_HPP #include #include #include #ifdef _MSC_VER #include #endif #include #include namespace migraph { inline namespace MIGRAPH_INLINE_NS { template using common_type = typename std::common_type::type; struct float_equal_fn { template {})> static bool apply(T x, T y) { return std::isfinite(x) and std::isfinite(y) and std::nextafter(x, std::numeric_limits::lowest()) <= y and std::nextafter(x, std::numeric_limits::max()) >= y; } template {})> static bool apply(T x, T y) { return x == y; } template bool operator()(T x, U y) const { return float_equal_fn::apply>(x, y); } }; static constexpr float_equal_fn float_equal{}; } // namespace MIGRAPH_INLINE_NS } // namespace migraph #endif