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
136df3db
Unverified
Commit
136df3db
authored
Oct 11, 2023
by
Artur Wojcik
Committed by
GitHub
Oct 10, 2023
Browse files
fix compilation of uniform int distribution (#2284)
parent
48afdcab
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
5 deletions
+20
-5
src/include/migraphx/op/random_uniform.hpp
src/include/migraphx/op/random_uniform.hpp
+20
-5
No files found.
src/include/migraphx/op/random_uniform.hpp
View file @
136df3db
...
...
@@ -77,11 +77,26 @@ struct random_uniform
using
type
=
typename
decltype
(
output
)
::
value_type
;
if
constexpr
(
std
::
is_integral
<
type
>
{})
{
// default range for all integer types is
// (0, std::uniform_int_distribution<type>::max()).
// Todo: enable different ranges
std
::
uniform_int_distribution
<
type
>
dis
;
std
::
generate
(
output
.
begin
(),
output
.
end
(),
[
&
]
{
return
dis
(
gen
);
});
#ifdef _MSC_VER
// According to the C++ specification, the effect is undefined if the result type
// for the generator is not one of short, int, long, long long, unsigned short,
// unsigned int, unsigned long, or unsigned long long. See
// https://en.cppreference.com/w/cpp/numeric/random/uniform_int_distribution.
if
constexpr
(
sizeof
(
type
)
==
1
)
{
std
::
uniform_int_distribution
<
int
>
dis
{
std
::
numeric_limits
<
type
>::
min
(),
std
::
numeric_limits
<
type
>::
max
()};
std
::
generate
(
output
.
begin
(),
output
.
end
(),
[
&
]
{
return
dis
(
gen
);
});
}
else
#endif
{
// default range for all integer types is
// (0, std::uniform_int_distribution<type>::max()).
// Todo: enable different ranges
std
::
uniform_int_distribution
<
type
>
dis
;
std
::
generate
(
output
.
begin
(),
output
.
end
(),
[
&
]
{
return
dis
(
gen
);
});
}
}
else
{
...
...
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