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
composable_kernel
Commits
789862ca
Commit
789862ca
authored
May 23, 2023
by
Rostyslav Geyyer
Browse files
Use seed as a runtime arg
parent
502942fe
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
+7
-6
include/ck/utility/data_type.hpp
include/ck/utility/data_type.hpp
+7
-6
No files found.
include/ck/utility/data_type.hpp
View file @
789862ca
...
@@ -1148,8 +1148,8 @@ inline __host__ __device__ constexpr bhalf_t bf16_convert_rtn<bhalf_t, half_t>(h
...
@@ -1148,8 +1148,8 @@ inline __host__ __device__ constexpr bhalf_t bf16_convert_rtn<bhalf_t, half_t>(h
// Pseudo random number generator
// Pseudo random number generator
// version for fp32
// version for fp32
template
<
typename
T
,
uint32_t
seed
,
std
::
enable_if_t
<
std
::
is_same
<
float
,
T
>{},
bool
>
=
false
>
template
<
typename
T
,
uint32_t
seed
_t
,
std
::
enable_if_t
<
std
::
is_same
<
float
,
T
>{},
bool
>
=
false
>
__host__
__device__
uint32_t
prand_generator
(
index_t
id
,
T
val
)
__host__
__device__
uint32_t
prand_generator
(
index_t
id
,
T
val
,
uint32_t
seed
=
seed_t
)
{
{
// uint32_t x = reinterpret_cast<uint32_t&>(val);
// uint32_t x = reinterpret_cast<uint32_t&>(val);
uint32_t
x
=
*
(
reinterpret_cast
<
uint32_t
*>
(
&
val
));
uint32_t
x
=
*
(
reinterpret_cast
<
uint32_t
*>
(
&
val
));
...
@@ -1165,8 +1165,8 @@ __host__ __device__ uint32_t prand_generator(index_t id, T val)
...
@@ -1165,8 +1165,8 @@ __host__ __device__ uint32_t prand_generator(index_t id, T val)
}
}
// version for fp16
// version for fp16
template
<
typename
T
,
uint32_t
seed
,
std
::
enable_if_t
<
std
::
is_same
<
half_t
,
T
>{},
bool
>
=
false
>
template
<
typename
T
,
uint32_t
seed
_t
,
std
::
enable_if_t
<
std
::
is_same
<
half_t
,
T
>{},
bool
>
=
false
>
__host__
__device__
uint32_t
prand_generator
(
index_t
id
,
T
val
)
__host__
__device__
uint32_t
prand_generator
(
index_t
id
,
T
val
,
uint32_t
seed
=
seed_t
)
{
{
// uint16_t x = reinterpret_cast<uint16_t&>(val);
// uint16_t x = reinterpret_cast<uint16_t&>(val);
uint16_t
x
=
*
(
reinterpret_cast
<
uint16_t
*>
(
&
val
));
uint16_t
x
=
*
(
reinterpret_cast
<
uint16_t
*>
(
&
val
));
...
@@ -1182,12 +1182,13 @@ __host__ __device__ uint32_t prand_generator(index_t id, T val)
...
@@ -1182,12 +1182,13 @@ __host__ __device__ uint32_t prand_generator(index_t id, T val)
// return 0 if data is not fp16 or fp32
// return 0 if data is not fp16 or fp32
template
<
typename
T
,
template
<
typename
T
,
uint32_t
seed
,
uint32_t
seed
_t
,
std
::
enable_if_t
<!
(
std
::
is_same
<
float
,
T
>{}
||
std
::
is_same
<
half_t
,
T
>
{}),
bool
>
=
false
>
std
::
enable_if_t
<!
(
std
::
is_same
<
float
,
T
>{}
||
std
::
is_same
<
half_t
,
T
>
{}),
bool
>
=
false
>
__host__
__device__
uint32_t
prand_generator
(
int
id
,
T
val
)
__host__
__device__
uint32_t
prand_generator
(
int
id
,
T
val
,
uint32_t
seed
=
seed_t
)
{
{
std
::
ignore
=
id
;
std
::
ignore
=
id
;
std
::
ignore
=
val
;
std
::
ignore
=
val
;
std
::
ignore
=
seed
;
return
0
;
return
0
;
}
}
...
...
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