"googlemock/test/gmock-actions_test.cc" did not exist on "a070cbd91c2a8bfe7caed64e31387312a1c5df5a"
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_conv_bn_relu_pooling2 : verify_program<test_conv_bn_relu_pooling2>
{
......@@ -17,7 +17,7 @@ struct test_conv_bn_relu_pooling2 : verify_program<test_conv_bn_relu_pooling2>
auto variance =
mm->add_literal(migraphx::abs(migraphx::generate_literal(vars, 4 + channels)));
return mm->add_instruction(
migraphx::op::batch_norm_inference{}, x, scale, bias, mean, variance);
migraphx::make_op("batch_norm_inference"), x, scale, bias, mean, variance);
}
migraphx::program create_program() const
{
......@@ -30,15 +30,28 @@ struct test_conv_bn_relu_pooling2 : verify_program<test_conv_bn_relu_pooling2>
migraphx::shape ws2{migraphx::shape::float_type, {2048, 1024, 1, 1}};
auto x1 = mm->add_parameter("x1", xs1);
auto w1 = mm->add_parameter("w1", ws1);
auto conv1 = mm->add_instruction(migraphx::op::convolution{{0, 0}, {1, 1}, {1, 1}}, x1, w1);
auto conv1 = mm->add_instruction(
migraphx::make_op("convolution",
{{"padding", {0, 0}}, {"stride", {1, 1}}, {"dilation", {1, 1}}}),
x1,
w1);
auto bn1 = add_bn(p, conv1, 2048);
auto x2 = mm->add_parameter("x2", xs2);
auto w2 = mm->add_parameter("w2", ws2);
auto conv2 = mm->add_instruction(migraphx::op::convolution{{0, 0}, {2, 2}, {1, 1}}, x2, w2);
auto bn2 = add_bn(p, conv2, 2048);
auto add = mm->add_instruction(migraphx::op::add{}, bn1, bn2);
auto relu = mm->add_instruction(migraphx::op::relu{}, add);
mm->add_instruction(migraphx::op::pooling{"average", {1, 1}, {2, 2}, {3, 3}}, relu);
auto conv2 = mm->add_instruction(
migraphx::make_op("convolution",
{{"padding", {0, 0}}, {"stride", {2, 2}}, {"dilation", {1, 1}}}),
x2,
w2);
auto bn2 = add_bn(p, conv2, 2048);
auto add = mm->add_instruction(migraphx::make_op("add"), bn1, bn2);
auto relu = mm->add_instruction(migraphx::make_op("relu"), add);
mm->add_instruction(migraphx::make_op("pooling",
{{"mode", "average"},
{"padding", {1, 1}},
{"stride", {2, 2}},
{"lengths", {3, 3}}}),
relu);
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_conv_pooling : verify_program<test_conv_pooling>
{
......@@ -14,9 +14,9 @@ struct test_conv_pooling : verify_program<test_conv_pooling>
mm->add_parameter("x", migraphx::shape{migraphx::shape::float_type, {4, 3, 32, 32}});
auto weights =
mm->add_parameter("w", migraphx::shape{migraphx::shape::float_type, {4, 3, 3, 3}});
auto conv = mm->add_instruction(migraphx::op::convolution{}, input, weights);
auto pooling = mm->add_instruction(migraphx::op::pooling{"max"}, conv);
mm->add_instruction(migraphx::op::relu{}, pooling);
auto conv = mm->add_instruction(migraphx::make_op("convolution"), input, weights);
auto pooling = mm->add_instruction(migraphx::make_op("pooling", {{"mode", "max"}}), conv);
mm->add_instruction(migraphx::make_op("relu"), pooling);
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_conv_relu : verify_program<test_conv_relu>
{
......@@ -14,8 +14,8 @@ struct test_conv_relu : verify_program<test_conv_relu>
mm->add_parameter("x", migraphx::shape{migraphx::shape::float_type, {4, 3, 3, 3}});
auto weights =
mm->add_parameter("w", migraphx::shape{migraphx::shape::float_type, {4, 3, 3, 3}});
auto conv = mm->add_instruction(migraphx::op::convolution{}, input, weights);
mm->add_instruction(migraphx::op::relu{}, conv);
auto conv = mm->add_instruction(migraphx::make_op("convolution"), input, weights);
mm->add_instruction(migraphx::make_op("relu"), conv);
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_conv_relu_half : verify_program<test_conv_relu_half>
{
......@@ -14,8 +14,8 @@ struct test_conv_relu_half : verify_program<test_conv_relu_half>
mm->add_parameter("x", migraphx::shape{migraphx::shape::half_type, {4, 3, 3, 3}});
auto weights =
mm->add_parameter("w", migraphx::shape{migraphx::shape::half_type, {4, 3, 3, 3}});
auto conv = mm->add_instruction(migraphx::op::convolution{}, input, weights);
mm->add_instruction(migraphx::op::relu{}, conv);
auto conv = mm->add_instruction(migraphx::make_op("convolution"), input, weights);
mm->add_instruction(migraphx::make_op("relu"), conv);
return p;
}
};
......@@ -2,7 +2,9 @@
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/operators.hpp>
#include <migraphx/serialize.hpp>
#include <migraphx/make_op.hpp>
struct test_convert : verify_program<test_convert>
{
......@@ -14,9 +16,15 @@ struct test_convert : verify_program<test_convert>
migraphx::shape sb{migraphx::shape::float_type, {24, 6}};
auto pa = mm->add_parameter("a", sa);
auto pb = mm->add_parameter("b", sb);
auto ia = mm->add_instruction(migraphx::op::convert{migraphx::shape::int8_type}, pa);
auto ib = mm->add_instruction(migraphx::op::convert{migraphx::shape::int8_type}, pb);
mm->add_instruction(migraphx::op::quant_dot{}, ia, ib);
auto ia = mm->add_instruction(
migraphx::make_op("convert",
{{"target_type", migraphx::to_value(migraphx::shape::int8_type)}}),
pa);
auto ib = mm->add_instruction(
migraphx::make_op("convert",
{{"target_type", migraphx::to_value(migraphx::shape::int8_type)}}),
pb);
mm->add_instruction(migraphx::make_op("quant_dot"), ia, ib);
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_cos : verify_program<test_cos>
{
......@@ -12,7 +12,7 @@ struct test_cos : verify_program<test_cos>
auto* mm = p.get_main_module();
migraphx::shape s{migraphx::shape::double_type, {8}};
auto x = mm->add_parameter("x", s);
mm->add_instruction(migraphx::op::cos{}, x);
mm->add_instruction(migraphx::make_op("cos"), 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_cosh : verify_program<test_cosh>
{
......@@ -12,7 +12,7 @@ struct test_cosh : verify_program<test_cosh>
auto* mm = p.get_main_module();
migraphx::shape s{migraphx::shape::double_type, {16}};
auto x = mm->add_parameter("x", s);
mm->add_instruction(migraphx::op::cosh{}, x);
mm->add_instruction(migraphx::make_op("cosh"), 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_deconv : verify_program<test_deconv>
{
......@@ -14,7 +14,7 @@ struct test_deconv : verify_program<test_deconv>
mm->add_parameter("x", migraphx::shape{migraphx::shape::float_type, {1, 1, 3, 3}});
auto weights =
mm->add_parameter("w", migraphx::shape{migraphx::shape::float_type, {1, 1, 3, 3}});
mm->add_instruction(migraphx::op::deconvolution{}, input, weights);
mm->add_instruction(migraphx::make_op("deconvolution"), input, weights);
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_deconv_1d : verify_program<test_deconv_1d>
{
......@@ -14,7 +14,11 @@ struct test_deconv_1d : verify_program<test_deconv_1d>
mm->add_parameter("x", migraphx::shape{migraphx::shape::float_type, {1, 1, 3}});
auto weights =
mm->add_parameter("w", migraphx::shape{migraphx::shape::float_type, {1, 1, 3}});
mm->add_instruction(migraphx::op::deconvolution{{0}, {1}, {1}}, input, weights);
mm->add_instruction(
migraphx::make_op("deconvolution",
{{"padding", {0}}, {"stride", {1}}, {"dilation", {1}}}),
input,
weights);
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_deconv_2x3 : verify_program<test_deconv_2x3>
{
......@@ -14,7 +14,11 @@ struct test_deconv_2x3 : verify_program<test_deconv_2x3>
mm->add_parameter("x", migraphx::shape{migraphx::shape::float_type, {1, 3, 6, 7}});
auto weights =
mm->add_parameter("w", migraphx::shape{migraphx::shape::float_type, {3, 4, 3, 3}});
mm->add_instruction(migraphx::op::deconvolution{{1, 1}, {2, 3}, {1, 1}}, input, weights);
mm->add_instruction(
migraphx::make_op("deconvolution",
{{"padding", {1, 1}}, {"stride", {2, 3}}, {"dilation", {1, 1}}}),
input,
weights);
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_deconv_3d : verify_program<test_deconv_3d>
{
......@@ -15,7 +15,11 @@ struct test_deconv_3d : verify_program<test_deconv_3d>
auto weights =
mm->add_parameter("w", migraphx::shape{migraphx::shape::float_type, {1, 1, 3, 3, 3}});
mm->add_instruction(
migraphx::op::deconvolution{{0, 0, 0}, {1, 1, 1}, {1, 1, 1}}, input, weights);
migraphx::make_op(
"deconvolution",
{{"padding", {0, 0, 0}}, {"stride", {1, 1, 1}}, {"dilation", {1, 1, 1}}}),
input,
weights);
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_div : verify_program<test_div>
{
......@@ -14,8 +14,8 @@ struct test_div : verify_program<test_div>
auto x = mm->add_parameter("x", s);
auto y = mm->add_parameter("y", s);
auto z = mm->add_parameter("z", s);
auto diff = mm->add_instruction(migraphx::op::div{}, x, y);
mm->add_instruction(migraphx::op::div{}, diff, z);
auto diff = mm->add_instruction(migraphx::make_op("div"), x, y);
mm->add_instruction(migraphx::make_op("div"), diff, z);
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_div2 : verify_program<test_div2>
{
......@@ -12,12 +12,13 @@ struct test_div2 : verify_program<test_div2>
auto* mm = p.get_main_module();
migraphx::shape s{migraphx::shape::float_type, {2, 3}};
migraphx::shape b{migraphx::shape::float_type, {3}};
auto x = mm->add_parameter("x", s);
auto y = mm->add_parameter("y", s);
auto z = mm->add_parameter("z", b);
auto zb = mm->add_instruction(migraphx::op::broadcast{1, s.lens()}, z);
auto diff = mm->add_instruction(migraphx::op::div{}, x, y);
mm->add_instruction(migraphx::op::div{}, diff, zb);
auto x = mm->add_parameter("x", s);
auto y = mm->add_parameter("y", s);
auto z = mm->add_parameter("z", b);
auto zb = mm->add_instruction(
migraphx::make_op("broadcast", {{"axis", 1}, {"dims", s.lens()}}), z);
auto diff = mm->add_instruction(migraphx::make_op("div"), x, y);
mm->add_instruction(migraphx::make_op("div"), diff, zb);
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_elu : verify_program<test_elu>
{
......@@ -11,7 +11,7 @@ struct test_elu : verify_program<test_elu>
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{1.0}, x);
mm->add_instruction(migraphx::make_op("leaky_relu", {{"alpha", 1.0}}), 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_equal : verify_program<test_equal>
{
......@@ -14,7 +14,7 @@ struct test_equal : verify_program<test_equal>
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::equal{}, input1, input2);
auto r = mm->add_instruction(migraphx::make_op("equal"), 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_equal_brcst : verify_program<test_equal_brcst>
{
......@@ -14,8 +14,9 @@ struct test_equal_brcst : verify_program<test_equal_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::equal{}, l0, bl1);
auto bl1 = mm->add_instruction(
migraphx::make_op("multibroadcast", {{"output_lens", s0.lens()}}), l1);
auto r = mm->add_instruction(migraphx::make_op("equal"), l0, bl1);
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_erf : verify_program<test_erf>
{
......@@ -12,7 +12,7 @@ struct test_erf : verify_program<test_erf>
auto* mm = p.get_main_module();
migraphx::shape s{migraphx::shape::float_type, {2, 3, 4, 6}};
auto param = mm->add_parameter("x", s);
mm->add_instruction(migraphx::op::erf{}, param);
mm->add_instruction(migraphx::make_op("erf"), param);
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_exp : verify_program<test_exp>
{
......@@ -11,8 +11,8 @@ struct test_exp : verify_program<test_exp>
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape s{migraphx::shape::float_type, {6}};
auto x = mm->add_instruction(migraphx::op::abs{}, mm->add_parameter("x", s));
mm->add_instruction(migraphx::op::exp{}, x);
auto x = mm->add_instruction(migraphx::make_op("abs"), mm->add_parameter("x", s));
mm->add_instruction(migraphx::make_op("exp"), 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_floor : verify_program<test_floor>
{
......@@ -13,7 +13,7 @@ struct test_floor : verify_program<test_floor>
migraphx::shape s{migraphx::shape::float_type, {2, 3, 4, 6}};
auto param = mm->add_parameter("x", s);
mm->add_instruction(migraphx::op::floor{}, param);
mm->add_instruction(migraphx::make_op("floor"), param);
return p;
};
};
......@@ -2,7 +2,8 @@
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/operators.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/quantization.hpp>
struct test_fp32_fp16_add : verify_program<test_fp32_fp16_add>
......@@ -14,9 +15,9 @@ struct test_fp32_fp16_add : verify_program<test_fp32_fp16_add>
migraphx::shape s{migraphx::shape::float_type, {2, 3}};
auto p1 = mm->add_parameter("x", s);
auto p2 = mm->add_parameter("y", s);
auto sum = mm->add_instruction(migraphx::op::add{}, p1, p2);
auto diff = mm->add_instruction(migraphx::op::sub{}, sum, p2);
mm->add_instruction(migraphx::op::add{}, diff, p1);
auto sum = mm->add_instruction(migraphx::make_op("add"), p1, p2);
auto diff = mm->add_instruction(migraphx::make_op("sub"), sum, p2);
mm->add_instruction(migraphx::make_op("add"), diff, p1);
migraphx::quantize_fp16(p, {"add"});
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