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
3265b9f0
Commit
3265b9f0
authored
Aug 10, 2023
by
umangyadav
Browse files
add test
parent
b92d27b0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
4 deletions
+17
-4
src/serialize.cpp
src/serialize.cpp
+6
-4
test/serialize_program.cpp
test/serialize_program.cpp
+11
-0
No files found.
src/serialize.cpp
View file @
3265b9f0
...
...
@@ -74,7 +74,8 @@ void migraphx_from_value(const value& v, literal& l)
}
else
{
assert
(
v
.
is_array
());
auto
v_data
=
v
.
at
(
"data"
);
assert
(
v_data
.
is_array
());
size_t
array_size
=
1
+
((
binary_size
-
1
)
/
partition_length
);
assert
(
array_size
==
v
.
size
());
std
::
vector
<
uint8_t
>
binary_array
(
binary_size
);
...
...
@@ -82,9 +83,10 @@ void migraphx_from_value(const value& v, literal& l)
for
(
size_t
i
=
0
;
i
<
array_size
;
++
i
)
{
binary_array
.
insert
(
binary_array
.
end
(),
v
.
at
(
i
).
get_binary
().
data
(),
v
.
at
(
i
).
get_binary
().
data
()
+
v
.
at
(
i
).
get_binary
().
size
());
read_size
+=
v
.
at
(
i
).
get_binary
().
size
();
v_data
.
at
(
i
).
get_binary
().
data
(),
v_data
.
at
(
i
).
get_binary
().
data
()
+
v_data
.
at
(
i
).
get_binary
().
size
());
read_size
+=
v_data
.
at
(
i
).
get_binary
().
size
();
}
assert
(
read_size
==
binary_size
);
l
=
literal
(
s
,
binary_array
.
data
());
...
...
test/serialize_program.cpp
View file @
3265b9f0
...
...
@@ -24,6 +24,7 @@
#include <migraphx/program.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/load_save.hpp>
#include <migraphx/generate.hpp>
#include "test.hpp"
#include <migraphx/make_op.hpp>
...
...
@@ -88,6 +89,16 @@ TEST_CASE(compiled)
EXPECT
(
p1
.
sort
()
==
p2
.
sort
());
}
TEST_CASE
(
large_literal
)
{
migraphx
::
program
p1
;
auto
*
mm
=
p1
.
get_main_module
();
mm
->
add_literal
(
migraphx
::
generate_literal
({
migraphx
::
shape
::
half_type
,
{
39664984
,
64
}}));
std
::
vector
<
char
>
buffer
=
migraphx
::
save_buffer
(
p1
);
migraphx
::
program
p2
=
migraphx
::
load_buffer
(
buffer
);
EXPECT
(
p1
.
sort
()
==
p2
.
sort
());
}
TEST_CASE
(
unknown_format
)
{
migraphx
::
file_options
options
;
...
...
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