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
1e220c00
"examples/git@developer.sourcefind.cn:OpenDAS/nni.git" did not exist on "ffc23cfbf7f44cfb08c55532f86de34d52815b0d"
Commit
1e220c00
authored
Nov 14, 2023
by
Umang Yadav
Browse files
add stringstream tests
parent
03f71398
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
81 additions
and
4 deletions
+81
-4
src/include/migraphx/float8.hpp
src/include/migraphx/float8.hpp
+5
-4
test/fp8e4m3fn.cpp
test/fp8e4m3fn.cpp
+19
-0
test/fp8e4m3fnuz.cpp
test/fp8e4m3fnuz.cpp
+19
-0
test/fp8e5m2.cpp
test/fp8e5m2.cpp
+20
-0
test/fp8e5m2fnuz.cpp
test/fp8e5m2fnuz.cpp
+18
-0
No files found.
src/include/migraphx/float8.hpp
View file @
1e220c00
...
@@ -268,9 +268,10 @@ inline std::ostream& operator<<(std::ostream& os, const fp8e4m3fnuz& rhs)
...
@@ -268,9 +268,10 @@ inline std::ostream& operator<<(std::ostream& os, const fp8e4m3fnuz& rhs)
inline
fp8e4m3fnuz
fabs
(
fp8e4m3fnuz
v
)
inline
fp8e4m3fnuz
fabs
(
fp8e4m3fnuz
v
)
{
{
v
.
data
=
v
.
data
&
0x7
f
;
// NOLINT
v
.
data
=
v
.
data
&
0x7
F
;
// NOLINT
return
v
;
return
v
;
}
}
// Special operator overloading
// Special operator overloading
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
fp8e4m3fn
&
rhs
)
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
fp8e4m3fn
&
rhs
)
{
{
...
@@ -279,7 +280,7 @@ inline std::ostream& operator<<(std::ostream& os, const fp8e4m3fn& rhs)
...
@@ -279,7 +280,7 @@ inline std::ostream& operator<<(std::ostream& os, const fp8e4m3fn& rhs)
inline
fp8e4m3fn
fabs
(
fp8e4m3fn
v
)
inline
fp8e4m3fn
fabs
(
fp8e4m3fn
v
)
{
{
v
.
data
=
v
.
data
&
0x7
f
;
// NOLINT
v
.
data
=
v
.
data
&
0x7
F
;
// NOLINT
return
v
;
return
v
;
}
}
...
@@ -291,7 +292,7 @@ inline std::ostream& operator<<(std::ostream& os, const fp8e5m2fnuz& rhs)
...
@@ -291,7 +292,7 @@ inline std::ostream& operator<<(std::ostream& os, const fp8e5m2fnuz& rhs)
inline
fp8e5m2fnuz
fabs
(
fp8e5m2fnuz
v
)
inline
fp8e5m2fnuz
fabs
(
fp8e5m2fnuz
v
)
{
{
v
.
data
=
v
.
data
&
0x7
f
;
// NOLINT
v
.
data
=
v
.
data
&
0x7
F
;
// NOLINT
return
v
;
return
v
;
}
}
// Special operator overloading
// Special operator overloading
...
@@ -302,7 +303,7 @@ inline std::ostream& operator<<(std::ostream& os, const fp8e5m2& rhs)
...
@@ -302,7 +303,7 @@ inline std::ostream& operator<<(std::ostream& os, const fp8e5m2& rhs)
inline
fp8e5m2
fabs
(
fp8e5m2
v
)
inline
fp8e5m2
fabs
(
fp8e5m2
v
)
{
{
v
.
data
=
v
.
data
&
0x7
f
;
// NOLINT
v
.
data
=
v
.
data
&
0x7
F
;
// NOLINT
return
v
;
return
v
;
}
}
template
<
>
template
<
>
...
...
test/fp8e4m3fn.cpp
View file @
1e220c00
...
@@ -248,4 +248,23 @@ TEST_CASE(test_binary_ops)
...
@@ -248,4 +248,23 @@ TEST_CASE(test_binary_ops)
EXPECT
(
not
migraphx
::
float_equal
(
f
,
e
));
EXPECT
(
not
migraphx
::
float_equal
(
f
,
e
));
}
}
TEST_CASE
(
test_fabs
)
{
auto
a
=
migraphx
::
fp8
::
fp8e4m3fn
(
-
1.0
);
auto
b
=
migraphx
::
fp8
::
fp8e4m3fn
(
1.0
);
EXPECT
(
migraphx
::
float_equal
(
b
,
migraphx
::
fp8
::
fabs
(
a
)));
}
TEST_CASE
(
test_stream_op
)
{
auto
a
=
migraphx
::
fp8
::
fp8e4m3fn
(
-
1.0
);
std
::
stringstream
ss
;
ss
<<
a
;
EXPECT
(
std
::
string
(
"-1"
)
==
ss
.
str
());
ss
=
std
::
stringstream
();
auto
b
=
std
::
numeric_limits
<
migraphx
::
fp8
::
fp8e4m3fn
>::
quiet_NaN
();
ss
<<
b
;
EXPECT
(
std
::
string
(
"nan"
)
==
ss
.
str
());
}
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 @
1e220c00
...
@@ -263,4 +263,23 @@ TEST_CASE(test_binary_ops)
...
@@ -263,4 +263,23 @@ TEST_CASE(test_binary_ops)
EXPECT
(
not
migraphx
::
float_equal
(
f
,
e
));
EXPECT
(
not
migraphx
::
float_equal
(
f
,
e
));
}
}
TEST_CASE
(
test_fabs
)
{
auto
a
=
migraphx
::
fp8
::
fp8e4m3fnuz
(
-
1.0
);
auto
b
=
migraphx
::
fp8
::
fp8e4m3fnuz
(
1.0
);
EXPECT
(
migraphx
::
float_equal
(
b
,
migraphx
::
fp8
::
fabs
(
a
)));
}
TEST_CASE
(
test_stream_op
)
{
auto
a
=
migraphx
::
fp8
::
fp8e4m3fnuz
(
-
1.0
);
std
::
stringstream
ss
;
ss
<<
a
;
EXPECT
(
std
::
string
(
"-1"
)
==
ss
.
str
());
ss
=
std
::
stringstream
();
auto
b
=
std
::
numeric_limits
<
migraphx
::
fp8
::
fp8e4m3fnuz
>::
quiet_NaN
();
ss
<<
b
;
EXPECT
(
std
::
string
(
"nan"
)
==
ss
.
str
());
}
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 @
1e220c00
...
@@ -29,6 +29,7 @@
...
@@ -29,6 +29,7 @@
#include "test.hpp"
#include "test.hpp"
#include <limits>
#include <limits>
#include <sstream>
float
fp8e5m2_to_fp32_value
(
uint8_t
input
)
float
fp8e5m2_to_fp32_value
(
uint8_t
input
)
{
{
...
@@ -444,4 +445,23 @@ TEST_CASE(test_binary_ops)
...
@@ -444,4 +445,23 @@ TEST_CASE(test_binary_ops)
EXPECT
(
not
migraphx
::
float_equal
(
f
,
e
));
EXPECT
(
not
migraphx
::
float_equal
(
f
,
e
));
}
}
TEST_CASE
(
test_fabs
)
{
auto
a
=
migraphx
::
fp8
::
fp8e5m2
(
-
1.0
);
auto
b
=
migraphx
::
fp8
::
fp8e5m2
(
1.0
);
EXPECT
(
migraphx
::
float_equal
(
b
,
migraphx
::
fp8
::
fabs
(
a
)));
}
TEST_CASE
(
test_stream_op
)
{
auto
a
=
migraphx
::
fp8
::
fp8e5m2
(
-
1.0
);
std
::
stringstream
ss
;
ss
<<
a
;
EXPECT
(
std
::
string
(
"-1"
)
==
ss
.
str
());
ss
=
std
::
stringstream
();
auto
b
=
std
::
numeric_limits
<
migraphx
::
fp8
::
fp8e5m2
>::
quiet_NaN
();
ss
<<
b
;
EXPECT
(
std
::
string
(
"nan"
)
==
ss
.
str
());
}
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 @
1e220c00
...
@@ -433,4 +433,22 @@ TEST_CASE(test_binary_ops)
...
@@ -433,4 +433,22 @@ TEST_CASE(test_binary_ops)
EXPECT
(
not
migraphx
::
float_equal
(
f
,
e
));
EXPECT
(
not
migraphx
::
float_equal
(
f
,
e
));
}
}
TEST_CASE
(
test_fabs
)
{
auto
a
=
migraphx
::
fp8
::
fp8e5m2fnuz
(
-
1.0
);
auto
b
=
migraphx
::
fp8
::
fp8e5m2fnuz
(
1.0
);
EXPECT
(
migraphx
::
float_equal
(
b
,
migraphx
::
fp8
::
fabs
(
a
)));
}
TEST_CASE
(
test_stream_op
)
{
auto
a
=
migraphx
::
fp8
::
fp8e5m2fnuz
(
-
1.0
);
std
::
stringstream
ss
;
ss
<<
a
;
EXPECT
(
std
::
string
(
"-1"
)
==
ss
.
str
());
ss
=
std
::
stringstream
();
auto
b
=
std
::
numeric_limits
<
migraphx
::
fp8
::
fp8e5m2fnuz
>::
quiet_NaN
();
ss
<<
b
;
EXPECT
(
std
::
string
(
"nan"
)
==
ss
.
str
());
}
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