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
5120f911
Commit
5120f911
authored
Oct 24, 2022
by
charlie
Browse files
Add ONNX tests
parent
2ce6ca15
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
81 additions
and
3 deletions
+81
-3
src/include/migraphx/op/multibroadcast.hpp
src/include/migraphx/op/multibroadcast.hpp
+2
-2
src/shape.cpp
src/shape.cpp
+2
-1
test/onnx/binary_dyn_brcst_mul_test.onnx
test/onnx/binary_dyn_brcst_mul_test.onnx
+0
-0
test/onnx/binary_dyn_brcst_prelu_test.onnx
test/onnx/binary_dyn_brcst_prelu_test.onnx
+0
-0
test/onnx/gen_onnx.py
test/onnx/gen_onnx.py
+34
-0
test/onnx/onnx_test.cpp
test/onnx/onnx_test.cpp
+43
-0
No files found.
src/include/migraphx/op/multibroadcast.hpp
View file @
5120f911
...
...
@@ -42,10 +42,10 @@ namespace op {
*/
struct
multibroadcast
{
std
::
vector
<
std
::
size_t
>
output_lens
;
std
::
vector
<
std
::
size_t
>
output_lens
=
{}
;
// optional attribute
std
::
vector
<
shape
::
dynamic_dimension
>
output_dyn_dims
;
std
::
vector
<
shape
::
dynamic_dimension
>
output_dyn_dims
=
{}
;
template
<
class
Self
,
class
F
>
static
auto
reflect
(
Self
&
self
,
F
f
)
...
...
src/shape.cpp
View file @
5120f911
...
...
@@ -473,7 +473,8 @@ shape shape::to_dynamic() const
{
return
*
this
;
}
return
{
type
(),
lens
(),
lens
(),
lens
()};
std
::
vector
<
std
::
size_t
>
zeroes
(
this
->
ndim
(),
0
);
return
{
type
(),
lens
(),
lens
(),
zeroes
};
}
std
::
size_t
shape
::
element_space
()
const
{
return
impl
->
element_space
();
}
...
...
test/onnx/binary_dyn_brcst_mul_test.onnx
0 → 100644
View file @
5120f911
File added
test/onnx/binary_dyn_brcst_prelu_test.onnx
0 → 100644
View file @
5120f911
File added
test/onnx/gen_onnx.py
View file @
5120f911
...
...
@@ -420,6 +420,40 @@ def batch_norm_invalid_bias_rank_test():
return
([
node
],
[
x
,
scale
,
bias
,
mean
,
var
],
[
out
])
@
onnx_test
def
binary_dyn_brcst_prelu_test
():
arg0
=
helper
.
make_tensor_value_info
(
'0'
,
TensorProto
.
FLOAT
,
[
None
,
3
,
4
,
5
])
arg1
=
helper
.
make_tensor_value_info
(
'1'
,
TensorProto
.
FLOAT
,
[
4
,
5
])
arg_out
=
helper
.
make_tensor_value_info
(
'out'
,
TensorProto
.
FLOAT
,
[
None
,
3
,
4
,
5
])
node
=
onnx
.
helper
.
make_node
(
'PRelu'
,
inputs
=
[
'0'
,
'1'
],
outputs
=
[
'out'
],
)
return
([
node
],
[
arg0
,
arg1
],
[
arg_out
])
@
onnx_test
def
binary_dyn_brcst_mul_test
():
arg0
=
helper
.
make_tensor_value_info
(
'0'
,
TensorProto
.
FLOAT
,
[
None
,
3
,
4
,
5
])
arg1
=
helper
.
make_tensor_value_info
(
'1'
,
TensorProto
.
FLOAT
,
[
4
,
1
])
arg_out
=
helper
.
make_tensor_value_info
(
'out'
,
TensorProto
.
FLOAT
,
[
None
,
3
,
4
,
5
])
node
=
onnx
.
helper
.
make_node
(
'Mul'
,
inputs
=
[
'0'
,
'1'
],
outputs
=
[
'out'
],
)
return
([
node
],
[
arg0
,
arg1
],
[
arg_out
])
@
onnx_test
def
cast_test
():
x
=
helper
.
make_tensor_value_info
(
'x'
,
TensorProto
.
FLOAT16
,
[
10
])
...
...
test/onnx/onnx_test.cpp
View file @
5120f911
...
...
@@ -522,6 +522,49 @@ TEST_CASE(batch_norm_invalid_bias_rank)
EXPECT(test::throws([&] { migraphx::parse_onnx("batch_norm_invalid_bias_rank.onnx"); }));
}
TEST_CASE(binary_dyn_brcst_prelu_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
auto l0 = mm->add_parameter(
"0",
migraphx::shape{migraphx::shape::float_type, {{1, 4, 0}, {3, 3, 0}, {4, 4, 0}, {5, 5, 0}}});
auto l1 = mm->add_parameter("1", migraphx::shape{migraphx::shape::float_type, {4, 5}});
auto ret = add_common_op(*mm, migraphx::make_op("prelu"), {l0, l1});
mm->add_return({ret});
migraphx::onnx_options options;
options.default_dyn_dim_value = {1, 4, 0};
auto prog = migraphx::parse_onnx("binary_dyn_brcst_prelu_test.onnx", options);
EXPECT(p == prog);
}
TEST_CASE(binary_dyn_brcst_mul_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
auto l0 = mm->add_parameter(
"0",
migraphx::shape{migraphx::shape::float_type, {{1, 4, 0}, {3, 3, 0}, {4, 4, 0}, {5, 5, 0}}});
auto l1 = mm->add_parameter("1", migraphx::shape{migraphx::shape::float_type, {4, 1}});
auto bl1 = mm->add_instruction(
migraphx::make_op("multibroadcast",
{{"out_dyn_dims", to_value(l0->get_shape().dyn_dims())}}),
l1,
l0);
auto ret = mm->add_instruction(migraphx::make_op("mul"), l0, bl1);
mm->add_return({ret});
migraphx::onnx_options options;
options.default_dyn_dim_value = {1, 4, 0};
auto prog = migraphx::parse_onnx("binary_dyn_brcst_mul_test.onnx", options);
EXPECT(p == prog);
}
TEST_CASE(cast_test)
{
migraphx::program p;
...
...
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