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,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_ladd : verify_program<test_fp32_fp16_ladd>
......@@ -16,7 +17,7 @@ struct test_fp32_fp16_ladd : verify_program<test_fp32_fp16_ladd>
std::iota(data.begin(), data.end(), 1.0f);
auto l1 = mm->add_literal(migraphx::literal(s, data));
auto l2 = mm->add_parameter("p2", s);
mm->add_instruction(migraphx::op::add{}, l1, l2);
mm->add_instruction(migraphx::make_op("add"), l1, l2);
migraphx::quantize_fp16(p, {"add"});
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_lall : verify_program<test_fp32_fp16_lall>
......@@ -16,7 +17,7 @@ struct test_fp32_fp16_lall : verify_program<test_fp32_fp16_lall>
std::iota(data.begin(), data.end(), 1.0f);
auto l1 = mm->add_literal(migraphx::literal(s, data));
auto l2 = mm->add_parameter("p2", s);
mm->add_instruction(migraphx::op::add{}, l1, l2);
mm->add_instruction(migraphx::make_op("add"), l1, l2);
migraphx::quantize_fp16(p, {"all"});
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_sub : verify_program<test_fp32_fp16_sub>
......@@ -14,9 +15,9 @@ struct test_fp32_fp16_sub : verify_program<test_fp32_fp16_sub>
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, {"sub"});
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_gather : verify_program<test_gather>
{
......@@ -16,7 +16,7 @@ struct test_gather : verify_program<test_gather>
auto a0 = mm->add_parameter("data", s);
auto a1 = mm->add_literal(migraphx::literal{s_indices, indices});
int axis = 0;
mm->add_instruction(migraphx::op::gather{axis}, a0, a1);
mm->add_instruction(migraphx::make_op("gather", {{"axis", axis}}), a0, a1);
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_gather_1d_index : verify_program<test_gather_1d_index>
{
......@@ -16,7 +16,7 @@ struct test_gather_1d_index : verify_program<test_gather_1d_index>
auto a0 = mm->add_parameter("data", s);
auto a1 = mm->add_literal(migraphx::literal{s_indices, indices});
int axis = -1;
mm->add_instruction(migraphx::op::gather{axis}, a0, a1);
mm->add_instruction(migraphx::make_op("gather", {{"axis", axis}}), a0, a1);
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_gather_neg_axis : verify_program<test_gather_neg_axis>
{
......@@ -16,7 +16,7 @@ struct test_gather_neg_axis : verify_program<test_gather_neg_axis>
auto a0 = mm->add_parameter("data", s);
auto a1 = mm->add_literal(migraphx::literal{s_indices, indices});
int axis = -1;
mm->add_instruction(migraphx::op::gather{axis}, a0, a1);
mm->add_instruction(migraphx::make_op("gather", {{"axis", axis}}), a0, a1);
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_gather_neg_indices : verify_program<test_gather_neg_indices>
{
......@@ -16,7 +16,7 @@ struct test_gather_neg_indices : verify_program<test_gather_neg_indices>
auto a0 = mm->add_parameter("data", s);
auto a1 = mm->add_literal(migraphx::literal{s_indices, indices});
int axis = -1;
mm->add_instruction(migraphx::op::gather{axis}, a0, a1);
mm->add_instruction(migraphx::make_op("gather", {{"axis", axis}}), a0, a1);
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_gather_scalar_index : verify_program<test_gather_scalar_index>
{
......@@ -16,7 +16,7 @@ struct test_gather_scalar_index : verify_program<test_gather_scalar_index>
auto a0 = mm->add_parameter("data", s);
auto a1 = mm->add_literal(migraphx::literal{s_indices, indices});
int axis = -1;
mm->add_instruction(migraphx::op::gather{axis}, a0, a1);
mm->add_instruction(migraphx::make_op("gather", {{"axis", axis}}), a0, a1);
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_gather_scalar_output : verify_program<test_gather_scalar_output>
{
......@@ -16,7 +16,7 @@ struct test_gather_scalar_output : verify_program<test_gather_scalar_output>
auto a0 = mm->add_parameter("data", s);
auto a1 = mm->add_literal(migraphx::literal{s_indices, indices});
int axis = 0;
mm->add_instruction(migraphx::op::gather{axis}, a0, a1);
mm->add_instruction(migraphx::make_op("gather", {{"axis", axis}}), a0, a1);
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_gelu : verify_program<test_gelu>
{
......@@ -11,18 +11,21 @@ struct test_gelu : verify_program<test_gelu>
migraphx::program p;
auto* mm = p.get_main_module();
std::vector<size_t> input_lens{1, 1, 5};
auto x = mm->add_parameter("x", {migraphx::shape::float_type, input_lens});
auto half = mm->add_literal(0.5f);
auto one = mm->add_literal(1.0f);
auto sqrt2 = mm->add_literal(static_cast<float>(M_SQRT2));
auto half_mbcast = mm->add_instruction(migraphx::op::multibroadcast{input_lens}, half);
auto mul_half = mm->add_instruction(migraphx::op::mul{}, x, half_mbcast);
auto sqrt2_mbcast = mm->add_instruction(migraphx::op::multibroadcast{input_lens}, sqrt2);
auto div = mm->add_instruction(migraphx::op::div{}, x, sqrt2_mbcast);
auto erf = mm->add_instruction(migraphx::op::erf{}, div);
auto one_mbcast = mm->add_instruction(migraphx::op::multibroadcast{input_lens}, one);
auto add_one = mm->add_instruction(migraphx::op::add{}, erf, one_mbcast);
mm->add_instruction(migraphx::op::mul{}, mul_half, add_one);
auto x = mm->add_parameter("x", {migraphx::shape::float_type, input_lens});
auto half = mm->add_literal(0.5f);
auto one = mm->add_literal(1.0f);
auto sqrt2 = mm->add_literal(static_cast<float>(M_SQRT2));
auto half_mbcast = mm->add_instruction(
migraphx::make_op("multibroadcast", {{"output_lens", input_lens}}), half);
auto mul_half = mm->add_instruction(migraphx::make_op("mul"), x, half_mbcast);
auto sqrt2_mbcast = mm->add_instruction(
migraphx::make_op("multibroadcast", {{"output_lens", input_lens}}), sqrt2);
auto div = mm->add_instruction(migraphx::make_op("div"), x, sqrt2_mbcast);
auto erf = mm->add_instruction(migraphx::make_op("erf"), div);
auto one_mbcast = mm->add_instruction(
migraphx::make_op("multibroadcast", {{"output_lens", input_lens}}), one);
auto add_one = mm->add_instruction(migraphx::make_op("add"), erf, one_mbcast);
mm->add_instruction(migraphx::make_op("mul"), mul_half, add_one);
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_gemm : verify_program<test_gemm>
{
......@@ -12,7 +12,7 @@ struct test_gemm : verify_program<test_gemm>
auto* mm = p.get_main_module();
auto a = mm->add_parameter("a", migraphx::shape{migraphx::shape::float_type, {4, 5}});
auto b = mm->add_parameter("b", migraphx::shape{migraphx::shape::float_type, {5, 3}});
mm->add_instruction(migraphx::op::dot{}, a, b);
mm->add_instruction(migraphx::make_op("dot"), a, b);
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_gemm_copy : verify_program<test_gemm_copy>
{
......@@ -16,8 +16,8 @@ struct test_gemm_copy : verify_program<test_gemm_copy>
auto pa = mm->add_parameter("a", sa);
auto pb = mm->add_parameter("b", sb);
auto pc = mm->add_parameter("c", sc);
auto dr = mm->add_instruction(migraphx::op::dot{}, pa, pb, pc);
mm->add_instruction(migraphx::op::add{}, dr, dr);
auto dr = mm->add_instruction(migraphx::make_op("dot"), pa, pb, pc);
mm->add_instruction(migraphx::make_op("add"), dr, dr);
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_gemm_ex : verify_program<test_gemm_ex>
{
......@@ -12,7 +12,7 @@ struct test_gemm_ex : verify_program<test_gemm_ex>
auto* mm = p.get_main_module();
auto a = mm->add_parameter("a", migraphx::shape{migraphx::shape::float_type, {1, 1, 4, 5}});
auto b = mm->add_parameter("b", migraphx::shape{migraphx::shape::float_type, {1, 1, 5, 3}});
mm->add_instruction(migraphx::op::dot{}, a, b);
mm->add_instruction(migraphx::make_op("dot"), a, b);
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_gemm_half : verify_program<test_gemm_half>
{
......@@ -12,7 +12,7 @@ struct test_gemm_half : verify_program<test_gemm_half>
auto* mm = p.get_main_module();
auto a = mm->add_parameter("a", migraphx::shape{migraphx::shape::half_type, {4, 5}});
auto b = mm->add_parameter("b", migraphx::shape{migraphx::shape::half_type, {5, 3}});
mm->add_instruction(migraphx::op::dot{}, a, b);
mm->add_instruction(migraphx::make_op("dot"), a, b);
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_gemm_ld //: verify_program<test_gemm_ld>
{
......@@ -14,7 +14,7 @@ struct test_gemm_ld //: verify_program<test_gemm_ld>
mm->add_parameter("a", migraphx::shape{migraphx::shape::float_type, {4, 5}, {10, 1}});
auto b =
mm->add_parameter("b", migraphx::shape{migraphx::shape::float_type, {5, 3}, {20, 1}});
mm->add_instruction(migraphx::op::dot{}, a, b);
mm->add_instruction(migraphx::make_op("dot"), a, b);
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_gemm_transposea : verify_program<test_gemm_transposea>
{
......@@ -12,8 +12,8 @@ struct test_gemm_transposea : verify_program<test_gemm_transposea>
auto* mm = p.get_main_module();
auto a = mm->add_parameter("a", migraphx::shape{migraphx::shape::float_type, {5, 4}});
auto b = mm->add_parameter("b", migraphx::shape{migraphx::shape::float_type, {5, 3}});
auto at = mm->add_instruction(migraphx::op::transpose{{1, 0}}, a);
mm->add_instruction(migraphx::op::dot{}, at, b);
auto at = mm->add_instruction(migraphx::make_op("transpose", {{"dims", {1, 0}}}), a);
mm->add_instruction(migraphx::make_op("dot"), at, b);
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_gemm_transposea_ex : verify_program<test_gemm_transposea_ex>
{
......@@ -12,8 +12,8 @@ struct test_gemm_transposea_ex : verify_program<test_gemm_transposea_ex>
auto* mm = p.get_main_module();
auto a = mm->add_parameter("a", migraphx::shape{migraphx::shape::float_type, {1, 1, 5, 4}});
auto b = mm->add_parameter("b", migraphx::shape{migraphx::shape::float_type, {1, 1, 5, 3}});
auto at = mm->add_instruction(migraphx::op::transpose{{0, 1, 3, 2}}, a);
mm->add_instruction(migraphx::op::dot{}, at, b);
auto at = mm->add_instruction(migraphx::make_op("transpose", {{"dims", {0, 1, 3, 2}}}), a);
mm->add_instruction(migraphx::make_op("dot"), at, b);
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_gemm_transposeab : verify_program<test_gemm_transposeab>
{
......@@ -12,9 +12,9 @@ struct test_gemm_transposeab : verify_program<test_gemm_transposeab>
auto* mm = p.get_main_module();
auto a = mm->add_parameter("a", migraphx::shape{migraphx::shape::float_type, {5, 4}});
auto b = mm->add_parameter("b", migraphx::shape{migraphx::shape::float_type, {3, 5}});
auto at = mm->add_instruction(migraphx::op::transpose{{1, 0}}, a);
auto bt = mm->add_instruction(migraphx::op::transpose{{1, 0}}, b);
mm->add_instruction(migraphx::op::dot{}, at, bt);
auto at = mm->add_instruction(migraphx::make_op("transpose", {{"dims", {1, 0}}}), a);
auto bt = mm->add_instruction(migraphx::make_op("transpose", {{"dims", {1, 0}}}), b);
mm->add_instruction(migraphx::make_op("dot"), at, bt);
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_gemm_transposeb : verify_program<test_gemm_transposeb>
{
......@@ -12,8 +12,8 @@ struct test_gemm_transposeb : verify_program<test_gemm_transposeb>
auto* mm = p.get_main_module();
auto a = mm->add_parameter("a", migraphx::shape{migraphx::shape::float_type, {4, 5}});
auto b = mm->add_parameter("b", migraphx::shape{migraphx::shape::float_type, {3, 5}});
auto bt = mm->add_instruction(migraphx::op::transpose{{1, 0}}, b);
mm->add_instruction(migraphx::op::dot{}, a, bt);
auto bt = mm->add_instruction(migraphx::make_op("transpose", {{"dims", {1, 0}}}), b);
mm->add_instruction(migraphx::make_op("dot"), a, bt);
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_gemm_transposeb_ex : verify_program<test_gemm_transposeb_ex>
{
......@@ -12,8 +12,8 @@ struct test_gemm_transposeb_ex : verify_program<test_gemm_transposeb_ex>
auto* mm = p.get_main_module();
auto a = mm->add_parameter("a", migraphx::shape{migraphx::shape::float_type, {1, 4, 5}});
auto b = mm->add_parameter("b", migraphx::shape{migraphx::shape::float_type, {1, 3, 5}});
auto bt = mm->add_instruction(migraphx::op::transpose{{0, 2, 1}}, b);
mm->add_instruction(migraphx::op::dot{}, a, bt);
auto bt = mm->add_instruction(migraphx::make_op("transpose", {{"dims", {0, 2, 1}}}), b);
mm->add_instruction(migraphx::make_op("dot"), a, bt);
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