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
3059c59c
Commit
3059c59c
authored
Jul 16, 2019
by
Shucai Xiao
Browse files
fix review comments
parent
b003c8fd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
19 deletions
+17
-19
src/onnx/onnx.cpp
src/onnx/onnx.cpp
+12
-14
test/onnx/onnx_test.cpp
test/onnx/onnx_test.cpp
+5
-5
No files found.
src/onnx/onnx.cpp
View file @
3059c59c
...
@@ -467,8 +467,7 @@ struct onnx_parser
...
@@ -467,8 +467,7 @@ struct onnx_parser
if
(
args
.
size
()
==
2
)
if
(
args
.
size
()
==
2
)
{
{
auto
s
=
args
[
1
]
->
eval
();
auto
s
=
args
[
1
]
->
eval
();
if
(
s
.
empty
())
check_arg_empty
(
s
,
"Reshape: dynamic shape is not supported"
);
MIGRAPHX_THROW
(
"Dynamic shape is not supported."
);
s
.
visit
([
&
](
auto
v
)
{
copy
(
v
,
std
::
back_inserter
(
op
.
dims
));
});
s
.
visit
([
&
](
auto
v
)
{
copy
(
v
,
std
::
back_inserter
(
op
.
dims
));
});
}
}
return
prog
.
add_instruction
(
op
,
args
[
0
]);
return
prog
.
add_instruction
(
op
,
args
[
0
]);
...
@@ -881,10 +880,7 @@ struct onnx_parser
...
@@ -881,10 +880,7 @@ struct onnx_parser
}
}
migraphx
::
argument
in
=
args
[
0
]
->
eval
();
migraphx
::
argument
in
=
args
[
0
]
->
eval
();
if
(
in
.
empty
())
check_arg_empty
(
in
,
"ConstantFill: dynamic shape is not supported"
);
{
MIGRAPHX_THROW
(
"ConstantFill: cannot handle dynamic shape as input"
);
}
std
::
vector
<
std
::
size_t
>
dims
;
std
::
vector
<
std
::
size_t
>
dims
;
in
.
visit
([
&
](
auto
input
)
{
dims
.
assign
(
input
.
begin
(),
input
.
end
());
});
in
.
visit
([
&
](
auto
input
)
{
dims
.
assign
(
input
.
begin
(),
input
.
end
());
});
...
@@ -948,10 +944,7 @@ struct onnx_parser
...
@@ -948,10 +944,7 @@ struct onnx_parser
else
else
{
{
migraphx
::
argument
in
=
args
[
0
]
->
eval
();
migraphx
::
argument
in
=
args
[
0
]
->
eval
();
if
(
in
.
empty
())
check_arg_empty
(
in
,
"ConstantOfShape: dynamic shape is not supported"
);
{
MIGRAPHX_THROW
(
"Parse ConstantOfShape: cannot handle dynamic shape as input"
);
}
std
::
vector
<
std
::
size_t
>
dims
;
std
::
vector
<
std
::
size_t
>
dims
;
in
.
visit
([
&
](
auto
input
)
{
dims
.
assign
(
input
.
begin
(),
input
.
end
());
});
in
.
visit
([
&
](
auto
input
)
{
dims
.
assign
(
input
.
begin
(),
input
.
end
());
});
...
@@ -975,10 +968,7 @@ struct onnx_parser
...
@@ -975,10 +968,7 @@ struct onnx_parser
{
{
auto
in_lens
=
args
[
0
]
->
get_shape
().
lens
();
auto
in_lens
=
args
[
0
]
->
get_shape
().
lens
();
migraphx
::
argument
arg_s
=
args
[
1
]
->
eval
();
migraphx
::
argument
arg_s
=
args
[
1
]
->
eval
();
if
(
arg_s
.
empty
())
check_arg_empty
(
arg_s
,
"Expand: dynamic shape is not supported"
);
{
MIGRAPHX_THROW
(
"Parse Expand: cannot handle dynamic shape as input"
);
}
std
::
vector
<
std
::
size_t
>
dims
;
std
::
vector
<
std
::
size_t
>
dims
;
arg_s
.
visit
([
&
](
auto
input
)
{
dims
.
assign
(
input
.
begin
(),
input
.
end
());
});
arg_s
.
visit
([
&
](
auto
input
)
{
dims
.
assign
(
input
.
begin
(),
input
.
end
());
});
auto
out_lens
=
compute_broadcasted_lens
(
in_lens
,
dims
);
auto
out_lens
=
compute_broadcasted_lens
(
in_lens
,
dims
);
...
@@ -1733,6 +1723,14 @@ struct onnx_parser
...
@@ -1733,6 +1723,14 @@ struct onnx_parser
}
}
}
}
}
}
void
check_arg_empty
(
const
argument
&
arg
,
const
std
::
string
&
msg
)
{
if
(
arg
.
empty
())
{
MIGRAPHX_THROW
(
msg
);
}
}
};
};
program
parse_onnx
(
const
std
::
string
&
name
)
program
parse_onnx
(
const
std
::
string
&
name
)
...
...
test/onnx/onnx_test.cpp
View file @
3059c59c
...
@@ -935,7 +935,7 @@ TEST_CASE(cast_test)
...
@@ -935,7 +935,7 @@ TEST_CASE(cast_test)
EXPECT
(
p
==
prog
);
EXPECT
(
p
==
prog
);
}
}
TEST_CASE
(
const_of_shape
1
)
TEST_CASE
(
const_of_shape
_float
)
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
migraphx
::
shape
ss
(
migraphx
::
shape
::
int32_type
,
{
3
});
migraphx
::
shape
ss
(
migraphx
::
shape
::
int32_type
,
{
3
});
...
@@ -948,20 +948,20 @@ TEST_CASE(const_of_shape1)
...
@@ -948,20 +948,20 @@ TEST_CASE(const_of_shape1)
EXPECT
(
p
==
prog
);
EXPECT
(
p
==
prog
);
}
}
TEST_CASE
(
const_of_shape
2
)
TEST_CASE
(
const_of_shape
_int64
)
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
migraphx
::
shape
ss
(
migraphx
::
shape
::
int32_type
,
{
3
});
migraphx
::
shape
ss
(
migraphx
::
shape
::
int32_type
,
{
3
});
p
.
add_literal
(
migraphx
::
literal
(
ss
,
{
2
,
3
,
4
}));
p
.
add_literal
(
migraphx
::
literal
(
ss
,
{
2
,
3
,
4
}));
migraphx
::
shape
s
(
migraphx
::
shape
::
int64_type
,
{
2
,
3
,
4
});
migraphx
::
shape
s
(
migraphx
::
shape
::
int64_type
,
{
2
,
3
,
4
});
std
::
vector
<
int64_t
>
vec
(
s
.
elements
(),
10
.0
f
);
std
::
vector
<
int64_t
>
vec
(
s
.
elements
(),
10
);
p
.
add_literal
(
migraphx
::
literal
(
s
,
vec
));
p
.
add_literal
(
migraphx
::
literal
(
s
,
vec
));
auto
prog
=
migraphx
::
parse_onnx
(
"const_of_shape2.onnx"
);
auto
prog
=
migraphx
::
parse_onnx
(
"const_of_shape2.onnx"
);
EXPECT
(
p
==
prog
);
EXPECT
(
p
==
prog
);
}
}
TEST_CASE
(
const_of_shape
3
)
TEST_CASE
(
const_of_shape
_no_value_attr
)
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
migraphx
::
shape
ss
(
migraphx
::
shape
::
int32_type
,
{
3
});
migraphx
::
shape
ss
(
migraphx
::
shape
::
int32_type
,
{
3
});
...
@@ -974,7 +974,7 @@ TEST_CASE(const_of_shape3)
...
@@ -974,7 +974,7 @@ TEST_CASE(const_of_shape3)
EXPECT
(
p
==
prog
);
EXPECT
(
p
==
prog
);
}
}
TEST_CASE
(
const_of_shape
4
)
TEST_CASE
(
const_of_shape
_empty_input
)
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
p
.
add_literal
(
migraphx
::
literal
());
p
.
add_literal
(
migraphx
::
literal
());
...
...
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