"docs/source/en/model_doc/fnet.md" did not exist on "d0422de5634d3b14ac5159d7f8a2ab9336821d22"
Unverified Commit 2466dd6f authored by Shucai Xiao's avatar Shucai Xiao Committed by GitHub
Browse files

Refactor program to module (#684)



* code backup

* clang format

* change corresponding tool files

* clang format
Co-authored-by: default avatarmvermeulen <5479696+mvermeulen@users.noreply.github.com>
parent de10423f
...@@ -16,6 +16,7 @@ struct test_lstm_bidirct_default_actv2 : verify_program<test_lstm_bidirct_defaul ...@@ -16,6 +16,7 @@ struct test_lstm_bidirct_default_actv2 : verify_program<test_lstm_bidirct_defaul
float clip = 0.0f; float clip = 0.0f;
migraphx::program p; migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape in_shape{migraphx::shape::float_type, {seq_len, batch_size, input_size}}; migraphx::shape in_shape{migraphx::shape::float_type, {seq_len, batch_size, input_size}};
migraphx::shape w_shape{migraphx::shape::float_type, migraphx::shape w_shape{migraphx::shape::float_type,
{num_dirct, 4 * hidden_size, input_size}}; {num_dirct, 4 * hidden_size, input_size}};
...@@ -24,23 +25,23 @@ struct test_lstm_bidirct_default_actv2 : verify_program<test_lstm_bidirct_defaul ...@@ -24,23 +25,23 @@ struct test_lstm_bidirct_default_actv2 : verify_program<test_lstm_bidirct_defaul
migraphx::shape b_shape{migraphx::shape::float_type, {num_dirct, 8 * hidden_size}}; migraphx::shape b_shape{migraphx::shape::float_type, {num_dirct, 8 * hidden_size}};
migraphx::shape ih_shape{migraphx::shape::float_type, {num_dirct, batch_size, hidden_size}}; migraphx::shape ih_shape{migraphx::shape::float_type, {num_dirct, batch_size, hidden_size}};
auto seq = p.add_parameter("seq", in_shape); auto seq = mm->add_parameter("seq", in_shape);
auto w = p.add_parameter("w", w_shape); auto w = mm->add_parameter("w", w_shape);
auto r = p.add_parameter("r", r_shape); auto r = mm->add_parameter("r", r_shape);
auto bias = p.add_parameter("bias", b_shape); auto bias = mm->add_parameter("bias", b_shape);
auto ih = p.add_parameter("ih", ih_shape); auto ih = mm->add_parameter("ih", ih_shape);
auto und = p.add_instruction(migraphx::op::undefined{}); auto und = mm->add_instruction(migraphx::op::undefined{});
p.add_instruction(migraphx::op::lstm{hidden_size, mm->add_instruction(migraphx::op::lstm{hidden_size,
{migraphx::op::tanh{}, migraphx::op::sigmoid{}}, {migraphx::op::tanh{}, migraphx::op::sigmoid{}},
migraphx::op::rnn_direction::bidirectional, migraphx::op::rnn_direction::bidirectional,
clip}, clip},
seq, seq,
w, w,
r, r,
bias, bias,
und, und,
ih); ih);
return p; return p;
} }
......
...@@ -16,6 +16,7 @@ struct test_lstm_bidirct_hs : verify_program<test_lstm_bidirct_hs> ...@@ -16,6 +16,7 @@ struct test_lstm_bidirct_hs : verify_program<test_lstm_bidirct_hs>
float clip = 0.0f; float clip = 0.0f;
migraphx::program p; migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape in_shape{migraphx::shape::float_type, {seq_len, batch_size, input_size}}; migraphx::shape in_shape{migraphx::shape::float_type, {seq_len, batch_size, input_size}};
migraphx::shape w_shape{migraphx::shape::float_type, migraphx::shape w_shape{migraphx::shape::float_type,
{num_dirct, 4 * hidden_size, input_size}}; {num_dirct, 4 * hidden_size, input_size}};
...@@ -25,24 +26,24 @@ struct test_lstm_bidirct_hs : verify_program<test_lstm_bidirct_hs> ...@@ -25,24 +26,24 @@ struct test_lstm_bidirct_hs : verify_program<test_lstm_bidirct_hs>
migraphx::shape ih_shape{migraphx::shape::float_type, {num_dirct, batch_size, hidden_size}}; migraphx::shape ih_shape{migraphx::shape::float_type, {num_dirct, batch_size, hidden_size}};
migraphx::shape sl_shape{migraphx::shape::int32_type, {batch_size}}; migraphx::shape sl_shape{migraphx::shape::int32_type, {batch_size}};
auto seq = p.add_parameter("seq", in_shape); auto seq = mm->add_parameter("seq", in_shape);
auto w = p.add_parameter("w", w_shape); auto w = mm->add_parameter("w", w_shape);
auto r = p.add_parameter("r", r_shape); auto r = mm->add_parameter("r", r_shape);
auto bias = p.add_parameter("bias", b_shape); auto bias = mm->add_parameter("bias", b_shape);
auto ih = p.add_parameter("ih", ih_shape); auto ih = mm->add_parameter("ih", ih_shape);
std::vector<int> sl_data{3, 2}; std::vector<int> sl_data{3, 2};
auto sql = p.add_literal(migraphx::literal{migraphx::literal{sl_shape, sl_data}}); auto sql = mm->add_literal(migraphx::literal{migraphx::literal{sl_shape, sl_data}});
p.add_instruction(migraphx::op::lstm{hidden_size, mm->add_instruction(migraphx::op::lstm{hidden_size,
{migraphx::op::sigmoid{}, migraphx::op::tanh{}}, {migraphx::op::sigmoid{}, migraphx::op::tanh{}},
migraphx::op::rnn_direction::bidirectional, migraphx::op::rnn_direction::bidirectional,
clip}, clip},
seq, seq,
w, w,
r, r,
bias, bias,
sql, sql,
ih); ih);
return p; return p;
} }
......
...@@ -16,6 +16,7 @@ struct test_lstm_bidirct_last : verify_program<test_lstm_bidirct_last> ...@@ -16,6 +16,7 @@ struct test_lstm_bidirct_last : verify_program<test_lstm_bidirct_last>
float clip = 0.0f; float clip = 0.0f;
migraphx::program p; migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape in_shape{migraphx::shape::float_type, {seq_len, batch_size, input_size}}; migraphx::shape in_shape{migraphx::shape::float_type, {seq_len, batch_size, input_size}};
migraphx::shape w_shape{migraphx::shape::float_type, migraphx::shape w_shape{migraphx::shape::float_type,
{num_dirct, 4 * hidden_size, input_size}}; {num_dirct, 4 * hidden_size, input_size}};
...@@ -26,16 +27,16 @@ struct test_lstm_bidirct_last : verify_program<test_lstm_bidirct_last> ...@@ -26,16 +27,16 @@ struct test_lstm_bidirct_last : verify_program<test_lstm_bidirct_last>
migraphx::shape ic_shape{migraphx::shape::float_type, {num_dirct, batch_size, hidden_size}}; migraphx::shape ic_shape{migraphx::shape::float_type, {num_dirct, batch_size, hidden_size}};
migraphx::shape pph_shape{migraphx::shape::float_type, {num_dirct, 3 * hidden_size}}; migraphx::shape pph_shape{migraphx::shape::float_type, {num_dirct, 3 * hidden_size}};
auto seq = p.add_parameter("seq", in_shape); auto seq = mm->add_parameter("seq", in_shape);
auto w = p.add_parameter("w", w_shape); auto w = mm->add_parameter("w", w_shape);
auto r = p.add_parameter("r", r_shape); auto r = mm->add_parameter("r", r_shape);
auto bias = p.add_parameter("bias", b_shape); auto bias = mm->add_parameter("bias", b_shape);
auto ih = p.add_parameter("ih", ih_shape); auto ih = mm->add_parameter("ih", ih_shape);
auto ic = p.add_parameter("ic", ic_shape); auto ic = mm->add_parameter("ic", ic_shape);
auto pph = p.add_parameter("pph", pph_shape); auto pph = mm->add_parameter("pph", pph_shape);
auto und = p.add_instruction(migraphx::op::undefined{}); auto und = mm->add_instruction(migraphx::op::undefined{});
auto output = p.add_instruction( auto output = mm->add_instruction(
migraphx::op::lstm{ migraphx::op::lstm{
hidden_size, hidden_size,
{migraphx::op::sigmoid{}, migraphx::op::tanh{}, migraphx::op::tanh{}}, {migraphx::op::sigmoid{}, migraphx::op::tanh{}, migraphx::op::tanh{}},
...@@ -49,7 +50,7 @@ struct test_lstm_bidirct_last : verify_program<test_lstm_bidirct_last> ...@@ -49,7 +50,7 @@ struct test_lstm_bidirct_last : verify_program<test_lstm_bidirct_last>
ih, ih,
ic, ic,
pph); pph);
p.add_instruction(migraphx::op::rnn_last_hs_output{}, output); mm->add_instruction(migraphx::op::rnn_last_hs_output{}, output);
return p; return p;
} }
......
...@@ -16,21 +16,22 @@ struct test_lstm_bidirct_seq1 : verify_program<test_lstm_bidirct_seq1> ...@@ -16,21 +16,22 @@ struct test_lstm_bidirct_seq1 : verify_program<test_lstm_bidirct_seq1>
float clip = 0.0f; float clip = 0.0f;
migraphx::program p; migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape in_shape{migraphx::shape::float_type, {seq_len, batch_size, input_size}}; migraphx::shape in_shape{migraphx::shape::float_type, {seq_len, batch_size, input_size}};
migraphx::shape w_shape{migraphx::shape::float_type, migraphx::shape w_shape{migraphx::shape::float_type,
{num_dirct, 4 * hidden_size, input_size}}; {num_dirct, 4 * hidden_size, input_size}};
migraphx::shape r_shape{migraphx::shape::float_type, migraphx::shape r_shape{migraphx::shape::float_type,
{num_dirct, 4 * hidden_size, hidden_size}}; {num_dirct, 4 * hidden_size, hidden_size}};
auto seq = p.add_parameter("seq", in_shape); auto seq = mm->add_parameter("seq", in_shape);
auto w = p.add_parameter("w", w_shape); auto w = mm->add_parameter("w", w_shape);
auto r = p.add_parameter("r", r_shape); auto r = mm->add_parameter("r", r_shape);
p.add_instruction(migraphx::op::lstm{hidden_size, mm->add_instruction(migraphx::op::lstm{hidden_size,
{migraphx::op::sigmoid{}, migraphx::op::tanh{}}, {migraphx::op::sigmoid{}, migraphx::op::tanh{}},
migraphx::op::rnn_direction::bidirectional, migraphx::op::rnn_direction::bidirectional,
clip}, clip},
seq, seq,
w, w,
r); r);
return p; return p;
} }
......
...@@ -16,15 +16,16 @@ struct test_lstm_forward_3args : verify_program<test_lstm_forward_3args> ...@@ -16,15 +16,16 @@ struct test_lstm_forward_3args : verify_program<test_lstm_forward_3args>
float clip = 0.0f; float clip = 0.0f;
migraphx::program p; migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape in_shape{migraphx::shape::float_type, {seq_len, batch_size, input_size}}; migraphx::shape in_shape{migraphx::shape::float_type, {seq_len, batch_size, input_size}};
migraphx::shape w_shape{migraphx::shape::float_type, migraphx::shape w_shape{migraphx::shape::float_type,
{num_dirct, 4 * hidden_size, input_size}}; {num_dirct, 4 * hidden_size, input_size}};
migraphx::shape r_shape{migraphx::shape::float_type, migraphx::shape r_shape{migraphx::shape::float_type,
{num_dirct, 4 * hidden_size, hidden_size}}; {num_dirct, 4 * hidden_size, hidden_size}};
auto seq = p.add_parameter("seq", in_shape); auto seq = mm->add_parameter("seq", in_shape);
auto w = p.add_parameter("w", w_shape); auto w = mm->add_parameter("w", w_shape);
auto r = p.add_parameter("r", r_shape); auto r = mm->add_parameter("r", r_shape);
p.add_instruction( mm->add_instruction(
migraphx::op::lstm{ migraphx::op::lstm{
hidden_size, hidden_size,
{migraphx::op::sigmoid{}, migraphx::op::tanh{}, migraphx::op::tanh{}}, {migraphx::op::sigmoid{}, migraphx::op::tanh{}, migraphx::op::tanh{}},
......
...@@ -16,16 +16,17 @@ struct test_lstm_forward_3args_und : verify_program<test_lstm_forward_3args_und> ...@@ -16,16 +16,17 @@ struct test_lstm_forward_3args_und : verify_program<test_lstm_forward_3args_und>
float clip = 0.0f; float clip = 0.0f;
migraphx::program p; migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape in_shape{migraphx::shape::float_type, {seq_len, batch_size, input_size}}; migraphx::shape in_shape{migraphx::shape::float_type, {seq_len, batch_size, input_size}};
migraphx::shape w_shape{migraphx::shape::float_type, migraphx::shape w_shape{migraphx::shape::float_type,
{num_dirct, 4 * hidden_size, input_size}}; {num_dirct, 4 * hidden_size, input_size}};
migraphx::shape r_shape{migraphx::shape::float_type, migraphx::shape r_shape{migraphx::shape::float_type,
{num_dirct, 4 * hidden_size, hidden_size}}; {num_dirct, 4 * hidden_size, hidden_size}};
auto seq = p.add_parameter("seq", in_shape); auto seq = mm->add_parameter("seq", in_shape);
auto w = p.add_parameter("w", w_shape); auto w = mm->add_parameter("w", w_shape);
auto r = p.add_parameter("r", r_shape); auto r = mm->add_parameter("r", r_shape);
auto und = p.add_instruction(migraphx::op::undefined{}); auto und = mm->add_instruction(migraphx::op::undefined{});
p.add_instruction( mm->add_instruction(
migraphx::op::lstm{ migraphx::op::lstm{
hidden_size, hidden_size,
{migraphx::op::sigmoid{}, migraphx::op::tanh{}, migraphx::op::tanh{}}, {migraphx::op::sigmoid{}, migraphx::op::tanh{}, migraphx::op::tanh{}},
......
...@@ -16,15 +16,16 @@ struct test_lstm_forward_default_actv : verify_program<test_lstm_forward_default ...@@ -16,15 +16,16 @@ struct test_lstm_forward_default_actv : verify_program<test_lstm_forward_default
float clip = 0.0f; float clip = 0.0f;
migraphx::program p; migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape in_shape{migraphx::shape::float_type, {seq_len, batch_size, input_size}}; migraphx::shape in_shape{migraphx::shape::float_type, {seq_len, batch_size, input_size}};
migraphx::shape w_shape{migraphx::shape::float_type, migraphx::shape w_shape{migraphx::shape::float_type,
{num_dirct, 4 * hidden_size, input_size}}; {num_dirct, 4 * hidden_size, input_size}};
migraphx::shape r_shape{migraphx::shape::float_type, migraphx::shape r_shape{migraphx::shape::float_type,
{num_dirct, 4 * hidden_size, hidden_size}}; {num_dirct, 4 * hidden_size, hidden_size}};
auto seq = p.add_parameter("seq", in_shape); auto seq = mm->add_parameter("seq", in_shape);
auto w = p.add_parameter("w", w_shape); auto w = mm->add_parameter("w", w_shape);
auto r = p.add_parameter("r", r_shape); auto r = mm->add_parameter("r", r_shape);
p.add_instruction( mm->add_instruction(
migraphx::op::lstm{hidden_size, {}, migraphx::op::rnn_direction::forward, clip}, migraphx::op::lstm{hidden_size, {}, migraphx::op::rnn_direction::forward, clip},
seq, seq,
w, w,
......
...@@ -16,6 +16,7 @@ struct test_lstm_forward_default_actv1 : verify_program<test_lstm_forward_defaul ...@@ -16,6 +16,7 @@ struct test_lstm_forward_default_actv1 : verify_program<test_lstm_forward_defaul
float clip = 0.0f; float clip = 0.0f;
migraphx::program p; migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape in_shape{migraphx::shape::float_type, {seq_len, batch_size, input_size}}; migraphx::shape in_shape{migraphx::shape::float_type, {seq_len, batch_size, input_size}};
migraphx::shape w_shape{migraphx::shape::float_type, migraphx::shape w_shape{migraphx::shape::float_type,
{num_dirct, 4 * hidden_size, input_size}}; {num_dirct, 4 * hidden_size, input_size}};
...@@ -24,14 +25,14 @@ struct test_lstm_forward_default_actv1 : verify_program<test_lstm_forward_defaul ...@@ -24,14 +25,14 @@ struct test_lstm_forward_default_actv1 : verify_program<test_lstm_forward_defaul
migraphx::shape b_shape{migraphx::shape::float_type, {num_dirct, 8 * hidden_size}}; migraphx::shape b_shape{migraphx::shape::float_type, {num_dirct, 8 * hidden_size}};
migraphx::shape ih_shape{migraphx::shape::float_type, {num_dirct, batch_size, hidden_size}}; migraphx::shape ih_shape{migraphx::shape::float_type, {num_dirct, batch_size, hidden_size}};
auto seq = p.add_parameter("seq", in_shape); auto seq = mm->add_parameter("seq", in_shape);
auto w = p.add_parameter("w", w_shape); auto w = mm->add_parameter("w", w_shape);
auto r = p.add_parameter("r", r_shape); auto r = mm->add_parameter("r", r_shape);
auto bias = p.add_parameter("bias", b_shape); auto bias = mm->add_parameter("bias", b_shape);
auto ih = p.add_parameter("ih", ih_shape); auto ih = mm->add_parameter("ih", ih_shape);
auto und = p.add_instruction(migraphx::op::undefined{}); auto und = mm->add_instruction(migraphx::op::undefined{});
p.add_instruction( mm->add_instruction(
migraphx::op::lstm{ migraphx::op::lstm{
hidden_size, {migraphx::op::sigmoid{}}, migraphx::op::rnn_direction::forward, clip}, hidden_size, {migraphx::op::sigmoid{}}, migraphx::op::rnn_direction::forward, clip},
seq, seq,
......
...@@ -16,6 +16,7 @@ struct test_lstm_forward_hs : verify_program<test_lstm_forward_hs> ...@@ -16,6 +16,7 @@ struct test_lstm_forward_hs : verify_program<test_lstm_forward_hs>
float clip = 0.0f; float clip = 0.0f;
migraphx::program p; migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape in_shape{migraphx::shape::float_type, {seq_len, batch_size, input_size}}; migraphx::shape in_shape{migraphx::shape::float_type, {seq_len, batch_size, input_size}};
migraphx::shape w_shape{migraphx::shape::float_type, migraphx::shape w_shape{migraphx::shape::float_type,
{num_dirct, 4 * hidden_size, input_size}}; {num_dirct, 4 * hidden_size, input_size}};
...@@ -26,16 +27,16 @@ struct test_lstm_forward_hs : verify_program<test_lstm_forward_hs> ...@@ -26,16 +27,16 @@ struct test_lstm_forward_hs : verify_program<test_lstm_forward_hs>
migraphx::shape ic_shape{migraphx::shape::float_type, {num_dirct, batch_size, hidden_size}}; migraphx::shape ic_shape{migraphx::shape::float_type, {num_dirct, batch_size, hidden_size}};
migraphx::shape pph_shape{migraphx::shape::float_type, {num_dirct, 3 * hidden_size}}; migraphx::shape pph_shape{migraphx::shape::float_type, {num_dirct, 3 * hidden_size}};
auto seq = p.add_parameter("seq", in_shape); auto seq = mm->add_parameter("seq", in_shape);
auto w = p.add_parameter("w", w_shape); auto w = mm->add_parameter("w", w_shape);
auto r = p.add_parameter("r", r_shape); auto r = mm->add_parameter("r", r_shape);
auto bias = p.add_parameter("bias", b_shape); auto bias = mm->add_parameter("bias", b_shape);
auto ih = p.add_parameter("ih", ih_shape); auto ih = mm->add_parameter("ih", ih_shape);
auto ic = p.add_parameter("ic", ic_shape); auto ic = mm->add_parameter("ic", ic_shape);
auto pph = p.add_parameter("pph", pph_shape); auto pph = mm->add_parameter("pph", pph_shape);
auto und = p.add_instruction(migraphx::op::undefined{}); auto und = mm->add_instruction(migraphx::op::undefined{});
p.add_instruction( mm->add_instruction(
migraphx::op::lstm{ migraphx::op::lstm{
hidden_size, hidden_size,
{migraphx::op::sigmoid{}, migraphx::op::tanh{}, migraphx::op::tanh{}}, {migraphx::op::sigmoid{}, migraphx::op::tanh{}, migraphx::op::tanh{}},
......
...@@ -16,6 +16,7 @@ struct test_lstm_forward_last : verify_program<test_lstm_forward_last> ...@@ -16,6 +16,7 @@ struct test_lstm_forward_last : verify_program<test_lstm_forward_last>
float clip = 0.0f; float clip = 0.0f;
migraphx::program p; migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape in_shape{migraphx::shape::float_type, {seq_len, batch_size, input_size}}; migraphx::shape in_shape{migraphx::shape::float_type, {seq_len, batch_size, input_size}};
migraphx::shape w_shape{migraphx::shape::float_type, migraphx::shape w_shape{migraphx::shape::float_type,
{num_dirct, 4 * hidden_size, input_size}}; {num_dirct, 4 * hidden_size, input_size}};
...@@ -27,16 +28,16 @@ struct test_lstm_forward_last : verify_program<test_lstm_forward_last> ...@@ -27,16 +28,16 @@ struct test_lstm_forward_last : verify_program<test_lstm_forward_last>
migraphx::shape ic_shape{migraphx::shape::float_type, {num_dirct, batch_size, hidden_size}}; migraphx::shape ic_shape{migraphx::shape::float_type, {num_dirct, batch_size, hidden_size}};
migraphx::shape pph_shape{migraphx::shape::float_type, {num_dirct, 3 * hidden_size}}; migraphx::shape pph_shape{migraphx::shape::float_type, {num_dirct, 3 * hidden_size}};
auto seq = p.add_parameter("seq", in_shape); auto seq = mm->add_parameter("seq", in_shape);
auto w = p.add_parameter("w", w_shape); auto w = mm->add_parameter("w", w_shape);
auto r = p.add_parameter("r", r_shape); auto r = mm->add_parameter("r", r_shape);
auto bias = p.add_parameter("bias", b_shape); auto bias = mm->add_parameter("bias", b_shape);
auto ih = p.add_parameter("ih", ih_shape); auto ih = mm->add_parameter("ih", ih_shape);
auto len = p.add_literal(migraphx::literal(l_shape, {1, 2})); auto len = mm->add_literal(migraphx::literal(l_shape, {1, 2}));
auto ic = p.add_parameter("ic", ic_shape); auto ic = mm->add_parameter("ic", ic_shape);
auto pph = p.add_parameter("pph", pph_shape); auto pph = mm->add_parameter("pph", pph_shape);
auto output = p.add_instruction( auto output = mm->add_instruction(
migraphx::op::lstm{ migraphx::op::lstm{
hidden_size, hidden_size,
{migraphx::op::sigmoid{}, migraphx::op::tanh{}, migraphx::op::tanh{}}, {migraphx::op::sigmoid{}, migraphx::op::tanh{}, migraphx::op::tanh{}},
...@@ -50,7 +51,7 @@ struct test_lstm_forward_last : verify_program<test_lstm_forward_last> ...@@ -50,7 +51,7 @@ struct test_lstm_forward_last : verify_program<test_lstm_forward_last>
ih, ih,
ic, ic,
pph); pph);
p.add_instruction(migraphx::op::rnn_last_hs_output{}, output, len); mm->add_instruction(migraphx::op::rnn_last_hs_output{}, output, len);
return p; return p;
} }
......
...@@ -16,15 +16,16 @@ struct test_lstm_forward_seq1 : verify_program<test_lstm_forward_seq1> ...@@ -16,15 +16,16 @@ struct test_lstm_forward_seq1 : verify_program<test_lstm_forward_seq1>
float clip = 0.0f; float clip = 0.0f;
migraphx::program p; migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape in_shape{migraphx::shape::float_type, {seq_len, batch_size, input_size}}; migraphx::shape in_shape{migraphx::shape::float_type, {seq_len, batch_size, input_size}};
migraphx::shape w_shape{migraphx::shape::float_type, migraphx::shape w_shape{migraphx::shape::float_type,
{num_dirct, 4 * hidden_size, input_size}}; {num_dirct, 4 * hidden_size, input_size}};
migraphx::shape r_shape{migraphx::shape::float_type, migraphx::shape r_shape{migraphx::shape::float_type,
{num_dirct, 4 * hidden_size, hidden_size}}; {num_dirct, 4 * hidden_size, hidden_size}};
auto seq = p.add_parameter("seq", in_shape); auto seq = mm->add_parameter("seq", in_shape);
auto w = p.add_parameter("w", w_shape); auto w = mm->add_parameter("w", w_shape);
auto r = p.add_parameter("r", r_shape); auto r = mm->add_parameter("r", r_shape);
p.add_instruction( mm->add_instruction(
migraphx::op::lstm{ migraphx::op::lstm{
hidden_size, hidden_size,
{migraphx::op::sigmoid{}, migraphx::op::tanh{}, migraphx::op::tanh{}}, {migraphx::op::sigmoid{}, migraphx::op::tanh{}, migraphx::op::tanh{}},
......
...@@ -16,15 +16,16 @@ struct test_lstm_reverse_3args : verify_program<test_lstm_reverse_3args> ...@@ -16,15 +16,16 @@ struct test_lstm_reverse_3args : verify_program<test_lstm_reverse_3args>
float clip = 0.0f; float clip = 0.0f;
migraphx::program p; migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape in_shape{migraphx::shape::float_type, {seq_len, batch_size, input_size}}; migraphx::shape in_shape{migraphx::shape::float_type, {seq_len, batch_size, input_size}};
migraphx::shape w_shape{migraphx::shape::float_type, migraphx::shape w_shape{migraphx::shape::float_type,
{num_dirct, 4 * hidden_size, input_size}}; {num_dirct, 4 * hidden_size, input_size}};
migraphx::shape r_shape{migraphx::shape::float_type, migraphx::shape r_shape{migraphx::shape::float_type,
{num_dirct, 4 * hidden_size, hidden_size}}; {num_dirct, 4 * hidden_size, hidden_size}};
auto seq = p.add_parameter("seq", in_shape); auto seq = mm->add_parameter("seq", in_shape);
auto w = p.add_parameter("w", w_shape); auto w = mm->add_parameter("w", w_shape);
auto r = p.add_parameter("r", r_shape); auto r = mm->add_parameter("r", r_shape);
p.add_instruction( mm->add_instruction(
migraphx::op::lstm{ migraphx::op::lstm{
hidden_size, hidden_size,
{migraphx::op::sigmoid{}, migraphx::op::tanh{}, migraphx::op::tanh{}}, {migraphx::op::sigmoid{}, migraphx::op::tanh{}, migraphx::op::tanh{}},
......
...@@ -16,15 +16,16 @@ struct test_lstm_reverse_3args_cell_output : verify_program<test_lstm_reverse_3a ...@@ -16,15 +16,16 @@ struct test_lstm_reverse_3args_cell_output : verify_program<test_lstm_reverse_3a
float clip = 0.0f; float clip = 0.0f;
migraphx::program p; migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape in_shape{migraphx::shape::float_type, {seq_len, batch_size, input_size}}; migraphx::shape in_shape{migraphx::shape::float_type, {seq_len, batch_size, input_size}};
migraphx::shape w_shape{migraphx::shape::float_type, migraphx::shape w_shape{migraphx::shape::float_type,
{num_dirct, 4 * hidden_size, input_size}}; {num_dirct, 4 * hidden_size, input_size}};
migraphx::shape r_shape{migraphx::shape::float_type, migraphx::shape r_shape{migraphx::shape::float_type,
{num_dirct, 4 * hidden_size, hidden_size}}; {num_dirct, 4 * hidden_size, hidden_size}};
auto seq = p.add_parameter("seq", in_shape); auto seq = mm->add_parameter("seq", in_shape);
auto w = p.add_parameter("w", w_shape); auto w = mm->add_parameter("w", w_shape);
auto r = p.add_parameter("r", r_shape); auto r = mm->add_parameter("r", r_shape);
auto hs = p.add_instruction( auto hs = mm->add_instruction(
migraphx::op::lstm{ migraphx::op::lstm{
hidden_size, hidden_size,
{migraphx::op::sigmoid{}, migraphx::op::tanh{}, migraphx::op::tanh{}}, {migraphx::op::sigmoid{}, migraphx::op::tanh{}, migraphx::op::tanh{}},
...@@ -33,7 +34,7 @@ struct test_lstm_reverse_3args_cell_output : verify_program<test_lstm_reverse_3a ...@@ -33,7 +34,7 @@ struct test_lstm_reverse_3args_cell_output : verify_program<test_lstm_reverse_3a
seq, seq,
w, w,
r); r);
p.add_instruction(migraphx::op::rnn_last_cell_output{}, hs); mm->add_instruction(migraphx::op::rnn_last_cell_output{}, hs);
return p; return p;
} }
......
...@@ -16,6 +16,7 @@ struct test_lstm_reverse_last : verify_program<test_lstm_reverse_last> ...@@ -16,6 +16,7 @@ struct test_lstm_reverse_last : verify_program<test_lstm_reverse_last>
float clip = 0.0f; float clip = 0.0f;
migraphx::program p; migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape in_shape{migraphx::shape::float_type, {seq_len, batch_size, input_size}}; migraphx::shape in_shape{migraphx::shape::float_type, {seq_len, batch_size, input_size}};
migraphx::shape w_shape{migraphx::shape::float_type, migraphx::shape w_shape{migraphx::shape::float_type,
{num_dirct, 4 * hidden_size, input_size}}; {num_dirct, 4 * hidden_size, input_size}};
...@@ -26,16 +27,16 @@ struct test_lstm_reverse_last : verify_program<test_lstm_reverse_last> ...@@ -26,16 +27,16 @@ struct test_lstm_reverse_last : verify_program<test_lstm_reverse_last>
migraphx::shape ic_shape{migraphx::shape::float_type, {num_dirct, batch_size, hidden_size}}; migraphx::shape ic_shape{migraphx::shape::float_type, {num_dirct, batch_size, hidden_size}};
migraphx::shape pph_shape{migraphx::shape::float_type, {num_dirct, 3 * hidden_size}}; migraphx::shape pph_shape{migraphx::shape::float_type, {num_dirct, 3 * hidden_size}};
auto seq = p.add_parameter("seq", in_shape); auto seq = mm->add_parameter("seq", in_shape);
auto w = p.add_parameter("w", w_shape); auto w = mm->add_parameter("w", w_shape);
auto r = p.add_parameter("r", r_shape); auto r = mm->add_parameter("r", r_shape);
auto bias = p.add_parameter("bias", b_shape); auto bias = mm->add_parameter("bias", b_shape);
auto ih = p.add_parameter("ih", ih_shape); auto ih = mm->add_parameter("ih", ih_shape);
auto ic = p.add_parameter("ic", ic_shape); auto ic = mm->add_parameter("ic", ic_shape);
auto pph = p.add_parameter("pph", pph_shape); auto pph = mm->add_parameter("pph", pph_shape);
auto und = p.add_instruction(migraphx::op::undefined{}); auto und = mm->add_instruction(migraphx::op::undefined{});
auto output = p.add_instruction( auto output = mm->add_instruction(
migraphx::op::lstm{ migraphx::op::lstm{
hidden_size, hidden_size,
{migraphx::op::sigmoid{}, migraphx::op::tanh{}, migraphx::op::tanh{}}, {migraphx::op::sigmoid{}, migraphx::op::tanh{}, migraphx::op::tanh{}},
...@@ -49,7 +50,7 @@ struct test_lstm_reverse_last : verify_program<test_lstm_reverse_last> ...@@ -49,7 +50,7 @@ struct test_lstm_reverse_last : verify_program<test_lstm_reverse_last>
ih, ih,
ic, ic,
pph); pph);
p.add_instruction(migraphx::op::rnn_last_hs_output{}, output); mm->add_instruction(migraphx::op::rnn_last_hs_output{}, output);
return p; return p;
} }
......
...@@ -16,15 +16,16 @@ struct test_lstm_three_outputs : verify_program<test_lstm_three_outputs> ...@@ -16,15 +16,16 @@ struct test_lstm_three_outputs : verify_program<test_lstm_three_outputs>
float clip = 0.0f; float clip = 0.0f;
migraphx::program p; migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape in_shape{migraphx::shape::float_type, {seq_len, batch_size, input_size}}; migraphx::shape in_shape{migraphx::shape::float_type, {seq_len, batch_size, input_size}};
migraphx::shape w_shape{migraphx::shape::float_type, migraphx::shape w_shape{migraphx::shape::float_type,
{num_dirct, 4 * hidden_size, input_size}}; {num_dirct, 4 * hidden_size, input_size}};
migraphx::shape r_shape{migraphx::shape::float_type, migraphx::shape r_shape{migraphx::shape::float_type,
{num_dirct, 4 * hidden_size, hidden_size}}; {num_dirct, 4 * hidden_size, hidden_size}};
auto seq = p.add_parameter("seq", in_shape); auto seq = mm->add_parameter("seq", in_shape);
auto w = p.add_parameter("w", w_shape); auto w = mm->add_parameter("w", w_shape);
auto r = p.add_parameter("r", r_shape); auto r = mm->add_parameter("r", r_shape);
auto hs = p.add_instruction( auto hs = mm->add_instruction(
migraphx::op::lstm{ migraphx::op::lstm{
hidden_size, hidden_size,
{migraphx::op::sigmoid{}, migraphx::op::tanh{}, migraphx::op::tanh{}}, {migraphx::op::sigmoid{}, migraphx::op::tanh{}, migraphx::op::tanh{}},
...@@ -33,9 +34,9 @@ struct test_lstm_three_outputs : verify_program<test_lstm_three_outputs> ...@@ -33,9 +34,9 @@ struct test_lstm_three_outputs : verify_program<test_lstm_three_outputs>
seq, seq,
w, w,
r); r);
auto last_hs = p.add_instruction(migraphx::op::rnn_last_hs_output{}, hs); auto last_hs = mm->add_instruction(migraphx::op::rnn_last_hs_output{}, hs);
auto last_cell = p.add_instruction(migraphx::op::rnn_last_cell_output{}, hs); auto last_cell = mm->add_instruction(migraphx::op::rnn_last_cell_output{}, hs);
p.add_return({hs, last_hs, last_cell}); mm->add_return({hs, last_hs, last_cell});
return p; return p;
} }
......
...@@ -16,15 +16,16 @@ struct test_lstm_two_outputs : verify_program<test_lstm_two_outputs> ...@@ -16,15 +16,16 @@ struct test_lstm_two_outputs : verify_program<test_lstm_two_outputs>
float clip = 0.0f; float clip = 0.0f;
migraphx::program p; migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape in_shape{migraphx::shape::float_type, {seq_len, batch_size, input_size}}; migraphx::shape in_shape{migraphx::shape::float_type, {seq_len, batch_size, input_size}};
migraphx::shape w_shape{migraphx::shape::float_type, migraphx::shape w_shape{migraphx::shape::float_type,
{num_dirct, 4 * hidden_size, input_size}}; {num_dirct, 4 * hidden_size, input_size}};
migraphx::shape r_shape{migraphx::shape::float_type, migraphx::shape r_shape{migraphx::shape::float_type,
{num_dirct, 4 * hidden_size, hidden_size}}; {num_dirct, 4 * hidden_size, hidden_size}};
auto seq = p.add_parameter("seq", in_shape); auto seq = mm->add_parameter("seq", in_shape);
auto w = p.add_parameter("w", w_shape); auto w = mm->add_parameter("w", w_shape);
auto r = p.add_parameter("r", r_shape); auto r = mm->add_parameter("r", r_shape);
auto hs = p.add_instruction( auto hs = mm->add_instruction(
migraphx::op::lstm{ migraphx::op::lstm{
hidden_size, hidden_size,
{migraphx::op::sigmoid{}, migraphx::op::tanh{}, migraphx::op::tanh{}}, {migraphx::op::sigmoid{}, migraphx::op::tanh{}, migraphx::op::tanh{}},
...@@ -33,8 +34,8 @@ struct test_lstm_two_outputs : verify_program<test_lstm_two_outputs> ...@@ -33,8 +34,8 @@ struct test_lstm_two_outputs : verify_program<test_lstm_two_outputs>
seq, seq,
w, w,
r); r);
auto last_hs = p.add_instruction(migraphx::op::rnn_last_hs_output{}, hs); auto last_hs = mm->add_instruction(migraphx::op::rnn_last_hs_output{}, hs);
p.add_return({hs, last_hs}); mm->add_return({hs, last_hs});
return p; return p;
} }
......
...@@ -9,10 +9,11 @@ struct test_max_pooling_ceil_3d : verify_program<test_max_pooling_ceil_3d> ...@@ -9,10 +9,11 @@ struct test_max_pooling_ceil_3d : verify_program<test_max_pooling_ceil_3d>
migraphx::program create_program() const migraphx::program create_program() const
{ {
migraphx::program p; migraphx::program p;
auto* mm = p.get_main_module();
auto input = auto input =
p.add_parameter("x", migraphx::shape{migraphx::shape::float_type, {1, 3, 5, 5, 5}}); mm->add_parameter("x", migraphx::shape{migraphx::shape::float_type, {1, 3, 5, 5, 5}});
auto op = migraphx::op::pooling{"max", {1, 1, 1}, {3, 3, 3}, {3, 3, 3}, true}; auto op = migraphx::op::pooling{"max", {1, 1, 1}, {3, 3, 3}, {3, 3, 3}, true};
p.add_instruction(op, input); mm->add_instruction(op, input);
return p; return p;
} }
}; };
...@@ -9,10 +9,11 @@ struct test_mul : verify_program<test_mul> ...@@ -9,10 +9,11 @@ struct test_mul : verify_program<test_mul>
migraphx::program create_program() const migraphx::program create_program() const
{ {
migraphx::program p; migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape s{migraphx::shape::float_type, {3}}; migraphx::shape s{migraphx::shape::float_type, {3}};
auto x = p.add_parameter("x", s); auto x = mm->add_parameter("x", s);
auto y = p.add_parameter("y", s); auto y = mm->add_parameter("y", s);
p.add_instruction(migraphx::op::mul{}, x, y); mm->add_instruction(migraphx::op::mul{}, x, y);
return p; return p;
} }
}; };
...@@ -9,15 +9,16 @@ struct test_mul_add : verify_program<test_mul_add> ...@@ -9,15 +9,16 @@ struct test_mul_add : verify_program<test_mul_add>
migraphx::program create_program() const migraphx::program create_program() const
{ {
migraphx::program p; migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape s{migraphx::shape::float_type, {2, 3}}; migraphx::shape s{migraphx::shape::float_type, {2, 3}};
migraphx::shape bs{migraphx::shape::float_type, {3}}; migraphx::shape bs{migraphx::shape::float_type, {3}};
auto x = p.add_parameter("x", s); auto x = mm->add_parameter("x", s);
auto a = p.add_parameter("a", bs); auto a = mm->add_parameter("a", bs);
auto b = p.add_parameter("b", bs); auto b = mm->add_parameter("b", bs);
auto ab = p.add_instruction(migraphx::op::broadcast{1, s.lens()}, a); auto ab = mm->add_instruction(migraphx::op::broadcast{1, s.lens()}, a);
auto bb = p.add_instruction(migraphx::op::broadcast{1, s.lens()}, b); auto bb = mm->add_instruction(migraphx::op::broadcast{1, s.lens()}, b);
auto mul = p.add_instruction(migraphx::op::mul{}, x, ab); auto mul = mm->add_instruction(migraphx::op::mul{}, x, ab);
p.add_instruction(migraphx::op::add{}, mul, bb); mm->add_instruction(migraphx::op::add{}, mul, bb);
return p; return p;
} }
}; };
...@@ -9,10 +9,11 @@ struct test_neg : verify_program<test_neg> ...@@ -9,10 +9,11 @@ struct test_neg : verify_program<test_neg>
migraphx::program create_program() const migraphx::program create_program() const
{ {
migraphx::program p; migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape s{migraphx::shape::double_type, {2, 3, 4, 6}}; migraphx::shape s{migraphx::shape::double_type, {2, 3, 4, 6}};
auto input = p.add_parameter("x", s); auto input = mm->add_parameter("x", s);
p.add_instruction(migraphx::op::neg{}, input); mm->add_instruction(migraphx::op::neg{}, input);
return p; return p;
}; };
}; };
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment