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
33649edd
Commit
33649edd
authored
Oct 26, 2023
by
Brian Pickrell
Browse files
update onnx_test cases for Resize
parent
154e24f2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
19 deletions
+22
-19
src/onnx/parse_resize.cpp
src/onnx/parse_resize.cpp
+0
-6
test/onnx/onnx_test.cpp
test/onnx/onnx_test.cpp
+22
-13
No files found.
src/onnx/parse_resize.cpp
View file @
33649edd
...
@@ -412,12 +412,6 @@ struct parse_resize : op_parser<parse_resize>
...
@@ -412,12 +412,6 @@ struct parse_resize : op_parser<parse_resize>
ind
[
out_idx
]
=
static_cast
<
int64_t
>
(
in_s
.
index
(
in_idx
));
ind
[
out_idx
]
=
static_cast
<
int64_t
>
(
in_s
.
index
(
in_idx
));
});
});
// get the number of dimensions
// std::size_t n_dim = out_lens.size();
// std::vector<std::vector<std::size_t>> vv_ind(2,
// std::vector<std::size_t>(out_elements));
// std::vector<std::vector<std::vector<std::size_t>>> vvv_ind(n_dim, vv_ind);
// std::vector<std::vector<float>> delta(n_dim, std::vector<float>(out_elements));
shape
ind_s
{
shape
::
int32_type
,
out_lens
};
shape
ind_s
{
shape
::
int32_type
,
out_lens
};
auto
ins_ind
=
info
.
add_literal
(
literal
(
ind_s
,
ind
));
auto
ins_ind
=
info
.
add_literal
(
literal
(
ind_s
,
ind
));
...
...
test/onnx/onnx_test.cpp
View file @
33649edd
...
@@ -6240,7 +6240,7 @@ TEST_CASE(resize_downsample_f_test)
...
@@ -6240,7 +6240,7 @@ TEST_CASE(resize_downsample_f_test)
migraphx::shape ss{migraphx::shape::float_type, {4}};
migraphx::shape ss{migraphx::shape::float_type, {4}};
mm->add_literal(migraphx::literal{ss, ds});
mm->add_literal(migraphx::literal{ss, ds});
migraphx::shape sx{migraphx::shape::float_type, {1, 1,
35, 60
}};
migraphx::shape sx{migraphx::shape::float_type, {1, 1,
2, 4
}};
auto inx = mm->add_parameter("X", sx);
auto inx = mm->add_parameter("X", sx);
mm->add_instruction(migraphx::make_op("undefined"));
mm->add_instruction(migraphx::make_op("undefined"));
...
@@ -6249,7 +6249,7 @@ TEST_CASE(resize_downsample_f_test)
...
@@ -6249,7 +6249,7 @@ TEST_CASE(resize_downsample_f_test)
std::vector<int> ind = {0, 3};
std::vector<int> ind = {0, 3};
auto li = mm->add_literal(migraphx::literal(si, ind));
auto li = mm->add_literal(migraphx::literal(si, ind));
auto lrsp = mm->add_instruction(migraphx::make_op("reshape", {{"dims", {
2100
}}}), inx);
auto lrsp = mm->add_instruction(migraphx::make_op("reshape", {{"dims", {
8
}}}), inx);
auto r = mm->add_instruction(migraphx::make_op("gather", {{"axis", 0}}), lrsp, li);
auto r = mm->add_instruction(migraphx::make_op("gather", {{"axis", 0}}), lrsp, li);
mm->add_return({r});
mm->add_return({r});
...
@@ -6262,29 +6262,38 @@ TEST_CASE(resize_downsample_f_dyn_test)
...
@@ -6262,29 +6262,38 @@ TEST_CASE(resize_downsample_f_dyn_test)
{
{
migraphx::program p;
migraphx::program p;
auto* mm = p.get_main_module();
auto* mm = p.get_main_module();
std::vector<float> ds = {1.
0
f, 1.
0
f, 0.6
f
, 0.6
f
};
std::vector<float> ds = {1.f, 1.f, 0.6
01
, 0.6
01
};
migraphx::shape ss{migraphx::shape::float_type, {4}};
migraphx::shape ss{migraphx::shape::float_type, {4}};
mm->add_literal(migraphx::literal{ss, ds});
mm->add_literal(migraphx::literal{ss, ds});
// reshape only allows one non-fixed dimension
// reshape only allows one non-fixed dimension
migraphx::shape sx{migraphx::shape::float_type, {{1, 4, {1, 4}}, {1, 1}, {
3
5,
3
5}, {
60, 60
}}};
migraphx::shape sx{migraphx::shape::float_type, {{1, 4, {1, 4}}, {1, 1}, {5, 5}, {
9, 9
}}};
auto inx = mm->add_parameter("X", sx);
auto inx = mm->add_parameter("X", sx);
mm->add_instruction(migraphx::make_op("undefined"));
mm->add_instruction(migraphx::make_op("undefined"));
// the "nearest" indices
to gather
// the "nearest" indices
for axis 1
migraphx::shape si{migraphx::shape::int
32
_type, {1
, 1, 1, 2
}};
migraphx::shape si
1
{migraphx::shape::int
64
_type, {1}};
std::vector<int> ind = {0
, 3
};
std::vector<int> ind
1
= {0};
auto li = mm->add_literal(migraphx::literal(si, ind));
auto li
1
= mm->add_literal(migraphx::literal(si
1
, ind
1
));
// dim corresponding to the non-static dimension in sx must be either 0 or -1. Still
// the "nearest" indices for axis 2
// don't know what this is for
migraphx::shape si2{migraphx::shape::int64_type, {3}};
auto lrsp = mm->add_instruction(migraphx::make_op("reshape", {{"dims", {0, 2100, 1, 1}}}), inx);
std::vector<int> ind2 = {0, 1, 3};
auto r = mm->add_instruction(migraphx::make_op("gather", {{"axis", 0}}), lrsp, li);
auto li2 = mm->add_literal(migraphx::literal(si2, ind2));
// the "nearest" indices for axis 3
migraphx::shape si3{migraphx::shape::int64_type, {5}};
std::vector<int> ind3 = {0, 1, 3, 4, 6};
auto li3 = mm->add_literal(migraphx::literal(si3, ind3));
auto r = mm->add_instruction(migraphx::make_op("gather", {{"axis", 1}}), inx, li1);
r = mm->add_instruction(migraphx::make_op("gather", {{"axis", 2}}), r, li2);
r = mm->add_instruction(migraphx::make_op("gather", {{"axis", 3}}), r, li3);
mm->add_return({r});
mm->add_return({r});
migraphx::onnx_options options;
migraphx::onnx_options options;
options.map_dyn_input_dims["X"] = {{1, 4, {1, 4}}, {1, 1}, {
3
5,
3
5}, {
60, 60
}};
options.map_dyn_input_dims["X"] = {{1, 4, {1, 4}}, {1, 1}, {5, 5}, {
9, 9
}};
auto prog = migraphx::parse_onnx("resize_downsample_f_dyn_test.onnx", options);
auto prog = migraphx::parse_onnx("resize_downsample_f_dyn_test.onnx", 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