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
9b53cf55
Commit
9b53cf55
authored
Feb 28, 2019
by
Shucai Xiao
Browse files
Merge branch 'extend_gemm_op' into seq2seq_example
parents
0db15370
ad8f88f5
Changes
63
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
100 additions
and
7 deletions
+100
-7
test/onnx/onnx_test.cpp
test/onnx/onnx_test.cpp
+22
-1
test/op_shape_test.cpp
test/op_shape_test.cpp
+78
-4
tools/include/target.hpp
tools/include/target.hpp
+0
-2
No files found.
test/onnx/onnx_test.cpp
View file @
9b53cf55
...
...
@@ -524,7 +524,7 @@ TEST_CASE(constant_test)
TEST_CASE
(
constant_test_scalar
)
{
migraphx
::
program
p
;
p
.
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
migraphx
::
shape
::
int32_type
,
{
1
},
{
0
}
},
{
1
}});
p
.
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
migraphx
::
shape
::
int32_type
},
{
1
}});
auto
prog
=
migraphx
::
parse_onnx
(
"constant_scalar.onnx"
);
EXPECT
(
p
==
prog
);
...
...
@@ -572,6 +572,27 @@ TEST_CASE(gemm_test)
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
gemm_ex
)
{
migraphx
::
program
p
;
auto
l0
=
p
.
add_parameter
(
"1"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
1
,
5
,
6
}});
auto
l1
=
p
.
add_parameter
(
"2"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
1
,
5
,
7
}});
auto
l2
=
p
.
add_parameter
(
"3"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
1
,
6
,
7
}});
auto
t0
=
p
.
add_instruction
(
migraphx
::
op
::
transpose
{{
0
,
1
,
3
,
2
}},
l0
);
auto
alpha
=
0.5
f
;
auto
res_ab
=
p
.
add_instruction
(
migraphx
::
op
::
dot
{
alpha
},
t0
,
l1
);
auto
beta
=
0.8
f
;
auto
l_beta
=
p
.
add_literal
(
beta
);
auto
brcst_beta
=
p
.
add_instruction
(
migraphx
::
op
::
scalar
{
l2
->
get_shape
()},
l_beta
);
auto
res_c
=
p
.
add_instruction
(
migraphx
::
op
::
mul
{},
l2
,
brcst_beta
);
p
.
add_instruction
(
migraphx
::
op
::
add
{},
res_ab
,
res_c
);
auto
prog
=
migraphx
::
parse_onnx
(
"gemm_test_ex.onnx"
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
add_scalar_test
)
{
migraphx
::
program
p
;
...
...
test/op_shape_test.cpp
View file @
9b53cf55
...
...
@@ -263,7 +263,7 @@ TEST_CASE(gather)
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
,
5
}};
migraphx
::
shape
indices
{
migraphx
::
shape
::
int32_type
,
{
1
},
{
0
}
};
migraphx
::
shape
indices
{
migraphx
::
shape
::
int32_type
};
int
axis
=
-
4
;
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
4
,
5
}},
migraphx
::
op
::
gather
{
axis
},
...
...
@@ -273,7 +273,7 @@ TEST_CASE(gather)
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
,
5
}};
migraphx
::
shape
indices
{
migraphx
::
shape
::
int32_type
,
{
1
},
{
0
}
};
migraphx
::
shape
indices
{
migraphx
::
shape
::
int32_type
};
int
axis
=
3
;
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
}},
migraphx
::
op
::
gather
{
axis
},
...
...
@@ -283,9 +283,9 @@ TEST_CASE(gather)
{
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{
3
}};
migraphx
::
shape
indices
{
migraphx
::
shape
::
int32_type
,
{
1
},
{
0
}
};
migraphx
::
shape
indices
{
migraphx
::
shape
::
int32_type
};
int
axis
=
0
;
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
},
{
0
}
},
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
},
migraphx
::
op
::
gather
{
axis
},
input
,
indices
);
...
...
@@ -316,6 +316,80 @@ TEST_CASE(gather)
}
}
TEST_CASE
(
dot
)
{
{
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
::
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
::
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
::
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
::
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
,
{
2
,
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
,
{
1
,
1
,
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
{},
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
}};
throws_shape
(
migraphx
::
op
::
dot
{},
s_m1
,
s_m2
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
2
,
2
,
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
3
,
2
,
5
,
7
}};
throws_shape
(
migraphx
::
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
::
op
::
dot
{},
s_m1
,
s_m2
);
}
{
migraphx
::
shape
s_m1
{
migraphx
::
shape
::
float_type
,
{
1
,
2
,
4
,
5
}};
migraphx
::
shape
s_m2
{
migraphx
::
shape
::
float_type
,
{
2
,
1
,
5
,
7
}};
throws_shape
(
migraphx
::
op
::
dot
{},
s_m1
,
s_m2
);
}
}
TEST_CASE
(
rnn
)
{
{
...
...
tools/include/target.hpp
View file @
9b53cf55
...
...
@@ -22,10 +22,8 @@ struct target
{
/// A unique name used to identify the target
std
::
string
name
()
const
;
/// The transformation passes to be run
/**
* @brief The transformation pass to be run during compilation.
* @details [long description]
*
* @param ctx This is the target-dependent context that is created by `get_context`
* @return The passes to be ran
...
...
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