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
fe11d758
Commit
fe11d758
authored
Nov 15, 2023
by
Brian Pickrell
Browse files
added special case for Upsample-7 in Resize parser but it breaks resize_downsample_c_test
parent
a24048bd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
14 deletions
+34
-14
src/onnx/parse_resize.cpp
src/onnx/parse_resize.cpp
+34
-14
test/onnx/upsample_ver7_test.onnx
test/onnx/upsample_ver7_test.onnx
+0
-0
No files found.
src/onnx/parse_resize.cpp
View file @
fe11d758
...
...
@@ -214,7 +214,7 @@ struct parse_resize : op_parser<parse_resize>
[](
const
shape
::
dynamic_dimension
&
dd
)
{
return
dd
.
is_fixed
();
});
if
(
not
mostly_fixed
)
MIGRAPHX_THROW
(
"PARSE_"
+
opd
.
o
p
_name
+
MIGRAPHX_THROW
(
"PARSE_"
+
opd
.
o
nnx
_name
+
": dynamic shape inputs other than batch size are not supported"
);
// Get static dimension set and
...
...
@@ -279,7 +279,7 @@ struct parse_resize : op_parser<parse_resize>
}
instruction_ref
parse
(
const
op_desc
&
opd
,
const
onnx_parser
&
/*
parser
*/
,
const
onnx_parser
&
parser
,
onnx_parser
::
node_info
info
,
std
::
vector
<
instruction_ref
>
args
)
const
{
...
...
@@ -296,14 +296,14 @@ struct parse_resize : op_parser<parse_resize>
if
(
contains
(
info
.
attributes
,
"exclude_outside"
)
and
info
.
attributes
.
at
(
"exclude_outside"
).
i
()
==
1
)
{
MIGRAPHX_THROW
(
"PARSE_"
+
opd
.
o
p
_name
+
": exclude_outside 1 is not supported!"
);
MIGRAPHX_THROW
(
"PARSE_"
+
opd
.
o
nnx
_name
+
": exclude_outside 1 is not supported!"
);
}
// input data shape info. Convert static lens to dynamic to simplify referencing them later
auto
in_s
=
args
[
0
]
->
get_shape
().
to_dynamic
();
if
(
args
[
0
]
->
get_shape
().
dynamic
()
and
in_s
.
ndim
()
<
2
)
MIGRAPHX_THROW
(
"PARSE_"
+
opd
.
o
p
_name
+
"PARSE_"
+
opd
.
o
nnx
_name
+
": requires 2 or more dimensions input, where first dimension is batch #"
);
std
::
vector
<
migraphx
::
shape
::
dynamic_dimension
>
in_dims
=
in_s
.
dyn_dims
();
...
...
@@ -314,11 +314,12 @@ struct parse_resize : op_parser<parse_resize>
std
::
vector
<
double
>
vec_scale
;
// Look at inputs and infer either output size or scale, depending on input type
// The input ROI is not currently suported
for
(
const
auto
&
arg
:
args
)
{
if
(
arg
!=
args
[
0
]
and
arg
->
get_shape
().
dynamic
())
{
MIGRAPHX_THROW
(
"PARSE_"
+
opd
.
o
p
_name
+
MIGRAPHX_THROW
(
"PARSE_"
+
opd
.
o
nnx
_name
+
": no dynamic input shapes allowed except the first one"
);
}
...
...
@@ -337,13 +338,13 @@ struct parse_resize : op_parser<parse_resize>
{
auto
arg_out_s
=
arg
->
eval
();
check_arg_empty
(
arg_out_s
,
"PARSE_"
+
opd
.
o
p
_name
+
": dynamic output size is not supported!"
);
"PARSE_"
+
opd
.
o
nnx
_name
+
": dynamic output size is not supported!"
);
out_lens
.
clear
();
arg_out_s
.
visit
([
&
](
auto
ol
)
{
out_lens
.
assign
(
ol
.
begin
(),
ol
.
end
());
});
if
(
out_lens
.
size
()
!=
in_s
.
ndim
())
{
MIGRAPHX_THROW
(
"PARSE_"
+
opd
.
o
p
_name
+
MIGRAPHX_THROW
(
"PARSE_"
+
opd
.
o
nnx
_name
+
": specified output rank does not match input rank"
);
}
...
...
@@ -361,16 +362,35 @@ struct parse_resize : op_parser<parse_resize>
{
// scale input
auto
arg_scale
=
arg
->
eval
();
check_arg_empty
(
arg_scale
,
"PARSE_"
+
opd
.
op_name
+
": dynamic input scale is not supported!"
);
arg_scale
.
visit
([
&
](
auto
v
)
{
vec_scale
.
assign
(
v
.
begin
(),
v
.
end
());
});
if
(
in_dims
.
size
()
!=
vec_scale
.
size
())
// Special-case for the deprecated Upsample-7 operation: scales is an attribute
// rather than an input. Upsample-9 uses scales as an input
if
(
opd
.
onnx_name
==
"Upsample"
and
arg_scale
.
empty
())
{
MIGRAPHX_THROW
(
"PARSE_"
+
opd
.
op_name
+
": specified scale rank does not match input rank"
);
if
(
contains
(
info
.
attributes
,
"scales"
))
{
// vec_scale = info.attributes.at("scales").vector<float>();
literal
scales
=
parser
.
parse_value
(
info
.
attributes
.
at
(
"scales"
));
scales
.
visit
([
&
](
auto
s
)
{
vec_scale
.
assign
(
s
.
begin
(),
s
.
end
());
});
}
else
MIGRAPHX_THROW
(
"PARSE_"
+
opd
.
onnx_name
+
": scales attribute missing"
);
}
else
{
check_arg_empty
(
arg_scale
,
"PARSE_"
+
opd
.
onnx_name
+
": dynamic input scale is not supported!"
);
arg_scale
.
visit
([
&
](
auto
v
)
{
vec_scale
.
assign
(
v
.
begin
(),
v
.
end
());
});
if
(
in_dims
.
size
()
!=
vec_scale
.
size
())
{
MIGRAPHX_THROW
(
"PARSE_"
+
opd
.
onnx_name
+
": specified scale rank does not match input rank"
);
}
}
std
::
transform
(
in_dims
.
begin
(),
in_dims
.
end
(),
vec_scale
.
begin
(),
...
...
@@ -383,7 +403,7 @@ struct parse_resize : op_parser<parse_resize>
}
}
if
(
out_lens
.
size
()
==
0
)
MIGRAPHX_THROW
(
"PARSE_"
+
opd
.
o
p
_name
+
": no input was given for scale or output size"
);
MIGRAPHX_THROW
(
"PARSE_"
+
opd
.
o
nnx
_name
+
": no input was given for scale or output size"
);
// Dynamic batch: Only args[0] can have a dynamic shape, only the 0'th
// dimension--batch size--can be non-fixed, and the only resize mode allowed is "nearest"
...
...
test/onnx/upsample_ver7_test.onnx
View file @
fe11d758
No preview for this file type
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