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
5866f279
Commit
5866f279
authored
Feb 02, 2019
by
Shucai Xiao
Browse files
add two more test cases for better code coverage.
parent
803e0a6d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
0 deletions
+92
-0
test/cpu_ops_test.cpp
test/cpu_ops_test.cpp
+58
-0
test/gpu/miopen.cpp
test/gpu/miopen.cpp
+34
-0
No files found.
test/cpu_ops_test.cpp
View file @
5866f279
...
@@ -1793,6 +1793,64 @@ TEST_CASE(rnn_bidirectional)
...
@@ -1793,6 +1793,64 @@ TEST_CASE(rnn_bidirectional)
std
::
vector
<
float
>
last_output_data
;
std
::
vector
<
float
>
last_output_data
;
last_output
.
visit
([
&
](
auto
out
)
{
last_output_data
.
assign
(
out
.
begin
(),
out
.
end
());
});
last_output
.
visit
([
&
](
auto
out
)
{
last_output_data
.
assign
(
out
.
begin
(),
out
.
end
());
});
std
::
vector
<
float
>
last_output_data_gold
{
0.03445704
,
0.19167931
,
-
0.3946827
,
-
0.30889652
,
-
0.22276389
,
0.44193283
,
-
0.16477929
,
-
0.11893477
,
-
0.29385301
,
0.16796815
,
0.51075965
,
0.40258689
,
-
0.13818839
,
0.44124447
,
0.14365635
,
0.14803654
};
EXPECT
(
migraphx
::
verify_range
(
last_output_data
,
last_output_data_gold
));
}
{
std
::
vector
<
float
>
ih_data
(
num_dirct
*
batch_size
*
hidden_size
,
0
);
migraphx
::
program
p
;
migraphx
::
shape
in_shape
{
migraphx
::
shape
::
float_type
,
{
seq_len
,
batch_size
,
input_size
}};
auto
seq
=
p
.
add_literal
(
migraphx
::
literal
{
in_shape
,
input
});
auto
w_data
=
wf_data
;
w_data
.
insert
(
w_data
.
end
(),
wr_data
.
begin
(),
wr_data
.
end
());
migraphx
::
shape
w_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
hidden_size
,
input_size
}};
auto
w
=
p
.
add_literal
(
migraphx
::
literal
{
w_shape
,
w_data
});
auto
r_data
=
rf_data
;
r_data
.
insert
(
r_data
.
end
(),
rr_data
.
begin
(),
rr_data
.
end
());
migraphx
::
shape
r_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
hidden_size
,
hidden_size
}};
auto
r
=
p
.
add_literal
(
migraphx
::
literal
{
r_shape
,
r_data
});
auto
bias_data
=
biasf_data
;
bias_data
.
insert
(
bias_data
.
end
(),
biasr_data
.
begin
(),
biasr_data
.
end
());
migraphx
::
shape
b_shape
{
migraphx
::
shape
::
float_type
,
{
num_dirct
,
2
*
hidden_size
}};
auto
bias
=
p
.
add_literal
(
migraphx
::
literal
{
b_shape
,
bias_data
});
auto
out_hs
=
p
.
add_instruction
(
migraphx
::
op
::
rnn
{
hidden_size
,
{
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
rnn
::
bidirectional
,
clip
},
seq
,
w
,
r
,
bias
);
p
.
add_instruction
(
migraphx
::
op
::
rnn_last_output
{},
out_hs
);
p
.
compile
(
migraphx
::
cpu
::
target
{});
auto
last_output
=
p
.
eval
({});
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.03445704
,
std
::
vector
<
float
>
last_output_data_gold
{
0.03445704
,
0.19167931
,
0.19167931
,
-
0.3946827
,
-
0.3946827
,
...
...
test/gpu/miopen.cpp
View file @
5866f279
...
@@ -1437,6 +1437,40 @@ struct test_rnn_bidirectional10
...
@@ -1437,6 +1437,40 @@ struct test_rnn_bidirectional10
}
}
};
};
struct
test_rnn_bi_3args
{
migraphx
::
program
create_program
()
const
{
std
::
size_t
batch_size
=
2
;
std
::
size_t
seq_len
=
10
;
std
::
size_t
hidden_size
=
4
;
std
::
size_t
input_size
=
3
;
std
::
size_t
num_dirct
=
2
;
float
clip
=
0.0
f
;
migraphx
::
program
p
;
migraphx
::
shape
in_shape
{
migraphx
::
shape
::
float_type
,
{
seq_len
,
batch_size
,
input_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
}};
auto
seq
=
p
.
add_parameter
(
"seq"
,
in_shape
);
auto
w
=
p
.
add_parameter
(
"w"
,
w_shape
);
auto
r
=
p
.
add_parameter
(
"r"
,
r_shape
);
auto
output
=
p
.
add_instruction
(
migraphx
::
op
::
rnn
{
hidden_size
,
{
migraphx
::
op
::
tanh
{},
migraphx
::
op
::
tanh
{}},
migraphx
::
op
::
rnn
::
bidirectional
,
clip
},
seq
,
w
,
r
);
p
.
add_instruction
(
migraphx
::
op
::
rnn_last_output
{},
output
);
return
p
;
}
};
int
main
()
int
main
()
{
{
verify_program
<
test_pooling_autopad
>
();
verify_program
<
test_pooling_autopad
>
();
...
...
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