Commit 8ca1ea60 authored by Paul's avatar Paul
Browse files

Formatting

parent 5df808fc
......@@ -7,22 +7,23 @@
namespace migraph {
template<class T, MIGRAPH_REQUIRES(std::is_floating_point<T>{})>
template <class T, MIGRAPH_REQUIRES(std::is_floating_point<T>{})>
T normalize(T z)
{
if(z == 0) return 0;
if(z == 0)
return 0;
return (2.0 / z) - 1.0;
}
template<class T, MIGRAPH_REQUIRES(std::is_signed<T>{})>
template <class T, MIGRAPH_REQUIRES(std::is_signed<T>{})>
T normalize(T z)
{
const auto max = std::numeric_limits<T>::max();
const auto half_max = max/2;
const auto half_max = max / 2;
return half_max - (z % max);
}
template<class T, MIGRAPH_REQUIRES(not std::is_signed<T>{} and std::is_integral<T>{})>
template <class T, MIGRAPH_REQUIRES(not std::is_signed<T>{} and std::is_integral<T>{})>
T normalize(T z)
{
const auto max = std::numeric_limits<T>::max();
......@@ -48,7 +49,6 @@ struct xorshf96_generator
z = t ^ x ^ y;
return normalize(z);
}
};
......
......@@ -13,7 +13,7 @@ struct and_ : std::is_same<and_<Bs...>, and_<(Bs || true)...>> // NOLINT
template <bool B>
using bool_c = std::integral_constant<bool, B>;
template<int N>
template <int N>
struct requires_enum
{
enum e
......@@ -22,7 +22,7 @@ struct requires_enum
};
};
#define MIGRAPH_REQUIRES_CAT(x, y) x ## y
#define MIGRAPH_REQUIRES_CAT(x, y) x##y
#ifdef CPPCHECK
#define MIGRAPH_REQUIRES(...) class = void
......@@ -30,11 +30,16 @@ struct requires_enum
#if 0
// TODO: This current crashed on clang
#define MIGRAPH_REQUIRES(...) \
typename migraph::requires_enum<__LINE__>::e MIGRAPH_REQUIRES_CAT(PrivateRequires, __LINE__) = migraph::requires_enum<__LINE__>::A, \
class = typename std::enable_if<and_<__VA_ARGS__, MIGRAPH_REQUIRES_CAT(PrivateRequires, __LINE__) == migraph::requires_enum<__LINE__>::A>{}>::type
typename migraph::requires_enum<__LINE__>::e MIGRAPH_REQUIRES_CAT( \
PrivateRequires, \
__LINE__) = migraph::requires_enum<__LINE__>::A, \
class = typename std::enable_if<and_<__VA_ARGS__, \
MIGRAPH_REQUIRES_CAT(PrivateRequires, __LINE__) == \
migraph::requires_enum<__LINE__>::A>{}>::type
#else
#define MIGRAPH_REQUIRES(...) \
typename migraph::requires_enum<__LINE__>::e MIGRAPH_REQUIRES_CAT(PrivateRequires, __LINE__) = migraph::requires_enum<__LINE__>::A, \
typename migraph::requires_enum<__LINE__>::e MIGRAPH_REQUIRES_CAT( \
PrivateRequires, __LINE__) = migraph::requires_enum<__LINE__>::A, \
class = typename std::enable_if<and_<__VA_ARGS__>{}>::type
#endif
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment