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_ROCM
Commits
0bb6e25f
Commit
0bb6e25f
authored
Nov 06, 2024
by
Rostyslav Geyyer
Browse files
Add scale <-> float conversions
parent
4c47048f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
0 deletions
+10
-0
include/ck/utility/e8m0_utils.hpp
include/ck/utility/e8m0_utils.hpp
+10
-0
No files found.
include/ck/utility/e8m0_utils.hpp
View file @
0bb6e25f
...
...
@@ -8,4 +8,14 @@
namespace
ck
::
utils
{
__host__
__device__
inline
float
cast_to_float
(
e8m0_scale_t
const
scale
)
{
return
std
::
pow
(
2
,
bit_cast
<
uint8_t
>
(
scale
)
-
NumericUtils
<
e8m0_scale_t
>::
bias
);
}
__host__
__device__
inline
e8m0_scale_t
cast_from_float
(
float
const
scale
)
{
return
static_cast
<
uint8_t
>
(
std
::
log2
(
scale
)
+
NumericUtils
<
e8m0_scale_t
>::
bias
);
}
}
// namespace ck::utils
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