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
b93ed440
Unverified
Commit
b93ed440
authored
Nov 09, 2023
by
Brian Pickrell
Committed by
GitHub
Nov 09, 2023
Browse files
Revert most recent merge for one file
parent
0662a9a3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
71 deletions
+3
-71
src/onnx/parse_resize.cpp
src/onnx/parse_resize.cpp
+3
-71
No files found.
src/onnx/parse_resize.cpp
View file @
b93ed440
...
@@ -181,76 +181,6 @@ static std::string get_nearest_mode(const onnx_parser::attribute_map& attr)
...
@@ -181,76 +181,6 @@ static std::string get_nearest_mode(const onnx_parser::attribute_map& attr)
return
nearest_mode
;
return
nearest_mode
;
}
}
static
std
::
vector
<
double
>
get_scales
(
const
onnx_parser
::
attribute_map
&
attr
)
{
std
::
vector
<
double
>
scales
;
if
(
contains
(
attr
,
"scales"
))
{
copy
(
attr
.
at
(
"scales"
).
floats
(),
std
::
back_inserter
(
scales
));
}
return
scales
;
}
static
void
parse_args
(
const
std
::
vector
<
instruction_ref
>&
args
,
const
std
::
vector
<
size_t
>&
in_lens
,
const
std
::
string
&
op_name
,
std
::
vector
<
double
>&
vec_scale
,
std
::
vector
<
std
::
size_t
>&
out_lens
)
{
for
(
const
auto
&
arg
:
args
)
{
if
(
arg
->
name
()
==
"undefined"
or
arg
==
args
.
front
())
{
continue
;
}
// skipped empty input
auto
lens
=
arg
->
get_shape
().
lens
();
if
(
lens
.
empty
())
{
continue
;
}
auto
type
=
arg
->
get_shape
().
type
();
// output size
if
(
type
==
shape
::
int64_type
)
{
auto
arg_out_s
=
arg
->
eval
();
check_arg_empty
(
arg_out_s
,
"PARSE_"
+
op_name
+
": dynamic output size is not supported!"
);
arg_out_s
.
visit
([
&
](
const
auto
&
ol
)
{
out_lens
.
assign
(
ol
.
begin
(),
ol
.
end
());
});
if
(
out_lens
.
size
()
!=
in_lens
.
size
())
{
MIGRAPHX_THROW
(
"PARSE_"
+
op_name
+
": specified output size does not match input size"
);
}
// compute the scale
vec_scale
.
resize
(
in_lens
.
size
());
std
::
transform
(
in_lens
.
begin
(),
in_lens
.
end
(),
out_lens
.
begin
(),
vec_scale
.
begin
(),
[](
auto
iss
,
auto
oss
)
{
return
1.0
*
oss
/
iss
;
});
}
else
{
// scale input
if
(
lens
[
0
]
==
in_lens
.
size
())
{
auto
arg_scale
=
arg
->
eval
();
check_arg_empty
(
arg_scale
,
"PARSE_"
+
op_name
+
": dynamic input scale is not supported!"
);
arg_scale
.
visit
([
&
](
const
auto
&
v
)
{
vec_scale
.
assign
(
v
.
begin
(),
v
.
end
());
});
}
}
}
}
struct
parse_resize
:
op_parser
<
parse_resize
>
struct
parse_resize
:
op_parser
<
parse_resize
>
{
{
std
::
vector
<
op_desc
>
operators
()
const
{
return
{{
"Resize"
},
{
"Upsample"
}};
}
std
::
vector
<
op_desc
>
operators
()
const
{
return
{{
"Resize"
},
{
"Upsample"
}};
}
...
@@ -379,7 +309,7 @@ struct parse_resize : op_parser<parse_resize>
...
@@ -379,7 +309,7 @@ struct parse_resize : op_parser<parse_resize>
std
::
vector
<
size_t
>
out_lens
(
in_s
.
ndim
());
std
::
vector
<
size_t
>
out_lens
(
in_s
.
ndim
());
// scale
// scale
std
::
vector
<
double
>
vec_scale
=
get_scales
(
info
.
attributes
)
;
std
::
vector
<
double
>
vec_scale
;
// Look at inputs and infer either output size or scale, depending on input type
// Look at inputs and infer either output size or scale, depending on input type
for
(
const
auto
&
arg
:
args
)
for
(
const
auto
&
arg
:
args
)
...
@@ -451,6 +381,8 @@ struct parse_resize : op_parser<parse_resize>
...
@@ -451,6 +381,8 @@ struct parse_resize : op_parser<parse_resize>
}
}
}
}
// 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"
if
(
args
[
0
]
->
get_shape
().
dynamic
())
if
(
args
[
0
]
->
get_shape
().
dynamic
())
{
{
return
dynamic_nearest_parse
(
out_lens
,
vec_scale
,
opd
,
info
,
args
);
return
dynamic_nearest_parse
(
out_lens
,
vec_scale
,
opd
,
info
,
args
);
...
...
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