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
98bf0b8b
"src/vscode:/vscode.git/clone" did not exist on "55493edf52d7bdf8aaff5c2f5e3683c955e6ccc4"
Commit
98bf0b8b
authored
Aug 03, 2022
by
Ted Themistokleous
Browse files
Force scalars to be the same shape when comming out of an if then/else block
parent
7bc8dd35
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
6 deletions
+12
-6
src/onnx/parse_if.cpp
src/onnx/parse_if.cpp
+12
-6
No files found.
src/onnx/parse_if.cpp
View file @
98bf0b8b
...
@@ -77,26 +77,32 @@ struct parse_if : op_parser<parse_if>
...
@@ -77,26 +77,32 @@ struct parse_if : op_parser<parse_if>
std
::
to_string
(
else_out_shapes
.
at
(
0
).
type
()));
std
::
to_string
(
else_out_shapes
.
at
(
0
).
type
()));
}
}
// Need to check static shapes result
// If either argument returns non scalar, promote the scalar to a 1D tensor to meet the
if
(
not
then_out_shapes
.
at
(
0
).
dynamic
()
&&
not
else_out_shapes
.
at
(
0
).
dynamic
())
// shape requirements
// if and only if the first dimension matches
if
(
not
then_out_shapes
.
at
(
0
).
scalar
()
||
not
else_out_shapes
.
at
(
0
).
scalar
)
{
{
if
(
then_out_shapes
.
at
(
0
).
scalar
())
if
(
then_out_shapes
.
at
(
0
).
scalar
())
{
{
if
(
then_out_shapes
.
at
(
0
).
lens
().
at
(
0
)
!=
else_out_shapes
.
at
(
0
).
lens
().
at
(
0
)
||
if
(
then_out_shapes
.
at
(
0
).
lens
().
at
(
0
)
!=
else_out_shapes
.
at
(
0
).
lens
().
at
(
0
))
then_out_shapes
.
at
(
0
).
strides
().
at
(
0
)
!=
1
)
{
{
MIGRAPHX_THROW
(
"PARSE_IF: "
+
info
.
name
+
MIGRAPHX_THROW
(
"PARSE_IF: "
+
info
.
name
+
"then out incompatible output shape with else"
);
"then out incompatible output shape with else"
);
}
}
migraphx
::
shape
s
(
then_out_shapes
.
at
(
0
).
type
(),
{
then_out_shapes
.
at
(
0
).
lens
().
at
(
0
),
1
},
{
1
,
1
});
then_mdl
->
add_outline
(
s
);
}
}
else
if
(
else_out_shapes
.
at
(
0
).
scalar
())
else
if
(
else_out_shapes
.
at
(
0
).
scalar
())
{
{
if
(
else_out_shapes
.
at
(
0
).
lens
().
at
(
0
)
!=
else_out_shapes
.
at
(
0
).
lens
().
at
(
0
)
||
if
(
else_out_shapes
.
at
(
0
).
lens
().
at
(
0
)
!=
else_out_shapes
.
at
(
0
).
lens
().
at
(
0
))
else_out_shapes
.
at
(
0
).
strides
().
at
(
0
)
==
1
)
{
{
MIGRAPHX_THROW
(
"PARSE_IF: "
+
info
.
name
+
MIGRAPHX_THROW
(
"PARSE_IF: "
+
info
.
name
+
"else out incompatible output shape with then"
);
"else out incompatible output shape with then"
);
}
}
migraphx
::
shape
s
(
else_out_shapes
.
at
(
0
).
type
(),
{
else_out_shapes
.
at
(
0
).
lens
().
at
(
0
),
1
},
{
1
,
1
});
else_mdl
->
add_outline
(
s
);
}
}
}
}
...
...
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