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
ff5d95e1
Commit
ff5d95e1
authored
Dec 11, 2023
by
Brian Pickrell
Browse files
Updated parse_resize to call new op for static outputs. Passes first static verify_onnx test
parent
a2534e6c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
21 deletions
+42
-21
src/include/migraphx/op/resize.hpp
src/include/migraphx/op/resize.hpp
+1
-0
src/onnx/parse_resize.cpp
src/onnx/parse_resize.cpp
+41
-21
No files found.
src/include/migraphx/op/resize.hpp
View file @
ff5d95e1
...
...
@@ -177,6 +177,7 @@ struct resize
//
std
::
transform
(
scale_input
.
begin
(),
scale_input
.
end
(),
vec_scale
.
begin
(),
[](
auto
scale_i
)
{
std
::
cout
<<
"scale input "
<<
scale_i
<<
"
\n
"
;
return
scale_i
;
});
...
...
src/onnx/parse_resize.cpp
View file @
ff5d95e1
...
...
@@ -314,34 +314,54 @@ struct parse_resize : op_parser<parse_resize>
std
::
size_t
out_elements
=
out_s
.
elements
();
auto
idx_op
=
get_original_idx_op
(
coord_trans_mode
);
// reshape input to one-dimension
std
::
vector
<
int64_t
>
rsp_lens
=
{
static_cast
<
int64_t
>
(
in_s
.
elements
())};
auto
rsp
=
info
.
add_instruction
(
make_op
(
"reshape"
,
{{
"dims"
,
rsp_lens
}}),
args
[
0
]);
if
(
mode
==
"nearest"
)
{
std
::
vector
<
int
>
ind
(
out_elements
);
// map out_idx to in_idx
auto
nearest_op
=
get_nearest_op
(
nearest_mode
);
shape_for_each
(
out_s
,
[
&
](
const
auto
&
out_idx_v
,
size_t
out_idx
)
{
std
::
vector
<
size_t
>
in_idx
(
out_idx_v
.
size
());
for
(
auto
ii
=
0
;
ii
<
in_lens
.
size
();
++
ii
)
{
auto
idx_val
=
idx_op
(
in_lens
[
ii
],
out_lens
[
ii
],
out_idx_v
[
ii
],
vec_scale
[
ii
]);
in_idx
[
ii
]
=
nearest_op
(
in_lens
[
ii
],
idx_val
);
}
ind
[
out_idx
]
=
static_cast
<
int64_t
>
(
in_s
.
index
(
in_idx
));
});
shape
ind_s
{
shape
::
int32_type
,
out_lens
};
auto
ins_ind
=
info
.
add_literal
(
literal
(
ind_s
,
ind
));
return
info
.
add_instruction
(
make_op
(
"gather"
,
{{
"axis"
,
0
}}),
rsp
,
ins_ind
);
// std::vector<int> ind(out_elements);
// // map out_idx to in_idx
// auto nearest_op = get_nearest_op(nearest_mode);
// shape_for_each(out_s, [&](const auto& out_idx_v, size_t out_idx) {
// std::vector<size_t> in_idx(out_idx_v.size());
// for(auto ii = 0; ii < in_lens.size(); ++ii)
// {
// auto idx_val = idx_op(in_lens[ii], out_lens[ii], out_idx_v[ii], vec_scale[ii]);
// in_idx[ii] = nearest_op(in_lens[ii], idx_val);
// }
// ind[out_idx] = static_cast<int64_t>(in_s.index(in_idx));
// });
// shape ind_s{shape::int32_type, out_lens};
// auto ins_ind = info.add_literal(literal(ind_s, ind));
// return info.add_instruction(make_op("gather", {{"axis", 0}}), rsp, ins_ind);
if
(
vec_scale
.
empty
())
{
shape
ind_s
{
shape
::
int32_type
,
{
out_lens
.
size
()}};
auto
ins_ind
=
info
.
add_literal
(
literal
(
ind_s
,
out_lens
));
ins_ind
->
debug_print
();
auto
zzq
=
ins_ind
->
get_shape
();
return
info
.
add_instruction
(
make_op
(
"resize"
,
{{
"sizes"
,
{
1
}},
{
"scales"
,
{}},
{
"nearest_mode"
,
nearest_mode
}
,
{
"coordinate_transformation_mode"
,
coord_trans_mode
}}),
args
[
0
],
ins_ind
);
}
else
{
shape
scale_s
{
shape
::
float_type
,
{
out_lens
.
size
()}};
auto
ins_ind
=
info
.
add_literal
(
literal
(
scale_s
,
vec_scale
));
ins_ind
->
debug_print
();
std
::
cout
<<
"
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//////////////
\n
"
;
auto
zzq
=
ins_ind
->
get_shape
();
return
info
.
add_instruction
(
make_op
(
"resize"
,
{{
"sizes"
,
{}},
{
"scales"
,
{
1
}},
{
"nearest_mode"
,
nearest_mode
}
,
{
"coordinate_transformation_mode"
,
coord_trans_mode
}}),
args
[
0
],
ins_ind
);
}
}
// linear mode
else
{
// reshape input to one-dimension
std
::
vector
<
int64_t
>
rsp_lens
=
{
static_cast
<
int64_t
>
(
in_s
.
elements
())};
auto
rsp
=
info
.
add_instruction
(
make_op
(
"reshape"
,
{{
"dims"
,
rsp_lens
}}),
args
[
0
]);
auto
nearest_floor
=
get_nearest_op
(
"floor"
);
auto
nearest_ceil
=
get_nearest_op
(
"ceil"
);
...
...
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