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
913ae362
Unverified
Commit
913ae362
authored
Dec 13, 2022
by
Chris Austen
Committed by
GitHub
Dec 13, 2022
Browse files
Merge branch 'develop' into optimize
parents
f1e16656
b8c8d09b
Changes
66
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
1642 additions
and
493 deletions
+1642
-493
test/onnx/transpose_dyn_test.onnx
test/onnx/transpose_dyn_test.onnx
+0
-0
test/op_shape_test.cpp
test/op_shape_test.cpp
+506
-144
test/ref_dot_op_test.cpp
test/ref_dot_op_test.cpp
+125
-18
test/ref_ops_test.cpp
test/ref_ops_test.cpp
+658
-331
test/ref_rnn_ops_test.cpp
test/ref_rnn_ops_test.cpp
+339
-0
test/shape_test.cpp
test/shape_test.cpp
+14
-0
No files found.
test/onnx/transpose_dyn_test.onnx
0 → 100644
View file @
913ae362
File added
test/op_shape_test.cpp
View file @
913ae362
...
...
@@ -81,6 +81,64 @@ void throws_shape(const migraphx::shape&, Ts...)
"An expected shape should not be passed to throws_shape function"
);
}
TEST_CASE
(
argmax_axis0
)
{
migraphx
::
shape
input
{
migraphx
::
shape
::
half_type
,
{
2
,
3
,
4
,
5
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
int64_type
,
{
1
,
3
,
4
,
5
}},
migraphx
::
make_op
(
"argmax"
,
{{
"axis"
,
0
}}),
input
);
}
TEST_CASE
(
argmax_axis1
)
{
migraphx
::
shape
input
{
migraphx
::
shape
::
half_type
,
{
2
,
3
,
4
,
5
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
int64_type
,
{
2
,
1
,
4
,
5
}},
migraphx
::
make_op
(
"argmax"
,
{{
"axis"
,
1
}}),
input
);
}
TEST_CASE
(
argmax_axis2
)
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
,
5
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
int64_type
,
{
2
,
3
,
1
,
5
}},
migraphx
::
make_op
(
"argmax"
,
{{
"axis"
,
2
}}),
input
);
}
TEST_CASE
(
argmax_axis_neg
)
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
,
5
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
int64_type
,
{
2
,
3
,
4
,
1
}},
migraphx
::
make_op
(
"argmax"
,
{{
"axis"
,
-
1
}}),
input
);
}
TEST_CASE
(
argmax_axis_outofbounds
)
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
,
5
}};
throws_shape
(
migraphx
::
make_op
(
"argmax"
,
{{
"axis"
,
4
}}),
input
);
}
TEST_CASE
(
argmax_dyn0
)
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
3
,
3
,
0
},
{
4
,
4
,
0
},
{
5
,
5
,
0
}}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
int64_type
,
{{
1
,
4
,
0
},
{
1
,
1
,
0
},
{
4
,
4
,
0
},
{
5
,
5
,
0
}}},
migraphx
::
make_op
(
"argmax"
,
{{
"axis"
,
1
}}),
input
);
}
TEST_CASE
(
argmax_dyn1
)
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
3
,
3
,
0
},
{
4
,
6
,
0
},
{
4
,
6
,
0
}}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
int64_type
,
{{
1
,
4
,
0
},
{
3
,
3
,
0
},
{
1
,
1
,
0
},
{
4
,
6
,
0
}}},
migraphx
::
make_op
(
"argmax"
,
{{
"axis"
,
2
}}),
input
);
}
TEST_CASE
(
binary_dyn_static_error
)
{
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
float_type
,
{
1
,
4
,
4
}};
...
...
@@ -409,6 +467,199 @@ TEST_CASE(deconvolution_shape)
weights_3d
);
}
TEST_CASE
(
dot_ndim_error0
)
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
5
}};
throws_shape
(
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
TEST_CASE
(
dot_ndim_error1
)
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
5
,
2
}};
throws_shape
(
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
TEST_CASE
(
dot_ndim_error2
)
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
1
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
5
}};
throws_shape
(
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
TEST_CASE
(
dot_ndim_error3
)
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
1
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
6
,
5
,
4
}};
throws_shape
(
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
TEST_CASE
(
dot_ndim_error4
)
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
1
,
1
,
5
,
7
}};
throws_shape
(
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
TEST_CASE
(
dot_mismatch_inner_error0
)
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
10
,
8
}};
throws_shape
(
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
TEST_CASE
(
dot_mismatch_inner_error1
)
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
4
,
6
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
5
,
8
}};
throws_shape
(
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
TEST_CASE
(
dot_mismatch_inner_error2
)
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
1
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
4
,
4
}};
throws_shape
(
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
TEST_CASE
(
dot_mismatch_inner_error3
)
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
1
,
1
,
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
1
,
2
,
5
,
7
}};
throws_shape
(
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
TEST_CASE
(
dot_mismatch_outer_error
)
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
1
,
4
,
6
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
2
,
5
,
8
}};
throws_shape
(
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
TEST_CASE
(
dot_2D_test0
)
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
5
,
8
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
4
,
8
}},
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
TEST_CASE
(
dot_2D_test1
)
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
1
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
5
,
4
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
4
}},
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
TEST_CASE
(
dot_2D_test2
)
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
5
,
8
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
4
,
8
}},
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
TEST_CASE
(
dot_2D_test3
)
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
1
,
1
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
1
,
1
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
1
}},
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
TEST_CASE
(
dot_3D_test0
)
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
1
,
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
1
,
5
,
8
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
4
,
8
}},
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
TEST_CASE
(
dot_3D_test_1
)
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
6
,
1
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
6
,
5
,
4
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
6
,
1
,
4
}},
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
TEST_CASE
(
dot_3D_test2
)
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
1
,
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
1
,
5
,
7
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
4
,
7
}},
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
TEST_CASE
(
dot_4D_test
)
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
1
,
6
,
1
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
1
,
6
,
5
,
4
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
6
,
1
,
4
}},
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
TEST_CASE
(
dot_dyn_static_test0
)
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
5
,
5
,
0
}}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
5
,
8
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
8
,
8
,
0
}}},
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
TEST_CASE
(
dot_dyn_static_mismatch_error
)
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
3
,
3
,
0
},
{
5
,
5
,
0
},
{
5
,
5
,
0
}}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
5
,
8
}};
throws_shape
(
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
TEST_CASE
(
dot_dyn_dyn_test0
)
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
5
,
5
,
0
}}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{{
5
,
5
,
0
},
{
6
,
8
,
8
}}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
6
,
8
,
8
}}},
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
TEST_CASE
(
dot_dyn_dyn_test1
)
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
4
,
5
,
5
}}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{{
4
,
5
,
5
},
{
6
,
8
,
8
}}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
6
,
8
,
8
}}},
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
TEST_CASE
(
dot_dyn_mismatch_test0
)
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
5
,
5
,
0
},
{
5
,
5
,
0
}}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
1
,
5
,
8
}};
throws_shape
(
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
TEST_CASE
(
dot_dyn_mismatch_test1
)
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{{
4
,
4
,
0
},
{
5
,
5
,
0
},
{
2
,
5
,
0
}}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
4
,
5
,
8
}};
throws_shape
(
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
TEST_CASE
(
flatten_shape
)
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{
2
,
4
,
6
,
8
}};
...
...
@@ -437,6 +688,62 @@ TEST_CASE(flatten_shape)
throws_shape
(
migraphx
::
make_op
(
"flatten"
,
{{
"axis"
,
-
5
}}),
input
);
}
TEST_CASE
(
flatten_dyn_axis0
)
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
4
,
4
,
0
},
{
6
,
6
,
0
},
{
8
,
8
,
0
}}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
1
,
1
,
0
},
{
192
,
768
,
0
}}},
migraphx
::
make_op
(
"flatten"
,
{{
"axis"
,
0
}}),
input
);
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
1
,
1
,
0
},
{
192
,
768
,
0
}}},
migraphx
::
make_op
(
"flatten"
,
{{
"axis"
,
-
4
}}),
input
);
}
TEST_CASE
(
flatten_dyn_axis1
)
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{{
2
,
2
,
2
},
{
4
,
4
,
0
},
{
4
,
6
,
5
},
{
4
,
6
,
5
}}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
2
,
2
,
2
},
{
4
*
4
*
4
,
4
*
6
*
6
,
0
}}},
migraphx
::
make_op
(
"flatten"
,
{{
"axis"
,
1
}}),
input
);
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
2
,
2
,
2
},
{
4
*
4
*
4
,
4
*
6
*
6
,
0
}}},
migraphx
::
make_op
(
"flatten"
,
{{
"axis"
,
-
3
}}),
input
);
}
TEST_CASE
(
flatten_dyn_axis2
)
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{{
2
,
2
,
2
},
{
4
,
4
,
0
},
{
4
,
6
,
5
},
{
4
,
6
,
5
}}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
2
*
4
,
2
*
4
,
0
},
{
4
*
4
,
6
*
6
,
5
*
5
}}},
migraphx
::
make_op
(
"flatten"
,
{{
"axis"
,
2
}}),
input
);
}
TEST_CASE
(
flatten_dyn_axis3
)
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
4
,
4
,
0
},
{
6
,
6
,
0
},
{
8
,
8
,
0
}}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
1
*
4
*
6
,
4
*
4
*
6
,
0
},
{
8
,
8
,
0
}}},
migraphx
::
make_op
(
"flatten"
,
{{
"axis"
,
3
}}),
input
);
}
TEST_CASE
(
flatten_dyn_axis4
)
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
4
,
4
,
0
},
{
6
,
6
,
0
},
{
8
,
8
,
0
}}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
1
*
4
*
6
*
8
,
4
*
4
*
6
*
8
,
0
},
{
1
,
1
,
0
}}},
migraphx
::
make_op
(
"flatten"
,
{{
"axis"
,
4
}}),
input
);
}
TEST_CASE
(
gather
)
{
{
...
...
@@ -524,46 +831,6 @@ TEST_CASE(gather)
}
}
// 3 input arguments
TEST_CASE
(
gemm
)
{
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
10
,
8
}};
throws_shape
(
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
4
,
6
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
5
,
8
}};
throws_shape
(
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
5
,
8
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
4
,
8
}},
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
1
,
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
1
,
5
,
8
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
4
,
8
}},
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
1
,
4
,
6
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
2
,
5
,
8
}};
throws_shape
(
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
}
TEST_CASE
(
get_tuple_elem_test
)
{
migraphx
::
shape
s0
{
migraphx
::
shape
::
bool_type
,
{
1
,
1
}};
...
...
@@ -1017,106 +1284,6 @@ TEST_CASE(lstm)
}
}
// 2 inputs arguments
TEST_CASE
(
matmul
)
{
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
5
}};
throws_shape
(
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
5
,
2
}};
throws_shape
(
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
1
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
5
}};
throws_shape
(
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
1
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
5
,
4
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
4
}},
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
1
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
4
,
4
}};
throws_shape
(
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
1
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
6
,
5
,
4
}};
throws_shape
(
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
6
,
1
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
6
,
5
,
4
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
6
,
1
,
4
}},
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
1
,
6
,
1
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
1
,
6
,
5
,
4
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
6
,
1
,
4
}},
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
5
,
8
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
4
,
8
}},
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
1
,
1
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
1
,
1
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
1
}},
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
1
,
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
1
,
5
,
7
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
4
,
7
}},
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
1
,
1
,
5
,
7
}};
throws_shape
(
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
1
,
1
,
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
1
,
2
,
5
,
7
}};
throws_shape
(
migraphx
::
make_op
(
"dot"
),
s_m1
,
s_m2
);
}
}
TEST_CASE
(
multibroadcast
)
{
{
...
...
@@ -1549,16 +1716,76 @@ TEST_CASE(nms_shape)
score_thres_s
);
}
TEST_CASE
(
pooling_shape
)
TEST_CASE
(
pooling_shape
0
)
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{
4
,
3
,
3
,
3
}};
throws_shape
(
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
max
},
{
"padding"
,
{
1
}},
{
"stride"
,
{
0
}},
{
"lengths"
,
{
1
}}}),
input
);
}
TEST_CASE
(
pooling_shape1
)
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{
4
,
3
,
3
,
3
}};
migraphx
::
shape
output
{
migraphx
::
shape
::
float_type
,
{
4
,
3
,
1
,
1
}};
expect_shape
(
output
,
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
max
},
{
"padding"
,
{
0
,
0
}},
{
"stride"
,
{
3
,
3
}},
{
"lengths"
,
{
1
,
1
}}}),
input
);
}
TEST_CASE
(
pooling_shape2
)
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{
4
,
3
,
3
,
3
}};
migraphx
::
shape
output
{
migraphx
::
shape
::
float_type
,
{
4
,
3
,
2
,
2
}};
expect_shape
(
output
,
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
max
},
{
"padding"
,
{
0
,
0
}},
{
"stride"
,
{
3
,
3
}},
{
"lengths"
,
{
1
,
1
}},
{
"ceil_mode"
,
true
}}),
input
);
}
TEST_CASE
(
pooling_shape3
)
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{
4
,
3
,
3
,
3
}};
migraphx
::
shape
output
{
migraphx
::
shape
::
float_type
,
{
4
,
3
,
3
,
3
}};
expect_shape
(
output
,
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
max
},
{
"padding"
,
{
2
,
2
}},
{
"stride"
,
{
3
,
3
}},
{
"lengths"
,
{
3
,
3
}},
{
"ceil_mode"
,
true
}}),
input
);
}
TEST_CASE
(
pooling_dyn_shape0
)
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
3
,
3
,
3
},
{
3
,
3
,
3
},
{
3
,
3
,
0
}}};
throws_shape
(
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
max
},
{
"padding"
,
{
1
}},
{
"stride"
,
{
0
}},
{
"lengths"
,
{
1
}}}),
input
);
}
TEST_CASE
(
pooling_dyn_shape1
)
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
3
,
3
,
3
},
{
3
,
3
,
3
},
{
3
,
3
,
0
}}};
migraphx
::
shape
output
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
3
,
3
,
3
},
{
1
,
1
,
1
},
{
1
,
1
,
0
}}};
expect_shape
(
output
,
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
max
},
...
...
@@ -1566,9 +1793,15 @@ TEST_CASE(pooling_shape)
{
"stride"
,
{
3
,
3
}},
{
"lengths"
,
{
1
,
1
}}}),
input
);
}
migraphx
::
shape
output1
{
migraphx
::
shape
::
float_type
,
{
4
,
3
,
2
,
2
}};
expect_shape
(
output1
,
TEST_CASE
(
pooling_dyn_shape2
)
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
5
,
5
,
0
},
{
3
,
3
,
3
},
{
3
,
3
,
0
}}};
migraphx
::
shape
output
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
5
,
5
,
0
},
{
2
,
2
,
2
},
{
2
,
2
,
0
}}};
expect_shape
(
output
,
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
max
},
{
"padding"
,
{
0
,
0
}},
...
...
@@ -1578,6 +1811,37 @@ TEST_CASE(pooling_shape)
input
);
}
TEST_CASE
(
pooling_dyn_shape3
)
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{{
4
,
4
,
0
},
{
3
,
3
,
0
},
{
4
,
12
,
8
},
{
4
,
12
,
8
}}};
migraphx
::
shape
output
{
migraphx
::
shape
::
float_type
,
{{
4
,
4
,
0
},
{
3
,
3
,
0
},
{
2
,
4
,
3
},
{
2
,
4
,
3
}}};
expect_shape
(
output
,
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
max
},
{
"padding"
,
{
0
,
0
}},
{
"stride"
,
{
3
,
3
}},
{
"lengths"
,
{
1
,
1
}}}),
input
);
}
TEST_CASE
(
pooling_dyn_shape4
)
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{{
4
,
4
,
0
},
{
3
,
3
,
0
},
{
4
,
12
,
8
},
{
4
,
12
,
8
}}};
migraphx
::
shape
output
{
migraphx
::
shape
::
float_type
,
{{
4
,
4
,
0
},
{
3
,
3
,
0
},
{
3
,
6
,
4
},
{
3
,
6
,
4
}}};
expect_shape
(
output
,
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
max
},
{
"padding"
,
{
2
,
2
}},
{
"stride"
,
{
3
,
3
}},
{
"lengths"
,
{
3
,
3
}},
{
"ceil_mode"
,
true
}}),
input
);
}
TEST_CASE
(
prefix_scan_sum
)
{
{
...
...
@@ -1920,6 +2184,20 @@ TEST_CASE(slice_shape)
TEST_CASE
(
softmax
)
{
test_softmax_variations
<
migraphx
::
op
::
softmax
>
();
}
TEST_CASE
(
softmax_dyn0
)
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
3
,
3
,
0
},
{
4
,
4
,
0
},
{
5
,
5
,
0
}}};
expect_shape
(
input
,
migraphx
::
make_op
(
"softmax"
,
{{
"axis"
,
0
}}),
input
);
}
TEST_CASE
(
softmax_dyn1
)
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{{
1
,
1
,
0
},
{
3
,
3
,
0
},
{
4
,
6
,
0
},
{
5
,
8
,
6
}}};
expect_shape
(
input
,
migraphx
::
make_op
(
"softmax"
,
{{
"axis"
,
0
}}),
input
);
}
TEST_CASE
(
test_argmax
)
{
{
...
...
@@ -2042,6 +2320,30 @@ TEST_CASE(test_squeeze_all)
expect_shape
(
s2
,
migraphx
::
make_op
(
"squeeze"
,
{{
"axes"
,
{
0
}}}),
s1
);
}
TEST_CASE
(
test_squeeze_dyn
)
{
migraphx
::
shape
s1
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
1
,
1
,
0
},
{
3
,
3
,
0
},
{
1
,
1
,
0
},
{
3
,
3
,
0
}}};
migraphx
::
shape
s2
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
1
,
1
,
0
},
{
3
,
3
,
0
},
{
3
,
3
,
0
}}};
expect_shape
(
s2
,
migraphx
::
make_op
(
"squeeze"
,
{{
"axes"
,
{
3
}}}),
s1
);
migraphx
::
shape
s3
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
3
,
3
,
0
},
{
3
,
3
,
0
}}};
expect_shape
(
s3
,
migraphx
::
make_op
(
"squeeze"
),
s1
);
throws_shape
(
migraphx
::
make_op
(
"squeeze"
,
{{
"axes"
,
{
0
}}}),
s1
);
}
TEST_CASE
(
test_squeeze_dyn_neg_axes
)
{
migraphx
::
shape
s1
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
1
,
1
,
0
},
{
3
,
3
,
0
},
{
1
,
1
,
0
},
{
3
,
3
,
0
}}};
migraphx
::
shape
s2
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
1
,
1
,
0
},
{
3
,
3
,
0
},
{
3
,
3
,
0
}}};
expect_shape
(
s2
,
migraphx
::
make_op
(
"squeeze"
,
{{
"axes"
,
{
-
2
}}}),
s1
);
migraphx
::
shape
s3
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
3
,
3
,
0
},
{
3
,
3
,
0
}}};
expect_shape
(
s3
,
migraphx
::
make_op
(
"squeeze"
,
{{
"axes"
,
{
-
2
,
-
4
}}}),
s1
);
}
TEST_CASE
(
test_squeeze_transpose
)
{
migraphx
::
shape
s1
{
migraphx
::
shape
::
float_type
,
{
4
,
4
,
1
},
{
4
,
1
,
4
}};
...
...
@@ -2083,6 +2385,30 @@ TEST_CASE(test_unsqueeze)
expect_shape
(
s2
,
migraphx
::
make_op
(
"unsqueeze"
,
{{
"axes"
,
{
2
}}}),
s1
);
}
TEST_CASE
(
test_unsqueeze_dyn
)
{
migraphx
::
shape
s1
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
3
},
{
2
,
5
,
0
},
{
3
,
3
,
0
}}};
migraphx
::
shape
s2
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
3
},
{
2
,
5
,
0
},
{
1
,
1
,
0
},
{
3
,
3
,
0
}}};
expect_shape
(
s2
,
migraphx
::
make_op
(
"unsqueeze"
,
{{
"axes"
,
{
2
}}}),
s1
);
migraphx
::
shape
s3
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
3
},
{
2
,
5
,
0
},
{
1
,
1
,
0
},
{
3
,
3
,
0
},
{
1
,
1
,
0
}}};
expect_shape
(
s3
,
migraphx
::
make_op
(
"unsqueeze"
,
{{
"axes"
,
{
2
,
4
}}}),
s1
);
throws_shape
(
migraphx
::
make_op
(
"unsqueeze"
,
{{
"axes"
,
{
2
,
4
}},
{
"steps"
,
{
2
}}}),
s1
);
}
TEST_CASE
(
test_unsqueeze_dyn_neg_axes
)
{
migraphx
::
shape
s1
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
3
},
{
2
,
5
,
0
},
{
3
,
3
,
0
}}};
migraphx
::
shape
s2
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
3
},
{
2
,
5
,
0
},
{
1
,
1
,
0
},
{
3
,
3
,
0
}}};
expect_shape
(
s2
,
migraphx
::
make_op
(
"unsqueeze"
,
{{
"axes"
,
{
-
2
}}}),
s1
);
migraphx
::
shape
s3
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
3
},
{
2
,
5
,
0
},
{
1
,
1
,
0
},
{
3
,
3
,
0
},
{
1
,
1
,
0
}}};
expect_shape
(
s3
,
migraphx
::
make_op
(
"unsqueeze"
,
{{
"axes"
,
{
-
1
,
-
3
}}}),
s1
);
}
TEST_CASE
(
test_unsqueeze_step
)
{
migraphx
::
shape
s1
{
migraphx
::
shape
::
float_type
,
{
4
,
5
,
12
}};
...
...
@@ -2114,13 +2440,27 @@ TEST_CASE(test_unsqueeze_mismatch_step_axis)
throws_shape
(
migraphx
::
make_op
(
"unsqueeze"
,
{{
"axes"
,
{
2
}},
{
"steps"
,
{
2
,
3
}}}),
s1
);
}
TEST_CASE
(
test_unsqueeze_negative_axis
)
TEST_CASE
(
test_unsqueeze_negative_axis
1
)
{
migraphx
::
shape
s1
{
migraphx
::
shape
::
float_type
,
{
4
,
5
,
3
}};
migraphx
::
shape
s2
{
migraphx
::
shape
::
float_type
,
{
4
,
5
,
1
,
3
}};
expect_shape
(
s2
,
migraphx
::
make_op
(
"unsqueeze"
,
{{
"axes"
,
{
-
2
}}}),
s1
);
}
TEST_CASE
(
test_unsqueeze_negative_axis2
)
{
migraphx
::
shape
s1
{
migraphx
::
shape
::
float_type
,
{
4
,
5
,
3
}};
migraphx
::
shape
s2
{
migraphx
::
shape
::
float_type
,
{
4
,
5
,
3
,
1
}};
expect_shape
(
s2
,
migraphx
::
make_op
(
"unsqueeze"
,
{{
"axes"
,
{
-
1
}}}),
s1
);
}
TEST_CASE
(
test_unsqueeze_negative_axis3
)
{
migraphx
::
shape
s1
{
migraphx
::
shape
::
float_type
,
{
4
,
5
,
3
}};
migraphx
::
shape
s2
{
migraphx
::
shape
::
float_type
,
{
4
,
1
,
5
,
3
}};
expect_shape
(
s2
,
migraphx
::
make_op
(
"unsqueeze"
,
{{
"axes"
,
{
-
3
}}}),
s1
);
}
TEST_CASE
(
test_unsqueeze_scalar
)
{
migraphx
::
shape
s1
{
migraphx
::
shape
::
float_type
,
{
1
},
{
0
}};
...
...
@@ -2226,6 +2566,28 @@ TEST_CASE(transpose_shape)
throws_shape
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
1
,
2
}}}),
input
);
}
TEST_CASE
(
transpose_dyn_shape0
)
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
2
,
2
,
0
}}};
migraphx
::
shape
output
{
migraphx
::
shape
::
float_type
,
{{
2
,
2
,
0
},
{
1
,
4
,
0
}}};
expect_shape
(
input
,
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
0
,
1
}}}),
input
);
expect_shape
(
output
,
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
1
,
0
}}}),
input
);
}
TEST_CASE
(
transpose_dyn_shape1
)
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
4
,
4
,
0
},
{
4
,
4
,
0
}}};
migraphx
::
shape
output
{
migraphx
::
shape
::
float_type
,
{{
4
,
4
,
0
},
{
4
,
4
,
0
},
{
1
,
4
,
0
}}};
expect_shape
(
input
,
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
0
,
1
,
2
}}}),
input
);
expect_shape
(
output
,
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
2
,
1
,
0
}}}),
input
);
}
TEST_CASE
(
transpose_axes_error
)
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{
2
,
2
}};
throws_shape
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
1
}}}),
input
);
}
TEST_CASE
(
step_test
)
{
migraphx
::
shape
s1
{
migraphx
::
shape
::
float_type
,
{
1
,
2
,
4
}};
...
...
test/ref_dot_op_test.cpp
View file @
913ae362
...
...
@@ -35,7 +35,7 @@
#include <migraphx/half.hpp>
template
<
class
T
>
void
matmul
_test
()
void
dot_2d
_test
()
{
migraphx
::
program
p
;
...
...
@@ -82,11 +82,11 @@ void matmul_test()
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
EXPECT
(
migraphx
::
verify_range
(
c
,
results_vector
));
}
TEST_CASE_REGISTER
(
matmul
_test
<
float
>
)
TEST_CASE_REGISTER
(
matmul
_test
<
double
>
)
TEST_CASE_REGISTER
(
dot_2d
_test
<
float
>
)
TEST_CASE_REGISTER
(
dot_2d
_test
<
double
>
)
template
<
class
T
>
void
matmul
_test
_ex
()
void
dot_4d
_test
()
{
migraphx
::
program
p
;
...
...
@@ -133,10 +133,10 @@ void matmul_test_ex()
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
EXPECT
(
migraphx
::
verify_range
(
c
,
results_vector
));
}
TEST_CASE_REGISTER
(
matmul
_test
_ex
<
float
>
)
TEST_CASE_REGISTER
(
matmul
_test
_ex
<
double
>
)
TEST_CASE_REGISTER
(
dot_4d
_test
<
float
>
)
TEST_CASE_REGISTER
(
dot_4d
_test
<
double
>
)
TEST_CASE
(
matmul_mutli_dim_2
)
TEST_CASE
(
dot_3D_test
)
{
migraphx
::
program
p
;
...
...
@@ -189,7 +189,7 @@ TEST_CASE(matmul_mutli_dim_2)
EXPECT
(
migraphx
::
verify_range
(
m
,
m_res
));
}
TEST_CASE
(
gemm_mutli_dim_2_beta
0
)
TEST_CASE
(
dot_3D_C_test
0
)
{
migraphx
::
program
p
;
...
...
@@ -265,7 +265,7 @@ TEST_CASE(gemm_mutli_dim_2_beta0)
EXPECT
(
migraphx
::
verify_range
(
m
,
m_res
));
}
TEST_CASE
(
gemm_beta_0
)
TEST_CASE
(
dot_3D_C_test1
)
{
migraphx
::
program
p
;
...
...
@@ -324,7 +324,7 @@ TEST_CASE(gemm_beta_0)
EXPECT
(
migraphx
::
verify_range
(
m
,
m_res
));
}
TEST_CASE
(
matmul_mutli_dim_2_3
)
TEST_CASE
(
dot_4D_test1
)
{
migraphx
::
program
p
;
...
...
@@ -363,7 +363,7 @@ TEST_CASE(matmul_mutli_dim_2_3)
EXPECT
(
migraphx
::
verify_range
(
m
,
m_res
));
}
TEST_CASE
(
gemm_mutli_dim1_2_3
)
TEST_CASE
(
dot_4D_alpha_beta_test
)
{
migraphx
::
program
p
;
...
...
@@ -417,7 +417,7 @@ TEST_CASE(gemm_mutli_dim1_2_3)
EXPECT
(
migraphx
::
verify_range
(
m
,
m_res
));
}
TEST_CASE
(
gemm_mutli_3args
)
TEST_CASE
(
dot_4D_alpha_beta_C_test
)
{
migraphx
::
program
p
;
...
...
@@ -469,7 +469,7 @@ TEST_CASE(gemm_mutli_3args)
EXPECT
(
migraphx
::
verify_range
(
m
,
m_res
));
}
TEST_CASE
(
gemm_3args
)
TEST_CASE
(
dot_2D_C_test0
)
{
{
migraphx
::
program
p
;
...
...
@@ -533,7 +533,7 @@ TEST_CASE(gemm_3args)
}
}
TEST_CASE
(
matmul
_vv_inner_product
)
TEST_CASE
(
dot
_vv_inner_product
)
{
{
migraphx
::
program
p
;
...
...
@@ -608,7 +608,7 @@ TEST_CASE(matmul_vv_inner_product)
}
}
TEST_CASE
(
matmul
_vm
)
TEST_CASE
(
dot
_vm
)
{
{
migraphx
::
program
p
;
...
...
@@ -778,7 +778,7 @@ TEST_CASE(matmul_vm)
}
}
TEST_CASE
(
matmul
_mv
)
TEST_CASE
(
dot
_mv
)
{
{
migraphx
::
program
p
;
...
...
@@ -899,7 +899,7 @@ TEST_CASE(matmul_mv)
}
}
TEST_CASE
(
matmul
_mm1
)
TEST_CASE
(
dot
_mm1
)
{
{
migraphx
::
program
p
;
...
...
@@ -1006,7 +1006,7 @@ TEST_CASE(matmul_mm1)
}
}
TEST_CASE
(
matmul
_mm2
)
TEST_CASE
(
dot
_mm2
)
{
{
migraphx
::
program
p
;
...
...
@@ -1193,6 +1193,113 @@ TEST_CASE(matmul_mm2)
}
}
TEST_CASE
(
dot_dyn_2D_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
5
,
5
,
0
}}};
auto
ap
=
mm
->
add_parameter
(
"a"
,
a_shape
);
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
float_type
,
{
5
,
3
}};
auto
bp
=
mm
->
add_parameter
(
"b"
,
b_shape
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"dot"
),
ap
,
bp
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
a
=
{
-
0.00925222
,
0.56250403
,
0.70107397
,
0.75402161
,
-
0.505885
,
1.33628943
,
-
0.11413
,
-
0.31270559
,
1.59336732
,
-
0.19361027
,
-
0.91620867
,
0.40108416
,
-
0.06969921
,
0.68483471
,
-
0.39906632
,
-
1.66423624
,
0.69040076
,
-
1.31490171
,
-
0.11282616
,
-
0.79391814
};
std
::
vector
<
float
>
b
=
{
6.09568541e-01
,
-
6.10527007e-01
,
3.66646462e-01
,
1.18951101e-01
,
5.58777432e-01
,
-
3.21296298e-01
,
-
5.95997198e-01
,
-
5.01425721e-01
,
-
2.84606807e-01
,
-
5.73673557e-01
,
-
8.99430260e-01
,
-
4.25103093e-01
,
1.53027987e+00
,
-
3.81407415e-04
,
-
3.29650255e-01
};
migraphx
::
shape
input_fixed_shape
{
migraphx
::
shape
::
float_type
,
{
4
,
5
}};
migraphx
::
parameter_map
params
;
params
[
"a"
]
=
migraphx
::
argument
(
input_fixed_shape
,
a
.
data
());
params
[
"b"
]
=
migraphx
::
argument
(
b_shape
,
b
.
data
());
auto
result
=
p
.
eval
(
params
).
back
();
std
::
vector
<
float
>
results_vector
;
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
c
=
{
-
1.56327541e+00
,
-
7.09570140e-01
,
-
5.37424982e-01
,
-
2.22994831e-01
,
-
2.15586437e+00
,
2.09177941e-03
,
-
1.47279677e+00
,
2.02627040e-01
,
-
6.04527691e-01
,
-
1.29885596e+00
,
2.16294914e+00
,
-
1.48101497e-01
};
EXPECT
(
migraphx
::
verify_range
(
c
,
results_vector
));
}
TEST_CASE
(
dot_dyn_4D_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
float_type
,
{{
1
,
1
,
0
},
{
1
,
1
,
0
},
{
4
,
6
,
4
},
{
5
,
5
,
0
}}};
auto
al
=
mm
->
add_parameter
(
"a"
,
a_shape
);
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
float_type
,
{
1
,
1
,
5
,
3
}};
auto
bl
=
mm
->
add_parameter
(
"b"
,
b_shape
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"dot"
),
al
,
bl
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
a
=
{
-
0.00925222
,
0.56250403
,
0.70107397
,
0.75402161
,
-
0.505885
,
1.33628943
,
-
0.11413
,
-
0.31270559
,
1.59336732
,
-
0.19361027
,
-
0.91620867
,
0.40108416
,
-
0.06969921
,
0.68483471
,
-
0.39906632
,
-
1.66423624
,
0.69040076
,
-
1.31490171
,
-
0.11282616
,
-
0.79391814
};
std
::
vector
<
float
>
b
=
{
6.09568541e-01
,
-
6.10527007e-01
,
3.66646462e-01
,
1.18951101e-01
,
5.58777432e-01
,
-
3.21296298e-01
,
-
5.95997198e-01
,
-
5.01425721e-01
,
-
2.84606807e-01
,
-
5.73673557e-01
,
-
8.99430260e-01
,
-
4.25103093e-01
,
1.53027987e+00
,
-
3.81407415e-04
,
-
3.29650255e-01
};
migraphx
::
shape
input_fixed_shape0
{
migraphx
::
shape
::
float_type
,
{
1
,
1
,
4
,
5
}};
migraphx
::
shape
input_fixed_shape1
{
migraphx
::
shape
::
float_type
,
{
1
,
1
,
5
,
3
}};
migraphx
::
parameter_map
params
;
params
[
"a"
]
=
migraphx
::
argument
(
input_fixed_shape0
,
a
.
data
());
params
[
"b"
]
=
migraphx
::
argument
(
input_fixed_shape1
,
b
.
data
());
auto
result
=
p
.
eval
(
params
).
back
();
std
::
vector
<
float
>
results_vector
;
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
c
=
{
-
1.56327541e+00
,
-
7.09570140e-01
,
-
5.37424982e-01
,
-
2.22994831e-01
,
-
2.15586437e+00
,
2.09177941e-03
,
-
1.47279677e+00
,
2.02627040e-01
,
-
6.04527691e-01
,
-
1.29885596e+00
,
2.16294914e+00
,
-
1.48101497e-01
};
EXPECT
(
migraphx
::
verify_range
(
c
,
results_vector
));
}
TEST_CASE
(
quant_dot_2args_multi4
)
{
{
...
...
test/ref_ops_test.cpp
View file @
913ae362
...
...
@@ -60,15 +60,16 @@ TEST_CASE(abs_test)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
abs_dyn
amic
_test
)
TEST_CASE
(
abs_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
std
::
vector
<
float
>
a
=
{
-
1
,
2
,
-
3
,
4
};
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{{
2
,
8
,
0
},
{
2
,
2
,
0
}}};
auto
input
=
mm
->
add_parameter
(
"X"
,
s
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"abs"
),
input
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
a
=
{
-
1
,
2
,
-
3
,
4
};
migraphx
::
parameter_map
params0
;
migraphx
::
shape
input_fixed_shape0
{
migraphx
::
shape
::
float_type
,
{
2
,
2
}};
params0
[
"X"
]
=
migraphx
::
argument
(
input_fixed_shape0
,
a
.
data
());
...
...
@@ -97,17 +98,17 @@ TEST_CASE(acos_test)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
acos_dyn
amic
_test
)
TEST_CASE
(
acos_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
::
dynamic_dimension
dd
{
3
,
8
,
0
};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
dd
}};
auto
input
=
mm
->
add_parameter
(
"X"
,
s
);
std
::
vector
<
float
>
input_data
{
-
0.8
f
,
0.0
f
,
1.0
f
};
mm
->
add_instruction
(
migraphx
::
make_op
(
"acos"
),
input
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
input_data
{
-
0.8
f
,
0.0
f
,
1.0
f
};
migraphx
::
parameter_map
params0
;
migraphx
::
shape
input_fixed_shape0
{
migraphx
::
shape
::
float_type
,
{
3
}};
params0
[
"X"
]
=
migraphx
::
argument
(
input_fixed_shape0
,
input_data
.
data
());
...
...
@@ -138,7 +139,7 @@ TEST_CASE(acosh_test)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
acosh_dyn
amic
_test
)
TEST_CASE
(
acosh_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
...
...
@@ -325,6 +326,28 @@ TEST_CASE(argmax_test_neg_2)
EXPECT
(
migraphx
::
verify_range
(
result_vec
,
res_gold
));
}
TEST_CASE
(
argmax_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{{
2
,
2
,
0
},
{
3
,
6
,
0
},
{
3
,
6
,
0
}}};
auto
dl
=
mm
->
add_parameter
(
"X"
,
s
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"argmax"
,
{{
"axis"
,
0
}}),
dl
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
data
=
{
1.2255
,
1.6834
,
-
2.0305
,
-
0.3221
,
0.4701
,
0.2583
,
0.7545
,
2.5758
,
-
1.6849
,
0.0928
,
0.9022
,
-
0.8765
,
-
0.4090
,
0.9301
,
2.0724
,
-
1.5706
,
0.4867
,
-
0.1493
,
0.6957
,
-
0.2179
,
0.7142
,
0.7177
,
0.0183
,
1.3497
};
migraphx
::
parameter_map
params
;
migraphx
::
shape
input_fixed_shape
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
}};
params
[
"X"
]
=
migraphx
::
argument
(
input_fixed_shape
,
data
.
data
());
auto
result
=
p
.
eval
(
params
).
back
();
std
::
vector
<
int64_t
>
result_vec
;
result
.
visit
([
&
](
auto
output
)
{
result_vec
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
int64_t
>
res_gold
=
{
0
,
0
,
1
,
0
,
1
,
0
,
0
,
0
,
1
,
1
,
0
,
1
};
EXPECT
(
migraphx
::
verify_range
(
result_vec
,
res_gold
));
}
TEST_CASE
(
argmin_test_0
)
{
migraphx
::
program
p
;
...
...
@@ -419,17 +442,17 @@ TEST_CASE(asin_test)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
asin_dyn
amic
_test
)
TEST_CASE
(
asin_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
::
dynamic_dimension
dd
{
3
,
8
,
0
};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
dd
}};
auto
input
=
mm
->
add_parameter
(
"X"
,
s
);
std
::
vector
<
float
>
input_data
{
-
0.5
f
,
0.0
f
,
0.9
f
};
mm
->
add_instruction
(
migraphx
::
make_op
(
"asin"
),
input
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
input_data
{
-
0.5
f
,
0.0
f
,
0.9
f
};
migraphx
::
parameter_map
params0
;
migraphx
::
shape
input_fixed_shape0
{
migraphx
::
shape
::
float_type
,
{
3
}};
params0
[
"X"
]
=
migraphx
::
argument
(
input_fixed_shape0
,
input_data
.
data
());
...
...
@@ -460,17 +483,17 @@ TEST_CASE(asinh_test)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
asinh_dyn
amic
_test
)
TEST_CASE
(
asinh_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
::
dynamic_dimension
dd
{
3
,
8
,
0
};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
dd
}};
auto
input
=
mm
->
add_parameter
(
"X"
,
s
);
std
::
vector
<
float
>
input_data
{
-
0.5
f
,
0.0
f
,
0.9
f
};
mm
->
add_instruction
(
migraphx
::
make_op
(
"asinh"
),
input
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
input_data
{
-
0.5
f
,
0.0
f
,
0.9
f
};
migraphx
::
parameter_map
params0
;
migraphx
::
shape
input_fixed_shape0
{
migraphx
::
shape
::
float_type
,
{
3
}};
params0
[
"X"
]
=
migraphx
::
argument
(
input_fixed_shape0
,
input_data
.
data
());
...
...
@@ -501,17 +524,17 @@ TEST_CASE(atan_test)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
atan_dyn
amic
_test
)
TEST_CASE
(
atan_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
::
dynamic_dimension
dd
{
3
,
8
,
0
};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
dd
}};
auto
input
=
mm
->
add_parameter
(
"X"
,
s
);
std
::
vector
<
float
>
input_data
{
-
1.0
f
,
0.0
f
,
1.0
f
};
mm
->
add_instruction
(
migraphx
::
make_op
(
"atan"
),
input
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
input_data
{
-
1.0
f
,
0.0
f
,
1.0
f
};
migraphx
::
parameter_map
params0
;
migraphx
::
shape
input_fixed_shape0
{
migraphx
::
shape
::
float_type
,
{
3
}};
params0
[
"X"
]
=
migraphx
::
argument
(
input_fixed_shape0
,
input_data
.
data
());
...
...
@@ -542,17 +565,17 @@ TEST_CASE(atanh_test)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
atanh_dyn
amic
_test
)
TEST_CASE
(
atanh_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
::
dynamic_dimension
dd
{
3
,
8
,
0
};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
dd
}};
auto
input
=
mm
->
add_parameter
(
"X"
,
s
);
std
::
vector
<
float
>
input_data
{
0.4435683
f
,
0.6223626
f
,
0.316958
f
};
mm
->
add_instruction
(
migraphx
::
make_op
(
"atanh"
),
input
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
input_data
{
0.4435683
f
,
0.6223626
f
,
0.316958
f
};
migraphx
::
parameter_map
params0
;
migraphx
::
shape
input_fixed_shape0
{
migraphx
::
shape
::
float_type
,
{
3
}};
params0
[
"X"
]
=
migraphx
::
argument
(
input_fixed_shape0
,
input_data
.
data
());
...
...
@@ -565,111 +588,136 @@ TEST_CASE(atanh_dynamic_test)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
avgpool_test
)
TEST_CASE
(
avgpool_
rank3_
test
)
{
// 1D case 1, input is 3D
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
s
=
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
4
}};
auto
op
=
migraphx
::
op
::
pooling
{
migraphx
::
op
::
pooling_mode
::
average
};
op
.
lengths
=
{
2
};
op
.
padding
=
{
0
};
op
.
stride
=
{
1
};
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
s
=
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
4
}};
auto
op
=
migraphx
::
op
::
pooling
{
migraphx
::
op
::
pooling_mode
::
average
};
op
.
lengths
=
{
2
};
op
.
padding
=
{
0
};
op
.
stride
=
{
1
};
std
::
vector
<
float
>
data
{
0.3
,
0.2
,
0.4
,
0.1
,
0.8
,
0.5
,
0.9
,
0.1
,
0.1
,
0.7
,
0.1
,
0.6
};
auto
l0
=
mm
->
add_literal
(
migraphx
::
literal
{
s
,
data
});
mm
->
add_instruction
(
op
,
l0
);
p
.
compile
(
migraphx
::
ref
::
target
{});
auto
result
=
p
.
eval
({}).
back
();
std
::
vector
<
float
>
data
{
0.3
,
0.2
,
0.4
,
0.1
,
0.8
,
0.5
,
0.9
,
0.1
,
0.1
,
0.7
,
0.1
,
0.6
};
auto
l0
=
mm
->
add_literal
(
migraphx
::
literal
{
s
,
data
});
mm
->
add_instruction
(
op
,
l0
);
p
.
compile
(
migraphx
::
ref
::
target
{});
auto
result
=
p
.
eval
({}).
back
();
std
::
vector
<
float
>
results_vector
;
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
gold
{
0.25
,
0.3
,
0.25
,
0.65
,
0.7
,
0.5
,
0.4
,
0.4
,
0.35
};
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
std
::
vector
<
float
>
results_vector
;
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
gold
{
0.25
,
0.3
,
0.25
,
0.65
,
0.7
,
0.5
,
0.4
,
0.4
,
0.35
};
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
avgpool_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
s
=
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
3
,
3
,
0
},
{
4
,
4
,
0
}}};
auto
x
=
mm
->
add_parameter
(
"X"
,
s
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
average
},
{
"lengths"
,
{
2
}},
{
"padding"
,
{
0
}},
{
"stride"
,
{
1
}}}),
x
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
data
{
0.3
,
0.2
,
0.4
,
0.1
,
0.8
,
0.5
,
0.9
,
0.1
,
0.1
,
0.7
,
0.1
,
0.6
};
migraphx
::
shape
input_fixed_shape
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
4
}};
migraphx
::
parameter_map
params
;
params
[
"X"
]
=
migraphx
::
argument
(
input_fixed_shape
,
data
.
data
());
auto
result
=
p
.
eval
(
params
).
back
();
std
::
vector
<
float
>
results_vector
;
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
gold
{
0.25
,
0.3
,
0.25
,
0.65
,
0.7
,
0.5
,
0.4
,
0.4
,
0.35
};
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
avgpool_rank3_stride2_test
)
{
// 1D case 2, stride 2
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
s
=
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
2
,
4
}};
auto
op
=
migraphx
::
op
::
pooling
{
migraphx
::
op
::
pooling_mode
::
average
};
op
.
lengths
=
{
2
};
op
.
padding
=
{
1
};
op
.
stride
=
{
2
};
std
::
vector
<
float
>
data
{
1.6321
,
-
2.4186
,
0.2239
,
-
1.4232
,
0.8158
,
0.4103
,
-
0.3149
,
-
0.1361
,
-
0.3442
,
2.007
,
0.4331
,
1.5295
,
0.9965
,
0.4766
,
1.0942
,
-
0.2915
};
auto
l0
=
mm
->
add_literal
(
migraphx
::
literal
{
s
,
data
});
mm
->
add_instruction
(
op
,
l0
);
p
.
compile
(
migraphx
::
ref
::
target
{});
auto
result
=
p
.
eval
({}).
back
();
std
::
vector
<
float
>
results_vector
;
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
gold
{
1.6321
,
-
1.0974
,
-
1.4232
,
0.8158
,
0.0477
,
-
0.1361
,
-
0.3442
,
1.22005
,
1.5295
,
0.9965
,
0.7854
,
-
0.2915
};
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
s
=
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
2
,
4
}};
auto
op
=
migraphx
::
op
::
pooling
{
migraphx
::
op
::
pooling_mode
::
average
};
op
.
lengths
=
{
2
};
op
.
padding
=
{
1
};
op
.
stride
=
{
2
};
std
::
vector
<
float
>
data
{
1.6321
,
-
2.4186
,
0.2239
,
-
1.4232
,
0.8158
,
0.4103
,
-
0.3149
,
-
0.1361
,
-
0.3442
,
2.007
,
0.4331
,
1.5295
,
0.9965
,
0.4766
,
1.0942
,
-
0.2915
};
auto
l0
=
mm
->
add_literal
(
migraphx
::
literal
{
s
,
data
});
mm
->
add_instruction
(
op
,
l0
);
p
.
compile
(
migraphx
::
ref
::
target
{});
auto
result
=
p
.
eval
({}).
back
();
std
::
vector
<
float
>
results_vector
;
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
gold
{
1.6321
,
-
1.0974
,
-
1.4232
,
0.8158
,
0.0477
,
-
0.1361
,
-
0.3442
,
1.22005
,
1.5295
,
0.9965
,
0.7854
,
-
0.2915
};
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
avgpool_rank5_test
)
{
// 3D, input is 5D
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
s
=
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
2
,
3
,
3
,
3
}};
auto
op
=
migraphx
::
op
::
pooling
{
migraphx
::
op
::
pooling_mode
::
average
};
op
.
lengths
=
{
2
,
2
,
2
};
op
.
padding
=
{
0
,
0
,
0
};
op
.
stride
=
{
1
,
1
,
1
};
std
::
vector
<
float
>
data
{
-
0.179
,
-
1.756
,
0.651
,
1.955
,
1.87
,
-
0.604
,
0.247
,
0.449
,
-
0.137
,
1.187
,
1.593
,
0.424
,
2.698
,
-
0.104
,
-
0.069
,
-
1.293
,
0.538
,
1.291
,
0.974
,
1.096
,
0.74
,
-
0.669
,
-
1.08
,
-
1.041
,
-
1.407
,
1.43
,
-
0.211
,
-
0.017
,
0.532
,
1.276
,
0.627
,
0.236
,
-
0.396
,
-
0.204
,
0.501
,
-
0.599
,
-
1.414
,
-
0.615
,
-
0.274
,
0.168
,
-
0.144
,
0.5
,
1.42
,
1.082
,
-
0.952
,
-
0.846
,
-
1.244
,
1.475
,
1.246
,
1.344
,
-
1.722
,
-
1.24
,
-
0.851
,
0.06
,
0.507
,
0.762
,
-
0.007
,
-
1.484
,
1.028
,
0.317
,
1.077
,
-
1.289
,
0.875
,
-
0.417
,
-
0.673
,
1.715
,
-
0.307
,
0.264
,
-
0.973
,
1.412
,
2.561
,
-
0.515
,
-
0.201
,
0.827
,
-
1.231
,
1.958
,
-
0.552
,
0.036
,
-
0.993
,
-
0.859
,
-
1.458
,
-
0.575
,
0.048
,
-
0.779
,
-
1.025
,
-
1.135
,
1.166
,
-
0.131
,
0.726
,
0.52
,
0.467
,
-
0.494
,
0.675
,
0.203
,
-
0.63
,
-
0.918
,
-
0.5
,
-
1.395
,
1.39
,
1.705
,
0.444
,
-
0.835
,
-
0.506
,
0.101
,
0.602
,
0.543
,
0.357
,
1.042
};
auto
l0
=
mm
->
add_literal
(
migraphx
::
literal
{
s
,
data
});
mm
->
add_instruction
(
op
,
l0
);
p
.
compile
(
migraphx
::
ref
::
target
{});
auto
result
=
p
.
eval
({}).
back
();
std
::
vector
<
float
>
results_vector
;
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
gold
{
0.908
,
0.250625
,
0.795
,
0.40425
,
0.711875
,
0.194875
,
0.014125
,
0.09425
,
-
0.078375
,
0.139375
,
0.46075
,
0.0285
,
-
0.188125
,
-
0.085
,
0.378125
,
-
0.085375
,
-
0.04
,
0.304125
,
0.40775
,
0.2835
,
0.112375
,
-
0.073375
,
0.4355
,
-
0.187
,
-
0.392625
,
-
0.258375
,
-
0.485875
,
-
0.0345
,
0.16125
,
-
0.131875
,
-
0.228375
,
0.068625
};
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
s
=
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
2
,
3
,
3
,
3
}};
auto
op
=
migraphx
::
op
::
pooling
{
migraphx
::
op
::
pooling_mode
::
average
};
op
.
lengths
=
{
2
,
2
,
2
};
op
.
padding
=
{
0
,
0
,
0
};
op
.
stride
=
{
1
,
1
,
1
};
std
::
vector
<
float
>
data
{
-
0.179
,
-
1.756
,
0.651
,
1.955
,
1.87
,
-
0.604
,
0.247
,
0.449
,
-
0.137
,
1.187
,
1.593
,
0.424
,
2.698
,
-
0.104
,
-
0.069
,
-
1.293
,
0.538
,
1.291
,
0.974
,
1.096
,
0.74
,
-
0.669
,
-
1.08
,
-
1.041
,
-
1.407
,
1.43
,
-
0.211
,
-
0.017
,
0.532
,
1.276
,
0.627
,
0.236
,
-
0.396
,
-
0.204
,
0.501
,
-
0.599
,
-
1.414
,
-
0.615
,
-
0.274
,
0.168
,
-
0.144
,
0.5
,
1.42
,
1.082
,
-
0.952
,
-
0.846
,
-
1.244
,
1.475
,
1.246
,
1.344
,
-
1.722
,
-
1.24
,
-
0.851
,
0.06
,
0.507
,
0.762
,
-
0.007
,
-
1.484
,
1.028
,
0.317
,
1.077
,
-
1.289
,
0.875
,
-
0.417
,
-
0.673
,
1.715
,
-
0.307
,
0.264
,
-
0.973
,
1.412
,
2.561
,
-
0.515
,
-
0.201
,
0.827
,
-
1.231
,
1.958
,
-
0.552
,
0.036
,
-
0.993
,
-
0.859
,
-
1.458
,
-
0.575
,
0.048
,
-
0.779
,
-
1.025
,
-
1.135
,
1.166
,
-
0.131
,
0.726
,
0.52
,
0.467
,
-
0.494
,
0.675
,
0.203
,
-
0.63
,
-
0.918
,
-
0.5
,
-
1.395
,
1.39
,
1.705
,
0.444
,
-
0.835
,
-
0.506
,
0.101
,
0.602
,
0.543
,
0.357
,
1.042
};
auto
l0
=
mm
->
add_literal
(
migraphx
::
literal
{
s
,
data
});
mm
->
add_instruction
(
op
,
l0
);
p
.
compile
(
migraphx
::
ref
::
target
{});
auto
result
=
p
.
eval
({}).
back
();
std
::
vector
<
float
>
results_vector
;
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
gold
{
0.908
,
0.250625
,
0.795
,
0.40425
,
0.711875
,
0.194875
,
0.014125
,
0.09425
,
-
0.078375
,
0.139375
,
0.46075
,
0.0285
,
-
0.188125
,
-
0.085
,
0.378125
,
-
0.085375
,
-
0.04
,
0.304125
,
0.40775
,
0.2835
,
0.112375
,
-
0.073375
,
0.4355
,
-
0.187
,
-
0.392625
,
-
0.258375
,
-
0.485875
,
-
0.0345
,
0.16125
,
-
0.131875
,
-
0.228375
,
0.068625
};
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
broadcast_test
)
...
...
@@ -758,17 +806,17 @@ TEST_CASE(ceil_test)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
ceil_dyn
amic
_test
)
TEST_CASE
(
ceil_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
::
dynamic_dimension
dd
{
4
,
12
,
0
};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
dd
}};
auto
input
=
mm
->
add_parameter
(
"X"
,
s
);
std
::
vector
<
float
>
input_data
=
{
1.1
,
1.5
,
1.6
,
-
1.1
,
-
1.5
,
-
1.6
,
0.0
,
2.0
,
-
2.0
};
auto
input
=
mm
->
add_parameter
(
"X"
,
s
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"ceil"
),
input
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
input_data
=
{
1.1
,
1.5
,
1.6
,
-
1.1
,
-
1.5
,
-
1.6
,
0.0
,
2.0
,
-
2.0
};
migraphx
::
parameter_map
params0
;
migraphx
::
shape
input_fixed_shape0
{
migraphx
::
shape
::
float_type
,
{
9
}};
params0
[
"X"
]
=
migraphx
::
argument
(
input_fixed_shape0
,
input_data
.
data
());
...
...
@@ -918,11 +966,38 @@ TEST_CASE(contiguous_test)
p
.
compile
(
migraphx
::
ref
::
target
{});
auto
result
=
p
.
eval
({}).
back
();
std
::
vector
<
size_t
>
new_strides
=
{
12
,
4
,
2
,
1
};
EXPECT
(
result
.
get_shape
().
strides
()
==
new_strides
);
std
::
vector
<
float
>
results_vector
(
12
);
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
gold
=
{
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
};
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
contiguous_param_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
2
,
2
},
{
12
,
1
,
6
,
3
}};
auto
a
=
mm
->
add_parameter
(
"X"
,
a_shape
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"contiguous"
),
a
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
data
(
12
);
std
::
iota
(
data
.
begin
(),
data
.
end
(),
0
);
migraphx
::
parameter_map
params
;
params
[
"X"
]
=
migraphx
::
argument
(
a_shape
,
data
.
data
());
auto
result
=
p
.
eval
(
params
).
back
();
std
::
vector
<
size_t
>
new_strides
=
{
12
,
4
,
2
,
1
};
EXPECT
(
result
.
get_shape
().
strides
()
==
new_strides
);
std
::
vector
<
float
>
results_vector
(
12
);
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
size_t
>
new_lens
=
{
1
,
3
,
2
,
2
};
std
::
vector
<
size_t
>
new_strides
=
{
12
,
1
,
6
,
3
};
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
data
));
std
::
vector
<
float
>
gold
=
{
0
,
3
,
6
,
9
,
1
,
4
,
7
,
10
,
2
,
5
,
8
,
11
};
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
contiguous_dyn_test
)
...
...
@@ -1069,7 +1144,7 @@ TEST_CASE(conv_dynamic_batch_test)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
sol
));
}
TEST_CASE
(
conv_dyn
amic
_img_shape_test
)
TEST_CASE
(
conv_dyn_img_shape_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
...
...
@@ -1158,7 +1233,7 @@ TEST_CASE(conv_dynamic_img_shape_test)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
sol
));
}
TEST_CASE
(
conv_dyn
amic
_weights_shape_test
)
TEST_CASE
(
conv_dyn_weights_shape_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
...
...
@@ -1235,7 +1310,7 @@ TEST_CASE(conv_dynamic_weights_shape_test)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
sol
));
}
TEST_CASE
(
conv_dyn
amic
_img_same_upper_test
)
TEST_CASE
(
conv_dyn_img_same_upper_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
...
...
@@ -1306,7 +1381,7 @@ TEST_CASE(conv_dynamic_img_same_upper_test)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
sol
));
}
TEST_CASE
(
conv_dyn
amic
_kernel_same_upper_test
)
TEST_CASE
(
conv_dyn_kernel_same_upper_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
...
...
@@ -1380,7 +1455,7 @@ TEST_CASE(conv_dynamic_kernel_same_upper_test)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
sol
));
}
TEST_CASE
(
conv_dyn
amic
_kernel_same_lower_test
)
TEST_CASE
(
conv_dyn_kernel_same_lower_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
...
...
@@ -1725,17 +1800,17 @@ TEST_CASE(cos_test)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
cos_dyn
amic
_test
)
TEST_CASE
(
cos_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
::
dynamic_dimension
dd
{
3
,
8
,
0
};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
dd
}};
auto
input
=
mm
->
add_parameter
(
"X"
,
s
);
std
::
vector
<
float
>
input_data
{
-
1
,
0
,
1
};
mm
->
add_instruction
(
migraphx
::
make_op
(
"cos"
),
input
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
input_data
{
-
1
,
0
,
1
};
migraphx
::
parameter_map
params0
;
migraphx
::
shape
input_fixed_shape0
{
migraphx
::
shape
::
float_type
,
{
3
}};
params0
[
"X"
]
=
migraphx
::
argument
(
input_fixed_shape0
,
input_data
.
data
());
...
...
@@ -1766,17 +1841,17 @@ TEST_CASE(cosh_test)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
cosh_dyn
amic
_test
)
TEST_CASE
(
cosh_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
::
dynamic_dimension
dd
{
3
,
8
,
0
};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
dd
}};
auto
input
=
mm
->
add_parameter
(
"X"
,
s
);
std
::
vector
<
float
>
input_data
=
{
-
1.0
,
2.0
,
-
3.0
,
4.0
};
auto
input
=
mm
->
add_parameter
(
"X"
,
s
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"cosh"
),
input
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
input_data
=
{
-
1.0
,
2.0
,
-
3.0
,
4.0
};
migraphx
::
parameter_map
params0
;
migraphx
::
shape
input_fixed_shape0
{
migraphx
::
shape
::
float_type
,
{
4
}};
params0
[
"X"
]
=
migraphx
::
argument
(
input_fixed_shape0
,
input_data
.
data
());
...
...
@@ -1999,18 +2074,18 @@ TEST_CASE(elu_test)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
elu_dyn
amic
_test
)
TEST_CASE
(
elu_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
::
dynamic_dimension
dd
{
3
,
8
,
0
};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
dd
}};
auto
input
=
mm
->
add_parameter
(
"X"
,
s
);
std
::
vector
<
float
>
input_data
{
-
1.0
,
2.0
,
-
3.0
,
4.0
};
auto
input
=
mm
->
add_parameter
(
"X"
,
s
);
float
alpha
=
0.5
;
mm
->
add_instruction
(
migraphx
::
make_op
(
"elu"
,
{{
"alpha"
,
alpha
}}),
input
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
input_data
{
-
1.0
,
2.0
,
-
3.0
,
4.0
};
migraphx
::
parameter_map
params0
;
migraphx
::
shape
input_fixed_shape0
{
migraphx
::
shape
::
float_type
,
{
4
}};
params0
[
"X"
]
=
migraphx
::
argument
(
input_fixed_shape0
,
input_data
.
data
());
...
...
@@ -2117,17 +2192,17 @@ TEST_CASE(erf_test)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
erf_dyn
amic
_test
)
TEST_CASE
(
erf_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
::
dynamic_dimension
dd
{
3
,
8
,
0
};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
dd
}};
auto
input
=
mm
->
add_parameter
(
"X"
,
s
);
std
::
vector
<
float
>
input_data
=
{
0.73785057
,
1.58165966
,
-
0.43597795
,
-
0.01677432
};
auto
input
=
mm
->
add_parameter
(
"X"
,
s
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"erf"
),
input
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
input_data
=
{
0.73785057
,
1.58165966
,
-
0.43597795
,
-
0.01677432
};
migraphx
::
parameter_map
params0
;
migraphx
::
shape
input_fixed_shape0
{
migraphx
::
shape
::
float_type
,
{
4
}};
params0
[
"X"
]
=
migraphx
::
argument
(
input_fixed_shape0
,
input_data
.
data
());
...
...
@@ -2158,17 +2233,17 @@ TEST_CASE(exp_test)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
exp_dyn
amic
_test
)
TEST_CASE
(
exp_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
::
dynamic_dimension
dd
{
3
,
8
,
0
};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
dd
}};
auto
input
=
mm
->
add_parameter
(
"X"
,
s
);
std
::
vector
<
float
>
input_data
{
-
1
,
0
,
1
};
mm
->
add_instruction
(
migraphx
::
make_op
(
"exp"
),
input
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
input_data
{
-
1
,
0
,
1
};
migraphx
::
parameter_map
params0
;
migraphx
::
shape
input_fixed_shape0
{
migraphx
::
shape
::
float_type
,
{
3
}};
params0
[
"X"
]
=
migraphx
::
argument
(
input_fixed_shape0
,
input_data
.
data
());
...
...
@@ -2199,17 +2274,17 @@ TEST_CASE(floor_test)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
floor_dyn
amic
_test
)
TEST_CASE
(
floor_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
::
dynamic_dimension
dd
{
5
,
12
,
0
};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
dd
}};
auto
input
=
mm
->
add_parameter
(
"X"
,
s
);
std
::
vector
<
float
>
input_data
=
{
1.1
,
1.5
,
0.6
,
-
1.1
,
-
1.5
,
-
0.6
,
0.0
,
2.0
,
-
2.0
};
auto
input
=
mm
->
add_parameter
(
"X"
,
s
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"floor"
),
input
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
input_data
=
{
1.1
,
1.5
,
0.6
,
-
1.1
,
-
1.5
,
-
0.6
,
0.0
,
2.0
,
-
2.0
};
migraphx
::
parameter_map
params0
;
migraphx
::
shape
input_fixed_shape0
{
migraphx
::
shape
::
float_type
,
{
9
}};
params0
[
"X"
]
=
migraphx
::
argument
(
input_fixed_shape0
,
input_data
.
data
());
...
...
@@ -2667,6 +2742,30 @@ TEST_CASE(globalavgpool_test)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
globalavgpool_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
s
=
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
1
,
1
,
0
},
{
3
,
3
,
0
},
{
2
,
6
,
0
},
{
2
,
6
,
2
}}};
auto
x
=
mm
->
add_parameter
(
"X"
,
s
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
average
},
{
"dyn_global"
,
true
}}),
x
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
data
{
0.3
,
0.2
,
0.4
,
0.1
,
0.8
,
0.5
,
0.9
,
0.1
,
0.1
,
0.7
,
0.1
,
0.6
};
migraphx
::
shape
input_fixed_shape
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
2
,
2
}};
migraphx
::
parameter_map
params
;
params
[
"X"
]
=
migraphx
::
argument
(
input_fixed_shape
,
data
.
data
());
auto
result
=
p
.
eval
(
params
).
back
();
std
::
vector
<
float
>
results_vector
(
3
);
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
gold
{
0.25
,
0.575
,
0.375
};
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
globallppool_test
)
{
migraphx
::
program
p
;
...
...
@@ -2689,6 +2788,30 @@ TEST_CASE(globallppool_test)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
globallppool_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
s
=
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
1
,
1
,
0
},
{
3
,
3
,
0
},
{
2
,
6
,
2
},
{
2
,
6
,
2
}}};
auto
x
=
mm
->
add_parameter
(
"X"
,
s
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
lpnorm
},
{
"dyn_global"
,
true
}}),
x
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
data
{
0.3
,
0.2
,
0.4
,
0.1
,
0.8
,
0.5
,
0.9
,
0.1
,
0.1
,
0.7
,
0.1
,
0.6
};
migraphx
::
shape
input_fixed_shape
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
2
,
2
}};
migraphx
::
parameter_map
params
;
params
[
"X"
]
=
migraphx
::
argument
(
input_fixed_shape
,
data
.
data
());
auto
result
=
p
.
eval
(
params
).
back
();
std
::
vector
<
float
>
results_vector
(
3
);
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
gold
{
0.5477225575051662
,
1.307669683062202
,
0.9327379053088815
};
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
globalmaxpool_test
)
{
migraphx
::
program
p
;
...
...
@@ -2710,6 +2833,30 @@ TEST_CASE(globalmaxpool_test)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
globalmaxpool_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
s
=
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
1
,
1
,
0
},
{
3
,
3
,
0
},
{
2
,
6
,
2
},
{
2
,
6
,
2
}}};
auto
x
=
mm
->
add_parameter
(
"X"
,
s
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
max
},
{
"dyn_global"
,
true
}}),
x
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
data
{
0.3
,
0.2
,
0.4
,
0.1
,
0.8
,
0.5
,
0.9
,
0.1
,
0.1
,
0.7
,
0.1
,
0.6
};
migraphx
::
shape
input_fixed_shape
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
2
,
2
}};
migraphx
::
parameter_map
params
;
params
[
"X"
]
=
migraphx
::
argument
(
input_fixed_shape
,
data
.
data
());
auto
result
=
p
.
eval
(
params
).
back
();
std
::
vector
<
float
>
results_vector
(
3
);
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
gold
{
0.4
,
0.9
,
0.7
};
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
greater_brcst_test
)
{
migraphx
::
program
p
;
...
...
@@ -2803,16 +2950,16 @@ TEST_CASE(identity_test)
EXPECT
(
std
::
equal
(
data
.
begin
(),
data
.
end
(),
results_vector
.
begin
()));
}
TEST_CASE
(
identity_dyn
amic
_test
)
TEST_CASE
(
identity_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{{
2
,
4
,
0
},
{
2
,
4
,
0
}}};
auto
input
=
mm
->
add_parameter
(
"X"
,
s
);
std
::
vector
<
int
>
input_data
{
1
,
2
,
3
,
4
};
mm
->
add_instruction
(
migraphx
::
make_op
(
"identity"
),
input
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
int
>
input_data
{
1
,
2
,
3
,
4
};
migraphx
::
parameter_map
params0
;
migraphx
::
shape
input_fixed_shape0
{
migraphx
::
shape
::
int32_type
,
{
2
,
2
}};
params0
[
"X"
]
=
migraphx
::
argument
(
input_fixed_shape0
,
input_data
.
data
());
...
...
@@ -3049,17 +3196,17 @@ TEST_CASE(isnan_test)
}
}
TEST_CASE
(
isnan_dyn
amic
_test
)
TEST_CASE
(
isnan_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{{
2
,
2
,
0
},
{
3
,
8
,
0
}}};
auto
input
=
mm
->
add_parameter
(
"X"
,
s
);
auto
nan_val
=
std
::
numeric_limits
<
float
>::
quiet_NaN
();
std
::
vector
<
float
>
input_data
=
{
1.2
,
5.2
,
nan_val
,
nan_val
,
0.
,
100.
};
auto
input
=
mm
->
add_parameter
(
"X"
,
s
);
auto
nan_val
=
std
::
numeric_limits
<
float
>::
quiet_NaN
();
mm
->
add_instruction
(
migraphx
::
make_op
(
"isnan"
),
input
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
input_data
=
{
1.2
,
5.2
,
nan_val
,
nan_val
,
0.
,
100.
};
migraphx
::
parameter_map
params0
;
migraphx
::
shape
input_fixed_shape0
{
migraphx
::
shape
::
float_type
,
{
2
,
3
}};
params0
[
"X"
]
=
migraphx
::
argument
(
input_fixed_shape0
,
input_data
.
data
());
...
...
@@ -3420,17 +3567,17 @@ TEST_CASE(log_test)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
log_dyn
amic
_test
)
TEST_CASE
(
log_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
::
dynamic_dimension
dd
{
3
,
8
,
0
};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
dd
}};
auto
input
=
mm
->
add_parameter
(
"X"
,
s
);
std
::
vector
<
float
>
input_data
=
{
1
,
2
,
3
};
auto
input
=
mm
->
add_parameter
(
"X"
,
s
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"log"
),
input
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
input_data
=
{
1
,
2
,
3
};
migraphx
::
parameter_map
params0
;
migraphx
::
shape
input_fixed_shape0
{
migraphx
::
shape
::
float_type
,
{
3
}};
params0
[
"X"
]
=
migraphx
::
argument
(
input_fixed_shape0
,
input_data
.
data
());
...
...
@@ -3732,61 +3879,93 @@ TEST_CASE(logsoftmax_test_axis_3)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
s
));
}
TEST_CASE
(
lppool_test
)
TEST_CASE
(
lppool_
l1_norm_
test
)
{
// L1 norm test
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
s
=
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
4
}};
auto
op
=
migraphx
::
op
::
pooling
{
migraphx
::
op
::
pooling_mode
::
lpnorm
};
op
.
lengths
=
{
2
};
op
.
padding
=
{
0
};
op
.
stride
=
{
1
};
op
.
lp_order
=
1
;
std
::
vector
<
float
>
data
{
0.3
,
0.2
,
0.4
,
0.1
,
0.8
,
0.5
,
0.9
,
0.1
,
0.1
,
0.7
,
0.1
,
0.6
};
auto
l0
=
mm
->
add_literal
(
migraphx
::
literal
{
s
,
data
});
mm
->
add_instruction
(
op
,
l0
);
p
.
compile
(
migraphx
::
ref
::
target
{});
auto
result
=
p
.
eval
({}).
back
();
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
s
=
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
4
}};
auto
op
=
migraphx
::
op
::
pooling
{
migraphx
::
op
::
pooling_mode
::
lpnorm
};
op
.
lengths
=
{
2
};
op
.
padding
=
{
0
};
op
.
stride
=
{
1
};
op
.
lp_order
=
1
;
std
::
vector
<
float
>
results_vector
;
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
gold
{
0.5
,
0.6
,
0.5
,
1.3
,
1.4
,
1.0
,
0.8
,
0.8
,
0.7
};
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
std
::
vector
<
float
>
data
{
0.3
,
0.2
,
0.4
,
0.1
,
0.8
,
0.5
,
0.9
,
0.1
,
0.1
,
0.7
,
0.1
,
0.6
};
auto
l0
=
mm
->
add_literal
(
migraphx
::
literal
{
s
,
data
});
mm
->
add_instruction
(
op
,
l0
);
p
.
compile
(
migraphx
::
ref
::
target
{});
auto
result
=
p
.
eval
({}).
back
();
std
::
vector
<
float
>
results_vector
;
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
gold
{
0.5
,
0.6
,
0.5
,
1.3
,
1.4
,
1.0
,
0.8
,
0.8
,
0.7
};
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
lppool_l2_norm_test
)
{
// L2 norm test
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
s
=
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
4
}};
auto
op
=
migraphx
::
op
::
pooling
{
migraphx
::
op
::
pooling_mode
::
lpnorm
};
op
.
lengths
=
{
2
};
op
.
padding
=
{
0
};
op
.
stride
=
{
1
};
op
.
lp_order
=
2
;
std
::
vector
<
float
>
data
{
0.3
,
0.2
,
0.4
,
0.1
,
0.8
,
0.5
,
0.9
,
0.1
,
0.1
,
0.7
,
0.1
,
0.6
};
auto
l0
=
mm
->
add_literal
(
migraphx
::
literal
{
s
,
data
});
mm
->
add_instruction
(
op
,
l0
);
p
.
compile
(
migraphx
::
ref
::
target
{});
auto
result
=
p
.
eval
({}).
back
();
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
s
=
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
4
}};
auto
op
=
migraphx
::
op
::
pooling
{
migraphx
::
op
::
pooling_mode
::
lpnorm
};
op
.
lengths
=
{
2
};
op
.
padding
=
{
0
};
op
.
stride
=
{
1
};
op
.
lp_order
=
2
;
std
::
vector
<
float
>
results_vector
;
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
gold
{
0.36055512754639896
,
0.447213595499958
,
0.4123105625617661
,
0.9433981132056605
,
1.0295630140987
,
0.9055385138137417
,
0.7071067811865475
,
0.7071067811865475
,
0.6082762530298219
};
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
std
::
vector
<
float
>
data
{
0.3
,
0.2
,
0.4
,
0.1
,
0.8
,
0.5
,
0.9
,
0.1
,
0.1
,
0.7
,
0.1
,
0.6
};
auto
l0
=
mm
->
add_literal
(
migraphx
::
literal
{
s
,
data
});
mm
->
add_instruction
(
op
,
l0
);
p
.
compile
(
migraphx
::
ref
::
target
{});
auto
result
=
p
.
eval
({}).
back
();
std
::
vector
<
float
>
results_vector
;
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
gold
{
0.36055512754639896
,
0.447213595499958
,
0.4123105625617661
,
0.9433981132056605
,
1.0295630140987
,
0.9055385138137417
,
0.7071067811865475
,
0.7071067811865475
,
0.6082762530298219
};
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
lppool_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
s
=
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
3
,
3
,
0
},
{
4
,
4
,
0
}}};
auto
x
=
mm
->
add_parameter
(
"X"
,
s
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
lpnorm
},
{
"lengths"
,
{
2
}},
{
"padding"
,
{
0
}},
{
"stride"
,
{
1
}}}),
x
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
data
{
0.3
,
0.2
,
0.4
,
0.1
,
0.8
,
0.5
,
0.9
,
0.1
,
0.1
,
0.7
,
0.1
,
0.6
};
migraphx
::
shape
input_fixed_shape
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
4
}};
migraphx
::
parameter_map
params
;
params
[
"X"
]
=
migraphx
::
argument
(
input_fixed_shape
,
data
.
data
());
auto
result
=
p
.
eval
(
params
).
back
();
std
::
vector
<
float
>
results_vector
;
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
gold
{
0.36055512754639896
,
0.447213595499958
,
0.4123105625617661
,
0.9433981132056605
,
1.0295630140987
,
0.9055385138137417
,
0.7071067811865475
,
0.7071067811865475
,
0.6082762530298219
};
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
lrn_test
)
...
...
@@ -3908,122 +4087,147 @@ TEST_CASE(maxpool_test)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
c
));
}
TEST_CASE
(
maxpool_
test_1D_3D
)
TEST_CASE
(
maxpool_
rank3_test0
)
{
// 1D case 1, input is 3D
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
s
=
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
4
}};
auto
op
=
migraphx
::
op
::
pooling
{
migraphx
::
op
::
pooling_mode
::
max
};
op
.
lengths
=
{
2
};
op
.
padding
=
{
0
};
op
.
stride
=
{
1
};
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
s
=
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
4
}};
auto
op
=
migraphx
::
op
::
pooling
{
migraphx
::
op
::
pooling_mode
::
max
};
op
.
lengths
=
{
2
};
op
.
padding
=
{
0
};
op
.
stride
=
{
1
};
std
::
vector
<
float
>
data
{
0.3
,
0.2
,
0.4
,
0.1
,
0.8
,
0.5
,
0.9
,
0.1
,
0.1
,
0.7
,
0.1
,
0.6
};
auto
l0
=
mm
->
add_literal
(
migraphx
::
literal
{
s
,
data
});
mm
->
add_instruction
(
op
,
l0
);
p
.
compile
(
migraphx
::
ref
::
target
{});
auto
result
=
p
.
eval
({}).
back
();
std
::
vector
<
float
>
data
{
0.3
,
0.2
,
0.4
,
0.1
,
0.8
,
0.5
,
0.9
,
0.1
,
0.1
,
0.7
,
0.1
,
0.6
};
auto
l0
=
mm
->
add_literal
(
migraphx
::
literal
{
s
,
data
});
mm
->
add_instruction
(
op
,
l0
);
p
.
compile
(
migraphx
::
ref
::
target
{});
auto
result
=
p
.
eval
({}).
back
();
std
::
vector
<
float
>
results_vector
;
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
gold
{
0.3
,
0.4
,
0.4
,
0.8
,
0.9
,
0.9
,
0.7
,
0.7
,
0.6
};
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
std
::
vector
<
float
>
results_vector
;
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
gold
{
0.3
,
0.4
,
0.4
,
0.8
,
0.9
,
0.9
,
0.7
,
0.7
,
0.6
};
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
maxpool_rank3_test1
)
{
// 1D case 2, input is 3D
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
s
=
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
2
,
5
}};
auto
op
=
migraphx
::
op
::
pooling
{
migraphx
::
op
::
pooling_mode
::
max
};
op
.
lengths
=
{
2
};
op
.
padding
=
{
0
};
op
.
stride
=
{
2
};
std
::
vector
<
float
>
data
{
0.4975
,
-
0.1226
,
-
0.0405
,
-
0.2861
,
-
0.1227
,
-
0.6186
,
-
0.9618
,
0.6022
,
-
0.1912
,
1.1925
,
0.5493
,
0.1692
,
-
0.8039
,
-
1.0281
,
0.9907
,
0.477
,
1.5001
,
-
1.1603
,
-
1.361
,
1.2556
};
auto
l0
=
mm
->
add_literal
(
migraphx
::
literal
{
s
,
data
});
mm
->
add_instruction
(
op
,
l0
);
p
.
compile
(
migraphx
::
ref
::
target
{});
auto
result
=
p
.
eval
({}).
back
();
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
s
=
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
2
,
5
}};
auto
op
=
migraphx
::
op
::
pooling
{
migraphx
::
op
::
pooling_mode
::
max
};
op
.
lengths
=
{
2
};
op
.
padding
=
{
0
};
op
.
stride
=
{
2
};
std
::
vector
<
float
>
results_vector
;
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
gold
{
0.4975
,
-
0.0405
,
-
0.6186
,
0.6022
,
0.5493
,
-
0.8039
,
1.5001
,
-
1.1603
};
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
std
::
vector
<
float
>
data
{
0.4975
,
-
0.1226
,
-
0.0405
,
-
0.2861
,
-
0.1227
,
-
0.6186
,
-
0.9618
,
0.6022
,
-
0.1912
,
1.1925
,
0.5493
,
0.1692
,
-
0.8039
,
-
1.0281
,
0.9907
,
0.477
,
1.5001
,
-
1.1603
,
-
1.361
,
1.2556
};
auto
l0
=
mm
->
add_literal
(
migraphx
::
literal
{
s
,
data
});
mm
->
add_instruction
(
op
,
l0
);
p
.
compile
(
migraphx
::
ref
::
target
{});
auto
result
=
p
.
eval
({}).
back
();
std
::
vector
<
float
>
results_vector
;
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
gold
{
0.4975
,
-
0.0405
,
-
0.6186
,
0.6022
,
0.5493
,
-
0.8039
,
1.5001
,
-
1.1603
};
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
maxpool_rank3_ceil_test
)
{
// 1D case 2, input is 3D, ceil mode
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
s
=
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
2
,
5
}};
auto
op
=
migraphx
::
op
::
pooling
{
migraphx
::
op
::
pooling_mode
::
max
};
op
.
lengths
=
{
2
};
op
.
padding
=
{
0
};
op
.
stride
=
{
2
};
op
.
ceil_mode
=
true
;
std
::
vector
<
float
>
data
{
0.4975
,
-
0.1226
,
-
0.0405
,
-
0.2861
,
-
0.1227
,
-
0.6186
,
-
0.9618
,
0.6022
,
-
0.1912
,
1.1925
,
0.5493
,
0.1692
,
-
0.8039
,
-
1.0281
,
0.9907
,
0.477
,
1.5001
,
-
1.1603
,
-
1.361
,
1.2556
};
auto
l0
=
mm
->
add_literal
(
migraphx
::
literal
{
s
,
data
});
mm
->
add_instruction
(
op
,
l0
);
p
.
compile
(
migraphx
::
ref
::
target
{});
auto
result
=
p
.
eval
({}).
back
();
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
s
=
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
2
,
5
}};
auto
op
=
migraphx
::
op
::
pooling
{
migraphx
::
op
::
pooling_mode
::
max
};
op
.
lengths
=
{
2
};
op
.
padding
=
{
0
};
op
.
stride
=
{
2
};
op
.
ceil_mode
=
true
;
std
::
vector
<
float
>
data
{
0.4975
,
-
0.1226
,
-
0.0405
,
-
0.2861
,
-
0.1227
,
-
0.6186
,
-
0.9618
,
0.6022
,
-
0.1912
,
1.1925
,
0.5493
,
0.1692
,
-
0.8039
,
-
1.0281
,
0.9907
,
0.477
,
1.5001
,
-
1.1603
,
-
1.361
,
1.2556
};
auto
l0
=
mm
->
add_literal
(
migraphx
::
literal
{
s
,
data
});
mm
->
add_instruction
(
op
,
l0
);
p
.
compile
(
migraphx
::
ref
::
target
{});
auto
result
=
p
.
eval
({}).
back
();
std
::
vector
<
float
>
results_vector
;
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
gold
{
0.4975
,
-
0.0405
,
-
0.1227
,
-
0.6186
,
0.6022
,
1.1925
,
0.5493
,
-
0.8039
,
0.9907
,
1.5001
,
-
1.1603
,
1.2556
};
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
std
::
vector
<
float
>
results_vector
;
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
gold
{
0.4975
,
-
0.0405
,
-
0.1227
,
-
0.6186
,
0.6022
,
1.1925
,
0.5493
,
-
0.8039
,
0.9907
,
1.5001
,
-
1.1603
,
1.2556
};
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
maxpool_rank5_test
)
{
// 3D, input is 5D
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
s
=
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
2
,
3
,
3
,
3
}};
auto
op
=
migraphx
::
op
::
pooling
{
migraphx
::
op
::
pooling_mode
::
max
};
op
.
lengths
=
{
2
,
2
,
2
};
op
.
padding
=
{
0
,
0
,
0
};
op
.
stride
=
{
2
,
2
,
2
};
std
::
vector
<
float
>
data
{
-
2.8029
,
0.5861
,
0.7015
,
0.1297
,
-
1.44
,
-
1.9472
,
0.7812
,
2.408
,
-
0.3145
,
0.3405
,
-
0.9146
,
0.0624
,
1.5064
,
-
0.8345
,
1.7977
,
1.8949
,
1.0073
,
-
0.2102
,
-
0.042
,
-
0.7146
,
0.6227
,
-
0.5263
,
-
2.2598
,
0.1713
,
0.449
,
0.5303
,
-
0.8622
,
-
0.5691
,
0.907
,
-
0.0569
,
-
1.5348
,
-
0.4109
,
-
0.1461
,
-
0.5445
,
0.4266
,
0.2282
,
1.3655
,
-
2.1519
,
0.6068
,
-
0.2001
,
-
0.4702
,
0.3864
,
1.7083
,
0.9096
,
0.4286
,
-
1.8866
,
0.7034
,
0.0293
,
1.4587
,
0.7672
,
-
2.8614
,
0.8124
,
-
0.053
,
1.0449
,
0.845
,
-
0.0131
,
0.1139
,
-
0.859
,
-
1.2681
,
-
0.6337
,
-
0.4644
,
0.1938
,
0.2889
,
0.9035
,
0.7118
,
-
0.5767
,
0.4577
,
-
0.0549
,
0.2237
,
0.5756
,
0.0677
,
-
0.0223
,
-
0.329
,
0.2364
,
2.7666
,
-
0.7417
,
-
1.3196
,
-
0.2655
,
0.1698
,
-
0.1777
,
-
0.9427
,
2.6859
,
-
0.7501
,
0.5175
,
1.0029
,
-
2.6436
,
-
0.4388
,
-
1.2348
,
-
0.1539
,
-
0.6229
,
-
0.4136
,
0.5085
,
0.4136
,
-
0.6439
,
-
1.1953
,
-
0.406
,
-
0.0195
,
0.1869
,
-
0.8664
,
1.1364
,
0.5041
,
0.0647
,
0.1941
,
-
1.0819
,
-
0.4629
,
-
0.5107
,
0.3612
,
-
0.3583
};
auto
l0
=
mm
->
add_literal
(
migraphx
::
literal
{
s
,
data
});
mm
->
add_instruction
(
op
,
l0
);
p
.
compile
(
migraphx
::
ref
::
target
{});
auto
result
=
p
.
eval
({}).
back
();
std
::
vector
<
float
>
results_vector
;
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
gold
{
1.5064
,
1.3655
,
0.9035
,
2.6859
};
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
s
=
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
2
,
3
,
3
,
3
}};
auto
op
=
migraphx
::
op
::
pooling
{
migraphx
::
op
::
pooling_mode
::
max
};
op
.
lengths
=
{
2
,
2
,
2
};
op
.
padding
=
{
0
,
0
,
0
};
op
.
stride
=
{
2
,
2
,
2
};
std
::
vector
<
float
>
data
{
-
2.8029
,
0.5861
,
0.7015
,
0.1297
,
-
1.44
,
-
1.9472
,
0.7812
,
2.408
,
-
0.3145
,
0.3405
,
-
0.9146
,
0.0624
,
1.5064
,
-
0.8345
,
1.7977
,
1.8949
,
1.0073
,
-
0.2102
,
-
0.042
,
-
0.7146
,
0.6227
,
-
0.5263
,
-
2.2598
,
0.1713
,
0.449
,
0.5303
,
-
0.8622
,
-
0.5691
,
0.907
,
-
0.0569
,
-
1.5348
,
-
0.4109
,
-
0.1461
,
-
0.5445
,
0.4266
,
0.2282
,
1.3655
,
-
2.1519
,
0.6068
,
-
0.2001
,
-
0.4702
,
0.3864
,
1.7083
,
0.9096
,
0.4286
,
-
1.8866
,
0.7034
,
0.0293
,
1.4587
,
0.7672
,
-
2.8614
,
0.8124
,
-
0.053
,
1.0449
,
0.845
,
-
0.0131
,
0.1139
,
-
0.859
,
-
1.2681
,
-
0.6337
,
-
0.4644
,
0.1938
,
0.2889
,
0.9035
,
0.7118
,
-
0.5767
,
0.4577
,
-
0.0549
,
0.2237
,
0.5756
,
0.0677
,
-
0.0223
,
-
0.329
,
0.2364
,
2.7666
,
-
0.7417
,
-
1.3196
,
-
0.2655
,
0.1698
,
-
0.1777
,
-
0.9427
,
2.6859
,
-
0.7501
,
0.5175
,
1.0029
,
-
2.6436
,
-
0.4388
,
-
1.2348
,
-
0.1539
,
-
0.6229
,
-
0.4136
,
0.5085
,
0.4136
,
-
0.6439
,
-
1.1953
,
-
0.406
,
-
0.0195
,
0.1869
,
-
0.8664
,
1.1364
,
0.5041
,
0.0647
,
0.1941
,
-
1.0819
,
-
0.4629
,
-
0.5107
,
0.3612
,
-
0.3583
};
auto
l0
=
mm
->
add_literal
(
migraphx
::
literal
{
s
,
data
});
mm
->
add_instruction
(
op
,
l0
);
p
.
compile
(
migraphx
::
ref
::
target
{});
auto
result
=
p
.
eval
({}).
back
();
std
::
vector
<
float
>
results_vector
;
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
gold
{
1.5064
,
1.3655
,
0.9035
,
2.6859
};
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
maxpool_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
s
=
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
3
,
3
,
0
},
{
4
,
4
,
0
}}};
auto
x
=
mm
->
add_parameter
(
"X"
,
s
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
max
},
{
"lengths"
,
{
2
}},
{
"padding"
,
{
0
}},
{
"stride"
,
{
1
}}}),
x
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
data
{
0.3
,
0.2
,
0.4
,
0.1
,
0.8
,
0.5
,
0.9
,
0.1
,
0.1
,
0.7
,
0.1
,
0.6
};
migraphx
::
shape
input_fixed_shape
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
4
}};
migraphx
::
parameter_map
params
;
params
[
"X"
]
=
migraphx
::
argument
(
input_fixed_shape
,
data
.
data
());
auto
result
=
p
.
eval
(
params
).
back
();
std
::
vector
<
float
>
results_vector
;
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
gold
{
0.3
,
0.4
,
0.4
,
0.8
,
0.9
,
0.9
,
0.7
,
0.7
,
0.6
};
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
min_test
)
...
...
@@ -4090,7 +4294,7 @@ TEST_CASE(fmod_test)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
fmod_dyn
amic
_test
)
TEST_CASE
(
fmod_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
...
...
@@ -4386,16 +4590,17 @@ TEST_CASE(neg_test)
EXPECT
(
migraphx
::
verify_range
(
result_vector
,
gold
));
}
TEST_CASE
(
neg_dyn
amic
_test
)
TEST_CASE
(
neg_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{{
2
,
4
,
0
},
{
3
,
3
,
0
}}};
std
::
vector
<
float
>
a
=
{
1.0
f
,
1.3
f
,
-
1.2
f
,
0.0
f
,
-
100.
f
,
200.
f
};
auto
input
=
mm
->
add_parameter
(
"X"
,
s
);
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"neg"
),
input
);
auto
input
=
mm
->
add_parameter
(
"X"
,
s
);
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"neg"
),
input
);
mm
->
add_return
({
ret
});
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
a
=
{
1.0
f
,
1.3
f
,
-
1.2
f
,
0.0
f
,
-
100.
f
,
200.
f
};
migraphx
::
parameter_map
params0
;
migraphx
::
shape
input_fixed_shape0
{
migraphx
::
shape
::
float_type
,
{
2
,
3
}};
params0
[
"X"
]
=
migraphx
::
argument
(
input_fixed_shape0
,
a
.
data
());
...
...
@@ -4407,7 +4612,7 @@ TEST_CASE(neg_dynamic_test)
EXPECT
(
migraphx
::
verify_range
(
result_vector
,
gold
));
}
TEST_CASE
(
nms_dyn
amic
_out_test
)
TEST_CASE
(
nms_dyn_out_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
...
...
@@ -4442,7 +4647,7 @@ TEST_CASE(nms_dynamic_out_test)
EXPECT
(
migraphx
::
verify_range
(
result
,
gold
));
}
TEST_CASE
(
nms_dyn
amic
_batch_test
)
TEST_CASE
(
nms_dyn_batch_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
...
...
@@ -4488,7 +4693,7 @@ TEST_CASE(nms_dynamic_batch_test)
EXPECT
(
migraphx
::
verify_range
(
result
,
gold
));
}
TEST_CASE
(
nms_dyn
amic
_boxes_test
)
TEST_CASE
(
nms_dyn_boxes_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
...
...
@@ -4531,7 +4736,7 @@ TEST_CASE(nms_dynamic_boxes_test)
EXPECT
(
migraphx
::
verify_range
(
result
,
gold
));
}
TEST_CASE
(
nms_dyn
amic
_classes_test
)
TEST_CASE
(
nms_dyn_classes_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
...
...
@@ -4777,17 +4982,17 @@ TEST_CASE(not_test)
}
}
TEST_CASE
(
not_dyn
amic
_test
)
TEST_CASE
(
not_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
::
dynamic_dimension
dd
{
3
,
8
,
0
};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
dd
}};
auto
input
=
mm
->
add_parameter
(
"X"
,
s
);
std
::
vector
<
float
>
input_data
{
0
,
8
,
1
,
-
32
};
mm
->
add_instruction
(
migraphx
::
make_op
(
"not"
),
input
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
input_data
{
0
,
8
,
1
,
-
32
};
migraphx
::
parameter_map
params0
;
migraphx
::
shape
input_fixed_shape0
{
migraphx
::
shape
::
float_type
,
{
4
}};
params0
[
"X"
]
=
migraphx
::
argument
(
input_fixed_shape0
,
input_data
.
data
());
...
...
@@ -5511,17 +5716,17 @@ TEST_CASE(recip_test)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
recip_dyn
amic
_test
)
TEST_CASE
(
recip_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
::
dynamic_dimension
dd
{
3
,
8
,
0
};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
dd
}};
auto
input
=
mm
->
add_parameter
(
"X"
,
s
);
std
::
vector
<
float
>
input_data
{
-
0.5
f
,
0.1
f
,
0.5
f
};
mm
->
add_instruction
(
migraphx
::
make_op
(
"recip"
),
input
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
input_data
{
-
0.5
f
,
0.1
f
,
0.5
f
};
migraphx
::
parameter_map
params0
;
migraphx
::
shape
input_fixed_shape0
{
migraphx
::
shape
::
float_type
,
{
3
}};
params0
[
"X"
]
=
migraphx
::
argument
(
input_fixed_shape0
,
input_data
.
data
());
...
...
@@ -5819,17 +6024,17 @@ TEST_CASE(relu_test)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
relu_dyn
amic
_test
)
TEST_CASE
(
relu_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
::
dynamic_dimension
dd
{
3
,
8
,
0
};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
dd
}};
auto
input
=
mm
->
add_parameter
(
"X"
,
s
);
std
::
vector
<
float
>
input_data
{
-
1.
f
,
0.
f
,
1.
f
};
mm
->
add_instruction
(
migraphx
::
make_op
(
"relu"
),
input
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
input_data
{
-
1.
f
,
0.
f
,
1.
f
};
migraphx
::
parameter_map
params0
;
migraphx
::
shape
input_fixed_shape0
{
migraphx
::
shape
::
float_type
,
{
3
}};
params0
[
"X"
]
=
migraphx
::
argument
(
input_fixed_shape0
,
input_data
.
data
());
...
...
@@ -6124,17 +6329,17 @@ TEST_CASE(round_test)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
round_dyn
amic
_test
)
TEST_CASE
(
round_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
::
dynamic_dimension
dd
{
4
,
10
,
0
};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
dd
}};
auto
input
=
mm
->
add_parameter
(
"X"
,
s
);
std
::
vector
<
float
>
input_data
{
1.1
,
1.5
,
1.6
,
-
1.1
,
-
1.5
,
-
1.6
,
0.0
,
2.0
,
-
2.0
};
mm
->
add_instruction
(
migraphx
::
make_op
(
"round"
),
input
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
input_data
{
1.1
,
1.5
,
1.6
,
-
1.1
,
-
1.5
,
-
1.6
,
0.0
,
2.0
,
-
2.0
};
migraphx
::
parameter_map
params0
;
migraphx
::
shape
input_fixed_shape0
{
migraphx
::
shape
::
float_type
,
{
9
}};
params0
[
"X"
]
=
migraphx
::
argument
(
input_fixed_shape0
,
input_data
.
data
());
...
...
@@ -6160,17 +6365,17 @@ TEST_CASE(rsqrt_test)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
rsqrt_dyn
amic
_test
)
TEST_CASE
(
rsqrt_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
::
dynamic_dimension
dd
{
3
,
8
,
0
};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
dd
}};
auto
input
=
mm
->
add_parameter
(
"X"
,
s
);
std
::
vector
<
float
>
input_data
{
4.0
,
16.0
,
64.0
};
mm
->
add_instruction
(
migraphx
::
make_op
(
"rsqrt"
),
input
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
input_data
{
4.0
,
16.0
,
64.0
};
migraphx
::
parameter_map
params0
;
migraphx
::
shape
input_fixed_shape0
{
migraphx
::
shape
::
float_type
,
{
3
}};
params0
[
"X"
]
=
migraphx
::
argument
(
input_fixed_shape0
,
input_data
.
data
());
...
...
@@ -6729,16 +6934,16 @@ TEST_CASE(sigmoid_test)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
sigmoid_dyn
amic
_test
)
TEST_CASE
(
sigmoid_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{{
2
,
4
,
0
},
{
2
,
2
,
0
}}};
auto
input
=
mm
->
add_parameter
(
"X"
,
s
);
std
::
vector
<
float
>
input_data
{
-
1
,
2
,
-
3
,
4
};
mm
->
add_instruction
(
migraphx
::
make_op
(
"sigmoid"
),
input
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
input_data
{
-
1
,
2
,
-
3
,
4
};
migraphx
::
parameter_map
params0
;
migraphx
::
shape
input_fixed_shape0
{
migraphx
::
shape
::
float_type
,
{
2
,
2
}};
params0
[
"X"
]
=
migraphx
::
argument
(
input_fixed_shape0
,
input_data
.
data
());
...
...
@@ -6765,17 +6970,17 @@ TEST_CASE(sign_test)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
sign_dyn
amic
_test
)
TEST_CASE
(
sign_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
::
dynamic_dimension
dd
{
3
,
8
,
0
};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
dd
}};
auto
input
=
mm
->
add_parameter
(
"X"
,
s
);
std
::
vector
<
float
>
input_data
{
1.02481645
,
0.85643062
,
-
0.03404123
,
-
0.92791926
,
0.0
};
mm
->
add_instruction
(
migraphx
::
make_op
(
"sign"
),
input
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
input_data
{
1.02481645
,
0.85643062
,
-
0.03404123
,
-
0.92791926
,
0.0
};
migraphx
::
parameter_map
params0
;
migraphx
::
shape
input_fixed_shape0
{
migraphx
::
shape
::
float_type
,
{
5
}};
params0
[
"X"
]
=
migraphx
::
argument
(
input_fixed_shape0
,
input_data
.
data
());
...
...
@@ -6804,17 +7009,17 @@ TEST_CASE(sin_test)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
sin_dyn
amic
_test
)
TEST_CASE
(
sin_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
::
dynamic_dimension
dd
{
3
,
8
,
0
};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
dd
}};
auto
input
=
mm
->
add_parameter
(
"X"
,
s
);
std
::
vector
<
float
>
input_data
=
{
-
1
,
0
,
1
};
auto
input
=
mm
->
add_parameter
(
"X"
,
s
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"sin"
),
input
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
input_data
=
{
-
1
,
0
,
1
};
migraphx
::
parameter_map
params0
;
migraphx
::
shape
input_fixed_shape0
{
migraphx
::
shape
::
float_type
,
{
3
}};
params0
[
"X"
]
=
migraphx
::
argument
(
input_fixed_shape0
,
input_data
.
data
());
...
...
@@ -6989,6 +7194,69 @@ TEST_CASE(softmax_test)
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
s
));
}
TEST_CASE
(
softmax_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
float_type
,
{{
1
,
10
,
0
},
{
1
,
3
,
3
},
{
4
,
4
,
0
},
{
2
,
2
,
2
}}};
auto
al
=
mm
->
add_parameter
(
"a"
,
a_shape
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"softmax"
,
{{
"axis"
,
1
}}),
al
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
a
=
{
-
5.61869681e-01
,
9.07827199e-01
,
1.29255986e+00
,
3.18533443e-02
,
-
1.22183852e-03
,
-
2.83830553e-01
,
-
1.03245842e+00
,
-
9.28322077e-01
,
-
8.82696748e-01
,
1.11327164e-01
,
-
9.20038462e-01
,
8.47388089e-01
,
2.51734018e-01
,
1.50563884e+00
,
2.23056650e+00
,
-
6.17576987e-02
,
-
1.00264274e-01
,
-
6.10369384e-01
,
1.17537189e+00
,
-
2.51560897e-01
,
-
8.50333512e-01
,
-
8.03578615e-01
,
-
6.51194930e-01
,
-
2.58137047e-01
,
4.65528190e-01
,
3.23284641e-02
,
-
1.54700470e+00
,
1.38096774e+00
,
5.39869189e-01
,
-
7.56884992e-01
,
1.81503093e+00
,
-
2.11269641e+00
,
1.92466557e+00
,
1.77230799e+00
,
2.21660900e+00
,
1.56777036e+00
,
-
2.08995026e-03
,
3.50566894e-01
,
-
1.15042710e+00
,
-
1.18577778e+00
,
8.90633047e-01
,
-
6.63949102e-02
,
1.44661188e+00
,
1.59215283e+00
,
-
2.56262213e-01
,
9.39079225e-01
,
4.07298543e-02
,
3.86590779e-01
,
6.09607756e-01
,
8.22331488e-01
,
-
2.82126725e-01
,
-
9.49052632e-01
,
-
4.24012303e-01
,
-
5.32990396e-01
,
-
3.18386006e+00
,
3.27092171e-01
,
-
1.33315325e+00
,
3.62459183e-01
,
3.74710828e-01
,
-
1.30302286e+00
,
1.79680198e-01
,
-
4.51832324e-01
,
4.34282750e-01
,
-
7.09520102e-01
,
6.20333970e-01
,
-
1.28712380e+00
,
2.04130828e-01
,
-
7.70607769e-01
,
1.61889160e+00
,
-
1.50951004e+00
,
-
4.10505563e-01
,
-
3.56566496e-02
,
-
1.29747534e+00
,
-
1.49967879e-01
,
7.77626812e-01
,
-
8.28408226e-02
,
2.73412596e-02
,
5.79780899e-03
,
9.87900198e-02
,
-
7.95276761e-01
,
-
1.38536084e+00
,
-
6.63573861e-01
,
3.89783204e-01
,
-
1.30670881e+00
,
-
7.62425125e-01
,
-
4.04883057e-01
,
6.24344349e-01
,
3.68128955e-01
,
-
1.01577950e+00
,
-
3.06715906e-01
,
5.67961395e-01
,
2.98198581e-01
,
-
1.63613629e+00
,
-
3.75131965e-01
,
-
6.75393403e-01
,
2.59172034e+00
,
6.75538957e-01
,
9.07939598e-02
,
1.92257717e-01
,
-
1.21592450e+00
,
-
2.73682117e-01
,
1.25232983e+00
,
-
1.39969170e+00
,
-
1.91483587e-01
,
2.57732719e-01
,
3.10056299e-01
,
1.41833842e+00
,
-
1.81386679e-01
,
3.92868072e-01
,
-
8.14771175e-01
,
2.02392387e+00
,
-
9.42091495e-02
,
-
3.77683818e-01
,
2.05638766e+00
,
2.93796062e-01
,
-
6.02131486e-01
,
2.70461679e-01
,
-
8.92358482e-01
,
1.04388881e+00
,
2.66154885e-01
};
migraphx
::
parameter_map
params
;
migraphx
::
shape
input_fixed_shape
{
migraphx
::
shape
::
float_type
,
{
5
,
3
,
4
,
2
}};
params
[
"a"
]
=
migraphx
::
argument
(
input_fixed_shape
,
a
.
data
());
auto
result
=
p
.
eval
(
params
).
back
();
std
::
vector
<
float
>
results_vector
(
120
);
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
s
=
{
0.30191708
,
0.59879845
,
0.50029165
,
0.24915339
,
0.36823985
,
0.13190967
,
0.0349741
,
0.18750034
,
0.21905553
,
0.27000085
,
0.0547399
,
0.56318235
,
0.47422904
,
0.78964758
,
0.91381913
,
0.44601166
,
0.47902739
,
0.13120073
,
0.4449684
,
0.18766427
,
0.15753111
,
0.07844277
,
0.05120674
,
0.36648798
,
0.14637007
,
0.13152322
,
0.01560997
,
0.29065287
,
0.49196178
,
0.10550152
,
0.81890774
,
0.06369215
,
0.62972021
,
0.74931765
,
0.67285055
,
0.35034987
,
0.28612873
,
0.31931475
,
0.04220394
,
0.16093165
,
0.22390974
,
0.11915915
,
0.3115395
,
0.35899726
,
0.22190949
,
0.57518375
,
0.13888834
,
0.7753762
,
0.4642328
,
0.57055861
,
0.21954368
,
0.34515455
,
0.09486015
,
0.40631217
,
0.01842281
,
0.48770609
,
0.06652815
,
0.36023033
,
0.42343026
,
0.24226256
,
0.17348589
,
0.44066274
,
0.6865865
,
0.17296699
,
0.46923906
,
0.06921105
,
0.3570261
,
0.4125829
,
0.73165393
,
0.15302512
,
0.29499072
,
0.33932695
,
0.30852377
,
0.40762195
,
0.40170741
,
0.36259529
,
0.60848355
,
0.42618036
,
0.31721094
,
0.02960522
,
0.28256637
,
0.24389413
,
0.2725659
,
0.10663581
,
0.27622163
,
0.28264219
,
0.53652936
,
0.09476089
,
0.40890986
,
0.34848392
,
0.32572666
,
0.53076893
,
0.11529481
,
0.29117745
,
0.14625968
,
0.8756339
,
0.49818122
,
0.10656087
,
0.1813329
,
0.17664003
,
0.21410346
,
0.80408043
,
0.02315119
,
0.27155462
,
0.32804728
,
0.13268511
,
0.61795473
,
0.49703068
,
0.41696799
,
0.10175809
,
0.71028161
,
0.29929739
,
0.17377149
,
0.76075399
,
0.20071237
,
0.32632929
,
0.36892858
,
0.09416146
,
0.26656723
,
0.42914796
};
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
s
));
}
TEST_CASE
(
sqdiff_test
)
{
migraphx
::
program
p
;
...
...
@@ -7111,6 +7379,25 @@ TEST_CASE(squeeze_test)
}
}
TEST_CASE
(
squeeze_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s1
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
1
,
1
,
0
},
{
3
,
3
,
0
},
{
1
,
1
,
0
},
{
3
,
3
,
0
}}};
auto
p0
=
mm
->
add_parameter
(
"x"
,
s1
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"squeeze"
,
{{
"axes"
,
{
1
}}}),
p0
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
input_data
(
4
*
3
*
3
);
migraphx
::
parameter_map
params0
;
migraphx
::
shape
input_fixed_shape0
{
migraphx
::
shape
::
float_type
,
{
4
,
1
,
3
,
1
,
3
}};
params0
[
"x"
]
=
migraphx
::
argument
(
input_fixed_shape0
,
input_data
.
data
());
auto
result
=
p
.
eval
(
params0
).
back
();
migraphx
::
shape
s2
{
migraphx
::
shape
::
float_type
,
{
4
,
3
,
1
,
3
}};
EXPECT
(
result
.
get_shape
()
==
s2
);
}
TEST_CASE
(
step_test
)
{
{
...
...
@@ -7336,11 +7623,6 @@ TEST_CASE(transpose_test)
mm
->
add_instruction
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
perm
}}),
l
);
p
.
compile
(
migraphx
::
ref
::
target
{});
auto
result
=
p
.
eval
({}).
back
();
result
.
visit
([
&
](
auto
output
)
{
std
::
vector
<
size_t
>
new_lens
=
{
1
,
3
,
2
,
2
};
EXPECT
(
bool
{
output
.
get_shape
().
lens
()
==
new_lens
});
});
}
{
migraphx
::
program
p
;
...
...
@@ -7360,6 +7642,32 @@ TEST_CASE(transpose_test)
}
}
TEST_CASE
(
transpose_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
2
,
2
,
0
},
{
2
,
2
,
0
},
{
3
,
3
,
0
}}};
auto
l
=
mm
->
add_parameter
(
"X"
,
s
);
std
::
vector
<
int64_t
>
perm
=
{
0
,
3
,
1
,
2
};
mm
->
add_instruction
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
perm
}}),
l
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
data
(
12
);
std
::
iota
(
data
.
begin
(),
data
.
end
(),
0
);
migraphx
::
parameter_map
params
;
migraphx
::
shape
input_fixed_shape
{
migraphx
::
shape
::
float_type
,
{
1
,
2
,
2
,
3
}};
params
[
"X"
]
=
migraphx
::
argument
(
input_fixed_shape
,
data
.
data
());
auto
result
=
p
.
eval
(
params
).
back
();
std
::
vector
<
size_t
>
new_lens
=
{
1
,
3
,
2
,
2
};
EXPECT
(
result
.
get_shape
().
lens
()
==
new_lens
);
std
::
vector
<
float
>
results_vector
(
12
);
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
gold
=
{
0
,
3
,
6
,
9
,
1
,
4
,
7
,
10
,
2
,
5
,
8
,
11
};
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
}
TEST_CASE
(
unsqueeze_test
)
{
{
...
...
@@ -7388,6 +7696,25 @@ TEST_CASE(unsqueeze_test)
}
}
TEST_CASE
(
unsqueeze_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s1
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
,
0
},
{
3
,
3
,
0
},
{
3
,
3
,
0
}}};
auto
p0
=
mm
->
add_parameter
(
"x"
,
s1
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"unsqueeze"
,
{{
"axes"
,
{
1
}}}),
p0
);
p
.
compile
(
migraphx
::
ref
::
target
{});
std
::
vector
<
float
>
input_data
(
4
*
3
*
3
);
migraphx
::
parameter_map
params0
;
migraphx
::
shape
input_fixed_shape0
{
migraphx
::
shape
::
float_type
,
{
4
,
3
,
3
}};
params0
[
"x"
]
=
migraphx
::
argument
(
input_fixed_shape0
,
input_data
.
data
());
auto
result
=
p
.
eval
(
params0
).
back
();
migraphx
::
shape
s2
{
migraphx
::
shape
::
float_type
,
{
4
,
1
,
3
,
3
}};
EXPECT
(
result
.
get_shape
()
==
s2
);
}
TEST_CASE
(
where_test
)
{
migraphx
::
program
p
;
...
...
test/ref_rnn_ops_test.cpp
View file @
913ae362
...
...
@@ -31,6 +31,7 @@
#include <migraphx/onnx.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/quantization.hpp>
#include <migraphx/serialize.hpp>
#include "test.hpp"
...
...
@@ -932,6 +933,90 @@ TEST_CASE(rnn_bidirectional)
}
}
TEST_CASE
(
rnn_fp16
)
{
std
::
size_t
batch_size
=
2
;
std
::
size_t
seq_len
=
2
;
std
::
size_t
hidden_size
=
4
;
std
::
size_t
input_size
=
3
;
std
::
size_t
num_dirct
=
1
;
std
::
vector
<
float
>
w_data
{
0.4691
,
0.3185
,
-
0.2227
,
0.4423
,
-
0.0609
,
-
0.2803
,
0.1744
,
0.3146
,
0.4049
,
-
0.3973
,
-
0.0890
,
-
0.1636
};
std
::
vector
<
float
>
r_data
{
-
0.0456
,
0.1061
,
0.1574
,
-
0.4928
,
-
0.4300
,
-
0.1909
,
-
0.0225
,
-
0.2668
,
0.1840
,
-
0.4453
,
-
0.4896
,
0.1302
,
-
0.0929
,
0.3545
,
-
0.4981
,
0.0616
};
std
::
vector
<
float
>
bias_data
{
-
0.4938
,
0.4355
,
-
0.3186
,
0.2094
,
0.1037
,
-
0.1071
,
0.4504
,
-
0.3990
};
std
::
vector
<
float
>
ih_data
(
num_dirct
*
batch_size
*
hidden_size
,
0
);
std
::
vector
<
float
>
input
(
seq_len
*
batch_size
*
input_size
,
0
);
input
[
0
]
=
input
[
1
]
=
1.0
;
migraphx
::
shape
in_shape
{
migraphx
::
shape
::
float_type
,
{
seq_len
,
batch_size
,
input_size
}};
migraphx
::
shape
ih_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
batch_size
,
hidden_size
}};
migraphx
::
shape
w_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
hidden_size
,
input_size
}};
migraphx
::
shape
r_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
hidden_size
,
hidden_size
}};
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
2
*
hidden_size
}};
float
clip
=
0.0
f
;
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
seq
=
mm
->
add_literal
(
migraphx
::
literal
{
in_shape
,
input
});
auto
w
=
mm
->
add_literal
(
migraphx
::
literal
{
w_shape
,
w_data
});
auto
r
=
mm
->
add_literal
(
migraphx
::
literal
{
r_shape
,
r_data
});
auto
seq_half
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
shape
::
half_type
}}),
seq
);
auto
w_half
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
shape
::
half_type
}}),
w
);
auto
r_half
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
shape
::
half_type
}}),
r
);
auto
out_hs
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"rnn"
,
{{
"hidden_size"
,
hidden_size
},
{
"actv_func"
,
{}},
{
"direction"
,
migraphx
::
to_value
(
migraphx
::
op
::
rnn_direction
::
forward
)},
{
"clip"
,
clip
}}),
seq_half
,
w_half
,
r_half
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"rnn_last_hs_output"
),
out_hs
);
p
.
compile
(
migraphx
::
ref
::
target
{});
auto
last_output
=
p
.
eval
({}).
back
();
std
::
vector
<
float
>
last_output_data
;
last_output
.
visit
([
&
](
auto
out
)
{
last_output_data
.
assign
(
out
.
begin
(),
out
.
end
());
});
std
::
vector
<
float
>
last_output_data_gold
{
0.2935145
,
-
0.23719997
,
-
0.31123261
,
-
0.18357255
,
0.
,
0.
,
0.
,
0.
};
EXPECT
(
migraphx
::
verify_range
(
last_output_data
,
last_output_data_gold
,
5e4
));
}
TEST_CASE
(
gru_forward
)
{
std
::
size_t
batch_size
=
2
;
...
...
@@ -2797,6 +2882,116 @@ TEST_CASE(gru_bidirectional_seq_1)
EXPECT
(
migraphx
::
verify_range
(
hs_data
,
hs_data_gold
));
}
TEST_CASE
(
gru_fp16
)
{
std
::
size_t
batch_size
=
2
;
std
::
size_t
seq_len
=
3
;
std
::
size_t
hidden_size
=
5
;
std
::
size_t
input_size
=
3
;
std
::
size_t
num_dirct
=
1
;
migraphx
::
shape
w_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
3
*
hidden_size
,
input_size
}};
std
::
vector
<
float
>
w_data
{
0.3485
,
-
0.0378
,
-
0.1782
,
0.1416
,
-
0.3096
,
-
0.2212
,
-
0.3883
,
0.1983
,
-
0.2418
,
0.1480
,
-
0.3255
,
0.1359
,
-
0.3551
,
-
0.3605
,
-
0.3482
,
-
0.1424
,
-
0.0495
,
-
0.1640
,
-
0.1979
,
-
0.2577
,
-
0.4097
,
-
0.1211
,
-
0.0412
,
0.1801
,
0.1721
,
-
0.4327
,
-
0.0498
,
0.2628
,
-
0.1573
,
-
0.1577
,
0.2759
,
-
0.2023
,
-
0.1185
,
-
0.2136
,
0.1294
,
-
0.2331
,
0.0701
,
0.4316
,
0.0480
,
0.0247
,
-
0.0166
,
-
0.2729
,
0.1712
,
-
0.3984
,
-
0.3905
};
migraphx
::
shape
r_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
3
*
hidden_size
,
hidden_size
}};
std
::
vector
<
float
>
r_data
{
0.2848
,
-
0.2851
,
-
0.3466
,
-
0.1718
,
-
0.1492
,
-
0.0082
,
0.2452
,
-
0.0401
,
0.3399
,
0.2529
,
-
0.0953
,
-
0.0903
,
-
0.1518
,
-
0.1373
,
0.3848
,
-
0.0130
,
-
0.4339
,
0.0406
,
-
0.1926
,
-
0.1131
,
0.4285
,
-
0.0013
,
0.2243
,
0.2752
,
0.1776
,
-
0.1720
,
0.0822
,
-
0.0295
,
0.1062
,
-
0.2721
,
-
0.2736
,
-
0.1826
,
0.3541
,
-
0.4259
,
0.2188
,
0.0706
,
0.3650
,
0.3947
,
0.2522
,
0.2179
,
-
0.0744
,
0.2122
,
-
0.4346
,
0.2760
,
0.4076
,
0.1183
,
-
0.1500
,
-
0.1704
,
0.3090
,
-
0.0706
,
-
0.2442
,
0.3021
,
0.1680
,
0.0783
,
-
0.3754
,
-
0.3469
,
-
0.2972
,
-
0.0170
,
0.4143
,
0.3801
,
0.3852
,
-
0.1170
,
-
0.2937
,
0.2979
,
-
0.1357
,
0.4257
,
0.3884
,
-
0.2916
,
0.1071
,
0.0934
,
0.3645
,
-
0.4310
,
-
0.3480
,
0.0702
,
-
0.1558
};
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
6
*
hidden_size
}};
std
::
vector
<
float
>
bias_data
{
0.0560
,
0.0310
,
-
0.1669
,
-
0.0781
,
0.1793
,
-
0.1758
,
0.3173
,
-
0.1650
,
-
0.3732
,
0.2946
,
-
0.0912
,
0.3118
,
0.1391
,
0.2755
,
0.2695
,
-
0.1059
,
-
0.2357
,
0.3629
,
-
0.2534
,
-
0.0494
,
0.0556
,
0.0881
,
-
0.2592
,
-
0.2213
,
0.2310
,
-
0.4044
,
0.1801
,
0.1438
,
0.3108
,
-
0.3607
};
migraphx
::
shape
in_shape
{
migraphx
::
shape
::
float_type
,
{
seq_len
,
batch_size
,
input_size
}};
std
::
vector
<
float
>
input
{
-
0.8432
,
-
0.9887
,
1.3041
,
-
2.6430
,
-
0.3306
,
-
0.8504
,
-
0.3933
,
0.5151
,
-
0.2951
,
0.0093
,
-
1.1948
,
-
0.1239
,
0.0373
,
1.3211
,
0.7854
,
-
0.4838
,
-
1.0536
,
-
0.2529
};
migraphx
::
shape
ih_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
batch_size
,
hidden_size
}};
std
::
vector
<
float
>
ih_data
{
-
0.0468
,
0.5691
,
-
0.0882
,
0.8340
,
0.1483
,
-
0.3902
,
-
0.5348
,
0.4178
,
1.0175
,
0.9212
};
float
clip
=
0.0
f
;
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
seq
=
mm
->
add_literal
(
migraphx
::
literal
{
in_shape
,
input
});
auto
w
=
mm
->
add_literal
(
migraphx
::
literal
{
w_shape
,
w_data
});
auto
r
=
mm
->
add_literal
(
migraphx
::
literal
{
r_shape
,
r_data
});
auto
bias
=
mm
->
add_literal
(
migraphx
::
literal
{
b_shape
,
bias_data
});
auto
und
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"undefined"
));
auto
ih
=
mm
->
add_literal
(
migraphx
::
literal
{
ih_shape
,
ih_data
});
auto
seq_half
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
shape
::
half_type
}}),
seq
);
auto
w_half
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
shape
::
half_type
}}),
w
);
auto
r_half
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
shape
::
half_type
}}),
r
);
auto
bias_half
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
shape
::
half_type
}}),
bias
);
auto
und_half
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
shape
::
half_type
}}),
und
);
auto
ih_half
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
shape
::
half_type
}}),
ih
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"gru"
,
{{
"hidden_size"
,
hidden_size
},
{
"actv_func"
,
migraphx
::
to_value
(
std
::
vector
<
migraphx
::
operation
>
{
migraphx
::
make_op
(
"sigmoid"
),
migraphx
::
make_op
(
"tanh"
)})},
{
"direction"
,
migraphx
::
to_value
(
migraphx
::
op
::
rnn_direction
::
forward
)},
{
"clip"
,
clip
},
{
"linear_before_reset"
,
1
}}),
seq_half
,
w_half
,
r_half
,
bias_half
,
und_half
,
ih_half
);
p
.
compile
(
migraphx
::
ref
::
target
{});
auto
hs_concat
=
p
.
eval
({}).
back
();
std
::
vector
<
float
>
hs_data
;
hs_concat
.
visit
([
&
](
auto
output
)
{
hs_data
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
hs_data_gold
{
-
0.27298412
,
0.42363745
,
-
0.09368783
,
0.4823072
,
-
0.02183238
,
-
0.6873896
,
0.16144305
,
0.31932795
,
0.6104771
,
0.79759157
,
-
0.31791314
,
0.5249062
,
0.08800987
,
0.46404213
,
-
0.11872687
,
-
0.26210734
,
0.34448293
,
-
0.0176422
,
0.48523626
,
0.60002893
,
-
0.3969709
,
0.43360898
,
0.35775262
,
0.23280787
,
-
0.52179873
,
-
0.21944991
,
0.4535257
,
-
0.13735442
,
0.51757574
,
0.50380427
};
EXPECT
(
migraphx
::
verify_range
(
hs_data
,
hs_data_gold
,
5e4
));
}
TEST_CASE
(
lstm_forward
)
{
std
::
size_t
batch_size
=
3
;
...
...
@@ -4651,4 +4846,148 @@ TEST_CASE(lstm_bidirectional_actv_func)
}
}
TEST_CASE
(
lstm_fp16
)
{
std
::
size_t
batch_size
=
3
;
std
::
size_t
seq_len
=
4
;
std
::
size_t
hidden_size
=
4
;
std
::
size_t
input_size
=
3
;
std
::
size_t
num_dirct
=
1
;
std
::
vector
<
float
>
w_data
{
0.1236
,
-
0.3942
,
0.4149
,
0.0795
,
0.4934
,
-
0.2858
,
0.2602
,
-
0.3098
,
0.0567
,
0.3344
,
0.3607
,
-
0.0551
,
0.4952
,
0.3799
,
0.0630
,
-
0.3532
,
0.0023
,
-
0.0592
,
0.4267
,
0.2382
,
-
0.0784
,
-
0.0032
,
-
0.2476
,
-
0.0206
,
-
0.4963
,
0.4837
,
0.0827
,
0.0123
,
-
0.1203
,
-
0.0279
,
-
0.0049
,
0.4721
,
-
0.3564
,
-
0.1286
,
0.4090
,
-
0.0504
,
0.0575
,
-
0.2138
,
0.1071
,
0.1976
,
-
0.0758
,
0.0139
,
-
0.0761
,
0.3991
,
-
0.2965
,
-
0.4845
,
-
0.1496
,
0.3285
};
std
::
vector
<
float
>
r_data
{
0.1237
,
0.1229
,
-
0.0766
,
-
0.1144
,
-
0.1186
,
0.2922
,
0.2478
,
0.3159
,
-
0.0522
,
0.1685
,
-
0.4621
,
0.1728
,
0.0670
,
-
0.2458
,
-
0.3835
,
-
0.4589
,
-
0.3109
,
0.4908
,
-
0.0133
,
-
0.1858
,
-
0.0590
,
-
0.0347
,
-
0.2353
,
-
0.0671
,
-
0.3812
,
-
0.0004
,
-
0.1432
,
0.2406
,
0.1033
,
-
0.0265
,
-
0.3902
,
0.0755
,
0.3733
,
0.4383
,
-
0.3140
,
0.2537
,
-
0.1818
,
-
0.4127
,
0.3506
,
0.2562
,
0.2926
,
0.1620
,
-
0.4849
,
-
0.4861
,
0.4426
,
0.2106
,
-
0.0005
,
0.4418
,
-
0.2926
,
-
0.3100
,
0.1500
,
-
0.0362
,
-
0.3801
,
-
0.0065
,
-
0.0631
,
0.1277
,
0.2315
,
0.4087
,
-
0.3963
,
-
0.4161
,
-
0.2169
,
-
0.1344
,
0.3468
,
-
0.2260
};
std
::
vector
<
float
>
bias_data
{
0.0088
,
0.1183
,
0.1642
,
-
0.2631
,
-
0.1330
,
-
0.4008
,
0.3881
,
-
0.4407
,
-
0.2760
,
0.1274
,
-
0.0083
,
-
0.2885
,
0.3949
,
-
0.0182
,
0.4445
,
0.3477
,
0.2266
,
0.3423
,
-
0.0674
,
-
0.4067
,
0.0807
,
0.1109
,
-
0.2036
,
0.1782
,
-
0.2467
,
-
0.0730
,
-
0.4216
,
0.0316
,
-
0.3025
,
0.3637
,
-
0.3181
,
-
0.4655
};
std
::
vector
<
float
>
input_data
{
-
0.5516
,
0.2391
,
-
1.6951
,
-
0.4313
,
-
0.9730
,
-
0.2005
,
2.3930
,
-
0.5221
,
-
0.1331
,
-
0.0910
,
1.2122
,
-
0.1952
,
0.4661
,
0.6494
,
2.1332
,
-
1.0972
,
0.9816
,
0.1122
,
0.3577
,
1.3508
,
-
0.5366
,
1.7449
,
0.5483
,
-
0.0701
,
-
0.4100
,
-
2.2344
,
0.3685
,
0.4583
,
2.3794
,
1.0372
,
-
0.8887
,
0.7892
,
-
0.4012
,
-
0.2818
,
-
2.3374
,
1.5310
};
std
::
vector
<
float
>
ih_data
{
1.9104
,
-
1.9004
,
0.3337
,
0.5741
,
0.5671
,
0.0458
,
0.4514
,
-
0.8968
,
-
0.9201
,
0.1962
,
0.5771
,
-
0.5332
};
std
::
vector
<
float
>
ic_data
{
0.9569
,
-
0.5981
,
1.1312
,
1.0945
,
1.1055
,
-
0.1212
,
-
0.9097
,
0.7831
,
-
1.6991
,
-
1.9498
,
-
1.2567
,
-
0.4114
};
std
::
vector
<
float
>
pph_data
{
1.84369764
,
0.68413646
,
-
0.44892886
,
-
1.50904413
,
0.3860796
,
-
0.52186625
,
1.08474445
,
-
1.80867321
,
1.32594529
,
0.4336262
,
-
0.83699064
,
0.49162736
};
float
clip
=
0.0
f
;
migraphx
::
shape
in_shape
{
migraphx
::
shape
::
float_type
,
{
seq_len
,
batch_size
,
input_size
}};
migraphx
::
shape
ih_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
batch_size
,
hidden_size
}};
migraphx
::
shape
ic_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
batch_size
,
hidden_size
}};
migraphx
::
shape
w_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
4
*
hidden_size
,
input_size
}};
migraphx
::
shape
r_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
4
*
hidden_size
,
hidden_size
}};
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
8
*
hidden_size
}};
migraphx
::
shape
pph_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
3
*
hidden_size
}};
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
seq
=
mm
->
add_literal
(
migraphx
::
literal
{
in_shape
,
input_data
});
auto
w
=
mm
->
add_literal
(
migraphx
::
literal
{
w_shape
,
w_data
});
auto
r
=
mm
->
add_literal
(
migraphx
::
literal
{
r_shape
,
r_data
});
auto
bias
=
mm
->
add_literal
(
migraphx
::
literal
{
b_shape
,
bias_data
});
auto
ih
=
mm
->
add_literal
(
migraphx
::
literal
{
ih_shape
,
ih_data
});
auto
ic
=
mm
->
add_literal
(
migraphx
::
literal
{
ic_shape
,
ic_data
});
auto
und
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"undefined"
));
auto
seq_half
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
shape
::
half_type
}}),
seq
);
auto
w_half
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
shape
::
half_type
}}),
w
);
auto
r_half
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
shape
::
half_type
}}),
r
);
auto
bias_half
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
shape
::
half_type
}}),
bias
);
auto
ih_half
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
shape
::
half_type
}}),
ih
);
auto
ic_half
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
shape
::
half_type
}}),
ic
);
auto
und_half
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
shape
::
half_type
}}),
und
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"lstm"
,
{{
"hidden_size"
,
hidden_size
},
{
"actv_func"
,
migraphx
::
to_value
(
std
::
vector
<
migraphx
::
operation
>
{
migraphx
::
make_op
(
"sigmoid"
),
migraphx
::
make_op
(
"tanh"
),
migraphx
::
make_op
(
"tanh"
)})},
{
"direction"
,
migraphx
::
to_value
(
migraphx
::
op
::
rnn_direction
::
forward
)},
{
"clip"
,
clip
},
{
"input_forget"
,
0
}}),
seq_half
,
w_half
,
r_half
,
bias_half
,
und_half
,
ih_half
,
ic_half
,
und_half
);
p
.
compile
(
migraphx
::
ref
::
target
{});
auto
hs_concat
=
p
.
eval
({}).
back
();
std
::
vector
<
float
>
hs_data
;
hs_concat
.
visit
([
&
](
auto
output
)
{
hs_data
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
hs_data_gold
{
0.0417273
,
-
0.272355
,
0.206765
,
0.223879
,
0.138193
,
-
0.0322939
,
-
0.0891815
,
0.15773
,
0.19139
,
-
0.127708
,
-
0.409371
,
-
0.136186
,
0.0742487
,
-
0.0800085
,
0.259897
,
0.0670196
,
0.184266
,
0.0610048
,
-
0.138041
,
0.0963885
,
0.0213755
,
-
0.146027
,
-
0.0324509
,
-
0.0620429
,
-
0.00532985
,
0.0440265
,
0.29654
,
-
0.0463156
,
0.0498799
,
0.125772
,
0.0533032
,
-
0.131413
,
0.0988431
,
-
0.018085
,
-
0.159434
,
0.030266
,
-
0.0847427
,
0.0874114
,
0.304256
,
-
0.0585745
,
-
0.0223018
,
0.131113
,
0.135643
,
-
0.0566208
,
0.142701
,
0.0342236
,
-
0.198664
,
0.0702607
};
EXPECT
(
migraphx
::
verify_range
(
hs_data
,
hs_data_gold
,
5e4
));
}
int
main
(
int
argc
,
const
char
*
argv
[])
{
test
::
run
(
argc
,
argv
);
}
test/shape_test.cpp
View file @
913ae362
...
...
@@ -160,6 +160,20 @@ TEST_CASE(test_shape_dynamic_compares)
EXPECT
(
ss0
.
str
()
!=
ss3
.
str
());
}
TEST_CASE
(
dynamic_dimension_size_t_compares
)
{
using
migraphx
::
shape
;
auto
a
=
shape
::
dynamic_dimension
{
2
,
2
,
2
};
EXPECT
(
a
==
2
);
EXPECT
(
a
!=
3
);
EXPECT
(
static_cast
<
std
::
size_t
>
(
2
)
==
a
);
EXPECT
(
static_cast
<
std
::
size_t
>
(
3
)
!=
a
);
auto
b
=
shape
::
dynamic_dimension
{
2
,
4
,
0
};
EXPECT
(
b
!=
2
);
EXPECT
(
static_cast
<
std
::
size_t
>
(
2
)
!=
b
);
}
TEST_CASE
(
test_shape_dynamic_errors
)
{
using
migraphx
::
shape
;
...
...
Prev
1
2
3
4
Next
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