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
357d2a80
Commit
357d2a80
authored
Mar 15, 2019
by
Shucai Xiao
Browse files
add shape test for the dot operator and fix a bug in compute shape function
parent
ddc5d078
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
251 additions
and
4 deletions
+251
-4
src/include/migraphx/operators.hpp
src/include/migraphx/operators.hpp
+1
-1
test/op_shape_test.cpp
test/op_shape_test.cpp
+250
-3
No files found.
src/include/migraphx/operators.hpp
View file @
357d2a80
...
...
@@ -926,7 +926,7 @@ struct dot
// C should be the same shape as A * B
auto
c_lens
=
inputs
[
2
].
lens
();
if
(
!
std
::
equal
(
c
_lens
.
begin
(),
c
_lens
.
end
(),
out
_lens
.
begin
()))
if
(
!
std
::
equal
(
out
_lens
.
begin
(),
out
_lens
.
end
(),
c
_lens
.
begin
()))
{
MIGRAPHX_THROW
(
"DOT: dimension mismatch, operand C: {"
+
to_string_range
(
c_lens
)
+
"}, cannot add to operand A * B: {"
+
...
...
test/op_shape_test.cpp
View file @
357d2a80
...
...
@@ -371,8 +371,74 @@ TEST_CASE(logsoftmax)
}
}
TEST_CASE
(
dot
)
// 2 inputs arguments
TEST_CASE
(
matmul
)
{
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
5
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
},
migraphx
::
op
::
dot
{},
s_m1
,
s_m2
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
4
}};
throws_shape
(
migraphx
::
op
::
dot
{},
s_m1
,
s_m2
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
5
,
4
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
4
}},
migraphx
::
op
::
dot
{},
s_m1
,
s_m2
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
4
,
4
}};
throws_shape
(
migraphx
::
op
::
dot
{},
s_m1
,
s_m2
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
6
,
5
,
4
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
6
,
4
}},
migraphx
::
op
::
dot
{},
s_m1
,
s_m2
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
5
,
4
,
4
}};
throws_shape
(
migraphx
::
op
::
dot
{},
s_m1
,
s_m2
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
6
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
5
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
6
}},
migraphx
::
op
::
dot
{},
s_m1
,
s_m2
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
6
,
4
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
5
}};
throws_shape
(
migraphx
::
op
::
dot
{},
s_m1
,
s_m2
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
3
,
6
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
5
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
6
}},
migraphx
::
op
::
dot
{},
s_m1
,
s_m2
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
3
,
5
,
4
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
5
}};
throws_shape
(
migraphx
::
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
}};
...
...
@@ -403,7 +469,7 @@ TEST_CASE(dot)
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
,
5
}};
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
3
,
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
5
,
7
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
,
7
}},
migraphx
::
op
::
dot
{},
...
...
@@ -412,7 +478,25 @@ TEST_CASE(dot)
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
1
,
1
,
4
,
5
}};
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
3
,
5
,
7
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
,
7
}},
migraphx
::
op
::
dot
{},
s_m1
,
s_m2
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
5
,
7
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
,
7
}},
migraphx
::
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
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
1
,
4
,
7
}},
migraphx
::
op
::
dot
{},
...
...
@@ -438,6 +522,24 @@ TEST_CASE(dot)
s_m2
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
2
,
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
2
,
1
,
5
,
7
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
2
,
4
,
7
}},
migraphx
::
op
::
dot
{},
s_m1
,
s_m2
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
2
,
1
,
5
,
7
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
1
,
4
,
7
}},
migraphx
::
op
::
dot
{},
s_m1
,
s_m2
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
3
,
1
,
4
,
6
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
3
,
1
,
5
,
7
}};
...
...
@@ -463,6 +565,151 @@ TEST_CASE(dot)
}
}
// 3 input arguments
TEST_CASE
(
gemm
)
{
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
5
,
8
}};
migraphx
::
shape
s_m3
{
migraphx
::
shape
::
float_type
};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
4
,
8
}},
migraphx
::
op
::
dot
{},
s_m1
,
s_m2
,
s_m3
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
5
,
8
}};
migraphx
::
shape
s_m3
{
migraphx
::
shape
::
float_type
,
{
1
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
4
,
8
}},
migraphx
::
op
::
dot
{},
s_m1
,
s_m2
,
s_m3
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
5
,
8
}};
migraphx
::
shape
s_m3
{
migraphx
::
shape
::
float_type
,
{
1
,
1
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
4
,
8
}},
migraphx
::
op
::
dot
{},
s_m1
,
s_m2
,
s_m3
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
5
,
8
}};
migraphx
::
shape
s_m3
{
migraphx
::
shape
::
float_type
,
{
8
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
4
,
8
}},
migraphx
::
op
::
dot
{},
s_m1
,
s_m2
,
s_m3
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
5
,
8
}};
migraphx
::
shape
s_m3
{
migraphx
::
shape
::
float_type
,
{
4
,
1
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
4
,
8
}},
migraphx
::
op
::
dot
{},
s_m1
,
s_m2
,
s_m3
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
5
,
8
}};
migraphx
::
shape
s_m3
{
migraphx
::
shape
::
float_type
,
{
4
}};
throws_shape
(
migraphx
::
op
::
dot
{},
s_m1
,
s_m2
,
s_m3
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
5
,
8
}};
migraphx
::
shape
s_m3
{
migraphx
::
shape
::
float_type
,
{
4
,
8
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
4
,
8
}},
migraphx
::
op
::
dot
{},
s_m1
,
s_m2
,
s_m3
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
5
,
8
}};
migraphx
::
shape
s_m3
{
migraphx
::
shape
::
float_type
,
{
1
,
8
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
4
,
8
}},
migraphx
::
op
::
dot
{},
s_m1
,
s_m2
,
s_m3
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
5
,
8
}};
migraphx
::
shape
s_m3
{
migraphx
::
shape
::
float_type
,
{
4
,
7
}};
throws_shape
(
migraphx
::
op
::
dot
{},
s_m1
,
s_m2
,
s_m3
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
5
,
8
}};
migraphx
::
shape
s_m3
{
migraphx
::
shape
::
float_type
,
{
3
,
8
}};
throws_shape
(
migraphx
::
op
::
dot
{},
s_m1
,
s_m2
,
s_m3
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
5
,
8
}};
migraphx
::
shape
s_m3
{
migraphx
::
shape
::
float_type
,
{
3
,
7
}};
throws_shape
(
migraphx
::
op
::
dot
{},
s_m1
,
s_m2
,
s_m3
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
1
,
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
1
,
5
,
8
}};
migraphx
::
shape
s_m3
{
migraphx
::
shape
::
float_type
,
{
1
,
4
,
8
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
4
,
8
}},
migraphx
::
op
::
dot
{},
s_m1
,
s_m2
,
s_m3
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
1
,
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
1
,
5
,
8
}};
migraphx
::
shape
s_m3
{
migraphx
::
shape
::
float_type
,
{
4
,
8
}};
throws_shape
(
migraphx
::
op
::
dot
{},
s_m1
,
s_m2
,
s_m3
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
1
,
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
1
,
5
,
8
}};
migraphx
::
shape
s_m3
{
migraphx
::
shape
::
float_type
};
throws_shape
(
migraphx
::
op
::
dot
{},
s_m1
,
s_m2
,
s_m3
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
1
,
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
1
,
5
,
8
}};
migraphx
::
shape
s_m3
{
migraphx
::
shape
::
float_type
,
{
1
,
8
}};
throws_shape
(
migraphx
::
op
::
dot
{},
s_m1
,
s_m2
,
s_m3
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
1
,
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
1
,
5
,
8
}};
migraphx
::
shape
s_m3
{
migraphx
::
shape
::
float_type
,
{
1
,
4
,
1
}};
throws_shape
(
migraphx
::
op
::
dot
{},
s_m1
,
s_m2
,
s_m3
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
2
,
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
1
,
5
,
8
}};
migraphx
::
shape
s_m3
{
migraphx
::
shape
::
float_type
,
{
1
,
4
,
8
}};
throws_shape
(
migraphx
::
op
::
dot
{},
s_m1
,
s_m2
,
s_m3
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
2
,
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
1
,
5
,
8
}};
migraphx
::
shape
s_m3
{
migraphx
::
shape
::
float_type
,
{
1
,
4
,
8
}};
throws_shape
(
migraphx
::
op
::
dot
{},
s_m1
,
s_m2
,
s_m3
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
2
,
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
2
,
5
,
8
}};
migraphx
::
shape
s_m3
{
migraphx
::
shape
::
float_type
};
throws_shape
(
migraphx
::
op
::
dot
{},
s_m1
,
s_m2
,
s_m3
);
}
}
TEST_CASE
(
rnn
)
{
{
...
...
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