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
8083e267
Commit
8083e267
authored
Jun 23, 2022
by
Khalique Ahmed
Browse files
formatting
parent
48f9e6ad
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
2 deletions
+15
-2
src/onnx/parse_reshape.cpp
src/onnx/parse_reshape.cpp
+15
-2
No files found.
src/onnx/parse_reshape.cpp
View file @
8083e267
...
...
@@ -53,8 +53,21 @@ struct parse_reshape : op_parser<parse_reshape>
s
.
visit
([
&
](
auto
v
)
{
copy
(
v
,
std
::
back_inserter
(
dims
));
});
}
return
info
.
add_instruction
(
make_op
(
"reshape"
,
{{
"dims"
,
dims
}}),
info
.
make_contiguous
(
args
[
0
]));
std
::
vector
<
size_t
>
orig_dims
=
args
[
0
]
->
get_shape
().
lens
();
auto
dims_acc
=
std
::
accumulate
(
dims
.
begin
(),
dims
.
end
(),
1
,
std
::
multiplies
<
int64_t
>
());
auto
orig_dims_acc
=
std
::
accumulate
(
orig_dims
.
begin
(),
orig_dims
.
end
(),
1
,
std
::
multiplies
<
int64_t
>
());
if
(
std
::
abs
(
dims_acc
)
==
orig_dims_acc
)
return
info
.
add_instruction
(
make_op
(
"reshape"
,
{{
"dims"
,
dims
}}),
info
.
make_contiguous
(
args
[
0
]));
if
(
parser
.
default_dim_value
*
std
::
abs
(
dims_acc
)
==
orig_dims_acc
)
{
dims
[
0
]
*=
parser
.
default_dim_value
;
return
info
.
add_instruction
(
make_op
(
"reshape"
,
{{
"dims"
,
dims
}}),
info
.
make_contiguous
(
args
[
0
]));
}
MIGRAPHX_THROW
(
"Reshape: incorrect number of elements: "
+
std
::
to_string
(
dims_acc
)
+
" versus "
+
std
::
to_string
(
orig_dims_acc
));
}
};
...
...
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