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
85d789f7
Commit
85d789f7
authored
Feb 11, 2019
by
Khalique
Browse files
manual merge and biasadd change
parents
864fafb2
a5b0afa0
Changes
68
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
431 additions
and
6 deletions
+431
-6
test/onnx/sub_scalar_test.onnx
test/onnx/sub_scalar_test.onnx
+0
-0
test/op_shape_test.cpp
test/op_shape_test.cpp
+342
-1
test/operation.cpp
test/operation.cpp
+1
-0
test/py/CMakeLists.txt
test/py/CMakeLists.txt
+21
-0
test/py/cpu.py
test/py/cpu.py
+17
-0
test/py/gpu.py
test/py/gpu.py
+14
-0
test/simplify_reshapes_test.cpp
test/simplify_reshapes_test.cpp
+34
-3
tools/include/operation.hpp
tools/include/operation.hpp
+2
-2
No files found.
test/onnx/sub_scalar_test.onnx
0 → 100644
View file @
85d789f7
File added
test/op_shape_test.cpp
View file @
85d789f7
...
@@ -108,10 +108,27 @@ TEST_CASE(reshape_shape)
...
@@ -108,10 +108,27 @@ TEST_CASE(reshape_shape)
expect_shape
(
output
,
migraphx
::
op
::
reshape
{
new_shape
},
input
);
expect_shape
(
output
,
migraphx
::
op
::
reshape
{
new_shape
},
input
);
}
}
for
(
auto
&&
new_shape
:
std
::
vector
<
std
::
vector
<
int64_t
>>
{{
8
,
3
,
2
,
2
},
{
1
,
3
,
-
1
,
-
1
}})
for
(
auto
&&
new_shape
:
std
::
vector
<
std
::
vector
<
int64_t
>>
{{
8
,
3
,
2
,
2
},
{
1
,
3
,
-
1
,
-
1
},
{
3
,
0
,
0
},
{
3
,
2
,
0
}})
{
{
throws_shape
(
migraphx
::
op
::
reshape
{
new_shape
},
input
);
throws_shape
(
migraphx
::
op
::
reshape
{
new_shape
},
input
);
}
}
std
::
vector
<
std
::
pair
<
std
::
vector
<
int64_t
>
,
migraphx
::
shape
>>
minus1_tests
{
{{
2
,
-
1
,
3
},
{
migraphx
::
shape
::
float_type
,
{
2
,
4
,
3
}}},
{{
0
,
-
1
,
0
},
{
migraphx
::
shape
::
float_type
,
{
24
,
1
,
1
}}},
{{
2
,
-
1
,
0
},
{
migraphx
::
shape
::
float_type
,
{
2
,
12
,
1
}}},
{{
0
,
0
,
-
1
},
{
migraphx
::
shape
::
float_type
,
{
24
,
1
,
1
}}},
{{
2
,
0
,
-
1
},
{
migraphx
::
shape
::
float_type
,
{
2
,
1
,
12
}}},
{{
-
1
,
2
,
3
},
{
migraphx
::
shape
::
float_type
,
{
4
,
2
,
3
}}},
{{
-
1
,
0
,
3
},
{
migraphx
::
shape
::
float_type
,
{
8
,
1
,
3
}}},
{{
-
1
,
0
,
0
},
{
migraphx
::
shape
::
float_type
,
{
24
,
1
,
1
}}},
{{
-
1
,
3
,
0
},
{
migraphx
::
shape
::
float_type
,
{
8
,
3
,
1
}}}};
for
(
auto
&
it
:
minus1_tests
)
{
expect_shape
(
it
.
second
,
migraphx
::
op
::
reshape
{
it
.
first
},
input
);
}
}
}
TEST_CASE
(
flatten_shape
)
TEST_CASE
(
flatten_shape
)
...
@@ -249,4 +266,328 @@ TEST_CASE(gather)
...
@@ -249,4 +266,328 @@ TEST_CASE(gather)
}
}
}
}
TEST_CASE
(
rnn
)
{
{
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
;
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
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
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
seq_len
,
num_dirct
,
batch_size
,
hidden_size
}},
migraphx
::
op
::
rnn
{
hidden_size
,
{
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
rnn_direction
::
forward
,
clip
},
in_shape
,
w_shape
,
r_shape
,
b_shape
,
ih_shape
);
}
{
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
;
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
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
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
seq_len
,
num_dirct
,
batch_size
,
hidden_size
}},
migraphx
::
op
::
rnn
{
hidden_size
,
{
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
rnn_direction
::
reverse
,
clip
},
in_shape
,
w_shape
,
r_shape
,
b_shape
,
ih_shape
);
}
{
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
=
2
;
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
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
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
seq_len
,
num_dirct
,
batch_size
,
hidden_size
}},
migraphx
::
op
::
rnn
{
hidden_size
,
{
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
rnn_direction
::
bidirectional
,
clip
},
in_shape
,
w_shape
,
r_shape
,
b_shape
,
ih_shape
);
}
{
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
;
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
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
}};
throws_shape
(
migraphx
::
op
::
rnn
{
hidden_size
+
1
,
{
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
rnn_direction
::
forward
,
clip
},
in_shape
,
w_shape
,
r_shape
,
b_shape
,
ih_shape
);
}
{
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
;
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
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
}};
throws_shape
(
migraphx
::
op
::
rnn
{
hidden_size
,
{
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
rnn_direction
::
bidirectional
,
clip
},
in_shape
,
w_shape
,
r_shape
,
b_shape
,
ih_shape
);
}
{
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
=
2
;
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
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
}};
throws_shape
(
migraphx
::
op
::
rnn
{
hidden_size
,
{
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
rnn_direction
::
forward
,
clip
},
in_shape
,
w_shape
,
r_shape
,
b_shape
,
ih_shape
);
}
}
TEST_CASE
(
gru
)
{
{
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
;
float
clip
=
0.0
f
;
migraphx
::
shape
in_shape
{
migraphx
::
shape
::
float_type
,
{
seq_len
,
batch_size
,
input_size
}};
migraphx
::
shape
w_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
3
*
hidden_size
,
input_size
}};
migraphx
::
shape
r_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
3
*
hidden_size
,
hidden_size
}};
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
6
*
hidden_size
}};
migraphx
::
shape
ih_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
batch_size
,
hidden_size
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
seq_len
,
num_dirct
,
batch_size
,
hidden_size
}},
migraphx
::
op
::
gru
{
hidden_size
,
{
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
rnn_direction
::
forward
,
clip
},
in_shape
,
w_shape
,
r_shape
,
b_shape
,
ih_shape
);
}
{
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
;
float
clip
=
0.0
f
;
migraphx
::
shape
in_shape
{
migraphx
::
shape
::
float_type
,
{
seq_len
,
batch_size
,
input_size
}};
migraphx
::
shape
w_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
3
*
hidden_size
,
input_size
}};
migraphx
::
shape
r_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
3
*
hidden_size
,
hidden_size
}};
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
6
*
hidden_size
}};
migraphx
::
shape
ih_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
batch_size
,
hidden_size
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
seq_len
,
num_dirct
,
batch_size
,
hidden_size
}},
migraphx
::
op
::
gru
{
hidden_size
,
{
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
rnn_direction
::
reverse
,
clip
},
in_shape
,
w_shape
,
r_shape
,
b_shape
,
ih_shape
);
}
{
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
=
2
;
float
clip
=
0.0
f
;
migraphx
::
shape
in_shape
{
migraphx
::
shape
::
float_type
,
{
seq_len
,
batch_size
,
input_size
}};
migraphx
::
shape
w_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
3
*
hidden_size
,
input_size
}};
migraphx
::
shape
r_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
3
*
hidden_size
,
hidden_size
}};
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
6
*
hidden_size
}};
migraphx
::
shape
ih_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
batch_size
,
hidden_size
}};
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
seq_len
,
num_dirct
,
batch_size
,
hidden_size
}},
migraphx
::
op
::
gru
{
hidden_size
,
{
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
rnn_direction
::
bidirectional
,
clip
},
in_shape
,
w_shape
,
r_shape
,
b_shape
,
ih_shape
);
}
{
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
;
float
clip
=
0.0
f
;
migraphx
::
shape
in_shape
{
migraphx
::
shape
::
float_type
,
{
seq_len
,
batch_size
,
input_size
}};
migraphx
::
shape
w_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
3
*
hidden_size
,
input_size
}};
migraphx
::
shape
r_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
3
*
hidden_size
,
hidden_size
}};
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
6
*
hidden_size
}};
migraphx
::
shape
ih_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
batch_size
,
hidden_size
}};
throws_shape
(
migraphx
::
op
::
gru
{
hidden_size
+
1
,
{
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
rnn_direction
::
forward
,
clip
},
in_shape
,
w_shape
,
r_shape
,
b_shape
,
ih_shape
);
}
{
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
;
float
clip
=
0.0
f
;
migraphx
::
shape
in_shape
{
migraphx
::
shape
::
float_type
,
{
seq_len
,
batch_size
,
input_size
}};
migraphx
::
shape
w_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
3
*
hidden_size
,
input_size
}};
migraphx
::
shape
r_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
3
*
hidden_size
,
hidden_size
}};
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
6
*
hidden_size
}};
migraphx
::
shape
ih_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
batch_size
,
hidden_size
}};
throws_shape
(
migraphx
::
op
::
gru
{
hidden_size
,
{
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
rnn_direction
::
bidirectional
,
clip
},
in_shape
,
w_shape
,
r_shape
,
b_shape
,
ih_shape
);
}
{
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
=
2
;
float
clip
=
0.0
f
;
migraphx
::
shape
in_shape
{
migraphx
::
shape
::
float_type
,
{
seq_len
,
batch_size
,
input_size
}};
migraphx
::
shape
w_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
3
*
hidden_size
,
input_size
}};
migraphx
::
shape
r_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
3
*
hidden_size
,
hidden_size
}};
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
6
*
hidden_size
}};
migraphx
::
shape
ih_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
batch_size
,
hidden_size
}};
throws_shape
(
migraphx
::
op
::
gru
{
hidden_size
,
{
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
rnn_direction
::
forward
,
clip
},
in_shape
,
w_shape
,
r_shape
,
b_shape
,
ih_shape
);
}
}
int
main
(
int
argc
,
const
char
*
argv
[])
{
test
::
run
(
argc
,
argv
);
}
int
main
(
int
argc
,
const
char
*
argv
[])
{
test
::
run
(
argc
,
argv
);
}
test/operation.cpp
View file @
85d789f7
#include <migraphx/operation.hpp>
#include <migraphx/operation.hpp>
#include <migraphx/context.hpp>
#include <sstream>
#include <sstream>
#include <string>
#include <string>
#include "test.hpp"
#include "test.hpp"
...
...
test/py/CMakeLists.txt
0 → 100644
View file @
85d789f7
find_package
(
PythonInterp
)
function
(
add_py_test NAME SCRIPT
)
set
(
ENV_COMMAND
${
CMAKE_COMMAND
}
-E env
"PYTHONPATH=$<TARGET_FILE_DIR:migraphx_py>"
)
add_test
(
NAME test_py_
${
NAME
}
COMMAND
${
ENV_COMMAND
}
${
PYTHON_EXECUTABLE
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
SCRIPT
}
${
ARGN
}
)
add_custom_target
(
test_py_
${
NAME
}
COMMAND
${
ENV_COMMAND
}
${
PYTHON_EXECUTABLE
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
SCRIPT
}
${
ARGN
}
COMMENT
"
${
PYTHON_EXECUTABLE
}
${
SCRIPT
}
"
)
endfunction
()
add_dependencies
(
tests migraphx_py
)
add_dependencies
(
check migraphx_py
)
add_py_test
(
cpu cpu.py WORKING_DIRECTORY
${
TEST_ONNX_DIR
}
)
if
(
MIGRAPHX_ENABLE_GPU
)
add_py_test
(
gpu gpu.py WORKING_DIRECTORY
${
TEST_ONNX_DIR
}
)
endif
()
test/py/cpu.py
0 → 100644
View file @
85d789f7
import
migraphx
p
=
migraphx
.
parse_onnx
(
"conv_relu_maxpool.onnx"
)
print
(
p
)
s1
=
p
.
get_shape
()
print
(
"Compiling ..."
)
p
.
compile
(
migraphx
.
get_target
(
"cpu"
))
print
(
p
)
s2
=
p
.
get_shape
()
assert
s1
==
s2
params
=
{}
for
key
,
value
in
p
.
get_parameter_shapes
().
items
():
print
(
"Parameter {} -> {}"
.
format
(
key
,
value
))
params
[
key
]
=
migraphx
.
generate_argument
(
value
)
r
=
p
.
run
(
params
)
print
(
r
)
test/py/gpu.py
0 → 100644
View file @
85d789f7
import
migraphx
p
=
migraphx
.
parse_onnx
(
"conv_relu_maxpool.onnx"
)
print
(
p
)
print
(
"Compiling ..."
)
p
.
compile
(
migraphx
.
get_target
(
"gpu"
))
print
(
p
)
params
=
{}
for
key
,
value
in
p
.
get_parameter_shapes
().
items
():
print
(
"Parameter {} -> {}"
.
format
(
key
,
value
))
params
[
key
]
=
migraphx
.
to_gpu
(
migraphx
.
generate_argument
(
value
))
r
=
migraphx
.
from_gpu
(
p
.
run
(
params
))
print
(
r
)
test/simplify_reshapes_test.cpp
View file @
85d789f7
...
@@ -27,9 +27,9 @@ TEST_CASE(double_contig)
...
@@ -27,9 +27,9 @@ TEST_CASE(double_contig)
p
.
compile
(
simplify_reshapes_target
{});
p
.
compile
(
simplify_reshapes_target
{});
EXPECT
(
p
.
get_shape
().
standard
());
EXPECT
(
p
.
get_shape
().
standard
());
EXPECT
(
not
p
.
get_shape
().
transposed
());
EXPECT
(
not
p
.
get_shape
().
transposed
());
EXPECT
(
std
::
distance
(
p
.
begin
(),
p
.
end
())
==
2
);
EXPECT
(
std
::
distance
(
p
.
begin
(),
p
.
end
())
==
4
);
auto
result
=
p
.
eval
({});
auto
result
=
p
.
eval
({});
EXPECT
(
result
=
=
get_2x2
());
EXPECT
(
result
!
=
get_2x2
());
}
}
TEST_CASE
(
double_transpose
)
TEST_CASE
(
double_transpose
)
...
@@ -95,7 +95,6 @@ TEST_CASE(double_transpose_sin_pass)
...
@@ -95,7 +95,6 @@ TEST_CASE(double_transpose_sin_pass)
p
.
compile
(
simplify_reshapes_target
{});
p
.
compile
(
simplify_reshapes_target
{});
EXPECT
(
p
.
get_shape
().
standard
());
EXPECT
(
p
.
get_shape
().
standard
());
EXPECT
(
not
p
.
get_shape
().
transposed
());
EXPECT
(
not
p
.
get_shape
().
transposed
());
// std::cout << p << std::endl;
// TODO: Fix this
// TODO: Fix this
// EXPECT(std::distance(p.begin(), p.end()) == 1);
// EXPECT(std::distance(p.begin(), p.end()) == 1);
auto
result
=
p
.
eval
({});
auto
result
=
p
.
eval
({});
...
@@ -134,4 +133,36 @@ TEST_CASE(reshape_transpose)
...
@@ -134,4 +133,36 @@ TEST_CASE(reshape_transpose)
EXPECT
(
std
::
distance
(
p
.
begin
(),
p
.
end
())
==
n
);
EXPECT
(
std
::
distance
(
p
.
begin
(),
p
.
end
())
==
n
);
}
}
TEST_CASE
(
transpose_contiguous
)
{
migraphx
::
program
p
;
auto
s
=
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
4
,
4
}};
auto
x
=
p
.
add_parameter
(
"x"
,
s
);
auto
t
=
p
.
add_instruction
(
migraphx
::
op
::
transpose
{{
1
,
0
}},
x
);
auto
c1
=
p
.
add_instruction
(
migraphx
::
op
::
contiguous
{},
t
);
p
.
add_instruction
(
pass_op
{},
c1
);
auto
out_shape
=
p
.
get_shape
();
auto
n
=
std
::
distance
(
p
.
begin
(),
p
.
end
());
p
.
compile
(
simplify_reshapes_target
{});
EXPECT
(
p
.
get_shape
()
==
out_shape
);
EXPECT
(
std
::
distance
(
p
.
begin
(),
p
.
end
())
==
n
);
}
TEST_CASE
(
transpose_double_contiguous
)
{
migraphx
::
program
p
;
auto
s
=
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
4
,
4
}};
auto
x
=
p
.
add_parameter
(
"x"
,
s
);
auto
t
=
p
.
add_instruction
(
migraphx
::
op
::
transpose
{{
1
,
0
}},
x
);
auto
c1
=
p
.
add_instruction
(
migraphx
::
op
::
contiguous
{},
t
);
auto
c2
=
p
.
add_instruction
(
migraphx
::
op
::
contiguous
{},
c1
);
p
.
add_instruction
(
pass_op
{},
c2
);
auto
out_shape
=
p
.
get_shape
();
auto
n
=
std
::
distance
(
p
.
begin
(),
p
.
end
());
p
.
compile
(
simplify_reshapes_target
{});
EXPECT
(
p
.
get_shape
()
==
out_shape
);
EXPECT
(
std
::
distance
(
p
.
begin
(),
p
.
end
())
==
n
-
1
);
EXPECT
(
p
.
has_instruction
(
t
));
}
int
main
(
int
argc
,
const
char
*
argv
[])
{
test
::
run
(
argc
,
argv
);
}
int
main
(
int
argc
,
const
char
*
argv
[])
{
test
::
run
(
argc
,
argv
);
}
tools/include/operation.hpp
View file @
85d789f7
...
@@ -7,17 +7,17 @@
...
@@ -7,17 +7,17 @@
#include <memory>
#include <memory>
#include <type_traits>
#include <type_traits>
#include <utility>
#include <utility>
#include <migraphx/shape.hpp>
#include <migraphx/reflect.hpp>
#include <migraphx/reflect.hpp>
#include <migraphx/streamutils.hpp>
#include <migraphx/streamutils.hpp>
#include <migraphx/argument.hpp>
#include <migraphx/argument.hpp>
#include <migraphx/context.hpp>
#include <migraphx/auto_any_cast.hpp>
#include <migraphx/auto_any_cast.hpp>
#include <migraphx/config.hpp>
#include <migraphx/config.hpp>
namespace
migraphx
{
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
inline
namespace
MIGRAPHX_INLINE_NS
{
struct
context
;
#ifdef DOXYGEN
#ifdef DOXYGEN
/// The operation interface represents an action an instruction will perform. All
/// The operation interface represents an action an instruction will perform. All
...
...
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