Unverified Commit 8d21fdc9 authored by Paul Fultz II's avatar Paul Fultz II Committed by GitHub
Browse files

Refactor to use make_op almost everywhere (#696)

* Load op when serializing

* Formatting

* Add missing clip field

* Use make_op almost everywhere

* Formatting

* More make ops for rnns

* Get rid of spaces

* Formatting

* Remove operators headers

* Formatting

* Remove unused op headers

* Increase line threshold
parent b5633c27
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include "verify_program.hpp" #include "verify_program.hpp"
#include <migraphx/program.hpp> #include <migraphx/program.hpp>
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/operators.hpp> #include <migraphx/make_op.hpp>
struct test_greater : verify_program<test_greater> struct test_greater : verify_program<test_greater>
{ {
...@@ -14,7 +14,7 @@ struct test_greater : verify_program<test_greater> ...@@ -14,7 +14,7 @@ struct test_greater : verify_program<test_greater>
migraphx::shape s{migraphx::shape::double_type, {2, 3, 4, 6}}; migraphx::shape s{migraphx::shape::double_type, {2, 3, 4, 6}};
auto input1 = mm->add_parameter("x", s); auto input1 = mm->add_parameter("x", s);
auto input2 = mm->add_parameter("y", s); auto input2 = mm->add_parameter("y", s);
auto r = mm->add_instruction(migraphx::op::greater{}, input1, input2); auto r = mm->add_instruction(migraphx::make_op("greater"), input1, input2);
mm->add_return({r}); mm->add_return({r});
return p; return p;
}; };
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include "verify_program.hpp" #include "verify_program.hpp"
#include <migraphx/program.hpp> #include <migraphx/program.hpp>
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/operators.hpp> #include <migraphx/make_op.hpp>
struct test_greater_brcst : verify_program<test_greater_brcst> struct test_greater_brcst : verify_program<test_greater_brcst>
{ {
...@@ -14,8 +14,9 @@ struct test_greater_brcst : verify_program<test_greater_brcst> ...@@ -14,8 +14,9 @@ struct test_greater_brcst : verify_program<test_greater_brcst>
auto l0 = mm->add_parameter("x", s0); auto l0 = mm->add_parameter("x", s0);
migraphx::shape s1{migraphx::shape::float_type, {3, 1}}; migraphx::shape s1{migraphx::shape::float_type, {3, 1}};
auto l1 = mm->add_parameter("y", s1); auto l1 = mm->add_parameter("y", s1);
auto bl1 = mm->add_instruction(migraphx::op::multibroadcast{s0.lens()}, l1); auto bl1 = mm->add_instruction(
auto r = mm->add_instruction(migraphx::op::greater{}, l0, bl1); migraphx::make_op("multibroadcast", {{"output_lens", s0.lens()}}), l1);
auto r = mm->add_instruction(migraphx::make_op("greater"), l0, bl1);
mm->add_return({r}); mm->add_return({r});
return p; return p;
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
#include "verify_program.hpp" #include "verify_program.hpp"
#include <migraphx/program.hpp> #include <migraphx/program.hpp>
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/serialize.hpp>
#include <migraphx/operators.hpp> #include <migraphx/operators.hpp>
struct test_gru_bidirct : verify_program<test_gru_bidirct> struct test_gru_bidirct : verify_program<test_gru_bidirct>
...@@ -30,20 +34,24 @@ struct test_gru_bidirct : verify_program<test_gru_bidirct> ...@@ -30,20 +34,24 @@ struct test_gru_bidirct : verify_program<test_gru_bidirct>
auto r = mm->add_parameter("r", r_shape); auto r = mm->add_parameter("r", r_shape);
auto bias = mm->add_parameter("bias", b_shape); auto bias = mm->add_parameter("bias", b_shape);
auto ih = mm->add_parameter("ih", ih_shape); auto ih = mm->add_parameter("ih", ih_shape);
auto und = mm->add_instruction(migraphx::op::undefined{}); auto und = mm->add_instruction(migraphx::make_op("undefined"));
auto hs = auto hs = mm->add_instruction(
mm->add_instruction(migraphx::op::gru{hidden_size, migraphx::make_op(
{migraphx::op::sigmoid{}, migraphx::op::tanh{}}, "gru",
migraphx::op::rnn_direction::bidirectional, {{"hidden_size", hidden_size},
clip}, {"actv_func",
seq, migraphx::to_value(std::vector<migraphx::operation>{migraphx::make_op("sigmoid"),
w, migraphx::make_op("tanh")})},
r, {"direction", migraphx::to_value(migraphx::op::rnn_direction::bidirectional)},
bias, {"clip", clip}}),
und, seq,
ih); w,
auto lho = mm->add_instruction(migraphx::op::rnn_last_hs_output{}, hs); r,
bias,
und,
ih);
auto lho = mm->add_instruction(migraphx::make_op("rnn_last_hs_output"), hs);
mm->add_return({hs, lho}); mm->add_return({hs, lho});
return p; return p;
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
#include "verify_program.hpp" #include "verify_program.hpp"
#include <migraphx/program.hpp> #include <migraphx/program.hpp>
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/serialize.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/operators.hpp> #include <migraphx/operators.hpp>
struct test_gru_bidirct_3args : verify_program<test_gru_bidirct_3args> struct test_gru_bidirct_3args : verify_program<test_gru_bidirct_3args>
...@@ -25,13 +29,18 @@ struct test_gru_bidirct_3args : verify_program<test_gru_bidirct_3args> ...@@ -25,13 +29,18 @@ struct test_gru_bidirct_3args : verify_program<test_gru_bidirct_3args>
auto seq = mm->add_parameter("seq", in_shape); auto seq = mm->add_parameter("seq", in_shape);
auto w = mm->add_parameter("w", w_shape); auto w = mm->add_parameter("w", w_shape);
auto r = mm->add_parameter("r", r_shape); auto r = mm->add_parameter("r", r_shape);
mm->add_instruction(migraphx::op::gru{hidden_size, mm->add_instruction(
{migraphx::op::sigmoid{}, migraphx::op::tanh{}}, migraphx::make_op(
migraphx::op::rnn_direction::bidirectional, "gru",
clip}, {{"hidden_size", hidden_size},
seq, {"actv_func",
w, migraphx::to_value(std::vector<migraphx::operation>{migraphx::make_op("sigmoid"),
r); migraphx::make_op("tanh")})},
{"direction", migraphx::to_value(migraphx::op::rnn_direction::bidirectional)},
{"clip", clip}}),
seq,
w,
r);
return p; return p;
} }
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
#include "verify_program.hpp" #include "verify_program.hpp"
#include <migraphx/program.hpp> #include <migraphx/program.hpp>
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/serialize.hpp>
#include <migraphx/operators.hpp> #include <migraphx/operators.hpp>
struct test_gru_bidirct_3args_und : verify_program<test_gru_bidirct_3args_und> struct test_gru_bidirct_3args_und : verify_program<test_gru_bidirct_3args_und>
...@@ -25,17 +29,22 @@ struct test_gru_bidirct_3args_und : verify_program<test_gru_bidirct_3args_und> ...@@ -25,17 +29,22 @@ struct test_gru_bidirct_3args_und : verify_program<test_gru_bidirct_3args_und>
auto seq = mm->add_parameter("seq", in_shape); auto seq = mm->add_parameter("seq", in_shape);
auto w = mm->add_parameter("w", w_shape); auto w = mm->add_parameter("w", w_shape);
auto r = mm->add_parameter("r", r_shape); auto r = mm->add_parameter("r", r_shape);
auto und = mm->add_instruction(migraphx::op::undefined{}); auto und = mm->add_instruction(migraphx::make_op("undefined"));
mm->add_instruction(migraphx::op::gru{hidden_size, mm->add_instruction(
{migraphx::op::sigmoid{}, migraphx::op::tanh{}}, migraphx::make_op(
migraphx::op::rnn_direction::bidirectional, "gru",
clip}, {{"hidden_size", hidden_size},
seq, {"actv_func",
w, migraphx::to_value(std::vector<migraphx::operation>{migraphx::make_op("sigmoid"),
r, migraphx::make_op("tanh")})},
und, {"direction", migraphx::to_value(migraphx::op::rnn_direction::bidirectional)},
und, {"clip", clip}}),
und); seq,
w,
r,
und,
und,
und);
return p; return p;
} }
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
#include "verify_program.hpp" #include "verify_program.hpp"
#include <migraphx/program.hpp> #include <migraphx/program.hpp>
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/serialize.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/operators.hpp> #include <migraphx/operators.hpp>
struct test_gru_bidirct_default_actv : verify_program<test_gru_bidirct_default_actv> struct test_gru_bidirct_default_actv : verify_program<test_gru_bidirct_default_actv>
...@@ -26,7 +30,12 @@ struct test_gru_bidirct_default_actv : verify_program<test_gru_bidirct_default_a ...@@ -26,7 +30,12 @@ struct test_gru_bidirct_default_actv : verify_program<test_gru_bidirct_default_a
auto w = mm->add_parameter("w", w_shape); auto w = mm->add_parameter("w", w_shape);
auto r = mm->add_parameter("r", r_shape); auto r = mm->add_parameter("r", r_shape);
mm->add_instruction( mm->add_instruction(
migraphx::op::gru{hidden_size, {}, migraphx::op::rnn_direction::bidirectional, clip}, migraphx::make_op(
"gru",
{{"hidden_size", hidden_size},
{"actv_func", {}},
{"direction", migraphx::to_value(migraphx::op::rnn_direction::bidirectional)},
{"clip", clip}}),
seq, seq,
w, w,
r); r);
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
#include "verify_program.hpp" #include "verify_program.hpp"
#include <migraphx/program.hpp> #include <migraphx/program.hpp>
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/serialize.hpp>
#include <migraphx/operators.hpp> #include <migraphx/operators.hpp>
struct test_gru_bidirct_default_actv1 : verify_program<test_gru_bidirct_default_actv1> struct test_gru_bidirct_default_actv1 : verify_program<test_gru_bidirct_default_actv1>
...@@ -30,18 +34,23 @@ struct test_gru_bidirct_default_actv1 : verify_program<test_gru_bidirct_default_ ...@@ -30,18 +34,23 @@ struct test_gru_bidirct_default_actv1 : verify_program<test_gru_bidirct_default_
auto r = mm->add_parameter("r", r_shape); auto r = mm->add_parameter("r", r_shape);
auto bias = mm->add_parameter("bias", b_shape); auto bias = mm->add_parameter("bias", b_shape);
auto ih = mm->add_parameter("ih", ih_shape); auto ih = mm->add_parameter("ih", ih_shape);
auto und = mm->add_instruction(migraphx::op::undefined{}); auto und = mm->add_instruction(migraphx::make_op("undefined"));
mm->add_instruction(migraphx::op::gru{hidden_size, mm->add_instruction(
{migraphx::op::sigmoid{}}, migraphx::make_op(
migraphx::op::rnn_direction::bidirectional, "gru",
clip}, {{"hidden_size", hidden_size},
seq, {"actv_func",
w, migraphx::to_value(
r, std::vector<migraphx::operation>{migraphx::make_op("sigmoid")})},
bias, {"direction", migraphx::to_value(migraphx::op::rnn_direction::bidirectional)},
und, {"clip", clip}}),
ih); seq,
w,
r,
bias,
und,
ih);
return p; return p;
} }
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
#include "verify_program.hpp" #include "verify_program.hpp"
#include <migraphx/program.hpp> #include <migraphx/program.hpp>
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/serialize.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/operators.hpp> #include <migraphx/operators.hpp>
struct test_gru_bidirct_seq1 : verify_program<test_gru_bidirct_seq1> struct test_gru_bidirct_seq1 : verify_program<test_gru_bidirct_seq1>
...@@ -25,13 +29,18 @@ struct test_gru_bidirct_seq1 : verify_program<test_gru_bidirct_seq1> ...@@ -25,13 +29,18 @@ struct test_gru_bidirct_seq1 : verify_program<test_gru_bidirct_seq1>
auto seq = mm->add_parameter("seq", in_shape); auto seq = mm->add_parameter("seq", in_shape);
auto w = mm->add_parameter("w", w_shape); auto w = mm->add_parameter("w", w_shape);
auto r = mm->add_parameter("r", r_shape); auto r = mm->add_parameter("r", r_shape);
mm->add_instruction(migraphx::op::gru{hidden_size, mm->add_instruction(
{migraphx::op::sigmoid{}, migraphx::op::tanh{}}, migraphx::make_op(
migraphx::op::rnn_direction::bidirectional, "gru",
clip}, {{"hidden_size", hidden_size},
seq, {"actv_func",
w, migraphx::to_value(std::vector<migraphx::operation>{migraphx::make_op("sigmoid"),
r); migraphx::make_op("tanh")})},
{"direction", migraphx::to_value(migraphx::op::rnn_direction::bidirectional)},
{"clip", clip}}),
seq,
w,
r);
return p; return p;
} }
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
#include "verify_program.hpp" #include "verify_program.hpp"
#include <migraphx/program.hpp> #include <migraphx/program.hpp>
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/serialize.hpp>
#include <migraphx/operators.hpp> #include <migraphx/operators.hpp>
struct test_gru_forward : verify_program<test_gru_forward> struct test_gru_forward : verify_program<test_gru_forward>
...@@ -30,20 +34,24 @@ struct test_gru_forward : verify_program<test_gru_forward> ...@@ -30,20 +34,24 @@ struct test_gru_forward : verify_program<test_gru_forward>
auto r = mm->add_parameter("r", r_shape); auto r = mm->add_parameter("r", r_shape);
auto bias = mm->add_parameter("bias", b_shape); auto bias = mm->add_parameter("bias", b_shape);
auto ih = mm->add_parameter("ih", ih_shape); auto ih = mm->add_parameter("ih", ih_shape);
auto und = mm->add_instruction(migraphx::op::undefined{}); auto und = mm->add_instruction(migraphx::make_op("undefined"));
auto hs = auto hs = mm->add_instruction(
mm->add_instruction(migraphx::op::gru{hidden_size, migraphx::make_op(
{migraphx::op::sigmoid{}, migraphx::op::tanh{}}, "gru",
migraphx::op::rnn_direction::forward, {{"hidden_size", hidden_size},
clip}, {"actv_func",
seq, migraphx::to_value(std::vector<migraphx::operation>{migraphx::make_op("sigmoid"),
w, migraphx::make_op("tanh")})},
r, {"direction", migraphx::to_value(migraphx::op::rnn_direction::forward)},
bias, {"clip", clip}}),
und, seq,
ih); w,
auto lho = mm->add_instruction(migraphx::op::rnn_last_hs_output{}, hs); r,
bias,
und,
ih);
auto lho = mm->add_instruction(migraphx::make_op("rnn_last_hs_output"), hs);
mm->add_return({lho, hs}); mm->add_return({lho, hs});
return p; return p;
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
#include "verify_program.hpp" #include "verify_program.hpp"
#include <migraphx/program.hpp> #include <migraphx/program.hpp>
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/serialize.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/operators.hpp> #include <migraphx/operators.hpp>
struct test_gru_forward_3args : verify_program<test_gru_forward_3args> struct test_gru_forward_3args : verify_program<test_gru_forward_3args>
...@@ -25,13 +29,18 @@ struct test_gru_forward_3args : verify_program<test_gru_forward_3args> ...@@ -25,13 +29,18 @@ struct test_gru_forward_3args : verify_program<test_gru_forward_3args>
auto seq = mm->add_parameter("seq", in_shape); auto seq = mm->add_parameter("seq", in_shape);
auto w = mm->add_parameter("w", w_shape); auto w = mm->add_parameter("w", w_shape);
auto r = mm->add_parameter("r", r_shape); auto r = mm->add_parameter("r", r_shape);
mm->add_instruction(migraphx::op::gru{hidden_size, mm->add_instruction(
{migraphx::op::sigmoid{}, migraphx::op::tanh{}}, migraphx::make_op(
migraphx::op::rnn_direction::forward, "gru",
clip}, {{"hidden_size", hidden_size},
seq, {"actv_func",
w, migraphx::to_value(std::vector<migraphx::operation>{migraphx::make_op("sigmoid"),
r); migraphx::make_op("tanh")})},
{"direction", migraphx::to_value(migraphx::op::rnn_direction::forward)},
{"clip", clip}}),
seq,
w,
r);
return p; return p;
} }
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
#include "verify_program.hpp" #include "verify_program.hpp"
#include <migraphx/program.hpp> #include <migraphx/program.hpp>
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/serialize.hpp>
#include <migraphx/operators.hpp> #include <migraphx/operators.hpp>
struct test_gru_forward_3args_und : verify_program<test_gru_forward_3args_und> struct test_gru_forward_3args_und : verify_program<test_gru_forward_3args_und>
...@@ -25,17 +29,22 @@ struct test_gru_forward_3args_und : verify_program<test_gru_forward_3args_und> ...@@ -25,17 +29,22 @@ struct test_gru_forward_3args_und : verify_program<test_gru_forward_3args_und>
auto seq = mm->add_parameter("seq", in_shape); auto seq = mm->add_parameter("seq", in_shape);
auto w = mm->add_parameter("w", w_shape); auto w = mm->add_parameter("w", w_shape);
auto r = mm->add_parameter("r", r_shape); auto r = mm->add_parameter("r", r_shape);
auto und = mm->add_instruction(migraphx::op::undefined{}); auto und = mm->add_instruction(migraphx::make_op("undefined"));
mm->add_instruction(migraphx::op::gru{hidden_size, mm->add_instruction(
{migraphx::op::sigmoid{}, migraphx::op::tanh{}}, migraphx::make_op(
migraphx::op::rnn_direction::forward, "gru",
clip}, {{"hidden_size", hidden_size},
seq, {"actv_func",
w, migraphx::to_value(std::vector<migraphx::operation>{migraphx::make_op("sigmoid"),
r, migraphx::make_op("tanh")})},
und, {"direction", migraphx::to_value(migraphx::op::rnn_direction::forward)},
und, {"clip", clip}}),
und); seq,
w,
r,
und,
und,
und);
return p; return p;
} }
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
#include "verify_program.hpp" #include "verify_program.hpp"
#include <migraphx/program.hpp> #include <migraphx/program.hpp>
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/serialize.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/operators.hpp> #include <migraphx/operators.hpp>
struct test_gru_forward_default_actv : verify_program<test_gru_forward_default_actv> struct test_gru_forward_default_actv : verify_program<test_gru_forward_default_actv>
...@@ -26,7 +30,12 @@ struct test_gru_forward_default_actv : verify_program<test_gru_forward_default_a ...@@ -26,7 +30,12 @@ struct test_gru_forward_default_actv : verify_program<test_gru_forward_default_a
auto w = mm->add_parameter("w", w_shape); auto w = mm->add_parameter("w", w_shape);
auto r = mm->add_parameter("r", r_shape); auto r = mm->add_parameter("r", r_shape);
mm->add_instruction( mm->add_instruction(
migraphx::op::gru{hidden_size, {}, migraphx::op::rnn_direction::forward, clip}, migraphx::make_op(
"gru",
{{"hidden_size", hidden_size},
{"actv_func", {}},
{"direction", migraphx::to_value(migraphx::op::rnn_direction::forward)},
{"clip", clip}}),
seq, seq,
w, w,
r); r);
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
#include "verify_program.hpp" #include "verify_program.hpp"
#include <migraphx/program.hpp> #include <migraphx/program.hpp>
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/serialize.hpp>
#include <migraphx/operators.hpp> #include <migraphx/operators.hpp>
struct test_gru_forward_default_actv1 : verify_program<test_gru_forward_default_actv1> struct test_gru_forward_default_actv1 : verify_program<test_gru_forward_default_actv1>
...@@ -30,11 +34,17 @@ struct test_gru_forward_default_actv1 : verify_program<test_gru_forward_default_ ...@@ -30,11 +34,17 @@ struct test_gru_forward_default_actv1 : verify_program<test_gru_forward_default_
auto r = mm->add_parameter("r", r_shape); auto r = mm->add_parameter("r", r_shape);
auto bias = mm->add_parameter("bias", b_shape); auto bias = mm->add_parameter("bias", b_shape);
auto ih = mm->add_parameter("ih", ih_shape); auto ih = mm->add_parameter("ih", ih_shape);
auto und = mm->add_instruction(migraphx::op::undefined{}); auto und = mm->add_instruction(migraphx::make_op("undefined"));
mm->add_instruction( mm->add_instruction(
migraphx::op::gru{ migraphx::make_op(
hidden_size, {migraphx::op::sigmoid{}}, migraphx::op::rnn_direction::forward, clip}, "gru",
{{"hidden_size", hidden_size},
{"actv_func",
migraphx::to_value(
std::vector<migraphx::operation>{migraphx::make_op("sigmoid")})},
{"direction", migraphx::to_value(migraphx::op::rnn_direction::forward)},
{"clip", clip}}),
seq, seq,
w, w,
r, r,
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
#include "verify_program.hpp" #include "verify_program.hpp"
#include <migraphx/program.hpp> #include <migraphx/program.hpp>
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/serialize.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/operators.hpp> #include <migraphx/operators.hpp>
struct test_gru_forward_seq1 : verify_program<test_gru_forward_seq1> struct test_gru_forward_seq1 : verify_program<test_gru_forward_seq1>
...@@ -25,13 +29,18 @@ struct test_gru_forward_seq1 : verify_program<test_gru_forward_seq1> ...@@ -25,13 +29,18 @@ struct test_gru_forward_seq1 : verify_program<test_gru_forward_seq1>
auto seq = mm->add_parameter("seq", in_shape); auto seq = mm->add_parameter("seq", in_shape);
auto w = mm->add_parameter("w", w_shape); auto w = mm->add_parameter("w", w_shape);
auto r = mm->add_parameter("r", r_shape); auto r = mm->add_parameter("r", r_shape);
mm->add_instruction(migraphx::op::gru{hidden_size, mm->add_instruction(
{migraphx::op::sigmoid{}, migraphx::op::tanh{}}, migraphx::make_op(
migraphx::op::rnn_direction::forward, "gru",
clip}, {{"hidden_size", hidden_size},
seq, {"actv_func",
w, migraphx::to_value(std::vector<migraphx::operation>{migraphx::make_op("sigmoid"),
r); migraphx::make_op("tanh")})},
{"direction", migraphx::to_value(migraphx::op::rnn_direction::forward)},
{"clip", clip}}),
seq,
w,
r);
return p; return p;
} }
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
#include "verify_program.hpp" #include "verify_program.hpp"
#include <migraphx/program.hpp> #include <migraphx/program.hpp>
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/serialize.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/operators.hpp> #include <migraphx/operators.hpp>
struct test_gru_reverse_3args : verify_program<test_gru_reverse_3args> struct test_gru_reverse_3args : verify_program<test_gru_reverse_3args>
...@@ -25,13 +29,18 @@ struct test_gru_reverse_3args : verify_program<test_gru_reverse_3args> ...@@ -25,13 +29,18 @@ struct test_gru_reverse_3args : verify_program<test_gru_reverse_3args>
auto seq = mm->add_parameter("seq", in_shape); auto seq = mm->add_parameter("seq", in_shape);
auto w = mm->add_parameter("w", w_shape); auto w = mm->add_parameter("w", w_shape);
auto r = mm->add_parameter("r", r_shape); auto r = mm->add_parameter("r", r_shape);
mm->add_instruction(migraphx::op::gru{hidden_size, mm->add_instruction(
{migraphx::op::sigmoid{}, migraphx::op::tanh{}}, migraphx::make_op(
migraphx::op::rnn_direction::reverse, "gru",
clip}, {{"hidden_size", hidden_size},
seq, {"actv_func",
w, migraphx::to_value(std::vector<migraphx::operation>{migraphx::make_op("sigmoid"),
r); migraphx::make_op("tanh")})},
{"direction", migraphx::to_value(migraphx::op::rnn_direction::reverse)},
{"clip", clip}}),
seq,
w,
r);
return p; return p;
} }
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
#include "verify_program.hpp" #include "verify_program.hpp"
#include <migraphx/program.hpp> #include <migraphx/program.hpp>
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/serialize.hpp>
#include <migraphx/operators.hpp> #include <migraphx/operators.hpp>
struct test_gru_reverse_last : verify_program<test_gru_reverse_last> struct test_gru_reverse_last : verify_program<test_gru_reverse_last>
...@@ -30,20 +34,24 @@ struct test_gru_reverse_last : verify_program<test_gru_reverse_last> ...@@ -30,20 +34,24 @@ struct test_gru_reverse_last : verify_program<test_gru_reverse_last>
auto r = mm->add_parameter("r", r_shape); auto r = mm->add_parameter("r", r_shape);
auto bias = mm->add_parameter("bias", b_shape); auto bias = mm->add_parameter("bias", b_shape);
auto ih = mm->add_parameter("ih", ih_shape); auto ih = mm->add_parameter("ih", ih_shape);
auto und = mm->add_instruction(migraphx::op::undefined{}); auto und = mm->add_instruction(migraphx::make_op("undefined"));
auto output = auto output = mm->add_instruction(
mm->add_instruction(migraphx::op::gru{hidden_size, migraphx::make_op(
{migraphx::op::sigmoid{}, migraphx::op::tanh{}}, "gru",
migraphx::op::rnn_direction::reverse, {{"hidden_size", hidden_size},
clip}, {"actv_func",
seq, migraphx::to_value(std::vector<migraphx::operation>{migraphx::make_op("sigmoid"),
w, migraphx::make_op("tanh")})},
r, {"direction", migraphx::to_value(migraphx::op::rnn_direction::reverse)},
bias, {"clip", clip}}),
und, seq,
ih); w,
mm->add_instruction(migraphx::op::rnn_last_hs_output{}, output); r,
bias,
und,
ih);
mm->add_instruction(migraphx::make_op("rnn_last_hs_output"), output);
return p; return p;
} }
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
#include "verify_program.hpp" #include "verify_program.hpp"
#include <migraphx/program.hpp> #include <migraphx/program.hpp>
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/serialize.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/operators.hpp> #include <migraphx/operators.hpp>
struct test_gru_two_outputs : verify_program<test_gru_two_outputs> struct test_gru_two_outputs : verify_program<test_gru_two_outputs>
...@@ -26,11 +30,16 @@ struct test_gru_two_outputs : verify_program<test_gru_two_outputs> ...@@ -26,11 +30,16 @@ struct test_gru_two_outputs : verify_program<test_gru_two_outputs>
auto w = mm->add_parameter("w", w_shape); auto w = mm->add_parameter("w", w_shape);
auto r = mm->add_parameter("r", r_shape); auto r = mm->add_parameter("r", r_shape);
auto hs = mm->add_instruction( auto hs = mm->add_instruction(
migraphx::op::gru{hidden_size, {}, migraphx::op::rnn_direction::forward, clip}, migraphx::make_op(
"gru",
{{"hidden_size", hidden_size},
{"actv_func", {}},
{"direction", migraphx::to_value(migraphx::op::rnn_direction::forward)},
{"clip", clip}}),
seq, seq,
w, w,
r); r);
auto last_hs = mm->add_instruction(migraphx::op::rnn_last_hs_output{}, hs); auto last_hs = mm->add_instruction(migraphx::make_op("rnn_last_hs_output"), hs);
mm->add_return({hs, last_hs}); mm->add_return({hs, last_hs});
return p; return p;
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
#include "verify_program.hpp" #include "verify_program.hpp"
#include <migraphx/program.hpp> #include <migraphx/program.hpp>
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/operators.hpp> #include <migraphx/operators.hpp>
migraphx::instruction_ref migraphx::instruction_ref
...@@ -14,22 +16,27 @@ add_layernorm(migraphx::module& m, migraphx::instruction_ref x, std::vector<size ...@@ -14,22 +16,27 @@ add_layernorm(migraphx::module& m, migraphx::instruction_ref x, std::vector<size
auto epsilon = m.add_literal(1e-12f); auto epsilon = m.add_literal(1e-12f);
auto exponent = m.add_literal(2.0f); auto exponent = m.add_literal(2.0f);
auto mean = m.add_instruction(migraphx::op::reduce_mean({2}), x); auto mean = m.add_instruction(migraphx::op::reduce_mean({2}), x);
auto mean_mbcast = m.add_instruction(migraphx::op::multibroadcast{{dims}}, mean); auto mean_mbcast =
auto sub = m.add_instruction(migraphx::op::sub{}, x, mean_mbcast); m.add_instruction(migraphx::make_op("multibroadcast", {{"output_lens", dims}}), mean);
auto exponent_mbcast = m.add_instruction(migraphx::op::multibroadcast{{dims}}, exponent); auto sub = m.add_instruction(migraphx::make_op("sub"), x, mean_mbcast);
auto pow = m.add_instruction(migraphx::op::pow{}, sub, exponent_mbcast); auto exponent_mbcast =
auto var = m.add_instruction(migraphx::op::reduce_mean({2}), pow); m.add_instruction(migraphx::make_op("multibroadcast", {{"output_lens", dims}}), exponent);
auto epsilon_mbcast = auto pow = m.add_instruction(migraphx::make_op("pow"), sub, exponent_mbcast);
m.add_instruction(migraphx::op::multibroadcast{{1, dims.at(1), 1}}, epsilon); auto var = m.add_instruction(migraphx::op::reduce_mean({2}), pow);
auto add_epsilon = m.add_instruction(migraphx::op::add{}, var, epsilon_mbcast); auto epsilon_mbcast = m.add_instruction(
auto sqrt = m.add_instruction(migraphx::op::sqrt{}, add_epsilon); migraphx::make_op("multibroadcast", {{"output_lens", {1, dims.at(1), 1}}}), epsilon);
auto sqrt_mbcast = m.add_instruction(migraphx::op::multibroadcast{dims}, sqrt); auto add_epsilon = m.add_instruction(migraphx::make_op("add"), var, epsilon_mbcast);
auto div = m.add_instruction(migraphx::op::div{}, sub, sqrt_mbcast); auto sqrt = m.add_instruction(migraphx::make_op("sqrt"), add_epsilon);
auto scale_mbcast = m.add_instruction(migraphx::op::multibroadcast{dims}, scale); auto sqrt_mbcast =
auto mul = m.add_instruction(migraphx::op::mul{}, scale_mbcast, div); m.add_instruction(migraphx::make_op("multibroadcast", {{"output_lens", dims}}), sqrt);
auto bias_mbcast = m.add_instruction(migraphx::op::multibroadcast{dims}, bias); auto div = m.add_instruction(migraphx::make_op("div"), sub, sqrt_mbcast);
return m.add_instruction(migraphx::op::add{}, mul, bias_mbcast); auto scale_mbcast =
m.add_instruction(migraphx::make_op("multibroadcast", {{"output_lens", dims}}), scale);
auto mul = m.add_instruction(migraphx::make_op("mul"), scale_mbcast, div);
auto bias_mbcast =
m.add_instruction(migraphx::make_op("multibroadcast", {{"output_lens", dims}}), bias);
return m.add_instruction(migraphx::make_op("add"), mul, bias_mbcast);
} }
struct test_layernorm : verify_program<test_layernorm> struct test_layernorm : verify_program<test_layernorm>
...@@ -68,8 +75,8 @@ struct test_layernorm_triadd : verify_program<test_layernorm_triadd> ...@@ -68,8 +75,8 @@ struct test_layernorm_triadd : verify_program<test_layernorm_triadd>
auto x = mm->add_parameter("x", migraphx::shape{migraphx::shape::float_type, dims}); auto x = mm->add_parameter("x", migraphx::shape{migraphx::shape::float_type, dims});
auto y = mm->add_parameter("y", migraphx::shape{migraphx::shape::float_type, dims}); auto y = mm->add_parameter("y", migraphx::shape{migraphx::shape::float_type, dims});
auto z = mm->add_parameter("z", migraphx::shape{migraphx::shape::float_type, dims}); auto z = mm->add_parameter("z", migraphx::shape{migraphx::shape::float_type, dims});
auto add1 = mm->add_instruction(migraphx::op::add{}, x, y); auto add1 = mm->add_instruction(migraphx::make_op("add"), x, y);
auto add2 = mm->add_instruction(migraphx::op::add{}, add1, z); auto add2 = mm->add_instruction(migraphx::make_op("add"), add1, z);
add_layernorm(*mm, add2, dims); add_layernorm(*mm, add2, dims);
return p; return p;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include "verify_program.hpp" #include "verify_program.hpp"
#include <migraphx/program.hpp> #include <migraphx/program.hpp>
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/operators.hpp> #include <migraphx/make_op.hpp>
struct test_leaky_relu : verify_program<test_leaky_relu> struct test_leaky_relu : verify_program<test_leaky_relu>
{ {
...@@ -11,7 +11,7 @@ struct test_leaky_relu : verify_program<test_leaky_relu> ...@@ -11,7 +11,7 @@ struct test_leaky_relu : verify_program<test_leaky_relu>
migraphx::program p; migraphx::program p;
auto* mm = p.get_main_module(); auto* mm = p.get_main_module();
auto x = mm->add_parameter("x", migraphx::shape{migraphx::shape::float_type, {4, 3, 3, 3}}); auto x = mm->add_parameter("x", migraphx::shape{migraphx::shape::float_type, {4, 3, 3, 3}});
mm->add_instruction(migraphx::op::leaky_relu{0.01}, x); mm->add_instruction(migraphx::make_op("leaky_relu", {{"alpha", 0.01}}), x);
return p; return p;
} }
}; };
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include "verify_program.hpp" #include "verify_program.hpp"
#include <migraphx/program.hpp> #include <migraphx/program.hpp>
#include <migraphx/generate.hpp> #include <migraphx/generate.hpp>
#include <migraphx/operators.hpp> #include <migraphx/make_op.hpp>
struct test_less : verify_program<test_less> struct test_less : verify_program<test_less>
{ {
...@@ -14,7 +14,7 @@ struct test_less : verify_program<test_less> ...@@ -14,7 +14,7 @@ struct test_less : verify_program<test_less>
migraphx::shape s{migraphx::shape::double_type, {2, 3, 4, 6}}; migraphx::shape s{migraphx::shape::double_type, {2, 3, 4, 6}};
auto input1 = mm->add_parameter("x", s); auto input1 = mm->add_parameter("x", s);
auto input2 = mm->add_parameter("y", s); auto input2 = mm->add_parameter("y", s);
auto r = mm->add_instruction(migraphx::op::less{}, input1, input2); auto r = mm->add_instruction(migraphx::make_op("less"), input1, input2);
mm->add_return({r}); mm->add_return({r});
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