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
114c341f
Commit
114c341f
authored
May 15, 2023
by
Rostyslav Geyyer
Browse files
Split f8_convert_sr in host and device
parent
fd2e6309
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
4 deletions
+21
-4
include/ck/utility/data_type.hpp
include/ck/utility/data_type.hpp
+21
-4
No files found.
include/ck/utility/data_type.hpp
View file @
114c341f
...
@@ -1172,13 +1172,30 @@ __host__ __device__ uint32_t prand_generator(int id, T val)
...
@@ -1172,13 +1172,30 @@ __host__ __device__ uint32_t prand_generator(int id, T val)
return
0
;
return
0
;
}
}
// Declare a template function for fp8 conversion using SR
// Declare a template function for fp8 conversion using SR
on host
template
<
typename
Y
,
typename
X
>
template
<
typename
Y
,
typename
X
>
__host__
__device__
constexpr
Y
f8_convert_sr
(
X
x
);
__host__
constexpr
Y
f8_convert_sr
(
X
x
);
// convert fp32 to fp8 with stochastic rounding
// Declare a template function for fp8 conversion using SR on device
template
<
typename
Y
,
typename
X
>
__device__
constexpr
Y
f8_convert_sr
(
X
x
);
// convert fp32 to fp8 with stochastic rounding on host
template
<
>
inline
__host__
f8_t
f8_convert_sr
<
f8_t
,
float
>
(
float
x
)
{
constexpr
bool
negative_zero_nan
=
true
;
constexpr
bool
clip
=
true
;
constexpr
f8_rounding_mode
rm
=
f8_rounding_mode
::
stochastic
;
constexpr
int
seed
=
42
;
// as thread id is not available on host, use 0 for prn generation
uint32_t
rng
=
prand_generator
<
float
,
seed
>
(
0
,
x
);
return
cast_to_f8
<
negative_zero_nan
,
clip
,
(
rm
==
f8_rounding_mode
::
stochastic
)
>
(
x
,
rng
);
}
// convert fp32 to fp8 with stochastic rounding on device
template
<
>
template
<
>
inline
__host__
__device__
f8_t
f8_convert_sr
<
f8_t
,
float
>
(
float
x
)
inline
__device__
f8_t
f8_convert_sr
<
f8_t
,
float
>
(
float
x
)
{
{
constexpr
bool
negative_zero_nan
=
true
;
constexpr
bool
negative_zero_nan
=
true
;
constexpr
bool
clip
=
true
;
constexpr
bool
clip
=
true
;
...
...
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