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
355e4f6f
Commit
355e4f6f
authored
Nov 14, 2023
by
Umang Yadav
Browse files
fix isfinite
parent
9ee0418d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
6 deletions
+59
-6
src/include/migraphx/float8.hpp
src/include/migraphx/float8.hpp
+4
-6
test/fp8e4m3fn.cpp
test/fp8e4m3fn.cpp
+14
-0
test/fp8e4m3fnuz.cpp
test/fp8e4m3fnuz.cpp
+14
-0
test/fp8e5m2.cpp
test/fp8e5m2.cpp
+13
-0
test/fp8e5m2fnuz.cpp
test/fp8e5m2fnuz.cpp
+14
-0
No files found.
src/include/migraphx/float8.hpp
View file @
355e4f6f
...
@@ -273,9 +273,8 @@ using fp8e5m2fnuz = float8<migraphx::fp8::f8_type::bf8, true>;
...
@@ -273,9 +273,8 @@ using fp8e5m2fnuz = float8<migraphx::fp8::f8_type::bf8, true>;
template
<
>
template
<
>
class
numeric_limits
<
fp8e4m3fnuz
>
class
numeric_limits
<
fp8e4m3fnuz
>
{
{
static
constexpr
bool
has_infinity
=
false
;
public:
public:
static
constexpr
bool
has_infinity
=
false
;
static
constexpr
fp8e4m3fnuz
epsilon
()
{
return
fp8e4m3fnuz
(
0x28
,
fp8e4m3fnuz
::
from_bits
());
}
static
constexpr
fp8e4m3fnuz
epsilon
()
{
return
fp8e4m3fnuz
(
0x28
,
fp8e4m3fnuz
::
from_bits
());
}
// NOLINTNEXTLINE
// NOLINTNEXTLINE
static
constexpr
fp8e4m3fnuz
quiet_NaN
()
{
return
fp8e4m3fnuz
(
0x80
,
fp8e4m3fnuz
::
from_bits
());
}
static
constexpr
fp8e4m3fnuz
quiet_NaN
()
{
return
fp8e4m3fnuz
(
0x80
,
fp8e4m3fnuz
::
from_bits
());
}
...
@@ -290,9 +289,8 @@ class numeric_limits<fp8e4m3fnuz>
...
@@ -290,9 +289,8 @@ class numeric_limits<fp8e4m3fnuz>
template
<
>
template
<
>
class
numeric_limits
<
fp8e4m3fn
>
class
numeric_limits
<
fp8e4m3fn
>
{
{
static
constexpr
bool
has_infinity
=
false
;
public:
public:
static
constexpr
bool
has_infinity
=
false
;
static
constexpr
fp8e4m3fn
epsilon
()
{
return
fp8e4m3fn
(
0x20
,
fp8e4m3fn
::
from_bits
());
}
static
constexpr
fp8e4m3fn
epsilon
()
{
return
fp8e4m3fn
(
0x20
,
fp8e4m3fn
::
from_bits
());
}
// NOLINTNEXTLINE
// NOLINTNEXTLINE
static
constexpr
fp8e4m3fn
quiet_NaN
()
{
return
fp8e4m3fn
(
0x7F
,
fp8e4m3fn
::
from_bits
());
}
static
constexpr
fp8e4m3fn
quiet_NaN
()
{
return
fp8e4m3fn
(
0x7F
,
fp8e4m3fn
::
from_bits
());
}
...
@@ -307,9 +305,8 @@ class numeric_limits<fp8e4m3fn>
...
@@ -307,9 +305,8 @@ class numeric_limits<fp8e4m3fn>
template
<
>
template
<
>
class
numeric_limits
<
fp8e5m2fnuz
>
class
numeric_limits
<
fp8e5m2fnuz
>
{
{
static
constexpr
bool
has_infinity
=
false
;
public:
public:
static
constexpr
bool
has_infinity
=
false
;
static
constexpr
fp8e5m2fnuz
epsilon
()
{
return
fp8e5m2fnuz
(
0x34
,
fp8e5m2fnuz
::
from_bits
());
}
static
constexpr
fp8e5m2fnuz
epsilon
()
{
return
fp8e5m2fnuz
(
0x34
,
fp8e5m2fnuz
::
from_bits
());
}
static
constexpr
fp8e5m2fnuz
quiet_NaN
()
// NOLINT
static
constexpr
fp8e5m2fnuz
quiet_NaN
()
// NOLINT
...
@@ -329,6 +326,7 @@ template <>
...
@@ -329,6 +326,7 @@ template <>
class
numeric_limits
<
fp8e5m2
>
class
numeric_limits
<
fp8e5m2
>
{
{
public:
public:
static
constexpr
bool
has_infinity
=
true
;
static
constexpr
fp8e5m2
epsilon
()
{
return
fp8e5m2
(
0x34
,
fp8e5m2
::
from_bits
());
}
static
constexpr
fp8e5m2
epsilon
()
{
return
fp8e5m2
(
0x34
,
fp8e5m2
::
from_bits
());
}
// 7D, 7E, 7F are positive NaNs and FD, FE, FF are negative NaNs
// 7D, 7E, 7F are positive NaNs and FD, FE, FF are negative NaNs
static
constexpr
fp8e5m2
quiet_NaN
()
{
return
fp8e5m2
(
0xFF
,
fp8e5m2
::
from_bits
());
}
// NOLINT
static
constexpr
fp8e5m2
quiet_NaN
()
{
return
fp8e5m2
(
0xFF
,
fp8e5m2
::
from_bits
());
}
// NOLINT
...
...
test/fp8e4m3fn.cpp
View file @
355e4f6f
...
@@ -212,4 +212,18 @@ TEST_CASE(test_max_eq_lowest)
...
@@ -212,4 +212,18 @@ TEST_CASE(test_max_eq_lowest)
EXPECT
(
migraphx
::
float_equal
(
std
::
numeric_limits
<
migraphx
::
fp8
::
fp8e4m3fn
>::
lowest
(),
EXPECT
(
migraphx
::
float_equal
(
std
::
numeric_limits
<
migraphx
::
fp8
::
fp8e4m3fn
>::
lowest
(),
-
1
*
std
::
numeric_limits
<
migraphx
::
fp8
::
fp8e4m3fn
>::
max
()));
-
1
*
std
::
numeric_limits
<
migraphx
::
fp8
::
fp8e4m3fn
>::
max
()));
}
}
TEST_CASE
(
test_isfinite
)
{
EXPECT
(
std
::
isfinite
(
migraphx
::
fp8
::
fp8e4m3fn
(
0.0
)));
EXPECT
(
std
::
isfinite
(
migraphx
::
fp8
::
fp8e4m3fn
(
-
0.0
)));
EXPECT
(
not
std
::
isfinite
(
migraphx
::
fp8
::
fp8e4m3fn
(
std
::
numeric_limits
<
migraphx
::
fp8
::
fp8e4m3fn
>::
quiet_NaN
())));
}
TEST_CASE
(
test_no_infinity
)
{
EXPECT
(
not
bool
{
std
::
numeric_limits
<
migraphx
::
fp8
::
fp8e4m3fn
>::
has_infinity
});
}
int
main
(
int
argc
,
const
char
*
argv
[])
{
test
::
run
(
argc
,
argv
);
}
int
main
(
int
argc
,
const
char
*
argv
[])
{
test
::
run
(
argc
,
argv
);
}
test/fp8e4m3fnuz.cpp
View file @
355e4f6f
...
@@ -227,4 +227,18 @@ TEST_CASE(test_max_eq_lowest)
...
@@ -227,4 +227,18 @@ TEST_CASE(test_max_eq_lowest)
EXPECT
(
migraphx
::
float_equal
(
std
::
numeric_limits
<
migraphx
::
fp8
::
fp8e4m3fnuz
>::
lowest
(),
EXPECT
(
migraphx
::
float_equal
(
std
::
numeric_limits
<
migraphx
::
fp8
::
fp8e4m3fnuz
>::
lowest
(),
-
1
*
std
::
numeric_limits
<
migraphx
::
fp8
::
fp8e4m3fnuz
>::
max
()));
-
1
*
std
::
numeric_limits
<
migraphx
::
fp8
::
fp8e4m3fnuz
>::
max
()));
}
}
TEST_CASE
(
test_isfinite
)
{
EXPECT
(
std
::
isfinite
(
migraphx
::
fp8
::
fp8e4m3fnuz
(
0.0
)));
EXPECT
(
std
::
isfinite
(
migraphx
::
fp8
::
fp8e4m3fnuz
(
-
0.0
)));
EXPECT
(
not
std
::
isfinite
(
migraphx
::
fp8
::
fp8e4m3fnuz
(
std
::
numeric_limits
<
migraphx
::
fp8
::
fp8e4m3fnuz
>::
quiet_NaN
())));
}
TEST_CASE
(
test_no_infinity
)
{
EXPECT
(
not
bool
{
std
::
numeric_limits
<
migraphx
::
fp8
::
fp8e4m3fnuz
>::
has_infinity
});
}
int
main
(
int
argc
,
const
char
*
argv
[])
{
test
::
run
(
argc
,
argv
);
}
int
main
(
int
argc
,
const
char
*
argv
[])
{
test
::
run
(
argc
,
argv
);
}
test/fp8e5m2.cpp
View file @
355e4f6f
...
@@ -409,4 +409,17 @@ TEST_CASE(test_max_eq_lowest)
...
@@ -409,4 +409,17 @@ TEST_CASE(test_max_eq_lowest)
EXPECT
(
migraphx
::
float_equal
(
std
::
numeric_limits
<
migraphx
::
fp8
::
fp8e5m2
>::
lowest
(),
EXPECT
(
migraphx
::
float_equal
(
std
::
numeric_limits
<
migraphx
::
fp8
::
fp8e5m2
>::
lowest
(),
-
1
*
std
::
numeric_limits
<
migraphx
::
fp8
::
fp8e5m2
>::
max
()));
-
1
*
std
::
numeric_limits
<
migraphx
::
fp8
::
fp8e5m2
>::
max
()));
}
}
TEST_CASE
(
test_isfinite
)
{
EXPECT
(
std
::
isfinite
(
migraphx
::
fp8
::
fp8e5m2
(
0.0
)));
EXPECT
(
std
::
isfinite
(
migraphx
::
fp8
::
fp8e5m2
(
-
0.0
)));
EXPECT
(
not
std
::
isfinite
(
migraphx
::
fp8
::
fp8e5m2
(
std
::
numeric_limits
<
migraphx
::
fp8
::
fp8e5m2
>::
infinity
())));
EXPECT
(
not
std
::
isfinite
(
migraphx
::
fp8
::
fp8e5m2
(
-
1.0
*
std
::
numeric_limits
<
migraphx
::
fp8
::
fp8e5m2
>::
infinity
())));
EXPECT
(
not
std
::
isfinite
(
migraphx
::
fp8
::
fp8e5m2
(
std
::
numeric_limits
<
migraphx
::
fp8
::
fp8e5m2
>::
quiet_NaN
())));
}
int
main
(
int
argc
,
const
char
*
argv
[])
{
test
::
run
(
argc
,
argv
);
}
int
main
(
int
argc
,
const
char
*
argv
[])
{
test
::
run
(
argc
,
argv
);
}
test/fp8e5m2fnuz.cpp
View file @
355e4f6f
...
@@ -397,4 +397,18 @@ TEST_CASE(test_max_eq_lowest)
...
@@ -397,4 +397,18 @@ TEST_CASE(test_max_eq_lowest)
EXPECT
(
migraphx
::
float_equal
(
std
::
numeric_limits
<
migraphx
::
fp8
::
fp8e5m2fnuz
>::
lowest
(),
EXPECT
(
migraphx
::
float_equal
(
std
::
numeric_limits
<
migraphx
::
fp8
::
fp8e5m2fnuz
>::
lowest
(),
-
1
*
std
::
numeric_limits
<
migraphx
::
fp8
::
fp8e5m2fnuz
>::
max
()));
-
1
*
std
::
numeric_limits
<
migraphx
::
fp8
::
fp8e5m2fnuz
>::
max
()));
}
}
TEST_CASE
(
test_isfinite
)
{
EXPECT
(
std
::
isfinite
(
migraphx
::
fp8
::
fp8e5m2fnuz
(
0.0
)));
EXPECT
(
std
::
isfinite
(
migraphx
::
fp8
::
fp8e5m2fnuz
(
-
0.0
)));
EXPECT
(
not
std
::
isfinite
(
migraphx
::
fp8
::
fp8e5m2fnuz
(
std
::
numeric_limits
<
migraphx
::
fp8
::
fp8e5m2fnuz
>::
quiet_NaN
())));
}
TEST_CASE
(
test_no_infinity
)
{
EXPECT
(
not
bool
{
std
::
numeric_limits
<
migraphx
::
fp8
::
fp8e5m2fnuz
>::
has_infinity
});
}
int
main
(
int
argc
,
const
char
*
argv
[])
{
test
::
run
(
argc
,
argv
);
}
int
main
(
int
argc
,
const
char
*
argv
[])
{
test
::
run
(
argc
,
argv
);
}
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