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
91c90830
Commit
91c90830
authored
Feb 17, 2019
by
Shucai Xiao
Browse files
more onnx tests for the lstm operator.
parent
00d54147
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
271 additions
and
1 deletion
+271
-1
test/onnx/onnx_lstm_f0af.onnx
test/onnx/onnx_lstm_f0af.onnx
+0
-0
test/onnx/onnx_lstm_f1af.onnx
test/onnx/onnx_lstm_f1af.onnx
+0
-0
test/onnx/onnx_lstm_f2af.onnx
test/onnx/onnx_lstm_f2af.onnx
+0
-0
test/onnx/onnx_lstm_f3args.onnx
test/onnx/onnx_lstm_f3args.onnx
+0
-0
test/onnx/onnx_lstm_f4args.onnx
test/onnx/onnx_lstm_f4args.onnx
+0
-0
test/onnx/onnx_lstm_f5args.onnx
test/onnx/onnx_lstm_f5args.onnx
+0
-0
test/onnx/onnx_lstm_f6args.onnx
test/onnx/onnx_lstm_f6args.onnx
+0
-0
test/onnx/onnx_lstm_f7args.onnx
test/onnx/onnx_lstm_f7args.onnx
+0
-0
test/onnx/onnx_rnn_test.cpp
test/onnx/onnx_rnn_test.cpp
+271
-1
No files found.
test/onnx/onnx_lstm_f0af.onnx
0 → 100644
View file @
91c90830
File added
test/onnx/onnx_lstm_f1af.onnx
0 → 100644
View file @
91c90830
File added
test/onnx/onnx_lstm_f2af.onnx
0 → 100644
View file @
91c90830
File added
test/onnx/onnx_lstm_f3args.onnx
0 → 100644
View file @
91c90830
File added
test/onnx/onnx_lstm_f4args.onnx
0 → 100644
View file @
91c90830
File added
test/onnx/onnx_lstm_f5args.onnx
0 → 100644
View file @
91c90830
File added
test/onnx/onnx_lstm_f6args.onnx
0 → 100644
View file @
91c90830
File added
test/onnx/onnx_lstm_f7args.onnx
0 → 100644
View file @
91c90830
File added
test/onnx/onnx_rnn_test.cpp
View file @
91c90830
...
...
@@ -48,7 +48,7 @@ TEST_CASE(rnn_test_bidirectional)
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
rnn_test_one
)
TEST_CASE
(
rnn_test_one
_direction
)
{
std
::
size_t
sl
=
5
;
// sequence len
std
::
size_t
bs
=
3
;
// batch size
...
...
@@ -640,8 +640,278 @@ TEST_CASE(lstm_forward)
EXPECT
(
p
==
prog
);
}
// 3 args
{
migraphx
::
program
p
;
auto
seq
=
p
.
add_parameter
(
"seq"
,
seq_shape
);
auto
w
=
p
.
add_parameter
(
"w"
,
w_shape
);
auto
r
=
p
.
add_parameter
(
"r"
,
r_shape
);
auto
und
=
p
.
add_instruction
(
migraphx
::
op
::
undefined
{});
auto
out_hs
=
p
.
add_instruction
(
migraphx
::
op
::
lstm
{
hs
,
{
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
rnn_direction
::
forward
,
clip
,
input_forget
},
seq
,
w
,
r
,
und
,
und
,
und
,
und
,
und
);
p
.
add_instruction
(
migraphx
::
op
::
rnn_last_output
{},
out_hs
);
p
.
add_instruction
(
migraphx
::
op
::
lstm_last_cell_output
{},
out_hs
);
auto
prog
=
migraphx
::
parse_onnx
(
"onnx_lstm_f3args.onnx"
);
EXPECT
(
p
==
prog
);
}
// 4 args
{
migraphx
::
program
p
;
auto
seq
=
p
.
add_parameter
(
"seq"
,
seq_shape
);
auto
w
=
p
.
add_parameter
(
"w"
,
w_shape
);
auto
r
=
p
.
add_parameter
(
"r"
,
r_shape
);
auto
bias
=
p
.
add_parameter
(
"bias"
,
bias_shape
);
auto
und
=
p
.
add_instruction
(
migraphx
::
op
::
undefined
{});
auto
out_hs
=
p
.
add_instruction
(
migraphx
::
op
::
lstm
{
hs
,
{
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
rnn_direction
::
forward
,
clip
,
input_forget
},
seq
,
w
,
r
,
bias
,
und
,
und
,
und
,
und
);
p
.
add_instruction
(
migraphx
::
op
::
rnn_last_output
{},
out_hs
);
p
.
add_instruction
(
migraphx
::
op
::
lstm_last_cell_output
{},
out_hs
);
auto
prog
=
migraphx
::
parse_onnx
(
"onnx_lstm_f4args.onnx"
);
EXPECT
(
p
==
prog
);
}
// 5 args
{
migraphx
::
program
p
;
auto
seq
=
p
.
add_parameter
(
"seq"
,
seq_shape
);
auto
w
=
p
.
add_parameter
(
"w"
,
w_shape
);
auto
r
=
p
.
add_parameter
(
"r"
,
r_shape
);
auto
bias
=
p
.
add_parameter
(
"bias"
,
bias_shape
);
auto
seq_len
=
p
.
add_parameter
(
"seq_len"
,
sl_shape
);
auto
und
=
p
.
add_instruction
(
migraphx
::
op
::
undefined
{});
auto
out_hs
=
p
.
add_instruction
(
migraphx
::
op
::
lstm
{
hs
,
{
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
rnn_direction
::
forward
,
clip
,
input_forget
},
seq
,
w
,
r
,
bias
,
seq_len
,
und
,
und
,
und
);
p
.
add_instruction
(
migraphx
::
op
::
rnn_last_output
{},
out_hs
);
p
.
add_instruction
(
migraphx
::
op
::
lstm_last_cell_output
{},
out_hs
);
auto
prog
=
migraphx
::
parse_onnx
(
"onnx_lstm_f5args.onnx"
);
EXPECT
(
p
==
prog
);
}
// 6 args
{
migraphx
::
program
p
;
auto
seq
=
p
.
add_parameter
(
"seq"
,
seq_shape
);
auto
w
=
p
.
add_parameter
(
"w"
,
w_shape
);
auto
r
=
p
.
add_parameter
(
"r"
,
r_shape
);
auto
bias
=
p
.
add_parameter
(
"bias"
,
bias_shape
);
auto
seq_len
=
p
.
add_parameter
(
"seq_len"
,
sl_shape
);
auto
ih
=
p
.
add_parameter
(
"h0"
,
ih_shape
);
auto
und
=
p
.
add_instruction
(
migraphx
::
op
::
undefined
{});
auto
out_hs
=
p
.
add_instruction
(
migraphx
::
op
::
lstm
{
hs
,
{
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
rnn_direction
::
forward
,
clip
,
input_forget
},
seq
,
w
,
r
,
bias
,
seq_len
,
ih
,
und
,
und
);
p
.
add_instruction
(
migraphx
::
op
::
rnn_last_output
{},
out_hs
);
p
.
add_instruction
(
migraphx
::
op
::
lstm_last_cell_output
{},
out_hs
);
auto
prog
=
migraphx
::
parse_onnx
(
"onnx_lstm_f6args.onnx"
);
EXPECT
(
p
==
prog
);
}
// 7 args
{
migraphx
::
program
p
;
auto
seq
=
p
.
add_parameter
(
"seq"
,
seq_shape
);
auto
w
=
p
.
add_parameter
(
"w"
,
w_shape
);
auto
r
=
p
.
add_parameter
(
"r"
,
r_shape
);
auto
bias
=
p
.
add_parameter
(
"bias"
,
bias_shape
);
auto
seq_len
=
p
.
add_parameter
(
"seq_len"
,
sl_shape
);
auto
ih
=
p
.
add_parameter
(
"h0"
,
ih_shape
);
auto
ic
=
p
.
add_parameter
(
"c0"
,
ih_shape
);
auto
und
=
p
.
add_instruction
(
migraphx
::
op
::
undefined
{});
auto
out_hs
=
p
.
add_instruction
(
migraphx
::
op
::
lstm
{
hs
,
{
migraphx
::
op
::
sigmoid
{},
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
rnn_direction
::
forward
,
clip
,
input_forget
},
seq
,
w
,
r
,
bias
,
seq_len
,
ih
,
ic
,
und
);
p
.
add_instruction
(
migraphx
::
op
::
rnn_last_output
{},
out_hs
);
p
.
add_instruction
(
migraphx
::
op
::
lstm_last_cell_output
{},
out_hs
);
auto
prog
=
migraphx
::
parse_onnx
(
"onnx_lstm_f7args.onnx"
);
EXPECT
(
p
==
prog
);
}
}
// activation functions
TEST_CASE
(
lstm_forward_actv_func
)
{
std
::
size_t
sl
=
5
;
// sequence len
std
::
size_t
bs
=
3
;
// batch size
std
::
size_t
hs
=
20
;
// hidden size
std
::
size_t
is
=
10
;
// input size
std
::
size_t
nd
=
1
;
// num directions
float
clip
=
0.0
f
;
int
input_forget
=
1
;
migraphx
::
shape
seq_shape
{
migraphx
::
shape
::
float_type
,
{
sl
,
bs
,
is
}};
migraphx
::
shape
w_shape
{
migraphx
::
shape
::
float_type
,
{
nd
,
4
*
hs
,
is
}};
migraphx
::
shape
r_shape
{
migraphx
::
shape
::
float_type
,
{
nd
,
4
*
hs
,
hs
}};
migraphx
::
shape
bias_shape
{
migraphx
::
shape
::
float_type
,
{
nd
,
8
*
hs
}};
migraphx
::
shape
sl_shape
{
migraphx
::
shape
::
int32_type
,
{
bs
}};
// no activation function specified
{
migraphx
::
program
p
;
auto
seq
=
p
.
add_parameter
(
"seq"
,
seq_shape
);
auto
w
=
p
.
add_parameter
(
"w"
,
w_shape
);
auto
r
=
p
.
add_parameter
(
"r"
,
r_shape
);
auto
und
=
p
.
add_instruction
(
migraphx
::
op
::
undefined
{});
auto
out_hs
=
p
.
add_instruction
(
migraphx
::
op
::
lstm
{
hs
,
{},
migraphx
::
op
::
rnn_direction
::
forward
,
clip
,
input_forget
},
seq
,
w
,
r
,
und
,
und
,
und
,
und
,
und
);
p
.
add_instruction
(
migraphx
::
op
::
rnn_last_output
{},
out_hs
);
p
.
add_instruction
(
migraphx
::
op
::
lstm_last_cell_output
{},
out_hs
);
auto
prog
=
migraphx
::
parse_onnx
(
"onnx_lstm_f0af.onnx"
);
EXPECT
(
p
==
prog
);
}
// 1 activation function specified
{
migraphx
::
program
p
;
auto
seq
=
p
.
add_parameter
(
"seq"
,
seq_shape
);
auto
w
=
p
.
add_parameter
(
"w"
,
w_shape
);
auto
r
=
p
.
add_parameter
(
"r"
,
r_shape
);
auto
bias
=
p
.
add_parameter
(
"bias"
,
bias_shape
);
auto
und
=
p
.
add_instruction
(
migraphx
::
op
::
undefined
{});
auto
out_hs
=
p
.
add_instruction
(
migraphx
::
op
::
lstm
{
hs
,
{
migraphx
::
op
::
sigmoid
{}},
migraphx
::
op
::
rnn_direction
::
forward
,
clip
,
input_forget
},
seq
,
w
,
r
,
bias
,
und
,
und
,
und
,
und
);
p
.
add_instruction
(
migraphx
::
op
::
rnn_last_output
{},
out_hs
);
p
.
add_instruction
(
migraphx
::
op
::
lstm_last_cell_output
{},
out_hs
);
auto
prog
=
migraphx
::
parse_onnx
(
"onnx_lstm_f1af.onnx"
);
EXPECT
(
p
==
prog
);
}
// 2 activation function specified
{
migraphx
::
program
p
;
auto
seq
=
p
.
add_parameter
(
"seq"
,
seq_shape
);
auto
w
=
p
.
add_parameter
(
"w"
,
w_shape
);
auto
r
=
p
.
add_parameter
(
"r"
,
r_shape
);
auto
bias
=
p
.
add_parameter
(
"bias"
,
bias_shape
);
auto
seq_len
=
p
.
add_parameter
(
"seq_len"
,
sl_shape
);
auto
und
=
p
.
add_instruction
(
migraphx
::
op
::
undefined
{});
auto
out_hs
=
p
.
add_instruction
(
migraphx
::
op
::
lstm
{
hs
,
{
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
sigmoid
{}},
migraphx
::
op
::
rnn_direction
::
forward
,
clip
,
input_forget
},
seq
,
w
,
r
,
bias
,
seq_len
,
und
,
und
,
und
);
p
.
add_instruction
(
migraphx
::
op
::
rnn_last_output
{},
out_hs
);
p
.
add_instruction
(
migraphx
::
op
::
lstm_last_cell_output
{},
out_hs
);
auto
prog
=
migraphx
::
parse_onnx
(
"onnx_lstm_f2af.onnx"
);
EXPECT
(
p
==
prog
);
}
}
TEST_CASE
(
lstm_reverse
)
{
std
::
size_t
sl
=
5
;
// sequence len
...
...
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