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
b1ad4b4f
Commit
b1ad4b4f
authored
Nov 22, 2024
by
Rostyslav Geyyer
Browse files
Update e8m0 casting
parent
bdc1dd6f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
2 deletions
+5
-2
include/ck/utility/data_type.hpp
include/ck/utility/data_type.hpp
+1
-0
include/ck/utility/e8m0_utils.hpp
include/ck/utility/e8m0_utils.hpp
+4
-2
No files found.
include/ck/utility/data_type.hpp
View file @
b1ad4b4f
...
@@ -16,6 +16,7 @@ using bf8_t = unsigned _BitInt(8);
...
@@ -16,6 +16,7 @@ using bf8_t = unsigned _BitInt(8);
struct
e8m0_scale_t
struct
e8m0_scale_t
{
{
// E8M0 scale is biased
using
type
=
uint8_t
;
using
type
=
uint8_t
;
type
data
;
type
data
;
constexpr
e8m0_scale_t
()
:
data
{
type
{}}
{}
constexpr
e8m0_scale_t
()
:
data
{
type
{}}
{}
...
...
include/ck/utility/e8m0_utils.hpp
View file @
b1ad4b4f
...
@@ -10,12 +10,14 @@ namespace ck::utils {
...
@@ -10,12 +10,14 @@ namespace ck::utils {
__host__
__device__
inline
float
cast_to_float
(
e8m0_scale_t
const
scale
)
__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
);
// TODO: check performance and try bit shift impl
return
std
::
powf
(
2
,
bit_cast
<
uint8_t
>
(
scale
)
-
NumericUtils
<
e8m0_scale_t
>::
bias
);
}
}
__host__
__device__
inline
e8m0_scale_t
cast_from_float
(
float
const
scale
)
__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
);
uint32_t
e
=
bit_cast
<
uint32_t
>
(
scale
)
&
NumericUtils
<
float
>::
nan_mask
;
return
static_cast
<
uint8_t
>
(
e
>>
23
);
}
}
template
<
>
template
<
>
...
...
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