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

Formatting

parent 5df808fc
...@@ -7,22 +7,23 @@ ...@@ -7,22 +7,23 @@
namespace migraph { 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) T normalize(T z)
{ {
if(z == 0) return 0; if(z == 0)
return 0;
return (2.0 / z) - 1.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) T normalize(T z)
{ {
const auto max = std::numeric_limits<T>::max(); 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); 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) T normalize(T z)
{ {
const auto max = std::numeric_limits<T>::max(); const auto max = std::numeric_limits<T>::max();
...@@ -48,7 +49,6 @@ struct xorshf96_generator ...@@ -48,7 +49,6 @@ struct xorshf96_generator
z = t ^ x ^ y; z = t ^ x ^ y;
return normalize(z); return normalize(z);
} }
}; };
......
...@@ -13,7 +13,7 @@ struct and_ : std::is_same<and_<Bs...>, and_<(Bs || true)...>> // NOLINT ...@@ -13,7 +13,7 @@ struct and_ : std::is_same<and_<Bs...>, and_<(Bs || true)...>> // NOLINT
template <bool B> template <bool B>
using bool_c = std::integral_constant<bool, B>; using bool_c = std::integral_constant<bool, B>;
template<int N> template <int N>
struct requires_enum struct requires_enum
{ {
enum e enum e
...@@ -22,20 +22,25 @@ struct requires_enum ...@@ -22,20 +22,25 @@ struct requires_enum
}; };
}; };
#define MIGRAPH_REQUIRES_CAT(x, y) x ## y #define MIGRAPH_REQUIRES_CAT(x, y) x##y
#ifdef CPPCHECK #ifdef CPPCHECK
#define MIGRAPH_REQUIRES(...) class = void #define MIGRAPH_REQUIRES(...) class = void
#else #else
#if 0 #if 0
// TODO: This current crashed on clang // TODO: This current crashed on clang
#define MIGRAPH_REQUIRES(...) \ #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( \
class = typename std::enable_if<and_<__VA_ARGS__, MIGRAPH_REQUIRES_CAT(PrivateRequires, __LINE__) == migraph::requires_enum<__LINE__>::A>{}>::type 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 #else
#define MIGRAPH_REQUIRES(...) \ #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( \
class = typename std::enable_if<and_<__VA_ARGS__>{}>::type PrivateRequires, __LINE__) = migraph::requires_enum<__LINE__>::A, \
class = typename std::enable_if<and_<__VA_ARGS__>{}>::type
#endif #endif
#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