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
ed0cb725
Commit
ed0cb725
authored
May 18, 2023
by
Rostyslav Geyyer
Browse files
Format
parent
dbd20ecc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
5 deletions
+13
-5
test/data_type/fp8.cpp
test/data_type/fp8.cpp
+13
-5
No files found.
test/data_type/fp8.cpp
View file @
ed0cb725
...
@@ -4,9 +4,9 @@
...
@@ -4,9 +4,9 @@
#include "gtest/gtest.h"
#include "gtest/gtest.h"
#include "ck/utility/data_type.hpp"
#include "ck/utility/data_type.hpp"
using
ck
::
f8_convert_sr
;
using
ck
::
f8_t
;
using
ck
::
f8_t
;
using
ck
::
type_convert
;
using
ck
::
type_convert
;
using
ck
::
f8_convert_sr
;
TEST
(
FP8
,
NumericLimits
)
TEST
(
FP8
,
NumericLimits
)
{
{
...
@@ -23,11 +23,15 @@ TEST(FP8, ConvertFP32Nearest)
...
@@ -23,11 +23,15 @@ TEST(FP8, ConvertFP32Nearest)
// convert 0 float to fp8 and back, check if holds
// convert 0 float to fp8 and back, check if holds
ASSERT_NEAR
(
0.0
f
,
type_convert
<
float
>
(
type_convert
<
f8_t
>
(
0.0
f
)),
abs_tol
);
ASSERT_NEAR
(
0.0
f
,
type_convert
<
float
>
(
type_convert
<
f8_t
>
(
0.0
f
)),
abs_tol
);
// convert minimal float to fp8 and back, check if holds
// convert minimal float to fp8 and back, check if holds
ASSERT_NEAR
(
std
::
numeric_limits
<
float
>::
min
(),
type_convert
<
float
>
(
type_convert
<
f8_t
>
(
std
::
numeric_limits
<
float
>::
min
())),
abs_tol
);
ASSERT_NEAR
(
std
::
numeric_limits
<
float
>::
min
(),
type_convert
<
float
>
(
type_convert
<
f8_t
>
(
std
::
numeric_limits
<
float
>::
min
())),
abs_tol
);
// convert maximal f8_t to float and check if equal to 240.0
// convert maximal f8_t to float and check if equal to 240.0
ASSERT_NEAR
(
240.0
f
,
type_convert
<
float
>
(
type_convert
<
f8_t
>
(
240.0
f
)),
abs_tol
);
ASSERT_NEAR
(
240.0
f
,
type_convert
<
float
>
(
type_convert
<
f8_t
>
(
240.0
f
)),
abs_tol
);
// convert maximal float to fp8 and back, check if clipped to 240.0
// convert maximal float to fp8 and back, check if clipped to 240.0
ASSERT_NEAR
(
240.0
f
,
type_convert
<
float
>
(
type_convert
<
f8_t
>
(
std
::
numeric_limits
<
float
>::
max
())),
abs_tol
);
ASSERT_NEAR
(
240.0
f
,
type_convert
<
float
>
(
type_convert
<
f8_t
>
(
std
::
numeric_limits
<
float
>::
max
())),
abs_tol
);
// convert inf float to f8_t and check if it is qNan
// convert inf float to f8_t and check if it is qNan
ASSERT_NEAR
(
0x80
,
type_convert
<
f8_t
>
(
std
::
numeric_limits
<
float
>::
infinity
()),
abs_tol
);
ASSERT_NEAR
(
0x80
,
type_convert
<
f8_t
>
(
std
::
numeric_limits
<
float
>::
infinity
()),
abs_tol
);
// positive float value to fp8 and back, check if holds
// positive float value to fp8 and back, check if holds
...
@@ -45,11 +49,15 @@ TEST(FP8, ConvertFP32Stochastic)
...
@@ -45,11 +49,15 @@ TEST(FP8, ConvertFP32Stochastic)
// convert 0 float to fp8 and back, check if holds
// convert 0 float to fp8 and back, check if holds
ASSERT_NEAR
(
0.0
f
,
type_convert
<
float
>
(
f8_convert_sr
<
f8_t
>
(
0.0
f
)),
abs_tol
);
ASSERT_NEAR
(
0.0
f
,
type_convert
<
float
>
(
f8_convert_sr
<
f8_t
>
(
0.0
f
)),
abs_tol
);
// convert minimal float to fp8 and back, check if holds
// convert minimal float to fp8 and back, check if holds
ASSERT_NEAR
(
std
::
numeric_limits
<
float
>::
min
(),
type_convert
<
float
>
(
f8_convert_sr
<
f8_t
>
(
std
::
numeric_limits
<
float
>::
min
())),
abs_tol
);
ASSERT_NEAR
(
std
::
numeric_limits
<
float
>::
min
(),
type_convert
<
float
>
(
f8_convert_sr
<
f8_t
>
(
std
::
numeric_limits
<
float
>::
min
())),
abs_tol
);
// convert maximal f8_t to float and check if equal to 240.0
// convert maximal f8_t to float and check if equal to 240.0
ASSERT_NEAR
(
240.0
f
,
type_convert
<
float
>
(
f8_convert_sr
<
f8_t
>
(
240.0
f
)),
abs_tol
);
ASSERT_NEAR
(
240.0
f
,
type_convert
<
float
>
(
f8_convert_sr
<
f8_t
>
(
240.0
f
)),
abs_tol
);
// convert maximal float to fp8 and back, check if clipped to 240.0
// convert maximal float to fp8 and back, check if clipped to 240.0
ASSERT_NEAR
(
240.0
f
,
type_convert
<
float
>
(
f8_convert_sr
<
f8_t
>
(
std
::
numeric_limits
<
float
>::
max
())),
abs_tol
);
ASSERT_NEAR
(
240.0
f
,
type_convert
<
float
>
(
f8_convert_sr
<
f8_t
>
(
std
::
numeric_limits
<
float
>::
max
())),
abs_tol
);
// convert inf float to f8_t and check if it is qNan
// convert inf float to f8_t and check if it is qNan
ASSERT_NEAR
(
0x80
,
f8_convert_sr
<
f8_t
>
(
std
::
numeric_limits
<
float
>::
infinity
()),
abs_tol
);
ASSERT_NEAR
(
0x80
,
f8_convert_sr
<
f8_t
>
(
std
::
numeric_limits
<
float
>::
infinity
()),
abs_tol
);
// positive float value to fp8 and back, check if holds
// positive float value to fp8 and back, check if holds
...
...
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