Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
8ca1ea60
Commit
8ca1ea60
authored
Aug 20, 2018
by
Paul
Browse files
Formatting
parent
5df808fc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
15 deletions
+20
-15
src/include/migraph/generate.hpp
src/include/migraph/generate.hpp
+7
-7
src/include/migraph/requires.hpp
src/include/migraph/requires.hpp
+13
-8
No files found.
src/include/migraph/generate.hpp
View file @
8ca1ea60
...
@@ -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
);
}
}
};
};
...
...
src/include/migraph/requires.hpp
View file @
8ca1ea60
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment