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
baf55e7f
Commit
baf55e7f
authored
Oct 13, 2022
by
Ted Themistokleous
Browse files
Fix another tidy issue with complexity
Just clean up the logic on this so we're not 5 levels deep on ifs.
parent
1e90dfd7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
13 deletions
+12
-13
src/onnx/parse_if.cpp
src/onnx/parse_if.cpp
+12
-13
No files found.
src/onnx/parse_if.cpp
View file @
baf55e7f
...
...
@@ -129,25 +129,24 @@ struct parse_if : op_parser<parse_if>
throw_shapes
();
}
auto
unsqueeze_last_op
=
[](
module_ref
&
mdl
,
std
::
vector
<
size_t
>&
out_shape
)
{
auto
last_else
=
*
(
--
(
out_shape
.
end
()));
if
(
last_else
<=
1
)
{
auto
convert_ins
=
mdl
->
add_instruction
(
make_op
(
"unsqueeze"
,
{{
"axes"
,
{
out_shape
.
size
()
-
1
}}}),
--
(
--
mdl
->
end
()));
mdl
->
replace_return
({
convert_ins
});
mdl
->
remove_instruction
({
--
convert_ins
});
}
auto
unsqueeze_last_op
=
[](
module_ref
&
mdl
,
const
std
::
vector
<
size_t
>&
out_shape
)
{
auto
convert_ins
=
mdl
->
add_instruction
(
make_op
(
"unsqueeze"
,
{{
"axes"
,
{
out_shape
.
size
()
-
1
}}}),
--
(
--
mdl
->
end
()));
mdl
->
replace_return
({
convert_ins
});
mdl
->
remove_instruction
({
--
convert_ins
});
};
auto
last_then
=
*
(
--
(
then_shape
.
end
()));
auto
last_else
=
*
(
--
(
else_shape
.
end
()));
// Find which dim to unsqueeze
if
(
then_shape
.
size
()
<
else_shape
.
size
())
if
(
(
then_shape
.
size
()
<
else_shape
.
size
())
&&
(
last_else
==
1
))
{
unsqueeze_last_op
(
then_mdl
,
else_shape
);
}
else
else
if
((
then_shape
.
size
()
>
else_shape
.
size
())
&&
(
last_then
==
1
))
{
unsqueeze_last_op
(
else_mdl
,
then_shape
);
}
...
...
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