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 @@
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/operators.hpp>
#include <migraphx/make_op.hpp>
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}};
auto input1 = mm->add_parameter("x", 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});
return p;
};
......
......@@ -2,7 +2,7 @@
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/operators.hpp>
#include <migraphx/make_op.hpp>
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);
migraphx::shape s1{migraphx::shape::float_type, {3, 1}};
auto l1 = mm->add_parameter("y", s1);
auto bl1 = mm->add_instruction(migraphx::op::multibroadcast{s0.lens()}, l1);
auto r = mm->add_instruction(migraphx::op::greater{}, l0, bl1);
auto bl1 = mm->add_instruction(
migraphx::make_op("multibroadcast", {{"output_lens", s0.lens()}}), l1);
auto r = mm->add_instruction(migraphx::make_op("greater"), l0, bl1);
mm->add_return({r});
return p;
......
......@@ -2,6 +2,10 @@
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/serialize.hpp>
#include <migraphx/operators.hpp>
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 bias = mm->add_parameter("bias", b_shape);
auto ih = mm->add_parameter("ih", ih_shape);
auto und = mm->add_instruction(migraphx::op::undefined{});
auto hs =
mm->add_instruction(migraphx::op::gru{hidden_size,
{migraphx::op::sigmoid{}, migraphx::op::tanh{}},
migraphx::op::rnn_direction::bidirectional,
clip},
seq,
w,
r,
bias,
und,
ih);
auto lho = mm->add_instruction(migraphx::op::rnn_last_hs_output{}, hs);
auto und = mm->add_instruction(migraphx::make_op("undefined"));
auto hs = mm->add_instruction(
migraphx::make_op(
"gru",
{{"hidden_size", hidden_size},
{"actv_func",
migraphx::to_value(std::vector<migraphx::operation>{migraphx::make_op("sigmoid"),
migraphx::make_op("tanh")})},
{"direction", migraphx::to_value(migraphx::op::rnn_direction::bidirectional)},
{"clip", clip}}),
seq,
w,
r,
bias,
und,
ih);
auto lho = mm->add_instruction(migraphx::make_op("rnn_last_hs_output"), hs);
mm->add_return({hs, lho});
return p;
......
......@@ -2,6 +2,10 @@
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/serialize.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/operators.hpp>
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 w = mm->add_parameter("w", w_shape);
auto r = mm->add_parameter("r", r_shape);
mm->add_instruction(migraphx::op::gru{hidden_size,
{migraphx::op::sigmoid{}, migraphx::op::tanh{}},
migraphx::op::rnn_direction::bidirectional,
clip},
seq,
w,
r);
mm->add_instruction(
migraphx::make_op(
"gru",
{{"hidden_size", hidden_size},
{"actv_func",
migraphx::to_value(std::vector<migraphx::operation>{migraphx::make_op("sigmoid"),
migraphx::make_op("tanh")})},
{"direction", migraphx::to_value(migraphx::op::rnn_direction::bidirectional)},
{"clip", clip}}),
seq,
w,
r);
return p;
}
......
......@@ -2,6 +2,10 @@
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/serialize.hpp>
#include <migraphx/operators.hpp>
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 w = mm->add_parameter("w", w_shape);
auto r = mm->add_parameter("r", r_shape);
auto und = mm->add_instruction(migraphx::op::undefined{});
mm->add_instruction(migraphx::op::gru{hidden_size,
{migraphx::op::sigmoid{}, migraphx::op::tanh{}},
migraphx::op::rnn_direction::bidirectional,
clip},
seq,
w,
r,
und,
und,
und);
auto und = mm->add_instruction(migraphx::make_op("undefined"));
mm->add_instruction(
migraphx::make_op(
"gru",
{{"hidden_size", hidden_size},
{"actv_func",
migraphx::to_value(std::vector<migraphx::operation>{migraphx::make_op("sigmoid"),
migraphx::make_op("tanh")})},
{"direction", migraphx::to_value(migraphx::op::rnn_direction::bidirectional)},
{"clip", clip}}),
seq,
w,
r,
und,
und,
und);
return p;
}
......
......@@ -2,6 +2,10 @@
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/serialize.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/operators.hpp>
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
auto w = mm->add_parameter("w", w_shape);
auto r = mm->add_parameter("r", r_shape);
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,
w,
r);
......
......@@ -2,6 +2,10 @@
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/serialize.hpp>
#include <migraphx/operators.hpp>
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_
auto r = mm->add_parameter("r", r_shape);
auto bias = mm->add_parameter("bias", b_shape);
auto ih = mm->add_parameter("ih", ih_shape);
auto und = mm->add_instruction(migraphx::op::undefined{});
mm->add_instruction(migraphx::op::gru{hidden_size,
{migraphx::op::sigmoid{}},
migraphx::op::rnn_direction::bidirectional,
clip},
seq,
w,
r,
bias,
und,
ih);
auto und = mm->add_instruction(migraphx::make_op("undefined"));
mm->add_instruction(
migraphx::make_op(
"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::bidirectional)},
{"clip", clip}}),
seq,
w,
r,
bias,
und,
ih);
return p;
}
......
......@@ -2,6 +2,10 @@
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/serialize.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/operators.hpp>
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 w = mm->add_parameter("w", w_shape);
auto r = mm->add_parameter("r", r_shape);
mm->add_instruction(migraphx::op::gru{hidden_size,
{migraphx::op::sigmoid{}, migraphx::op::tanh{}},
migraphx::op::rnn_direction::bidirectional,
clip},
seq,
w,
r);
mm->add_instruction(
migraphx::make_op(
"gru",
{{"hidden_size", hidden_size},
{"actv_func",
migraphx::to_value(std::vector<migraphx::operation>{migraphx::make_op("sigmoid"),
migraphx::make_op("tanh")})},
{"direction", migraphx::to_value(migraphx::op::rnn_direction::bidirectional)},
{"clip", clip}}),
seq,
w,
r);
return p;
}
......
......@@ -2,6 +2,10 @@
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/serialize.hpp>
#include <migraphx/operators.hpp>
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 bias = mm->add_parameter("bias", b_shape);
auto ih = mm->add_parameter("ih", ih_shape);
auto und = mm->add_instruction(migraphx::op::undefined{});
auto hs =
mm->add_instruction(migraphx::op::gru{hidden_size,
{migraphx::op::sigmoid{}, migraphx::op::tanh{}},
migraphx::op::rnn_direction::forward,
clip},
seq,
w,
r,
bias,
und,
ih);
auto lho = mm->add_instruction(migraphx::op::rnn_last_hs_output{}, hs);
auto und = mm->add_instruction(migraphx::make_op("undefined"));
auto hs = mm->add_instruction(
migraphx::make_op(
"gru",
{{"hidden_size", hidden_size},
{"actv_func",
migraphx::to_value(std::vector<migraphx::operation>{migraphx::make_op("sigmoid"),
migraphx::make_op("tanh")})},
{"direction", migraphx::to_value(migraphx::op::rnn_direction::forward)},
{"clip", clip}}),
seq,
w,
r,
bias,
und,
ih);
auto lho = mm->add_instruction(migraphx::make_op("rnn_last_hs_output"), hs);
mm->add_return({lho, hs});
return p;
......
......@@ -2,6 +2,10 @@
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/serialize.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/operators.hpp>
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 w = mm->add_parameter("w", w_shape);
auto r = mm->add_parameter("r", r_shape);
mm->add_instruction(migraphx::op::gru{hidden_size,
{migraphx::op::sigmoid{}, migraphx::op::tanh{}},
migraphx::op::rnn_direction::forward,
clip},
seq,
w,
r);
mm->add_instruction(
migraphx::make_op(
"gru",
{{"hidden_size", hidden_size},
{"actv_func",
migraphx::to_value(std::vector<migraphx::operation>{migraphx::make_op("sigmoid"),
migraphx::make_op("tanh")})},
{"direction", migraphx::to_value(migraphx::op::rnn_direction::forward)},
{"clip", clip}}),
seq,
w,
r);
return p;
}
......
......@@ -2,6 +2,10 @@
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/serialize.hpp>
#include <migraphx/operators.hpp>
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 w = mm->add_parameter("w", w_shape);
auto r = mm->add_parameter("r", r_shape);
auto und = mm->add_instruction(migraphx::op::undefined{});
mm->add_instruction(migraphx::op::gru{hidden_size,
{migraphx::op::sigmoid{}, migraphx::op::tanh{}},
migraphx::op::rnn_direction::forward,
clip},
seq,
w,
r,
und,
und,
und);
auto und = mm->add_instruction(migraphx::make_op("undefined"));
mm->add_instruction(
migraphx::make_op(
"gru",
{{"hidden_size", hidden_size},
{"actv_func",
migraphx::to_value(std::vector<migraphx::operation>{migraphx::make_op("sigmoid"),
migraphx::make_op("tanh")})},
{"direction", migraphx::to_value(migraphx::op::rnn_direction::forward)},
{"clip", clip}}),
seq,
w,
r,
und,
und,
und);
return p;
}
......
......@@ -2,6 +2,10 @@
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/serialize.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/operators.hpp>
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
auto w = mm->add_parameter("w", w_shape);
auto r = mm->add_parameter("r", r_shape);
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,
w,
r);
......
......@@ -2,6 +2,10 @@
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/serialize.hpp>
#include <migraphx/operators.hpp>
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_
auto r = mm->add_parameter("r", r_shape);
auto bias = mm->add_parameter("bias", b_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, {migraphx::op::sigmoid{}}, migraphx::op::rnn_direction::forward, clip},
migraphx::make_op(
"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,
w,
r,
......
......@@ -2,6 +2,10 @@
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/serialize.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/operators.hpp>
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 w = mm->add_parameter("w", w_shape);
auto r = mm->add_parameter("r", r_shape);
mm->add_instruction(migraphx::op::gru{hidden_size,
{migraphx::op::sigmoid{}, migraphx::op::tanh{}},
migraphx::op::rnn_direction::forward,
clip},
seq,
w,
r);
mm->add_instruction(
migraphx::make_op(
"gru",
{{"hidden_size", hidden_size},
{"actv_func",
migraphx::to_value(std::vector<migraphx::operation>{migraphx::make_op("sigmoid"),
migraphx::make_op("tanh")})},
{"direction", migraphx::to_value(migraphx::op::rnn_direction::forward)},
{"clip", clip}}),
seq,
w,
r);
return p;
}
......
......@@ -2,6 +2,10 @@
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/serialize.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/operators.hpp>
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 w = mm->add_parameter("w", w_shape);
auto r = mm->add_parameter("r", r_shape);
mm->add_instruction(migraphx::op::gru{hidden_size,
{migraphx::op::sigmoid{}, migraphx::op::tanh{}},
migraphx::op::rnn_direction::reverse,
clip},
seq,
w,
r);
mm->add_instruction(
migraphx::make_op(
"gru",
{{"hidden_size", hidden_size},
{"actv_func",
migraphx::to_value(std::vector<migraphx::operation>{migraphx::make_op("sigmoid"),
migraphx::make_op("tanh")})},
{"direction", migraphx::to_value(migraphx::op::rnn_direction::reverse)},
{"clip", clip}}),
seq,
w,
r);
return p;
}
......
......@@ -2,6 +2,10 @@
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/serialize.hpp>
#include <migraphx/operators.hpp>
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 bias = mm->add_parameter("bias", b_shape);
auto ih = mm->add_parameter("ih", ih_shape);
auto und = mm->add_instruction(migraphx::op::undefined{});
auto output =
mm->add_instruction(migraphx::op::gru{hidden_size,
{migraphx::op::sigmoid{}, migraphx::op::tanh{}},
migraphx::op::rnn_direction::reverse,
clip},
seq,
w,
r,
bias,
und,
ih);
mm->add_instruction(migraphx::op::rnn_last_hs_output{}, output);
auto und = mm->add_instruction(migraphx::make_op("undefined"));
auto output = mm->add_instruction(
migraphx::make_op(
"gru",
{{"hidden_size", hidden_size},
{"actv_func",
migraphx::to_value(std::vector<migraphx::operation>{migraphx::make_op("sigmoid"),
migraphx::make_op("tanh")})},
{"direction", migraphx::to_value(migraphx::op::rnn_direction::reverse)},
{"clip", clip}}),
seq,
w,
r,
bias,
und,
ih);
mm->add_instruction(migraphx::make_op("rnn_last_hs_output"), output);
return p;
}
......
......@@ -2,6 +2,10 @@
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/serialize.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/operators.hpp>
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 r = mm->add_parameter("r", r_shape);
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,
w,
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});
return p;
......
......@@ -2,6 +2,8 @@
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/operators.hpp>
migraphx::instruction_ref
......@@ -14,22 +16,27 @@ add_layernorm(migraphx::module& m, migraphx::instruction_ref x, std::vector<size
auto epsilon = m.add_literal(1e-12f);
auto exponent = m.add_literal(2.0f);
auto mean = m.add_instruction(migraphx::op::reduce_mean({2}), x);
auto mean_mbcast = m.add_instruction(migraphx::op::multibroadcast{{dims}}, mean);
auto sub = m.add_instruction(migraphx::op::sub{}, x, mean_mbcast);
auto exponent_mbcast = m.add_instruction(migraphx::op::multibroadcast{{dims}}, exponent);
auto pow = m.add_instruction(migraphx::op::pow{}, sub, exponent_mbcast);
auto var = m.add_instruction(migraphx::op::reduce_mean({2}), pow);
auto epsilon_mbcast =
m.add_instruction(migraphx::op::multibroadcast{{1, dims.at(1), 1}}, epsilon);
auto add_epsilon = m.add_instruction(migraphx::op::add{}, var, epsilon_mbcast);
auto sqrt = m.add_instruction(migraphx::op::sqrt{}, add_epsilon);
auto sqrt_mbcast = m.add_instruction(migraphx::op::multibroadcast{dims}, sqrt);
auto div = m.add_instruction(migraphx::op::div{}, sub, sqrt_mbcast);
auto scale_mbcast = m.add_instruction(migraphx::op::multibroadcast{dims}, scale);
auto mul = m.add_instruction(migraphx::op::mul{}, scale_mbcast, div);
auto bias_mbcast = m.add_instruction(migraphx::op::multibroadcast{dims}, bias);
return m.add_instruction(migraphx::op::add{}, mul, bias_mbcast);
auto mean = m.add_instruction(migraphx::op::reduce_mean({2}), x);
auto mean_mbcast =
m.add_instruction(migraphx::make_op("multibroadcast", {{"output_lens", dims}}), mean);
auto sub = m.add_instruction(migraphx::make_op("sub"), x, mean_mbcast);
auto exponent_mbcast =
m.add_instruction(migraphx::make_op("multibroadcast", {{"output_lens", dims}}), exponent);
auto pow = m.add_instruction(migraphx::make_op("pow"), sub, exponent_mbcast);
auto var = m.add_instruction(migraphx::op::reduce_mean({2}), pow);
auto epsilon_mbcast = m.add_instruction(
migraphx::make_op("multibroadcast", {{"output_lens", {1, dims.at(1), 1}}}), epsilon);
auto add_epsilon = m.add_instruction(migraphx::make_op("add"), var, epsilon_mbcast);
auto sqrt = m.add_instruction(migraphx::make_op("sqrt"), add_epsilon);
auto sqrt_mbcast =
m.add_instruction(migraphx::make_op("multibroadcast", {{"output_lens", dims}}), sqrt);
auto div = m.add_instruction(migraphx::make_op("div"), sub, sqrt_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>
......@@ -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 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 add1 = mm->add_instruction(migraphx::op::add{}, x, y);
auto add2 = mm->add_instruction(migraphx::op::add{}, add1, z);
auto add1 = mm->add_instruction(migraphx::make_op("add"), x, y);
auto add2 = mm->add_instruction(migraphx::make_op("add"), add1, z);
add_layernorm(*mm, add2, dims);
return p;
}
......
......@@ -2,7 +2,7 @@
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/operators.hpp>
#include <migraphx/make_op.hpp>
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;
auto* mm = p.get_main_module();
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;
}
};
......@@ -2,7 +2,7 @@
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/operators.hpp>
#include <migraphx/make_op.hpp>
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}};
auto input1 = mm->add_parameter("x", 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});
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