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
61e4e1d7
Commit
61e4e1d7
authored
Nov 16, 2023
by
Umang Yadav
Browse files
use 31 for min value
parent
98a838f4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
src/include/migraphx/float8_impl.hpp
src/include/migraphx/float8_impl.hpp
+4
-4
No files found.
src/include/migraphx/float8_impl.hpp
View file @
61e4e1d7
...
@@ -168,9 +168,9 @@ constexpr uint8_t cast_to_f8(T f_x, bool stoch = false, uint32_t rng = 0)
...
@@ -168,9 +168,9 @@ constexpr uint8_t cast_to_f8(T f_x, bool stoch = false, uint32_t rng = 0)
}
}
mantissa
+=
(
1u
<<
mfmt
);
// Add the implicit 1 into mantissa
mantissa
+=
(
1u
<<
mfmt
);
// Add the implicit 1 into mantissa
}
}
// shifting by more than sizeof(T) is undefined behaviour, cap shift to 31
bool
midpoint
=
(
mantissa
&
((
1u
<<
std
::
min
(
3
2
u
,
mfmt
-
Wm
+
exponent_diff
))
-
1
))
==
bool
midpoint
=
(
mantissa
&
((
1u
<<
std
::
min
(
3
1
u
,
mfmt
-
Wm
+
exponent_diff
))
-
1
))
==
(
1u
<<
std
::
min
(
3
2
u
,
mfmt
-
Wm
+
exponent_diff
-
1
));
(
1u
<<
std
::
min
(
3
1
u
,
mfmt
-
Wm
+
exponent_diff
-
1
));
/* This part is a bit tricky. The judgment of whether it is a tie needs to be done before we
/* This part is a bit tricky. The judgment of whether it is a tie needs to be done before we
shift right as shift right could rip off some residual part and make something not midpoint look
shift right as shift right could rip off some residual part and make something not midpoint look
like midpoint. For example, the fp16 number 0x1002 (0 00100 0000000010), it is larger than
like midpoint. For example, the fp16 number 0x1002 (0 00100 0000000010), it is larger than
...
@@ -178,7 +178,7 @@ constexpr uint8_t cast_to_f8(T f_x, bool stoch = false, uint32_t rng = 0)
...
@@ -178,7 +178,7 @@ constexpr uint8_t cast_to_f8(T f_x, bool stoch = false, uint32_t rng = 0)
*/
*/
if
(
exponent_diff
>
0
)
if
(
exponent_diff
>
0
)
mantissa
>>=
exponent_diff
;
mantissa
>>=
std
::
min
(
31u
,
uint32_t
(
exponent_diff
))
;
else
if
(
exponent_diff
==
-
1
)
else
if
(
exponent_diff
==
-
1
)
mantissa
<<=
-
exponent_diff
;
mantissa
<<=
-
exponent_diff
;
bool
implicit_one
=
mantissa
&
(
1
<<
mfmt
);
bool
implicit_one
=
mantissa
&
(
1
<<
mfmt
);
...
...
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