Commit d2549384 authored by Khalique's avatar Khalique
Browse files

manual merge

parents 67048d04 ab6cd9d3
#include <migraph/program.hpp>
#include <migraph/iterator_for.hpp>
#include <migraph/instruction.hpp>
#include <migraphx/program.hpp>
#include <migraphx/iterator_for.hpp>
#include <migraphx/instruction.hpp>
#include <sstream>
#include "test.hpp"
#include <basic_ops.hpp>
struct id_target
{
struct context
{
void finish() const {}
};
migraphx::context ctx = context{};
std::string name() const { return "id"; }
std::vector<migraph::pass> get_passes(migraph::context&) const { return {}; }
migraph::context get_context() const { return {}; }
std::vector<migraphx::pass> get_passes(migraphx::context&) const { return {}; }
migraphx::context get_context() const { return ctx; }
};
struct id_ctx_op
{
std::string name() const { return "id_ctx_op"; }
migraphx::argument
compute(id_target::context&, const migraphx::shape&, std::vector<migraphx::argument> args) const
{
if(args.empty())
return {};
return args.front();
}
migraphx::shape compute_shape(std::vector<migraphx::shape> inputs) const
{
if(inputs.empty())
return {};
return inputs.front();
}
int output_alias(const std::vector<migraphx::shape>&) const { return 0; }
};
struct id_ctx_final_op
{
std::string name() const { return "id_ctx_final_op"; }
migraphx::argument compute(const migraphx::shape&, std::vector<migraphx::argument> args) const
{
if(args.empty())
return {};
return args.front();
}
void finalize(id_target::context&, const migraphx::shape&, const std::vector<migraphx::shape>&)
{
}
migraphx::shape compute_shape(std::vector<migraphx::shape> inputs) const
{
if(inputs.empty())
return {};
return inputs.front();
}
int output_alias(const std::vector<migraphx::shape>&) const { return 0; }
};
struct reverse_pass
{
std::string name() const { return "reverse_pass"; }
void apply(migraph::program& p) const
void apply(migraphx::program& p) const
{
for(auto ins : migraph::iterator_for(p))
for(auto ins : migraphx::iterator_for(p))
{
if(ins->name() == "sum")
{
......@@ -36,35 +84,35 @@ struct reverse_pass
struct reverse_target
{
std::string name() const { return "reverse"; }
std::vector<migraph::pass> get_passes(migraph::context&) const { return {reverse_pass{}}; }
migraph::context get_context() const { return {}; }
std::vector<migraphx::pass> get_passes(migraphx::context&) const { return {reverse_pass{}}; }
migraphx::context get_context() const { return {}; }
};
struct double_reverse_target
{
std::string name() const { return "double_reverse"; }
std::vector<migraph::pass> get_passes(migraph::context&) const
std::vector<migraphx::pass> get_passes(migraphx::context&) const
{
return {reverse_pass{}, reverse_pass{}};
}
migraph::context get_context() const { return {}; }
migraphx::context get_context() const { return {}; }
};
TEST_CASE(literal_test1)
{
migraph::program p;
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
p.add_instruction(sum_op{}, one, two);
auto result = p.eval({});
EXPECT(result == migraph::literal{3});
EXPECT(result != migraph::literal{4});
EXPECT(result == migraphx::literal{3});
EXPECT(result != migraphx::literal{4});
}
TEST_CASE(literal_test2)
{
migraph::program p;
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
......@@ -72,15 +120,15 @@ TEST_CASE(literal_test2)
p.add_instruction(sum_op{}, sum1, two);
auto result = p.eval({});
EXPECT(result == migraph::literal{5});
EXPECT(result != migraph::literal{3});
EXPECT(result == migraphx::literal{5});
EXPECT(result != migraphx::literal{3});
}
TEST_CASE(print_test)
{
migraph::program p;
migraphx::program p;
auto x = p.add_parameter("x", {migraph::shape::int64_type});
auto x = p.add_parameter("x", {migraphx::shape::int64_type});
auto two = p.add_literal(2);
p.add_instruction(sum_op{}, x, two);
......@@ -92,36 +140,36 @@ TEST_CASE(print_test)
TEST_CASE(param_test)
{
migraph::program p;
migraphx::program p;
auto x = p.add_parameter("x", {migraph::shape::int64_type});
auto y = p.add_parameter("y", {migraph::shape::int64_type});
auto x = p.add_parameter("x", {migraphx::shape::int64_type});
auto y = p.add_parameter("y", {migraphx::shape::int64_type});
p.add_instruction(sum_op{}, x, y);
auto result = p.eval(
{{"x", migraph::literal{1}.get_argument()}, {"y", migraph::literal{2}.get_argument()}});
EXPECT(result == migraph::literal{3});
EXPECT(result != migraph::literal{4});
{{"x", migraphx::literal{1}.get_argument()}, {"y", migraphx::literal{2}.get_argument()}});
EXPECT(result == migraphx::literal{3});
EXPECT(result != migraphx::literal{4});
}
TEST_CASE(param_error_test)
{
migraph::program p;
migraphx::program p;
auto x = p.add_parameter("x", {migraph::shape::int64_type});
auto y = p.add_parameter("y", {migraph::shape::int64_type});
auto x = p.add_parameter("x", {migraphx::shape::int64_type});
auto y = p.add_parameter("y", {migraphx::shape::int64_type});
p.add_instruction(sum_op{}, x, y);
EXPECT(test::throws<migraph::exception>(
EXPECT(test::throws<migraphx::exception>(
[&] {
p.eval({{"x", migraph::literal{1}.get_argument()}});
p.eval({{"x", migraphx::literal{1}.get_argument()}});
},
"Parameter not found: y"));
}
TEST_CASE(replace_test)
{
migraph::program p;
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
......@@ -130,13 +178,13 @@ TEST_CASE(replace_test)
EXPECT(bool{p.validate() == p.end()});
auto result = p.eval({});
EXPECT(result == migraph::literal{1});
EXPECT(result != migraph::literal{3});
EXPECT(result == migraphx::literal{1});
EXPECT(result != migraphx::literal{3});
}
TEST_CASE(replace_ins_test)
{
migraph::program p;
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
......@@ -146,13 +194,13 @@ TEST_CASE(replace_ins_test)
EXPECT(bool{p.validate() == p.end()});
auto result = p.eval({});
EXPECT(result == migraph::literal{1});
EXPECT(result != migraph::literal{3});
EXPECT(result == migraphx::literal{1});
EXPECT(result != migraphx::literal{3});
}
TEST_CASE(replace_ins_test2)
{
migraph::program p;
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
......@@ -163,13 +211,13 @@ TEST_CASE(replace_ins_test2)
EXPECT(bool{p.validate() == p.end()});
auto result = p.eval({});
EXPECT(result == migraph::literal{2});
EXPECT(result != migraph::literal{3});
EXPECT(result == migraphx::literal{2});
EXPECT(result != migraphx::literal{3});
}
TEST_CASE(insert_replace_test)
{
migraph::program p;
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
......@@ -181,47 +229,95 @@ TEST_CASE(insert_replace_test)
EXPECT(bool{p.validate() == p.end()});
auto result = p.eval({});
EXPECT(result == migraph::literal{4});
EXPECT(result != migraph::literal{5});
EXPECT(result == migraphx::literal{4});
EXPECT(result != migraphx::literal{5});
}
TEST_CASE(target_test)
{
migraph::program p;
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
p.add_instruction(sum_op{}, one, two);
p.compile(id_target{});
auto result = p.eval({});
EXPECT(result == migraph::literal{3});
EXPECT(result != migraph::literal{4});
EXPECT(result == migraphx::literal{3});
EXPECT(result != migraphx::literal{4});
}
TEST_CASE(reverse_target_test)
{
migraph::program p;
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
p.add_instruction(sum_op{}, two, one);
p.compile(reverse_target{});
auto result = p.eval({});
EXPECT(result == migraph::literal{1});
EXPECT(result != migraph::literal{4});
EXPECT(result == migraphx::literal{1});
EXPECT(result != migraphx::literal{4});
}
TEST_CASE(double_reverse_target_test)
{
migraph::program p;
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
p.add_instruction(sum_op{}, two, one);
p.compile(double_reverse_target{});
auto result = p.eval({});
EXPECT(result == migraph::literal{3});
EXPECT(result != migraph::literal{4});
EXPECT(result == migraphx::literal{3});
EXPECT(result != migraphx::literal{4});
}
// Check that the program doesnt modify the context directly, and only the operators modify the
// context
TEST_CASE(eval_context1)
{
migraphx::program p;
id_target t{};
EXPECT(is_shared(t.ctx, t.get_context()));
auto one = p.add_literal(1);
auto two = p.add_literal(2);
p.add_instruction(sum_op{}, one, two);
p.compile(t);
EXPECT(is_shared(t.ctx, p.get_context()));
p.eval({});
EXPECT(is_shared(t.ctx, p.get_context()));
}
TEST_CASE(eval_context2)
{
migraphx::program p;
id_target t{};
EXPECT(is_shared(t.ctx, t.get_context()));
auto one = p.add_literal(1);
auto two = p.add_literal(2);
p.add_instruction(id_ctx_op{}, one, two);
p.compile(t);
EXPECT(is_shared(t.ctx, p.get_context()));
p.eval({});
// id_ctx_op will modify the context
EXPECT(not is_shared(t.ctx, p.get_context()));
}
TEST_CASE(eval_context3)
{
migraphx::program p;
id_target t{};
EXPECT(is_shared(t.ctx, t.get_context()));
auto one = p.add_literal(1);
auto two = p.add_literal(2);
p.add_instruction(id_ctx_final_op{}, one, two);
p.compile(t);
// Finalizer will modify the context
EXPECT(not is_shared(t.ctx, p.get_context()));
auto ctx = p.get_context();
p.eval({});
EXPECT(is_shared(ctx, p.get_context()));
EXPECT(not is_shared(t.ctx, p.get_context()));
}
int main(int argc, const char* argv[]) { test::run(argc, argv); }
#include <migraph/fwd_conv_batchnorm_rewrite.hpp>
#include <migraph/program.hpp>
#include <migraph/cpu/target.hpp>
#include <migraph/operators.hpp>
#include <migraph/instruction.hpp>
#include <migraphx/fwd_conv_batchnorm_rewrite.hpp>
#include <migraphx/program.hpp>
#include <migraphx/cpu/target.hpp>
#include <migraphx/operators.hpp>
#include <migraphx/instruction.hpp>
#include <test.hpp>
#include <migraph/verify.hpp>
#include <migraphx/verify.hpp>
TEST_CASE(fwd_conv_batchnorm_rewrite_test)
{
......@@ -30,29 +30,30 @@ TEST_CASE(fwd_conv_batchnorm_rewrite_test)
-0.62146691, -2.40572931, -1.47175612, 1.49654601, -1.07070376, -0.65908074, -0.28457694,
1.60046717, 0.20677642, -1.51844486, 0.41203847, -0.01285751, 0.07948031, -0.91507006,
-1.59481079, -0.12856238, 0.39970482, -1.89015158, 0.66969754, 0.10312618};
migraph::shape xs{migraph::shape::float_type, {1, 3, 6, 6}};
migraph::shape ws{migraph::shape::float_type, {1, 3, 3, 3}};
migraph::shape vars{migraph::shape::float_type, {1}};
migraphx::shape xs{migraphx::shape::float_type, {1, 3, 6, 6}};
migraphx::shape ws{migraphx::shape::float_type, {1, 3, 3, 3}};
migraphx::shape vars{migraphx::shape::float_type, {1}};
auto create_program = [&]() {
migraph::program p;
auto x = p.add_literal(xs, xdata);
auto w = p.add_literal(ws, wdata);
auto conv = p.add_instruction(migraph::op::convolution{{{0, 0}}, {{1, 1}}, {{1, 1}}}, x, w);
auto scale = p.add_literal(migraph::literal{vars, {3.0f}});
auto bias = p.add_literal(migraph::literal{vars, {8.1f}});
auto mean = p.add_literal(migraph::literal{vars, {4.0f}});
auto variance = p.add_literal(migraph::literal{vars, {37.11f}});
p.add_instruction(migraph::op::batch_norm_inference{}, conv, scale, bias, mean, variance);
migraphx::program p;
auto x = p.add_literal(xs, xdata);
auto w = p.add_literal(ws, wdata);
auto conv =
p.add_instruction(migraphx::op::convolution{{{0, 0}}, {{1, 1}}, {{1, 1}}}, x, w);
auto scale = p.add_literal(migraphx::literal{vars, {3.0f}});
auto bias = p.add_literal(migraphx::literal{vars, {8.1f}});
auto mean = p.add_literal(migraphx::literal{vars, {4.0f}});
auto variance = p.add_literal(migraphx::literal{vars, {37.11f}});
p.add_instruction(migraphx::op::batch_norm_inference{}, conv, scale, bias, mean, variance);
return p;
};
migraph::program p1 = create_program();
migraph::program p2 = create_program();
migraph::fwd_conv_batchnorm_rewrite opt;
migraphx::program p1 = create_program();
migraphx::program p2 = create_program();
migraphx::fwd_conv_batchnorm_rewrite opt;
opt.apply(p2);
p1.compile(migraph::cpu::target{});
p2.compile(migraph::cpu::target{});
p1.compile(migraphx::cpu::target{});
p2.compile(migraphx::cpu::target{});
auto result1 = p1.eval({});
auto result2 = p2.eval({});
......@@ -61,7 +62,7 @@ TEST_CASE(fwd_conv_batchnorm_rewrite_test)
std::vector<float> results_vector2;
result1.visit([&](auto output) { results_vector1.assign(output.begin(), output.end()); });
result2.visit([&](auto output) { results_vector2.assign(output.begin(), output.end()); });
EXPECT(migraph::verify_range(results_vector1, results_vector2));
EXPECT(migraphx::verify_range(results_vector1, results_vector2));
}
int main(int argc, const char* argv[]) { test::run(argc, argv); }
#include <test.hpp>
#include <basic_ops.hpp>
#include <migraph/program.hpp>
#include <migraph/instruction.hpp>
#include <migraph/generate.hpp>
#include <migraph/gpu/target.hpp>
#include <migraph/gpu/hip.hpp>
#include <migraphx/program.hpp>
#include <migraphx/instruction.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/gpu/target.hpp>
#include <migraphx/gpu/hip.hpp>
void gpu_literal_test()
{
migraph::program p;
auto lit = generate_literal(migraph::shape{migraph::shape::float_type, {4, 3, 3, 3}});
migraphx::program p;
auto lit = generate_literal(migraphx::shape{migraphx::shape::float_type, {4, 3, 3, 3}});
p.add_literal(lit);
p.compile(migraph::gpu::target{});
p.compile(migraphx::gpu::target{});
auto scratch = p.get_parameter("scratch");
if(scratch == p.end())
{
auto result = p.eval({});
EXPECT(lit == migraph::gpu::from_gpu(result));
EXPECT(lit == migraphx::gpu::from_gpu(result));
}
else
{
......
#include <migraph/program.hpp>
#include <migraph/operators.hpp>
#include <migraph/generate.hpp>
#include <migraph/cpu/target.hpp>
#include <migraph/gpu/target.hpp>
#include <migraph/gpu/miopen.hpp>
#include <migraph/gpu/hip.hpp>
#include <migraph/manage_ptr.hpp>
#include <migraph/type_name.hpp>
#include <migraph/verify_args.hpp>
#include <migraph/instruction.hpp>
#include <migraphx/program.hpp>
#include <migraphx/operators.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/cpu/target.hpp>
#include <migraphx/gpu/target.hpp>
#include <migraphx/gpu/miopen.hpp>
#include <migraphx/gpu/hip.hpp>
#include <migraphx/manage_ptr.hpp>
#include <migraphx/type_name.hpp>
#include <migraphx/verify_args.hpp>
#include <migraphx/instruction.hpp>
#include <miopen/miopen.h>
......@@ -81,12 +81,12 @@ auto get_hash(const T& x)
return std::hash<T>{}(x);
}
void compile_check(migraph::program& p, const migraph::target& t)
void compile_check(migraphx::program& p, const migraphx::target& t)
{
auto name = t.name();
auto s = p.get_shape();
std::stringstream ss;
p.compile(t, migraph::tracer{ss});
p.compile(t, migraphx::tracer{ss});
if(p.get_shape() != s)
{
std::cout << ss.str() << std::endl;
......@@ -95,47 +95,48 @@ void compile_check(migraph::program& p, const migraph::target& t)
}
template <class V>
migraph::argument run_cpu(migraph::program& p)
migraphx::argument run_cpu(migraphx::program& p)
{
V v;
p = v.create_program();
auto_print pp{p, 0};
compile_check(p, migraph::cpu::target{});
migraph::program::parameter_map m;
compile_check(p, migraphx::cpu::target{});
migraphx::program::parameter_map m;
for(auto&& x : p.get_parameter_shapes())
{
m[x.first] = migraph::generate_argument(x.second, get_hash(x.first));
m[x.first] = migraphx::generate_argument(x.second, get_hash(x.first));
}
return p.eval(m);
}
template <class V>
migraph::argument run_gpu(migraph::program& p)
migraphx::argument run_gpu(migraphx::program& p)
{
V v;
p = v.create_program();
auto_print pp{p, 1};
compile_check(p, migraph::gpu::target{});
migraph::program::parameter_map m;
compile_check(p, migraphx::gpu::target{});
migraphx::program::parameter_map m;
for(auto&& x : p.get_parameter_shapes())
{
m[x.first] = migraph::gpu::to_gpu(migraph::generate_argument(x.second, get_hash(x.first)));
m[x.first] =
migraphx::gpu::to_gpu(migraphx::generate_argument(x.second, get_hash(x.first)));
}
EXPECT(bool{m.find("output") != m.end()});
return migraph::gpu::from_gpu(p.eval(m));
return migraphx::gpu::from_gpu(p.eval(m));
}
template <class V>
void verify_program()
{
auto_print::set_terminate_handler(migraph::get_type_name<V>());
// std::cout << migraph::get_type_name<V>() << std::endl;
migraph::program cpu_prog;
migraph::program gpu_prog;
auto_print::set_terminate_handler(migraphx::get_type_name<V>());
// std::cout << migraphx::get_type_name<V>() << std::endl;
migraphx::program cpu_prog;
migraphx::program gpu_prog;
auto cpu_arg_f = detach_async([&] { return run_cpu<V>(cpu_prog); });
auto gpu_arg = run_gpu<V>(gpu_prog);
auto cpu_arg = cpu_arg_f.get();
bool passed = verify_args(migraph::get_type_name<V>(), cpu_arg, gpu_arg);
bool passed = verify_args(migraphx::get_type_name<V>(), cpu_arg, gpu_arg);
if(not passed)
{
V v;
......@@ -150,82 +151,215 @@ void verify_program()
struct test_literals
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
migraphx::program p;
auto input = p.add_literal(
generate_literal(migraph::shape{migraph::shape::float_type, {4, 3, 3, 3}}));
generate_literal(migraphx::shape{migraphx::shape::float_type, {4, 3, 3, 3}}));
auto weights = p.add_literal(
generate_literal(migraph::shape{migraph::shape::float_type, {4, 3, 3, 3}}));
auto conv = p.add_instruction(migraph::op::convolution{}, input, weights);
p.add_instruction(migraph::op::relu{}, conv);
generate_literal(migraphx::shape{migraphx::shape::float_type, {4, 3, 3, 3}}));
auto conv = p.add_instruction(migraphx::op::convolution{}, input, weights);
p.add_instruction(migraphx::op::relu{}, conv);
return p;
}
};
struct test_add
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
migraph::shape s{migraph::shape::float_type, {3}};
migraphx::program p;
migraphx::shape s{migraphx::shape::float_type, {3}};
auto x = p.add_parameter("x", s);
auto y = p.add_parameter("y", s);
p.add_instruction(migraph::op::add{}, x, y);
p.add_instruction(migraphx::op::add{}, x, y);
return p;
}
};
struct test_add_half
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
migraph::shape s{migraph::shape::half_type, {3}};
migraphx::program p;
migraphx::shape s{migraphx::shape::half_type, {3}};
auto x = p.add_parameter("x", s);
auto y = p.add_parameter("y", s);
p.add_instruction(migraph::op::add{}, x, y);
p.add_instruction(migraphx::op::add{}, x, y);
return p;
}
};
struct test_mul
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
migraph::shape s{migraph::shape::float_type, {3}};
migraphx::program p;
migraphx::shape s{migraphx::shape::float_type, {3}};
auto x = p.add_parameter("x", s);
auto y = p.add_parameter("y", s);
p.add_instruction(migraph::op::mul{}, x, y);
p.add_instruction(migraphx::op::mul{}, x, y);
return p;
}
};
struct test_exp
{
migraphx::program create_program() const
{
migraphx::program p;
migraphx::shape s{migraphx::shape::float_type, {6}};
std::vector<float> data{0.1f, 0.2f, 1.f, 2.f, 0.6f, 10.f};
auto x = p.add_literal(s, data);
p.add_instruction(migraphx::op::exp{}, x);
return p;
}
};
struct test_log
{
migraphx::program create_program() const
{
migraphx::program p;
migraphx::shape s{migraphx::shape::float_type, {6}};
std::vector<float> data{0.1f, 0.2f, 1.f, 2.f, 0.6f, 100.f};
auto x = p.add_literal(s, data);
p.add_instruction(migraphx::op::log{}, x);
return p;
}
};
struct test_sin
{
migraphx::program create_program() const
{
migraphx::program p;
migraphx::shape s{migraphx::shape::float_type, {10}};
auto x = p.add_parameter("x", s);
p.add_instruction(migraphx::op::sin{}, x);
return p;
}
};
struct test_cos
{
migraphx::program create_program() const
{
migraphx::program p;
migraphx::shape s{migraphx::shape::double_type, {8}};
auto x = p.add_parameter("x", s);
p.add_instruction(migraphx::op::cos{}, x);
return p;
}
};
struct test_tan
{
migraphx::program create_program() const
{
migraphx::program p;
migraphx::shape s{migraphx::shape::float_type, {16}};
auto x = p.add_parameter("x", s);
p.add_instruction(migraphx::op::tan{}, x);
return p;
}
};
struct test_sinh
{
migraphx::program create_program() const
{
migraphx::program p;
migraphx::shape s{migraphx::shape::double_type, {16}};
auto x = p.add_parameter("x", s);
p.add_instruction(migraphx::op::sinh{}, x);
return p;
}
};
struct test_cosh
{
migraphx::program create_program() const
{
migraphx::program p;
migraphx::shape s{migraphx::shape::double_type, {16}};
auto x = p.add_parameter("x", s);
p.add_instruction(migraphx::op::cosh{}, x);
return p;
}
};
struct test_tanh
{
migraphx::program create_program() const
{
migraphx::program p;
auto x = p.add_parameter("x", migraphx::shape{migraphx::shape::float_type, {4, 3, 3, 3}});
p.add_instruction(migraphx::op::tanh{}, x);
return p;
}
};
struct test_asin
{
migraphx::program create_program() const
{
migraphx::program p;
migraphx::shape s{migraphx::shape::double_type, {16}};
auto x = p.add_parameter("x", s);
p.add_instruction(migraphx::op::asin{}, x);
return p;
}
};
struct test_acos
{
migraphx::program create_program() const
{
migraphx::program p;
migraphx::shape s{migraphx::shape::double_type, {16}};
auto x = p.add_parameter("x", s);
p.add_instruction(migraphx::op::acos{}, x);
return p;
}
};
struct test_atan
{
migraphx::program create_program() const
{
migraphx::program p;
migraphx::shape s{migraphx::shape::double_type, {16}};
auto x = p.add_parameter("x", s);
p.add_instruction(migraphx::op::atan{}, x);
return p;
}
};
struct test_scale
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
migraph::shape s{migraph::shape::float_type, {3}};
migraphx::program p;
migraphx::shape s{migraphx::shape::float_type, {3}};
auto x = p.add_parameter("x", s);
auto y = p.add_parameter("y", migraph::shape::float_type);
auto scale = p.add_instruction(migraph::op::scalar{s}, y);
p.add_instruction(migraph::op::mul{}, x, scale);
auto y = p.add_parameter("y", migraphx::shape::float_type);
auto scale = p.add_instruction(migraphx::op::scalar{s}, y);
p.add_instruction(migraphx::op::mul{}, x, scale);
return p;
}
};
struct test_slice
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
migraph::shape s{migraph::shape::int32_type, {2, 2, 4}};
migraphx::program p;
migraphx::shape s{migraphx::shape::int32_type, {2, 2, 4}};
auto x = p.add_parameter("x", s);
auto y = p.add_parameter("y", {migraph::shape::int32_type, {2, 2, 2}});
auto slice0 = p.add_instruction(migraph::op::slice{{2}, {0}, {2}}, x);
p.add_instruction(migraph::op::add{}, y, slice0);
auto y = p.add_parameter("y", {migraphx::shape::int32_type, {2, 2, 2}});
auto slice0 = p.add_instruction(migraphx::op::slice{{2}, {0}, {2}}, x);
p.add_instruction(migraphx::op::add{}, y, slice0);
return p;
}
......@@ -233,219 +367,272 @@ struct test_slice
struct test_triadd
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
migraph::shape s{migraph::shape::float_type, {3}};
migraphx::program p;
migraphx::shape s{migraphx::shape::float_type, {3}};
auto x = p.add_parameter("x", s);
auto y = p.add_parameter("y", s);
auto z = p.add_parameter("z", s);
auto sum = p.add_instruction(migraph::op::add{}, x, y);
p.add_instruction(migraph::op::add{}, sum, z);
auto sum = p.add_instruction(migraphx::op::add{}, x, y);
p.add_instruction(migraphx::op::add{}, sum, z);
return p;
}
};
struct test_triadd2
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
migraph::shape s{migraph::shape::float_type, {2, 3}};
migraph::shape b{migraph::shape::float_type, {3}};
migraphx::program p;
migraphx::shape s{migraphx::shape::float_type, {2, 3}};
migraphx::shape b{migraphx::shape::float_type, {3}};
auto x = p.add_parameter("x", s);
auto y = p.add_parameter("y", s);
auto z = p.add_parameter("z", b);
auto zb = p.add_instruction(migraph::op::broadcast{1, s}, z);
auto sum = p.add_instruction(migraph::op::add{}, x, y);
p.add_instruction(migraph::op::add{}, sum, zb);
auto zb = p.add_instruction(migraphx::op::broadcast{1, s}, z);
auto sum = p.add_instruction(migraphx::op::add{}, x, y);
p.add_instruction(migraphx::op::add{}, sum, zb);
return p;
}
};
struct test_add_broadcast
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
migraph::shape s{migraph::shape::float_type, {3}};
auto x = p.add_parameter("x", {migraph::shape::float_type, {2, 2, 3}});
auto y = p.add_parameter("y", {migraph::shape::float_type, {2, 2}});
auto by = p.add_instruction(migraph::op::broadcast{0, x->get_shape()}, y);
p.add_instruction(migraph::op::add{}, x, by);
migraphx::program p;
migraphx::shape s{migraphx::shape::float_type, {3}};
auto x = p.add_parameter("x", {migraphx::shape::float_type, {2, 2, 3}});
auto y = p.add_parameter("y", {migraphx::shape::float_type, {2, 2}});
auto by = p.add_instruction(migraphx::op::broadcast{0, x->get_shape()}, y);
p.add_instruction(migraphx::op::add{}, x, by);
return p;
}
};
struct test_add_broadcast2
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
migraph::shape s{migraph::shape::float_type, {3}};
auto x = p.add_parameter("x", {migraph::shape::float_type, {2, 3, 4}});
auto y = p.add_parameter("y", {migraph::shape::float_type, {3}});
auto by = p.add_instruction(migraph::op::broadcast{1, x->get_shape()}, y);
p.add_instruction(migraph::op::add{}, x, by);
migraphx::program p;
migraphx::shape s{migraphx::shape::float_type, {3}};
auto x = p.add_parameter("x", {migraphx::shape::float_type, {2, 3, 4}});
auto y = p.add_parameter("y", {migraphx::shape::float_type, {3}});
auto by = p.add_instruction(migraphx::op::broadcast{1, x->get_shape()}, y);
p.add_instruction(migraphx::op::add{}, x, by);
return p;
}
};
struct test_add_broadcast3
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
migraph::shape s{migraph::shape::float_type, {3}};
auto x = p.add_parameter("x", {migraph::shape::float_type, {2, 4, 5}});
auto y = p.add_parameter("y", {migraph::shape::float_type, {4}});
auto by = p.add_instruction(migraph::op::broadcast{1, x->get_shape()}, y);
p.add_instruction(migraph::op::add{}, x, by);
migraphx::program p;
migraphx::shape s{migraphx::shape::float_type, {3}};
auto x = p.add_parameter("x", {migraphx::shape::float_type, {2, 4, 5}});
auto y = p.add_parameter("y", {migraphx::shape::float_type, {4}});
auto by = p.add_instruction(migraphx::op::broadcast{1, x->get_shape()}, y);
p.add_instruction(migraphx::op::add{}, x, by);
return p;
}
};
struct test_add_broadcast4
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
migraph::shape s{migraph::shape::float_type, {3}};
auto x = p.add_parameter("x", {migraph::shape::float_type, {2, 3, 5}});
auto y = p.add_parameter("y", {migraph::shape::float_type, {3}});
auto by = p.add_instruction(migraph::op::broadcast{1, x->get_shape()}, y);
p.add_instruction(migraph::op::add{}, x, by);
migraphx::program p;
migraphx::shape s{migraphx::shape::float_type, {3}};
auto x = p.add_parameter("x", {migraphx::shape::float_type, {2, 3, 5}});
auto y = p.add_parameter("y", {migraphx::shape::float_type, {3}});
auto by = p.add_instruction(migraphx::op::broadcast{1, x->get_shape()}, y);
p.add_instruction(migraphx::op::add{}, x, by);
return p;
}
};
struct test_add_broadcast5
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
migraph::shape s{migraph::shape::float_type, {3}};
auto x = p.add_parameter("x", {migraph::shape::float_type, {2, 4, 8}});
auto y = p.add_parameter("y", {migraph::shape::float_type, {4}});
auto by = p.add_instruction(migraph::op::broadcast{1, x->get_shape()}, y);
p.add_instruction(migraph::op::add{}, x, by);
migraphx::program p;
migraphx::shape s{migraphx::shape::float_type, {3}};
auto x = p.add_parameter("x", {migraphx::shape::float_type, {2, 4, 8}});
auto y = p.add_parameter("y", {migraphx::shape::float_type, {4}});
auto by = p.add_instruction(migraphx::op::broadcast{1, x->get_shape()}, y);
p.add_instruction(migraphx::op::add{}, x, by);
return p;
}
};
struct test_triadd_broadcast
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
migraph::shape s{migraph::shape::float_type, {3}};
auto x = p.add_parameter("x", {migraph::shape::float_type, {2, 2, 3}});
auto y = p.add_parameter("y", {migraph::shape::float_type, {2, 2}});
auto z = p.add_parameter("z", {migraph::shape::float_type, {2, 2, 3}});
auto by = p.add_instruction(migraph::op::broadcast{0, x->get_shape()}, y);
auto sum = p.add_instruction(migraph::op::add{}, x, by);
p.add_instruction(migraph::op::add{}, sum, z);
migraphx::program p;
migraphx::shape s{migraphx::shape::float_type, {3}};
auto x = p.add_parameter("x", {migraphx::shape::float_type, {2, 2, 3}});
auto y = p.add_parameter("y", {migraphx::shape::float_type, {2, 2}});
auto z = p.add_parameter("z", {migraphx::shape::float_type, {2, 2, 3}});
auto by = p.add_instruction(migraphx::op::broadcast{0, x->get_shape()}, y);
auto sum = p.add_instruction(migraphx::op::add{}, x, by);
p.add_instruction(migraphx::op::add{}, sum, z);
return p;
}
};
struct test_softmax
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
auto x = p.add_parameter("x", migraph::shape{migraph::shape::float_type, {5, 3, 4, 2}});
p.add_instruction(migraph::op::softmax{}, x);
migraphx::program p;
auto x = p.add_parameter("x", migraphx::shape{migraphx::shape::float_type, {5, 3, 4, 2}});
p.add_instruction(migraphx::op::softmax{}, x);
return p;
}
};
struct test_softmax2
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
auto x = p.add_parameter("x", migraph::shape{migraph::shape::float_type, {1, 1000, 1, 1}});
p.add_instruction(migraph::op::softmax{}, x);
migraphx::program p;
auto x =
p.add_parameter("x", migraphx::shape{migraphx::shape::float_type, {1, 1000, 1, 1}});
p.add_instruction(migraphx::op::softmax{}, x);
return p;
}
};
struct test_conv
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
auto input = p.add_parameter("x", migraph::shape{migraph::shape::float_type, {4, 3, 3, 3}});
migraphx::program p;
auto input =
p.add_parameter("x", migraphx::shape{migraphx::shape::float_type, {4, 3, 3, 3}});
auto weights =
p.add_parameter("w", migraph::shape{migraph::shape::float_type, {4, 3, 3, 3}});
p.add_instruction(migraph::op::convolution{}, input, weights);
p.add_parameter("w", migraphx::shape{migraphx::shape::float_type, {4, 3, 3, 3}});
p.add_instruction(migraphx::op::convolution{}, input, weights);
return p;
}
};
struct test_conv2
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
migraphx::program p;
auto input =
p.add_parameter("x", migraphx::shape{migraphx::shape::float_type, {1, 512, 28, 28}});
auto weights =
p.add_parameter("w", migraphx::shape{migraphx::shape::float_type, {256, 512, 1, 1}});
p.add_instruction(migraphx::op::convolution{{0, 0}, {1, 1}, {1, 1}}, input, weights);
return p;
}
};
struct test_group_conv
{
migraphx::program create_program() const
{
migraphx::program p;
auto input =
p.add_parameter("x", migraph::shape{migraph::shape::float_type, {1, 512, 28, 28}});
p.add_parameter("x", migraphx::shape{migraphx::shape::float_type, {1, 4, 16, 16}});
auto weights =
p.add_parameter("w", migraph::shape{migraph::shape::float_type, {256, 512, 1, 1}});
p.add_instruction(migraph::op::convolution{{0, 0}, {1, 1}, {1, 1}}, input, weights);
p.add_parameter("w", migraphx::shape{migraphx::shape::float_type, {4, 1, 3, 3}});
migraphx::op::convolution op;
op.group = 4;
p.add_instruction(op, input, weights);
return p;
}
};
struct test_conv_relu
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
auto input = p.add_parameter("x", migraph::shape{migraph::shape::float_type, {4, 3, 3, 3}});
migraphx::program p;
auto input =
p.add_parameter("x", migraphx::shape{migraphx::shape::float_type, {4, 3, 3, 3}});
auto weights =
p.add_parameter("w", migraph::shape{migraph::shape::float_type, {4, 3, 3, 3}});
auto conv = p.add_instruction(migraph::op::convolution{}, input, weights);
p.add_instruction(migraph::op::relu{}, conv);
p.add_parameter("w", migraphx::shape{migraphx::shape::float_type, {4, 3, 3, 3}});
auto conv = p.add_instruction(migraphx::op::convolution{}, input, weights);
p.add_instruction(migraphx::op::relu{}, conv);
return p;
}
};
struct test_conv_relu_half
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
auto input = p.add_parameter("x", migraph::shape{migraph::shape::half_type, {4, 3, 3, 3}});
migraphx::program p;
auto input =
p.add_parameter("x", migraphx::shape{migraphx::shape::half_type, {4, 3, 3, 3}});
auto weights =
p.add_parameter("w", migraph::shape{migraph::shape::half_type, {4, 3, 3, 3}});
auto conv = p.add_instruction(migraph::op::convolution{}, input, weights);
p.add_instruction(migraph::op::relu{}, conv);
p.add_parameter("w", migraphx::shape{migraphx::shape::half_type, {4, 3, 3, 3}});
auto conv = p.add_instruction(migraphx::op::convolution{}, input, weights);
p.add_instruction(migraphx::op::relu{}, conv);
return p;
}
};
struct test_add_relu
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
auto x = p.add_parameter("x", migraph::shape{migraph::shape::float_type, {4, 3, 3, 3}});
auto y = p.add_parameter("y", migraph::shape{migraph::shape::float_type, {4, 3, 3, 3}});
auto add = p.add_instruction(migraph::op::add{}, x, y);
p.add_instruction(migraph::op::relu{}, add);
migraphx::program p;
auto x = p.add_parameter("x", migraphx::shape{migraphx::shape::float_type, {4, 3, 3, 3}});
auto y = p.add_parameter("y", migraphx::shape{migraphx::shape::float_type, {4, 3, 3, 3}});
auto add = p.add_instruction(migraphx::op::add{}, x, y);
p.add_instruction(migraphx::op::relu{}, add);
return p;
}
};
struct test_sigmoid
{
migraphx::program create_program() const
{
migraphx::program p;
auto x = p.add_parameter("x", migraphx::shape{migraphx::shape::float_type, {4, 3, 3, 3}});
p.add_instruction(migraphx::op::sigmoid{}, x);
return p;
}
};
struct test_abs
{
migraphx::program create_program() const
{
migraphx::program p;
auto x = p.add_parameter("x", migraphx::shape{migraphx::shape::float_type, {4, 3, 3, 3}});
p.add_instruction(migraphx::op::abs{}, x);
return p;
}
};
struct test_leaky_relu
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
auto x = p.add_parameter("x", migraph::shape{migraph::shape::float_type, {4, 3, 3, 3}});
p.add_instruction(migraph::op::leaky_relu{0.01}, x);
migraphx::program p;
auto x = p.add_parameter("x", migraphx::shape{migraphx::shape::float_type, {4, 3, 3, 3}});
p.add_instruction(migraphx::op::leaky_relu{0.01}, x);
return p;
}
};
struct test_elu
{
migraphx::program create_program() const
{
migraphx::program p;
auto x = p.add_parameter("x", migraphx::shape{migraphx::shape::float_type, {4, 3, 3, 3}});
p.add_instruction(migraphx::op::leaky_relu{1.0}, x);
return p;
}
};
......@@ -463,28 +650,28 @@ struct test_lrn
struct test_conv_pooling
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
migraphx::program p;
auto input =
p.add_parameter("x", migraph::shape{migraph::shape::float_type, {4, 3, 32, 32}});
p.add_parameter("x", migraphx::shape{migraphx::shape::float_type, {4, 3, 32, 32}});
auto weights =
p.add_parameter("w", migraph::shape{migraph::shape::float_type, {4, 3, 3, 3}});
auto conv = p.add_instruction(migraph::op::convolution{}, input, weights);
auto pooling = p.add_instruction(migraph::op::pooling{"max"}, conv);
p.add_instruction(migraph::op::relu{}, pooling);
p.add_parameter("w", migraphx::shape{migraphx::shape::float_type, {4, 3, 3, 3}});
auto conv = p.add_instruction(migraphx::op::convolution{}, input, weights);
auto pooling = p.add_instruction(migraphx::op::pooling{"max"}, conv);
p.add_instruction(migraphx::op::relu{}, pooling);
return p;
}
};
struct test_global_avg_pooling
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
migraphx::program p;
auto input =
p.add_parameter("x", migraph::shape{migraph::shape::float_type, {1, 3, 16, 16}});
auto op = migraph::op::pooling{"average"};
p.add_parameter("x", migraphx::shape{migraphx::shape::float_type, {1, 3, 16, 16}});
auto op = migraphx::op::pooling{"average"};
auto lens = input->get_shape().lens();
op.lengths = {lens[2], lens[3]};
p.add_instruction(op, input);
......@@ -494,12 +681,12 @@ struct test_global_avg_pooling
struct test_global_max_pooling
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
migraphx::program p;
auto input =
p.add_parameter("x", migraph::shape{migraph::shape::float_type, {1, 3, 16, 16}});
auto op = migraph::op::pooling{"max"};
p.add_parameter("x", migraphx::shape{migraphx::shape::float_type, {1, 3, 16, 16}});
auto op = migraphx::op::pooling{"max"};
auto lens = input->get_shape().lens();
op.lengths = {lens[2], lens[3]};
p.add_instruction(op, input);
......@@ -509,88 +696,90 @@ struct test_global_max_pooling
struct test_gemm
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
auto a = p.add_parameter("a", migraph::shape{migraph::shape::float_type, {4, 5}});
auto b = p.add_parameter("b", migraph::shape{migraph::shape::float_type, {5, 3}});
p.add_instruction(migraph::op::dot{}, a, b);
migraphx::program p;
auto a = p.add_parameter("a", migraphx::shape{migraphx::shape::float_type, {4, 5}});
auto b = p.add_parameter("b", migraphx::shape{migraphx::shape::float_type, {5, 3}});
p.add_instruction(migraphx::op::dot{}, a, b);
return p;
}
};
struct test_gemm_half
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
auto a = p.add_parameter("a", migraph::shape{migraph::shape::half_type, {4, 5}});
auto b = p.add_parameter("b", migraph::shape{migraph::shape::half_type, {5, 3}});
p.add_instruction(migraph::op::dot{}, a, b);
migraphx::program p;
auto a = p.add_parameter("a", migraphx::shape{migraphx::shape::half_type, {4, 5}});
auto b = p.add_parameter("b", migraphx::shape{migraphx::shape::half_type, {5, 3}});
p.add_instruction(migraphx::op::dot{}, a, b);
return p;
}
};
struct test_gemm_ld
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
auto a = p.add_parameter("a", migraph::shape{migraph::shape::float_type, {4, 5}, {10, 1}});
auto b = p.add_parameter("b", migraph::shape{migraph::shape::float_type, {5, 3}, {20, 1}});
p.add_instruction(migraph::op::dot{}, a, b);
migraphx::program p;
auto a =
p.add_parameter("a", migraphx::shape{migraphx::shape::float_type, {4, 5}, {10, 1}});
auto b =
p.add_parameter("b", migraphx::shape{migraphx::shape::float_type, {5, 3}, {20, 1}});
p.add_instruction(migraphx::op::dot{}, a, b);
return p;
}
};
struct test_gemm_transposeb
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
auto a = p.add_parameter("a", migraph::shape{migraph::shape::float_type, {4, 5}});
auto b = p.add_parameter("b", migraph::shape{migraph::shape::float_type, {3, 5}});
auto bt = p.add_instruction(migraph::op::transpose{{1, 0}}, b);
p.add_instruction(migraph::op::dot{}, a, bt);
migraphx::program p;
auto a = p.add_parameter("a", migraphx::shape{migraphx::shape::float_type, {4, 5}});
auto b = p.add_parameter("b", migraphx::shape{migraphx::shape::float_type, {3, 5}});
auto bt = p.add_instruction(migraphx::op::transpose{{1, 0}}, b);
p.add_instruction(migraphx::op::dot{}, a, bt);
return p;
}
};
struct test_gemm_transposea
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
auto a = p.add_parameter("a", migraph::shape{migraph::shape::float_type, {5, 4}});
auto b = p.add_parameter("b", migraph::shape{migraph::shape::float_type, {5, 3}});
auto at = p.add_instruction(migraph::op::transpose{{1, 0}}, a);
p.add_instruction(migraph::op::dot{}, at, b);
migraphx::program p;
auto a = p.add_parameter("a", migraphx::shape{migraphx::shape::float_type, {5, 4}});
auto b = p.add_parameter("b", migraphx::shape{migraphx::shape::float_type, {5, 3}});
auto at = p.add_instruction(migraphx::op::transpose{{1, 0}}, a);
p.add_instruction(migraphx::op::dot{}, at, b);
return p;
}
};
struct test_gemm_transposeab
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
auto a = p.add_parameter("a", migraph::shape{migraph::shape::float_type, {5, 4}});
auto b = p.add_parameter("b", migraph::shape{migraph::shape::float_type, {3, 5}});
auto at = p.add_instruction(migraph::op::transpose{{1, 0}}, a);
auto bt = p.add_instruction(migraph::op::transpose{{1, 0}}, b);
p.add_instruction(migraph::op::dot{}, at, bt);
migraphx::program p;
auto a = p.add_parameter("a", migraphx::shape{migraphx::shape::float_type, {5, 4}});
auto b = p.add_parameter("b", migraphx::shape{migraphx::shape::float_type, {3, 5}});
auto at = p.add_instruction(migraphx::op::transpose{{1, 0}}, a);
auto bt = p.add_instruction(migraphx::op::transpose{{1, 0}}, b);
p.add_instruction(migraphx::op::dot{}, at, bt);
return p;
}
};
struct test_contiguous
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
migraph::shape s{migraph::shape::float_type, {4, 4, 4, 3}, {48, 4, 1, 16}};
migraphx::program p;
migraphx::shape s{migraphx::shape::float_type, {4, 4, 4, 3}, {48, 4, 1, 16}};
auto x = p.add_parameter("x", s);
p.add_instruction(migraph::op::contiguous{}, x);
p.add_instruction(migraphx::op::contiguous{}, x);
EXPECT(p.get_shape().standard());
return p;
}
......@@ -598,14 +787,14 @@ struct test_contiguous
struct test_transpose
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
migraph::shape s{migraph::shape::float_type, {4, 3, 4, 4}};
migraphx::program p;
migraphx::shape s{migraphx::shape::float_type, {4, 3, 4, 4}};
auto x = p.add_parameter("x", s);
std::vector<int64_t> perm = {0, 2, 3, 1};
auto l = p.add_instruction(migraph::op::transpose{perm}, x);
p.add_instruction(migraph::op::contiguous{}, l);
auto l = p.add_instruction(migraphx::op::transpose{perm}, x);
p.add_instruction(migraphx::op::contiguous{}, l);
return p;
}
};
......@@ -617,18 +806,18 @@ struct test_batchnorm_inference_2
const size_t channels = 256;
const size_t batches = 1;
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
migraphx::program p;
migraph::shape s{migraph::shape::float_type, {batches, channels, height, width}};
migraph::shape vars{migraph::shape::float_type, {channels}};
migraphx::shape s{migraphx::shape::float_type, {batches, channels, height, width}};
migraphx::shape vars{migraphx::shape::float_type, {channels}};
auto x = p.add_parameter("x", s);
auto scale = p.add_literal(migraph::abs(migraph::generate_literal(vars, 1)));
auto bias = p.add_literal(migraph::abs(migraph::generate_literal(vars, 2)));
auto mean = p.add_literal(migraph::abs(migraph::generate_literal(vars, 3)));
auto variance = p.add_literal(migraph::abs(migraph::generate_literal(vars, 4)));
p.add_instruction(migraph::op::batch_norm_inference{}, x, scale, bias, mean, variance);
auto scale = p.add_literal(migraphx::abs(migraphx::generate_literal(vars, 1)));
auto bias = p.add_literal(migraphx::abs(migraphx::generate_literal(vars, 2)));
auto mean = p.add_literal(migraphx::abs(migraphx::generate_literal(vars, 3)));
auto variance = p.add_literal(migraphx::abs(migraphx::generate_literal(vars, 4)));
p.add_instruction(migraphx::op::batch_norm_inference{}, x, scale, bias, mean, variance);
return p;
}
};
......@@ -640,200 +829,268 @@ struct test_batchnorm_inference
const size_t channels = 3;
const size_t batches = 4;
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
migraphx::program p;
migraph::shape s{migraph::shape::float_type, {batches, channels, height, width}};
migraph::shape vars{migraph::shape::float_type, {channels}};
migraphx::shape s{migraphx::shape::float_type, {batches, channels, height, width}};
migraphx::shape vars{migraphx::shape::float_type, {channels}};
auto x = p.add_parameter("x", s);
auto scale = p.add_literal(migraph::abs(migraph::generate_literal(vars, 1)));
auto bias = p.add_literal(migraph::abs(migraph::generate_literal(vars, 2)));
auto mean = p.add_literal(migraph::abs(migraph::generate_literal(vars, 3)));
auto variance = p.add_literal(migraph::abs(migraph::generate_literal(vars, 4)));
p.add_instruction(migraph::op::batch_norm_inference{}, x, scale, bias, mean, variance);
auto scale = p.add_literal(migraphx::abs(migraphx::generate_literal(vars, 1)));
auto bias = p.add_literal(migraphx::abs(migraphx::generate_literal(vars, 2)));
auto mean = p.add_literal(migraphx::abs(migraphx::generate_literal(vars, 3)));
auto variance = p.add_literal(migraphx::abs(migraphx::generate_literal(vars, 4)));
p.add_instruction(migraphx::op::batch_norm_inference{}, x, scale, bias, mean, variance);
return p;
}
};
struct test_conv_bn
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
migraphx::program p;
migraph::shape xs{migraph::shape::float_type, {1, 3, 224, 224}};
migraph::shape ws{migraph::shape::float_type, {64, 3, 7, 7}};
migraph::shape vars{migraph::shape::float_type, {64}};
migraphx::shape xs{migraphx::shape::float_type, {1, 3, 224, 224}};
migraphx::shape ws{migraphx::shape::float_type, {64, 3, 7, 7}};
migraphx::shape vars{migraphx::shape::float_type, {64}};
auto x = p.add_parameter("x", xs);
auto w = p.add_parameter("w", ws);
auto conv = p.add_instruction(migraph::op::convolution{{3, 3}, {2, 2}, {1, 1}}, x, w);
auto scale = p.add_literal(migraph::abs(migraph::generate_literal(vars, 1)));
auto bias = p.add_literal(migraph::abs(migraph::generate_literal(vars, 2)));
auto mean = p.add_literal(migraph::abs(migraph::generate_literal(vars, 3)));
auto variance = p.add_literal(migraph::abs(migraph::generate_literal(vars, 4)));
p.add_instruction(migraph::op::batch_norm_inference{}, conv, scale, bias, mean, variance);
auto conv = p.add_instruction(migraphx::op::convolution{{3, 3}, {2, 2}, {1, 1}}, x, w);
auto scale = p.add_literal(migraphx::abs(migraphx::generate_literal(vars, 1)));
auto bias = p.add_literal(migraphx::abs(migraphx::generate_literal(vars, 2)));
auto mean = p.add_literal(migraphx::abs(migraphx::generate_literal(vars, 3)));
auto variance = p.add_literal(migraphx::abs(migraphx::generate_literal(vars, 4)));
p.add_instruction(migraphx::op::batch_norm_inference{}, conv, scale, bias, mean, variance);
return p;
}
};
struct test_conv_bn_relu_pooling
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
migraphx::program p;
migraph::shape xs{migraph::shape::float_type, {1, 3, 224, 224}};
migraph::shape ws{migraph::shape::float_type, {64, 3, 7, 7}};
migraph::shape vars{migraph::shape::float_type, {64}};
migraphx::shape xs{migraphx::shape::float_type, {1, 3, 224, 224}};
migraphx::shape ws{migraphx::shape::float_type, {64, 3, 7, 7}};
migraphx::shape vars{migraphx::shape::float_type, {64}};
auto x = p.add_parameter("x", xs);
auto w = p.add_parameter("w", ws);
auto conv = p.add_instruction(migraph::op::convolution{{3, 3}, {2, 2}, {1, 1}}, x, w);
auto scale = p.add_literal(migraph::abs(migraph::generate_literal(vars, 1)));
auto bias = p.add_literal(migraph::abs(migraph::generate_literal(vars, 2)));
auto mean = p.add_literal(migraph::abs(migraph::generate_literal(vars, 3)));
auto variance = p.add_literal(migraph::abs(migraph::generate_literal(vars, 4)));
auto conv = p.add_instruction(migraphx::op::convolution{{3, 3}, {2, 2}, {1, 1}}, x, w);
auto scale = p.add_literal(migraphx::abs(migraphx::generate_literal(vars, 1)));
auto bias = p.add_literal(migraphx::abs(migraphx::generate_literal(vars, 2)));
auto mean = p.add_literal(migraphx::abs(migraphx::generate_literal(vars, 3)));
auto variance = p.add_literal(migraphx::abs(migraphx::generate_literal(vars, 4)));
auto bn = p.add_instruction(
migraph::op::batch_norm_inference{}, conv, scale, bias, mean, variance);
auto relu = p.add_instruction(migraph::op::relu{}, bn);
p.add_instruction(migraph::op::pooling{"average", {1, 1}, {2, 2}, {3, 3}}, relu);
migraphx::op::batch_norm_inference{}, conv, scale, bias, mean, variance);
auto relu = p.add_instruction(migraphx::op::relu{}, bn);
p.add_instruction(migraphx::op::pooling{"average", {1, 1}, {2, 2}, {3, 3}}, relu);
return p;
}
};
struct test_concat
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
migraphx::program p;
std::size_t axis = 1;
migraph::shape s0{migraph::shape::int32_type, {2, 2}};
migraph::shape s1{migraph::shape::int32_type, {2, 3}};
migraph::shape s2{migraph::shape::int32_type, {2, 1}};
migraphx::shape s0{migraphx::shape::int32_type, {2, 2}};
migraphx::shape s1{migraphx::shape::int32_type, {2, 3}};
migraphx::shape s2{migraphx::shape::int32_type, {2, 1}};
auto l0 = p.add_parameter("x", s0);
auto l1 = p.add_parameter("y", s1);
auto l2 = p.add_parameter("z", s2);
p.add_instruction(migraph::op::concat{axis}, l0, l1, l2);
p.add_instruction(migraphx::op::concat{axis}, l0, l1, l2);
return p;
}
};
struct test_concat2
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
migraphx::program p;
std::size_t axis = 0;
migraph::shape s0{migraph::shape::int32_type, {2, 2}};
migraph::shape s1{migraph::shape::int32_type, {3, 2}};
migraph::shape s2{migraph::shape::int32_type, {1, 2}};
migraphx::shape s0{migraphx::shape::int32_type, {2, 2}};
migraphx::shape s1{migraphx::shape::int32_type, {3, 2}};
migraphx::shape s2{migraphx::shape::int32_type, {1, 2}};
auto l0 = p.add_parameter("x", s0);
auto l1 = p.add_parameter("y", s1);
auto l2 = p.add_parameter("z", s2);
p.add_instruction(migraph::op::concat{axis}, l0, l1, l2);
p.add_instruction(migraphx::op::concat{axis}, l0, l1, l2);
return p;
}
};
struct test_concat_relu
{
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
migraphx::program p;
std::size_t axis = 0;
migraph::shape s0{migraph::shape::float_type, {2, 2}};
migraph::shape s1{migraph::shape::float_type, {3, 2}};
migraph::shape s2{migraph::shape::float_type, {1, 2}};
migraphx::shape s0{migraphx::shape::float_type, {2, 2}};
migraphx::shape s1{migraphx::shape::float_type, {3, 2}};
migraphx::shape s2{migraphx::shape::float_type, {1, 2}};
auto l0 = p.add_parameter("x", s0);
auto l1 = p.add_parameter("y", s1);
auto l2 = p.add_parameter("z", s2);
auto r0 = p.add_instruction(migraph::op::relu{}, l0);
auto r1 = p.add_instruction(migraph::op::relu{}, l1);
auto r2 = p.add_instruction(migraph::op::relu{}, l2);
auto c0 = p.add_instruction(migraph::op::concat{axis}, r0, r1, r2);
p.add_instruction(migraph::op::relu{}, c0);
auto r0 = p.add_instruction(migraphx::op::relu{}, l0);
auto r1 = p.add_instruction(migraphx::op::relu{}, l1);
auto r2 = p.add_instruction(migraphx::op::relu{}, l2);
auto c0 = p.add_instruction(migraphx::op::concat{axis}, r0, r1, r2);
p.add_instruction(migraphx::op::relu{}, c0);
return p;
}
};
struct test_pad
{
migraphx::program create_program() const
{
migraphx::program p;
migraphx::shape s0{migraphx::shape::int32_type, {1, 96, 165, 165}};
std::vector<int64_t> pads0 = {0, 0, 0, 0, 0, 0, 1, 1};
std::vector<int64_t> pads1 = {0, 0, 0, 0, 1, 1, 1, 1};
std::vector<int64_t> pads2 = {1, 1, 1, 1, 0, 0, 0, 0};
std::vector<int64_t> pads3 = {1, 0, 1, 0, 1, 0, 2, 0};
auto l0 = p.add_parameter("x", s0);
p.add_instruction(migraphx::op::pad{pads0}, l0);
p.add_instruction(migraphx::op::pad{pads1}, l0);
p.add_instruction(migraphx::op::pad{pads2}, l0);
p.add_instruction(migraphx::op::pad{pads3}, l0);
return p;
}
};
struct test_pooling_autopad
{
migraphx::program create_program() const
{
migraphx::program p;
migraphx::shape s0{migraphx::shape::float_type, {1, 3, 63, 63}};
auto l0 = p.add_parameter("x", s0);
migraphx::op::pooling op{"max"};
op.padding_mode = migraphx::op::padding_mode_t::same;
op.lengths = {2, 2};
op.stride = {2, 2};
p.add_instruction(op, l0);
return p;
}
};
struct test_gather
{
migraphx::program create_program() const
{
migraphx::program p;
migraphx::shape s{migraphx::shape::float_type, {3, 3}};
migraphx::shape s_indices{migraphx::shape::int32_type, {2, 2}};
std::vector<int> indices{1, 2, 2, 1};
auto a0 = p.add_parameter("data", s);
auto a1 = p.add_literal(migraphx::literal{s_indices, indices});
int axis = 0;
p.add_instruction(migraphx::op::gather{axis}, a0, a1);
return p;
}
};
struct test_gather_neg_axis
{
migraphx::program create_program() const
{
migraphx::program p;
migraphx::shape s{migraphx::shape::float_type, {3, 3}};
migraphx::shape s_indices{migraphx::shape::int32_type, {2, 2}};
std::vector<int> indices{1, 2, 2, 1};
auto a0 = p.add_parameter("data", s);
auto a1 = p.add_literal(migraphx::literal{s_indices, indices});
int axis = -1;
p.add_instruction(migraphx::op::gather{axis}, a0, a1);
return p;
}
};
void manual_identity()
{
migraph::program p;
migraphx::program p;
std::vector<float> data0 = {0, 1, 2, 3};
migraph::shape s0{migraph::shape::float_type, {2, 2}};
auto l0 = p.add_literal(migraph::literal{s0, data0});
p.add_instruction(migraph::op::identity{}, l0);
p.compile(migraph::gpu::target{});
migraph::program::parameter_map m;
migraphx::shape s0{migraphx::shape::float_type, {2, 2}};
auto l0 = p.add_literal(migraphx::literal{s0, data0});
p.add_instruction(migraphx::op::identity{}, l0);
p.compile(migraphx::gpu::target{});
migraphx::program::parameter_map m;
for(auto&& x : p.get_parameter_shapes())
{
m[x.first] = migraph::gpu::to_gpu(migraph::generate_argument(x.second));
m[x.first] = migraphx::gpu::to_gpu(migraphx::generate_argument(x.second));
}
auto result = migraph::gpu::from_gpu(p.eval(m));
auto result = migraphx::gpu::from_gpu(p.eval(m));
std::cout << result << std::endl;
}
void manual_test_concat_relu()
{
migraph::program p;
migraphx::program p;
std::size_t axis = 0;
std::vector<float> data0 = {0, 1, 2, 3};
std::vector<float> data1 = {4, 5, 6, 7, 8, 9};
std::vector<float> data2 = {10, 11};
migraph::shape s0{migraph::shape::float_type, {2, 2}};
migraph::shape s1{migraph::shape::float_type, {3, 2}};
migraph::shape s2{migraph::shape::float_type, {1, 2}};
auto l0 = p.add_literal(migraph::literal{s0, data0});
auto l1 = p.add_literal(migraph::literal{s1, data1});
auto l2 = p.add_literal(migraph::literal{s2, data2});
auto r0 = p.add_instruction(migraph::op::relu{}, l0);
auto r1 = p.add_instruction(migraph::op::relu{}, l1);
auto r2 = p.add_instruction(migraph::op::relu{}, l2);
auto c0 = p.add_instruction(migraph::op::concat{axis}, r0, r1, r2);
p.add_instruction(migraph::op::relu{}, c0);
p.compile(migraph::gpu::target{});
migraph::program::parameter_map m;
migraphx::shape s0{migraphx::shape::float_type, {2, 2}};
migraphx::shape s1{migraphx::shape::float_type, {3, 2}};
migraphx::shape s2{migraphx::shape::float_type, {1, 2}};
auto l0 = p.add_literal(migraphx::literal{s0, data0});
auto l1 = p.add_literal(migraphx::literal{s1, data1});
auto l2 = p.add_literal(migraphx::literal{s2, data2});
auto r0 = p.add_instruction(migraphx::op::relu{}, l0);
auto r1 = p.add_instruction(migraphx::op::relu{}, l1);
auto r2 = p.add_instruction(migraphx::op::relu{}, l2);
auto c0 = p.add_instruction(migraphx::op::concat{axis}, r0, r1, r2);
p.add_instruction(migraphx::op::relu{}, c0);
p.compile(migraphx::gpu::target{});
migraphx::program::parameter_map m;
for(auto&& x : p.get_parameter_shapes())
{
m[x.first] = migraph::gpu::to_gpu(migraph::generate_argument(x.second));
m[x.first] = migraphx::gpu::to_gpu(migraphx::generate_argument(x.second));
}
auto result = migraph::gpu::from_gpu(p.eval(m));
auto result = migraphx::gpu::from_gpu(p.eval(m));
std::cout << result << std::endl;
}
struct test_conv_bn_relu_pooling2
{
static migraph::instruction_ref
add_bn(migraph::program& p, migraph::instruction_ref x, std::size_t channels)
static migraphx::instruction_ref
add_bn(migraphx::program& p, migraphx::instruction_ref x, std::size_t channels)
{
migraph::shape vars{migraph::shape::float_type, {channels}};
auto scale = p.add_literal(migraph::abs(migraph::generate_literal(vars, 1 + channels)));
auto bias = p.add_literal(migraph::abs(migraph::generate_literal(vars, 2 + channels)));
auto mean = p.add_literal(migraph::abs(migraph::generate_literal(vars, 3 + channels)));
auto variance = p.add_literal(migraph::abs(migraph::generate_literal(vars, 4 + channels)));
migraphx::shape vars{migraphx::shape::float_type, {channels}};
auto scale = p.add_literal(migraphx::abs(migraphx::generate_literal(vars, 1 + channels)));
auto bias = p.add_literal(migraphx::abs(migraphx::generate_literal(vars, 2 + channels)));
auto mean = p.add_literal(migraphx::abs(migraphx::generate_literal(vars, 3 + channels)));
auto variance =
p.add_literal(migraphx::abs(migraphx::generate_literal(vars, 4 + channels)));
return p.add_instruction(
migraph::op::batch_norm_inference{}, x, scale, bias, mean, variance);
migraphx::op::batch_norm_inference{}, x, scale, bias, mean, variance);
}
migraph::program create_program() const
migraphx::program create_program() const
{
migraph::program p;
migraphx::program p;
migraph::shape xs1{migraph::shape::float_type, {1, 512, 7, 7}};
migraph::shape xs2{migraph::shape::float_type, {1, 1024, 14, 14}};
migraph::shape ws1{migraph::shape::float_type, {2048, 512, 1, 1}};
migraph::shape ws2{migraph::shape::float_type, {2048, 1024, 1, 1}};
migraphx::shape xs1{migraphx::shape::float_type, {1, 512, 7, 7}};
migraphx::shape xs2{migraphx::shape::float_type, {1, 1024, 14, 14}};
migraphx::shape ws1{migraphx::shape::float_type, {2048, 512, 1, 1}};
migraphx::shape ws2{migraphx::shape::float_type, {2048, 1024, 1, 1}};
auto x1 = p.add_parameter("x1", xs1);
auto w1 = p.add_parameter("w1", ws1);
auto conv1 = p.add_instruction(migraph::op::convolution{{0, 0}, {1, 1}, {1, 1}}, x1, w1);
auto conv1 = p.add_instruction(migraphx::op::convolution{{0, 0}, {1, 1}, {1, 1}}, x1, w1);
auto bn1 = add_bn(p, conv1, 2048);
auto x2 = p.add_parameter("x2", xs2);
auto w2 = p.add_parameter("w2", ws2);
auto conv2 = p.add_instruction(migraph::op::convolution{{0, 0}, {2, 2}, {1, 1}}, x2, w2);
auto conv2 = p.add_instruction(migraphx::op::convolution{{0, 0}, {2, 2}, {1, 1}}, x2, w2);
auto bn2 = add_bn(p, conv2, 2048);
auto add = p.add_instruction(migraph::op::add{}, bn1, bn2);
auto relu = p.add_instruction(migraph::op::relu{}, add);
p.add_instruction(migraph::op::pooling{"average", {1, 1}, {2, 2}, {3, 3}}, relu);
auto add = p.add_instruction(migraphx::op::add{}, bn1, bn2);
auto relu = p.add_instruction(migraphx::op::relu{}, add);
p.add_instruction(migraphx::op::pooling{"average", {1, 1}, {2, 2}, {3, 3}}, relu);
return p;
}
};
......@@ -841,12 +1098,26 @@ struct test_conv_bn_relu_pooling2
int main()
{
verify_program<test_lrn>();
verify_program<test_pooling_autopad>();
verify_program<test_abs>();
verify_program<test_concat>();
verify_program<test_concat2>();
verify_program<test_concat_relu>();
verify_program<test_pad>();
verify_program<test_add>();
verify_program<test_add_half>();
verify_program<test_mul>();
verify_program<test_exp>();
verify_program<test_log>();
verify_program<test_sin>();
verify_program<test_cos>();
verify_program<test_tan>();
verify_program<test_sinh>();
verify_program<test_cosh>();
verify_program<test_tanh>();
verify_program<test_asin>();
verify_program<test_acos>();
verify_program<test_atan>();
verify_program<test_scale>();
verify_program<test_triadd>();
verify_program<test_triadd2>();
......@@ -860,10 +1131,13 @@ int main()
verify_program<test_softmax2>();
verify_program<test_conv>();
verify_program<test_conv2>();
verify_program<test_group_conv>();
verify_program<test_conv_relu>();
verify_program<test_conv_relu_half>();
verify_program<test_add_relu>();
verify_program<test_leaky_relu>();
verify_program<test_sigmoid>();
verify_program<test_elu>();
verify_program<test_conv_pooling>();
verify_program<test_global_avg_pooling>();
verify_program<test_global_max_pooling>();
......@@ -881,4 +1155,6 @@ int main()
verify_program<test_conv_bn_relu_pooling>();
verify_program<test_conv_bn_relu_pooling2>();
verify_program<test_slice>();
verify_program<test_gather>();
verify_program<test_gather_neg_axis>();
}
#include <migraph/program.hpp>
#include <migraph/argument.hpp>
#include <migraph/shape.hpp>
#include <migraphx/program.hpp>
#include <migraphx/argument.hpp>
#include <migraphx/shape.hpp>
struct sum_op
{
std::string name() const { return "sum"; }
migraph::argument
compute(migraph::context&, const migraph::shape&, std::vector<migraph::argument> args) const
migraphx::argument
compute(migraphx::context&, const migraphx::shape&, std::vector<migraphx::argument> args) const
{
migraph::argument result;
migraphx::argument result;
if(args.size() != 2)
MIGRAPH_THROW("Wrong args");
MIGRAPHX_THROW("Wrong args");
if(args[0].get_shape() != args[1].get_shape())
MIGRAPH_THROW("Wrong args");
MIGRAPHX_THROW("Wrong args");
if(args[0].get_shape().lens().size() != 1)
MIGRAPH_THROW("Wrong args");
MIGRAPHX_THROW("Wrong args");
if(args[0].get_shape().lens().front() != 1)
MIGRAPH_THROW("Wrong args");
MIGRAPHX_THROW("Wrong args");
args[0].visit_at([&](auto x) {
args[1].visit_at([&](auto y) { result = migraph::literal{x + y}.get_argument(); });
args[1].visit_at([&](auto y) { result = migraphx::literal{x + y}.get_argument(); });
});
return result;
}
migraph::shape compute_shape(std::vector<migraph::shape> inputs) const
migraphx::shape compute_shape(std::vector<migraphx::shape> inputs) const
{
if(inputs.size() != 2)
MIGRAPH_THROW("Wrong inputs");
MIGRAPHX_THROW("Wrong inputs");
return inputs.front();
}
};
......@@ -35,29 +35,29 @@ struct sum_op
struct minus_op
{
std::string name() const { return "minus"; }
migraph::argument
compute(migraph::context&, const migraph::shape&, std::vector<migraph::argument> args) const
migraphx::argument
compute(migraphx::context&, const migraphx::shape&, std::vector<migraphx::argument> args) const
{
migraph::argument result;
migraphx::argument result;
if(args.size() != 2)
MIGRAPH_THROW("Wrong args");
MIGRAPHX_THROW("Wrong args");
if(args[0].get_shape() != args[1].get_shape())
MIGRAPH_THROW("Wrong args");
MIGRAPHX_THROW("Wrong args");
if(args[0].get_shape().lens().size() != 1)
MIGRAPH_THROW("Wrong args");
MIGRAPHX_THROW("Wrong args");
if(args[0].get_shape().lens().front() != 1)
MIGRAPH_THROW("Wrong args");
MIGRAPHX_THROW("Wrong args");
args[0].visit_at([&](auto x) {
args[1].visit_at([&](auto y) { result = migraph::literal{x - y}.get_argument(); });
args[1].visit_at([&](auto y) { result = migraphx::literal{x - y}.get_argument(); });
});
return result;
}
migraph::shape compute_shape(std::vector<migraph::shape> inputs) const
migraphx::shape compute_shape(std::vector<migraphx::shape> inputs) const
{
if(inputs.size() != 2)
MIGRAPH_THROW("Wrong inputs");
MIGRAPHX_THROW("Wrong inputs");
return inputs.front();
}
};
......@@ -65,35 +65,35 @@ struct minus_op
struct pass_op
{
std::string name() const { return "pass"; }
migraph::argument
compute(migraph::context&, const migraph::shape&, std::vector<migraph::argument> args) const
migraphx::argument
compute(migraphx::context&, const migraphx::shape&, std::vector<migraphx::argument> args) const
{
if(args.empty())
return {};
return args.front();
}
migraph::shape compute_shape(std::vector<migraph::shape> inputs) const
migraphx::shape compute_shape(std::vector<migraphx::shape> inputs) const
{
if(inputs.empty())
return {};
return inputs.front();
}
int output_alias(const std::vector<migraph::shape>&) const { return 0; }
int output_alias(const std::vector<migraphx::shape>&) const { return 0; }
};
struct pass_standard_op
{
std::string name() const { return "pass"; }
migraph::argument
compute(migraph::context&, const migraph::shape&, std::vector<migraph::argument> args) const
migraphx::argument
compute(migraphx::context&, const migraphx::shape&, std::vector<migraphx::argument> args) const
{
if(args.empty())
return {};
return args.front();
}
migraph::shape compute_shape(std::vector<migraph::shape> inputs) const
migraphx::shape compute_shape(std::vector<migraphx::shape> inputs) const
{
for(auto&& input : inputs)
{
......@@ -104,37 +104,38 @@ struct pass_standard_op
return {};
return inputs.front();
}
int output_alias(const std::vector<migraph::shape>&) const { return 0; }
int output_alias(const std::vector<migraphx::shape>&) const { return 0; }
};
struct nop
{
std::string name() const { return "nop"; }
migraph::argument
compute(migraph::context&, const migraph::shape&, const std::vector<migraph::argument>&) const
migraphx::argument compute(migraphx::context&,
const migraphx::shape&,
const std::vector<migraphx::argument>&) const
{
return {};
}
migraph::shape compute_shape(const std::vector<migraph::shape>&) const { return {}; }
migraphx::shape compute_shape(const std::vector<migraphx::shape>&) const { return {}; }
};
inline migraph::literal get_2x2()
inline migraphx::literal get_2x2()
{
return migraph::literal{{migraph::shape::float_type, {2, 2}}, {1, 2, 3, 4}};
return migraphx::literal{{migraphx::shape::float_type, {2, 2}}, {1, 2, 3, 4}};
}
inline migraph::literal get_2x2_transposed()
inline migraphx::literal get_2x2_transposed()
{
return migraph::literal{{migraph::shape::float_type, {2, 2}, {1, 2}}, {1, 2, 3, 4}};
return migraphx::literal{{migraphx::shape::float_type, {2, 2}, {1, 2}}, {1, 2, 3, 4}};
}
inline migraph::literal get_2()
inline migraphx::literal get_2()
{
return migraph::literal{{migraph::shape::float_type, {2}}, {1, 2}};
return migraphx::literal{{migraphx::shape::float_type, {2}}, {1, 2}};
}
inline migraph::literal get_2_broadcasted()
inline migraphx::literal get_2_broadcasted()
{
return migraph::literal{{migraph::shape::float_type, {2, 1}, {1, 0}}, {1, 2}};
return migraphx::literal{{migraphx::shape::float_type, {2, 1}, {1, 0}}, {1, 2}};
}
#ifndef MIGRAPH_GUARD_ROB_HPP
#define MIGRAPH_GUARD_ROB_HPP
#ifndef MIGRAPHX_GUARD_ROB_HPP
#define MIGRAPHX_GUARD_ROB_HPP
#ifdef __clang__
#pragma clang diagnostic push
......@@ -30,7 +30,8 @@ struct mem_data_ptr
using type = T C::*;
};
#define MIGRAPH_ROB(name, Type, C, mem) \
// NOLINTNEXTLINE
#define MIGRAPHX_ROB(name, Type, C, mem) \
struct name##_tag : mem_data_ptr<C, Type> \
{ \
}; \
......
......@@ -7,8 +7,8 @@
#include <unordered_map>
#include <vector>
#ifndef MIGRAPH_GUARD_TEST_TEST_HPP
#define MIGRAPH_GUARD_TEST_TEST_HPP
#ifndef MIGRAPHX_GUARD_TEST_TEST_HPP
#define MIGRAPHX_GUARD_TEST_TEST_HPP
namespace test {
// NOLINTNEXTLINE
......@@ -111,7 +111,7 @@ struct lhs_expression
struct capture
{
template <class T>
auto operator->*(const T& x)
auto operator->*(const T& x) const
{
return make_lhs_expression(x);
}
......@@ -189,7 +189,7 @@ inline auto& get_test_cases()
inline void add_test_case(std::string name, std::function<void()> f)
{
get_test_cases().emplace_back(name, f);
get_test_cases().emplace_back(std::move(name), std::move(f));
}
struct auto_register
......@@ -224,7 +224,13 @@ inline void run(int argc, const char* argv[])
std::unordered_map<std::string, std::function<void()>> m(get_test_cases().begin(),
get_test_cases().end());
for(auto&& name : cases)
run_test_case(name, m[name]);
{
auto f = m.find(name);
if(f == m.end())
std::cout << "[ ERROR ] Test case '" << name << "' not found." << std::endl;
else
run_test_case(name, f->second);
}
}
}
......@@ -248,6 +254,7 @@ inline void run(int argc, const char* argv[])
// NOLINTNEXTLINE
#define TEST_CAT(x, ...) TEST_PRIMITIVE_CAT(x, __VA_ARGS__)
// NOLINTNEXTLINE
#define TEST_PRIMITIVE_CAT(x, ...) x##__VA_ARGS__
// NOLINTNEXTLINE
......
#include <migraph/literal.hpp>
#include <migraphx/literal.hpp>
#include <sstream>
#include <string>
#include "test.hpp"
TEST_CASE(literal_test)
{
EXPECT(migraph::literal{1} == migraph::literal{1});
EXPECT(migraph::literal{1} != migraph::literal{2});
EXPECT(migraph::literal{} == migraph::literal{});
EXPECT(migraph::literal{} != migraph::literal{2});
EXPECT(migraphx::literal{1} == migraphx::literal{1});
EXPECT(migraphx::literal{1} != migraphx::literal{2});
EXPECT(migraphx::literal{} == migraphx::literal{});
EXPECT(migraphx::literal{} != migraphx::literal{2});
migraph::literal l1{1};
migraph::literal l2 = l1; // NOLINT
migraphx::literal l1{1};
migraphx::literal l2 = l1; // NOLINT
EXPECT(l1 == l2);
EXPECT(l1.at<int>(0) == 1);
EXPECT(!l1.empty());
EXPECT(!l2.empty());
migraph::literal l3{};
migraph::literal l4{};
migraphx::literal l3{};
migraphx::literal l4{};
EXPECT(l3 == l4);
EXPECT(l3.empty());
EXPECT(l4.empty());
......@@ -27,7 +27,7 @@ TEST_CASE(literal_test)
TEST_CASE(literal_os1)
{
migraph::literal l{1};
migraphx::literal l{1};
std::stringstream ss;
ss << l;
EXPECT(ss.str() == "1");
......@@ -35,7 +35,7 @@ TEST_CASE(literal_os1)
TEST_CASE(literal_os2)
{
migraph::literal l{};
migraphx::literal l{};
std::stringstream ss;
ss << l;
EXPECT(ss.str().empty());
......@@ -43,8 +43,8 @@ TEST_CASE(literal_os2)
TEST_CASE(literal_os3)
{
migraph::shape s{migraph::shape::int64_type, {3}};
migraph::literal l{s, {1, 2, 3}};
migraphx::shape s{migraphx::shape::int64_type, {3}};
migraphx::literal l{s, {1, 2, 3}};
std::stringstream ss;
ss << l;
EXPECT(ss.str() == "1, 2, 3");
......
#include <migraph/matcher.hpp>
#include <migraph/iterator_for.hpp>
#include <migraphx/matcher.hpp>
#include <migraphx/iterator_for.hpp>
#include <test.hpp>
#include <basic_ops.hpp>
namespace match = migraph::match;
namespace match = migraphx::match;
template <class M>
migraph::match::matcher_result find_match(migraph::program& p, M&& m)
migraphx::match::matcher_result find_match(migraphx::program& p, M&& m)
{
migraph::match::matcher_result result;
for(auto ins : migraph::iterator_for(p))
migraphx::match::matcher_result result;
for(auto ins : migraphx::iterator_for(p))
{
result = migraph::match::match_instruction(p, ins, m);
result = migraphx::match::match_instruction(p, ins, m);
if(result.result != p.end())
return result;
}
......@@ -20,7 +20,7 @@ migraph::match::matcher_result find_match(migraph::program& p, M&& m)
void match1()
{
migraph::program p;
migraphx::program p;
auto l = p.add_literal(1);
auto m = match::standard_shape();
auto r = find_match(p, m);
......@@ -29,7 +29,7 @@ void match1()
TEST_CASE(match_name1)
{
migraph::program p;
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
auto sum = p.add_instruction(sum_op{}, one, two);
......@@ -41,7 +41,7 @@ TEST_CASE(match_name1)
TEST_CASE(match_name2)
{
migraph::program p;
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
auto sum = p.add_instruction(sum_op{}, one, two);
......@@ -53,7 +53,7 @@ TEST_CASE(match_name2)
TEST_CASE(match_name3)
{
migraph::program p;
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
auto sum = p.add_instruction(sum_op{}, one, two);
......@@ -65,7 +65,7 @@ TEST_CASE(match_name3)
TEST_CASE(match_arg1)
{
migraph::program p;
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
auto sum = p.add_instruction(sum_op{}, one, two);
......@@ -77,7 +77,7 @@ TEST_CASE(match_arg1)
TEST_CASE(match_arg2)
{
migraph::program p;
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
auto sum = p.add_instruction(sum_op{}, one, two);
......@@ -89,7 +89,7 @@ TEST_CASE(match_arg2)
TEST_CASE(match_arg3)
{
migraph::program p;
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
auto sum = p.add_instruction(sum_op{}, one, two);
......@@ -101,7 +101,7 @@ TEST_CASE(match_arg3)
TEST_CASE(match_arg4)
{
migraph::program p;
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
auto sum = p.add_instruction(sum_op{}, one, two);
......@@ -113,7 +113,7 @@ TEST_CASE(match_arg4)
TEST_CASE(match_arg5)
{
migraph::program p;
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
auto sum = p.add_instruction(sum_op{}, one, two);
......@@ -125,7 +125,7 @@ TEST_CASE(match_arg5)
TEST_CASE(match_arg6)
{
migraph::program p;
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
auto sum = p.add_instruction(sum_op{}, one, two);
......@@ -137,7 +137,7 @@ TEST_CASE(match_arg6)
TEST_CASE(match_arg7)
{
migraph::program p;
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
auto sum = p.add_instruction(sum_op{}, one, two);
......@@ -150,7 +150,7 @@ TEST_CASE(match_arg7)
TEST_CASE(match_args1)
{
migraph::program p;
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
auto sum = p.add_instruction(sum_op{}, one, two);
......@@ -163,7 +163,7 @@ TEST_CASE(match_args1)
TEST_CASE(match_args2)
{
migraph::program p;
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
auto sum = p.add_instruction(sum_op{}, one, two);
......@@ -176,7 +176,7 @@ TEST_CASE(match_args2)
TEST_CASE(match_args3)
{
migraph::program p;
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
auto sum = p.add_instruction(sum_op{}, one, two);
......@@ -188,7 +188,7 @@ TEST_CASE(match_args3)
TEST_CASE(match_args4)
{
migraph::program p;
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
auto sum1 = p.add_instruction(sum_op{}, one, two);
......@@ -202,7 +202,7 @@ TEST_CASE(match_args4)
TEST_CASE(match_args5)
{
migraph::program p;
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
auto sum = p.add_instruction(sum_op{}, one, two);
......@@ -215,7 +215,7 @@ TEST_CASE(match_args5)
TEST_CASE(match_args6)
{
migraph::program p;
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
auto sum = p.add_instruction(sum_op{}, one, two);
......@@ -227,7 +227,7 @@ TEST_CASE(match_args6)
TEST_CASE(match_args7)
{
migraph::program p;
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
auto sum = p.add_instruction(sum_op{}, one, two);
......@@ -241,7 +241,7 @@ TEST_CASE(match_args7)
TEST_CASE(match_either_args1)
{
migraph::program p;
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
auto sum1 = p.add_instruction(sum_op{}, one, two);
......@@ -255,7 +255,7 @@ TEST_CASE(match_either_args1)
TEST_CASE(match_either_args2)
{
migraph::program p;
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
auto sum1 = p.add_instruction(sum_op{}, one, two);
......@@ -269,7 +269,7 @@ TEST_CASE(match_either_args2)
TEST_CASE(match_either_args3)
{
migraph::program p;
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
auto sum1 = p.add_instruction(sum_op{}, one, two);
......@@ -283,7 +283,7 @@ TEST_CASE(match_either_args3)
TEST_CASE(match_all_of1)
{
migraph::program p;
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
auto sum = p.add_instruction(sum_op{}, one, two);
......@@ -296,7 +296,7 @@ TEST_CASE(match_all_of1)
TEST_CASE(match_all_of2)
{
migraph::program p;
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
auto sum = p.add_instruction(sum_op{}, one, two);
......@@ -309,7 +309,7 @@ TEST_CASE(match_all_of2)
TEST_CASE(match_any_of1)
{
migraph::program p;
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
auto sum = p.add_instruction(sum_op{}, one, two);
......@@ -322,7 +322,7 @@ TEST_CASE(match_any_of1)
TEST_CASE(match_any_of2)
{
migraph::program p;
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
auto sum = p.add_instruction(sum_op{}, one, two);
......@@ -335,7 +335,7 @@ TEST_CASE(match_any_of2)
TEST_CASE(match_none_of1)
{
migraph::program p;
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
auto sum = p.add_instruction(sum_op{}, one, two);
......@@ -348,7 +348,7 @@ TEST_CASE(match_none_of1)
TEST_CASE(match_none_of2)
{
migraph::program p;
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
auto sum = p.add_instruction(sum_op{}, one, two);
......@@ -361,7 +361,7 @@ TEST_CASE(match_none_of2)
TEST_CASE(match_bind1)
{
migraph::program p;
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
auto sum = p.add_instruction(sum_op{}, one, two);
......@@ -382,18 +382,21 @@ TEST_CASE(match_bind1)
struct match_find_sum
{
migraph::instruction_ref ins;
migraphx::instruction_ref ins;
auto matcher() const { return match::name("sum"); }
void apply(migraph::program&, match::matcher_result r) const { EXPECT(bool{r.result == ins}); }
void apply(migraphx::program&, const match::matcher_result& r) const
{
EXPECT(bool{r.result == ins});
}
};
struct match_find_literal
{
migraph::instruction_ref ins;
migraphx::instruction_ref ins;
auto matcher() const { return match::name("@literal"); }
void apply(migraph::program&, match::matcher_result r) const
void apply(migraphx::program&, const match::matcher_result& r) const
{
EXPECT(bool{r.result != ins});
EXPECT(r.result->name() == "@literal");
......@@ -402,7 +405,7 @@ struct match_find_literal
TEST_CASE(match_finder)
{
migraph::program p;
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
auto sum = p.add_instruction(sum_op{}, one, two);
......
#include <migraph/memory_coloring.hpp>
#include <migraph/operators.hpp>
#include <migraph/generate.hpp>
#include <migraph/instruction.hpp>
#include <migraphx/memory_coloring.hpp>
#include <migraphx/operators.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/instruction.hpp>
#include <basic_ops.hpp>
#include <test.hpp>
struct memory_coloring_target
{
std::string name() const { return "memory_coloring"; }
std::vector<migraph::pass> get_passes(migraph::context&) const
std::vector<migraphx::pass> get_passes(migraphx::context&) const
{
return {migraph::memory_coloring{"allocate", true}};
return {migraphx::memory_coloring{"allocate", true}};
}
migraph::context get_context() const { return {}; }
migraphx::context get_context() const { return {}; }
};
struct allocate
{
migraph::shape s{};
migraphx::shape s{};
std::string name() const { return "allocate"; }
migraph::shape compute_shape(const std::vector<migraph::shape>& inputs) const
migraphx::shape compute_shape(const std::vector<migraphx::shape>& inputs) const
{
migraph::check_shapes{inputs, *this}.has(1);
migraphx::check_shapes{inputs, *this}.has(1);
return inputs.front();
}
migraph::argument compute(migraph::context&,
const migraph::shape& output_shape,
const std::vector<migraph::argument>&) const
migraphx::argument compute(migraphx::context&,
const migraphx::shape& output_shape,
const std::vector<migraphx::argument>&) const
{
return {output_shape};
}
};
migraph::instruction_ref add_alloc(migraph::program& p, const migraph::shape& s)
migraphx::instruction_ref add_alloc(migraphx::program& p, const migraphx::shape& s)
{
auto a0 = p.add_outline(s);
return p.add_instruction(allocate{}, a0);
}
bool no_allocate(const migraph::program& p)
bool no_allocate(const migraphx::program& p)
{
return std::none_of(p.begin(), p.end(), [](auto&& ins) { return ins.name() == "allocate"; });
}
TEST_CASE(test1)
{
migraph::program p;
auto a1 = add_alloc(p, {migraph::shape::float_type, {8}});
migraphx::program p;
auto a1 = add_alloc(p, {migraphx::shape::float_type, {8}});
auto p1 = p.add_instruction(pass_op{}, a1);
auto a2 = add_alloc(p, {migraph::shape::float_type, {40}});
auto a2 = add_alloc(p, {migraphx::shape::float_type, {40}});
p.add_instruction(pass_op{}, a2, p1);
p.compile(memory_coloring_target{});
CHECK(p.get_parameter_shape("scratch").bytes() == 192);
......@@ -57,12 +57,12 @@ TEST_CASE(test1)
TEST_CASE(test2)
{
migraph::program p;
auto input = p.add_parameter("input", migraph::shape{migraph::shape::float_type, {16}});
migraphx::program p;
auto input = p.add_parameter("input", migraphx::shape{migraphx::shape::float_type, {16}});
auto a1 = add_alloc(p, {migraph::shape::float_type, {128}});
auto a1 = add_alloc(p, {migraphx::shape::float_type, {128}});
auto p1 = p.add_instruction(pass_op{}, a1, input);
auto p2 = add_alloc(p, {migraph::shape::float_type, {40}});
auto p2 = add_alloc(p, {migraphx::shape::float_type, {40}});
p.add_instruction(pass_op{}, p2, p1);
p.compile(memory_coloring_target{});
CHECK(p.get_parameter_shape("scratch").bytes() == 672);
......@@ -71,11 +71,11 @@ TEST_CASE(test2)
TEST_CASE(test3)
{
migraph::program p;
auto a1 = add_alloc(p, {migraph::shape::float_type, {8}});
auto p2 = add_alloc(p, {migraph::shape::float_type, {128}});
migraphx::program p;
auto a1 = add_alloc(p, {migraphx::shape::float_type, {8}});
auto p2 = add_alloc(p, {migraphx::shape::float_type, {128}});
auto p1 = p.add_instruction(pass_op{}, p2, a1);
auto p3 = add_alloc(p, {migraph::shape::float_type, {40}});
auto p3 = add_alloc(p, {migraphx::shape::float_type, {40}});
p.add_instruction(pass_op{}, p3, p1);
p.compile(memory_coloring_target{});
CHECK(p.get_parameter_shape("scratch").bytes() == 704); // The optimal solution is actually 672
......@@ -84,11 +84,11 @@ TEST_CASE(test3)
TEST_CASE(test4)
{
migraph::program p;
auto a1 = add_alloc(p, {migraph::shape::float_type, {0}});
auto p2 = add_alloc(p, {migraph::shape::float_type, {128}});
migraphx::program p;
auto a1 = add_alloc(p, {migraphx::shape::float_type, {0}});
auto p2 = add_alloc(p, {migraphx::shape::float_type, {128}});
auto p1 = p.add_instruction(pass_op{}, p2, a1);
auto p3 = add_alloc(p, {migraph::shape::float_type, {40}});
auto p3 = add_alloc(p, {migraphx::shape::float_type, {40}});
p.add_instruction(pass_op{}, p3, p1);
p.compile(memory_coloring_target{});
CHECK(p.get_parameter_shape("scratch").bytes() == 672);
......@@ -97,10 +97,10 @@ TEST_CASE(test4)
TEST_CASE(test5)
{
migraph::program p;
auto a1 = add_alloc(p, {migraph::shape::float_type, {40}});
migraphx::program p;
auto a1 = add_alloc(p, {migraphx::shape::float_type, {40}});
auto p1 = p.add_instruction(pass_op{}, a1);
auto p2 = add_alloc(p, {migraph::shape::float_type, {8}});
auto p2 = add_alloc(p, {migraphx::shape::float_type, {8}});
p.add_instruction(pass_op{}, p2, p1);
p.compile(memory_coloring_target{});
CHECK(p.get_parameter_shape("scratch").bytes() == 192);
......@@ -109,11 +109,11 @@ TEST_CASE(test5)
TEST_CASE(test6)
{
migraph::program p;
auto a1 = add_alloc(p, {migraph::shape::float_type, {8}});
migraphx::program p;
auto a1 = add_alloc(p, {migraphx::shape::float_type, {8}});
auto p1 = p.add_instruction(pass_op{}, a1);
auto p2 = add_alloc(p, {migraph::shape::float_type, {40}});
auto p3 = add_alloc(p, {migraph::shape::float_type, {40}});
auto p2 = add_alloc(p, {migraphx::shape::float_type, {40}});
auto p3 = add_alloc(p, {migraphx::shape::float_type, {40}});
p.add_instruction(pass_op{}, p3, p2, p1);
p.compile(memory_coloring_target{});
CHECK(p.get_parameter_shape("scratch").bytes() == 352);
......@@ -122,11 +122,11 @@ TEST_CASE(test6)
TEST_CASE(test7)
{
migraph::program p;
auto a1 = add_alloc(p, {migraph::shape::float_type, {8}});
migraphx::program p;
auto a1 = add_alloc(p, {migraphx::shape::float_type, {8}});
auto p1 = p.add_instruction(pass_op{}, a1);
auto p2 = add_alloc(p, {migraph::shape::float_type, {40}});
auto p3 = add_alloc(p, {migraph::shape::float_type, {8}});
auto p2 = add_alloc(p, {migraphx::shape::float_type, {40}});
auto p3 = add_alloc(p, {migraphx::shape::float_type, {8}});
p.add_instruction(pass_op{}, p3, p2, p1);
p.compile(memory_coloring_target{});
CHECK(p.get_parameter_shape("scratch").bytes() == 224);
......@@ -135,11 +135,11 @@ TEST_CASE(test7)
TEST_CASE(test8)
{
migraph::program p;
auto a1 = add_alloc(p, {migraph::shape::float_type, {8}});
migraphx::program p;
auto a1 = add_alloc(p, {migraphx::shape::float_type, {8}});
auto p1 = p.add_instruction(pass_op{}, a1);
auto p2 = add_alloc(p, {migraph::shape::float_type, {40}});
auto p3 = add_alloc(p, {migraph::shape::float_type, {192}});
auto p2 = add_alloc(p, {migraphx::shape::float_type, {40}});
auto p3 = add_alloc(p, {migraphx::shape::float_type, {192}});
p.add_instruction(pass_op{}, p3, p2, p1);
p.compile(memory_coloring_target{});
CHECK(p.get_parameter_shape("scratch").bytes() == 960);
......@@ -148,11 +148,11 @@ TEST_CASE(test8)
TEST_CASE(test9)
{
migraph::program p;
auto a1 = add_alloc(p, {migraph::shape::float_type, {8}});
migraphx::program p;
auto a1 = add_alloc(p, {migraphx::shape::float_type, {8}});
auto p1 = p.add_instruction(pass_op{}, a1);
auto p2 = add_alloc(p, {migraph::shape::float_type, {8}});
auto p3 = add_alloc(p, {migraph::shape::float_type, {8}});
auto p2 = add_alloc(p, {migraphx::shape::float_type, {8}});
auto p3 = add_alloc(p, {migraphx::shape::float_type, {8}});
p.add_instruction(pass_op{}, p3, p2, p1);
p.compile(memory_coloring_target{});
CHECK(p.get_parameter_shape("scratch").bytes() == 96);
......@@ -161,8 +161,8 @@ TEST_CASE(test9)
TEST_CASE(test10)
{
migraph::program p;
auto a1 = add_alloc(p, {migraph::shape::float_type, {8}});
migraphx::program p;
auto a1 = add_alloc(p, {migraphx::shape::float_type, {8}});
p.add_instruction(pass_op{}, a1);
p.compile(memory_coloring_target{});
CHECK(p.get_parameter_shape("scratch").bytes() == 32);
......@@ -171,11 +171,11 @@ TEST_CASE(test10)
TEST_CASE(test11)
{
migraph::program p;
auto a1 = add_alloc(p, {migraph::shape::float_type, {8}});
migraphx::program p;
auto a1 = add_alloc(p, {migraphx::shape::float_type, {8}});
auto p1 = p.add_instruction(pass_op{}, a1);
auto a2 = add_alloc(p, {migraph::shape::float_type, {40}});
auto a3 = add_alloc(p, {migraph::shape::float_type, {8}});
auto a2 = add_alloc(p, {migraphx::shape::float_type, {40}});
auto a3 = add_alloc(p, {migraphx::shape::float_type, {8}});
auto p2 = p.add_instruction(pass_op{}, a2, p1);
p.add_instruction(pass_op{}, a3, p2);
p.compile(memory_coloring_target{});
......@@ -185,11 +185,11 @@ TEST_CASE(test11)
TEST_CASE(test12)
{
migraph::program p;
auto a1 = add_alloc(p, {migraph::shape::float_type, {40}});
migraphx::program p;
auto a1 = add_alloc(p, {migraphx::shape::float_type, {40}});
auto p1 = p.add_instruction(pass_op{}, a1);
auto a2 = add_alloc(p, {migraph::shape::float_type, {8}});
auto a3 = add_alloc(p, {migraph::shape::float_type, {40}});
auto a2 = add_alloc(p, {migraphx::shape::float_type, {8}});
auto a3 = add_alloc(p, {migraphx::shape::float_type, {40}});
auto p2 = p.add_instruction(pass_op{}, a2, p1);
p.add_instruction(pass_op{}, a3, p2);
p.compile(memory_coloring_target{});
......@@ -199,11 +199,11 @@ TEST_CASE(test12)
TEST_CASE(test13)
{
migraph::program p;
auto a1 = add_alloc(p, {migraph::shape::float_type, {8}});
auto a3 = add_alloc(p, {migraph::shape::float_type, {8}});
migraphx::program p;
auto a1 = add_alloc(p, {migraphx::shape::float_type, {8}});
auto a3 = add_alloc(p, {migraphx::shape::float_type, {8}});
auto p1 = p.add_instruction(pass_op{}, a1);
auto a2 = add_alloc(p, {migraph::shape::float_type, {40}});
auto a2 = add_alloc(p, {migraphx::shape::float_type, {40}});
auto p2 = p.add_instruction(pass_op{}, a2, p1);
p.add_instruction(pass_op{}, a3, p2);
p.compile(memory_coloring_target{});
......@@ -213,10 +213,10 @@ TEST_CASE(test13)
TEST_CASE(test14)
{
migraph::program p;
auto a3 = add_alloc(p, {migraph::shape::float_type, {8}});
auto a2 = add_alloc(p, {migraph::shape::float_type, {40}});
auto a1 = add_alloc(p, {migraph::shape::float_type, {8}});
migraphx::program p;
auto a3 = add_alloc(p, {migraphx::shape::float_type, {8}});
auto a2 = add_alloc(p, {migraphx::shape::float_type, {40}});
auto a1 = add_alloc(p, {migraphx::shape::float_type, {8}});
auto p1 = p.add_instruction(pass_op{}, a1);
auto p2 = p.add_instruction(pass_op{}, a2, p1);
p.add_instruction(pass_op{}, a3, p2);
......@@ -227,12 +227,12 @@ TEST_CASE(test14)
TEST_CASE(test15)
{
migraph::program p;
auto a1 = add_alloc(p, {migraph::shape::float_type, {8}});
migraphx::program p;
auto a1 = add_alloc(p, {migraphx::shape::float_type, {8}});
auto p1 = p.add_instruction(pass_op{}, a1);
auto a2 = add_alloc(p, {migraph::shape::float_type, {40}});
auto a2 = add_alloc(p, {migraphx::shape::float_type, {40}});
auto p2 = p.add_instruction(pass_op{}, a2);
auto a3 = add_alloc(p, {migraph::shape::float_type, {40}});
auto a3 = add_alloc(p, {migraphx::shape::float_type, {40}});
p.add_instruction(pass_op{}, a3, p1, p2);
p.compile(memory_coloring_target{});
CHECK(p.get_parameter_shape("scratch").bytes() == 352);
......@@ -241,12 +241,12 @@ TEST_CASE(test15)
TEST_CASE(test16)
{
migraph::program p;
auto a1 = p.add_literal(migraph::generate_literal({migraph::shape::float_type, {8}}));
migraphx::program p;
auto a1 = p.add_literal(migraphx::generate_literal({migraphx::shape::float_type, {8}}));
auto p1 = p.add_instruction(pass_op{}, a1);
auto a2 = p.add_literal(migraph::generate_literal({migraph::shape::float_type, {40}}));
auto a2 = p.add_literal(migraphx::generate_literal({migraphx::shape::float_type, {40}}));
auto p2 = p.add_instruction(pass_op{}, a2);
auto a3 = add_alloc(p, {migraph::shape::float_type, {40}});
auto a3 = add_alloc(p, {migraphx::shape::float_type, {40}});
p.add_instruction(pass_op{}, a3, p1, p2);
p.compile(memory_coloring_target{});
CHECK(p.get_parameter_shape("scratch").bytes() == 160);
......@@ -255,11 +255,11 @@ TEST_CASE(test16)
TEST_CASE(test17)
{
migraph::program p;
auto a3 = add_alloc(p, {migraph::shape::float_type, {40}});
auto a1 = p.add_literal(migraph::generate_literal({migraph::shape::float_type, {8}}));
migraphx::program p;
auto a3 = add_alloc(p, {migraphx::shape::float_type, {40}});
auto a1 = p.add_literal(migraphx::generate_literal({migraphx::shape::float_type, {8}}));
auto p1 = p.add_instruction(pass_op{}, a1);
auto a2 = p.add_literal(migraph::generate_literal({migraph::shape::float_type, {40}}));
auto a2 = p.add_literal(migraphx::generate_literal({migraphx::shape::float_type, {40}}));
auto p2 = p.add_instruction(pass_op{}, a2);
p.add_instruction(pass_op{}, a3, p1, p2);
p.compile(memory_coloring_target{});
......@@ -269,12 +269,12 @@ TEST_CASE(test17)
TEST_CASE(test18)
{
migraph::program p;
auto a1 = add_alloc(p, {migraph::shape::float_type, {8}});
migraphx::program p;
auto a1 = add_alloc(p, {migraphx::shape::float_type, {8}});
auto p1 = p.add_instruction(pass_op{}, a1);
auto p2 = p.add_instruction(pass_op{}, a1, p1);
auto p3 = p.add_instruction(pass_op{}, p2, p1);
auto a2 = add_alloc(p, {migraph::shape::float_type, {40}});
auto a2 = add_alloc(p, {migraphx::shape::float_type, {40}});
p.add_instruction(pass_op{}, a2, p1, p2, p3);
p.compile(memory_coloring_target{});
CHECK(p.get_parameter_shape("scratch").bytes() == 192);
......@@ -283,12 +283,12 @@ TEST_CASE(test18)
TEST_CASE(test19)
{
migraph::program p;
auto a1 = add_alloc(p, {migraph::shape::float_type, {8}});
migraphx::program p;
auto a1 = add_alloc(p, {migraphx::shape::float_type, {8}});
auto p1 = p.add_instruction(pass_op{}, a1);
auto a2 = add_alloc(p, {migraph::shape::float_type, {40}});
auto a2 = add_alloc(p, {migraphx::shape::float_type, {40}});
auto p2 = p.add_instruction(pass_op{}, a2, p1);
auto a3 = add_alloc(p, {migraph::shape::float_type, {40}});
auto a3 = add_alloc(p, {migraphx::shape::float_type, {40}});
p.add_instruction(pass_op{}, a3, p2, p1);
p.compile(memory_coloring_target{});
CHECK(p.get_parameter_shape("scratch").bytes() == 352);
......@@ -297,12 +297,12 @@ TEST_CASE(test19)
TEST_CASE(test20)
{
migraph::program p;
auto a1 = add_alloc(p, {migraph::shape::float_type, {32}});
auto a2 = add_alloc(p, {migraph::shape::float_type, {32}});
auto a3 = add_alloc(p, {migraph::shape::float_type, {32}});
migraphx::program p;
auto a1 = add_alloc(p, {migraphx::shape::float_type, {32}});
auto a2 = add_alloc(p, {migraphx::shape::float_type, {32}});
auto a3 = add_alloc(p, {migraphx::shape::float_type, {32}});
auto p1 = p.add_instruction(pass_op{}, a1, a2, a3);
auto a4 = add_alloc(p, {migraph::shape::float_type, {32}});
auto a4 = add_alloc(p, {migraphx::shape::float_type, {32}});
p.add_instruction(pass_op{}, a4, p1);
p.compile(memory_coloring_target{});
CHECK(p.get_parameter_shape("scratch").bytes() == 384);
......@@ -311,12 +311,12 @@ TEST_CASE(test20)
TEST_CASE(test21)
{
migraph::program p;
auto a1 = add_alloc(p, {migraph::shape::float_type, {32}});
auto a2 = add_alloc(p, {migraph::shape::float_type, {8}});
auto a3 = add_alloc(p, {migraph::shape::float_type, {32}});
migraphx::program p;
auto a1 = add_alloc(p, {migraphx::shape::float_type, {32}});
auto a2 = add_alloc(p, {migraphx::shape::float_type, {8}});
auto a3 = add_alloc(p, {migraphx::shape::float_type, {32}});
auto p1 = p.add_instruction(pass_op{}, a1, a2, a3);
auto a4 = add_alloc(p, {migraph::shape::float_type, {8}});
auto a4 = add_alloc(p, {migraphx::shape::float_type, {8}});
p.add_instruction(pass_op{}, a4, p1);
p.compile(memory_coloring_target{});
CHECK(p.get_parameter_shape("scratch").bytes() == 288);
......@@ -325,12 +325,12 @@ TEST_CASE(test21)
TEST_CASE(test22)
{
migraph::program p;
auto a1 = add_alloc(p, {migraph::shape::float_type, {32}});
auto a2 = add_alloc(p, {migraph::shape::float_type, {32}});
auto a3 = add_alloc(p, {migraph::shape::float_type, {8}});
migraphx::program p;
auto a1 = add_alloc(p, {migraphx::shape::float_type, {32}});
auto a2 = add_alloc(p, {migraphx::shape::float_type, {32}});
auto a3 = add_alloc(p, {migraphx::shape::float_type, {8}});
auto p1 = p.add_instruction(pass_op{}, a1, a2, a3);
auto a4 = add_alloc(p, {migraph::shape::float_type, {8}});
auto a4 = add_alloc(p, {migraphx::shape::float_type, {8}});
p.add_instruction(pass_op{}, a4, p1);
p.compile(memory_coloring_target{});
CHECK(p.get_parameter_shape("scratch").bytes() == 288);
......@@ -339,12 +339,12 @@ TEST_CASE(test22)
TEST_CASE(test23)
{
migraph::program p;
auto a1 = add_alloc(p, {migraph::shape::float_type, {8}});
auto a2 = add_alloc(p, {migraph::shape::float_type, {32}});
auto a3 = add_alloc(p, {migraph::shape::float_type, {32}});
migraphx::program p;
auto a1 = add_alloc(p, {migraphx::shape::float_type, {8}});
auto a2 = add_alloc(p, {migraphx::shape::float_type, {32}});
auto a3 = add_alloc(p, {migraphx::shape::float_type, {32}});
auto p1 = p.add_instruction(pass_op{}, a1, a2, a3);
auto a4 = add_alloc(p, {migraph::shape::float_type, {8}});
auto a4 = add_alloc(p, {migraphx::shape::float_type, {8}});
p.add_instruction(pass_op{}, a4, p1);
p.compile(memory_coloring_target{});
CHECK(p.get_parameter_shape("scratch").bytes() == 288);
......@@ -353,12 +353,12 @@ TEST_CASE(test23)
TEST_CASE(test24)
{
migraph::program p;
auto a1 = add_alloc(p, {migraph::shape::float_type, {32}});
auto a2 = add_alloc(p, {migraph::shape::float_type, {32}});
auto a3 = add_alloc(p, {migraph::shape::float_type, {32}});
migraphx::program p;
auto a1 = add_alloc(p, {migraphx::shape::float_type, {32}});
auto a2 = add_alloc(p, {migraphx::shape::float_type, {32}});
auto a3 = add_alloc(p, {migraphx::shape::float_type, {32}});
auto p1 = p.add_instruction(pass_op{}, a1, a2, a3);
auto a4 = add_alloc(p, {migraph::shape::float_type, {8}});
auto a4 = add_alloc(p, {migraphx::shape::float_type, {8}});
p.add_instruction(pass_op{}, a4, p1);
p.compile(memory_coloring_target{});
CHECK(p.get_parameter_shape("scratch").bytes() == 384);
......@@ -367,12 +367,12 @@ TEST_CASE(test24)
TEST_CASE(test25)
{
migraph::program p;
auto a1 = add_alloc(p, {migraph::shape::float_type, {8}});
migraphx::program p;
auto a1 = add_alloc(p, {migraphx::shape::float_type, {8}});
p.add_instruction(nop{});
auto p1 = p.add_instruction(pass_op{}, a1);
p.add_instruction(nop{});
auto a2 = add_alloc(p, {migraph::shape::float_type, {40}});
auto a2 = add_alloc(p, {migraphx::shape::float_type, {40}});
p.add_instruction(pass_op{}, a2, p1);
p.compile(memory_coloring_target{});
CHECK(p.get_parameter_shape("scratch").bytes() == 192);
......@@ -381,12 +381,12 @@ TEST_CASE(test25)
TEST_CASE(test26)
{
migraph::program p;
auto a1 = add_alloc(p, {migraph::shape::float_type, {8}});
migraphx::program p;
auto a1 = add_alloc(p, {migraphx::shape::float_type, {8}});
p.add_instruction(nop{}, a1);
auto p1 = p.add_instruction(pass_op{}, a1);
p.add_instruction(nop{}, a1, p1);
auto a2 = add_alloc(p, {migraph::shape::float_type, {40}});
auto a2 = add_alloc(p, {migraphx::shape::float_type, {40}});
p.add_instruction(pass_op{}, a2, p1);
p.compile(memory_coloring_target{});
CHECK(p.get_parameter_shape("scratch").bytes() == 192);
......@@ -395,10 +395,10 @@ TEST_CASE(test26)
TEST_CASE(test27)
{
migraph::program p;
auto a1 = add_alloc(p, {migraph::shape::float_type, {8}});
migraphx::program p;
auto a1 = add_alloc(p, {migraphx::shape::float_type, {8}});
auto p1 = p.add_instruction(pass_op{}, a1);
auto a2 = add_alloc(p, {migraph::shape::float_type, {40}});
auto a2 = add_alloc(p, {migraphx::shape::float_type, {40}});
p.add_instruction(nop{}, a2, p1);
p.compile(memory_coloring_target{});
CHECK(p.get_parameter_shape("scratch").bytes() == 192);
......@@ -407,11 +407,11 @@ TEST_CASE(test27)
TEST_CASE(test28)
{
migraph::program p;
auto output = p.add_parameter("output", {migraph::shape::float_type, {8}});
auto a1 = add_alloc(p, {migraph::shape::float_type, {8}});
migraphx::program p;
auto output = p.add_parameter("output", {migraphx::shape::float_type, {8}});
auto a1 = add_alloc(p, {migraphx::shape::float_type, {8}});
auto p1 = p.add_instruction(pass_op{}, a1);
auto a2 = add_alloc(p, {migraph::shape::float_type, {40}});
auto a2 = add_alloc(p, {migraphx::shape::float_type, {40}});
auto p2 = p.add_instruction(pass_op{}, a2, p1);
p.add_instruction(pass_op{}, p2, output);
p.compile(memory_coloring_target{});
......@@ -421,11 +421,11 @@ TEST_CASE(test28)
TEST_CASE(test29)
{
migraph::program p;
auto output = p.add_parameter("output", {migraph::shape::float_type, {8}});
auto a1 = add_alloc(p, {migraph::shape::float_type, {8}});
migraphx::program p;
auto output = p.add_parameter("output", {migraphx::shape::float_type, {8}});
auto a1 = add_alloc(p, {migraphx::shape::float_type, {8}});
auto p1 = p.add_instruction(pass_op{}, a1);
auto a2 = add_alloc(p, {migraph::shape::float_type, {40}});
auto a2 = add_alloc(p, {migraphx::shape::float_type, {40}});
auto p2 = p.add_instruction(pass_op{}, a2, p1);
p.move_instruction(output, p2);
p.add_instruction(pass_op{}, p2, output);
......@@ -436,11 +436,11 @@ TEST_CASE(test29)
TEST_CASE(test30)
{
migraph::program p;
auto output = p.add_parameter("x", {migraph::shape::float_type, {8}});
auto a1 = add_alloc(p, {migraph::shape::float_type, {8}});
migraphx::program p;
auto output = p.add_parameter("x", {migraphx::shape::float_type, {8}});
auto a1 = add_alloc(p, {migraphx::shape::float_type, {8}});
auto p1 = p.add_instruction(pass_op{}, a1);
auto a2 = add_alloc(p, {migraph::shape::float_type, {40}});
auto a2 = add_alloc(p, {migraphx::shape::float_type, {40}});
auto p2 = p.add_instruction(pass_op{}, a2, p1);
p.move_instruction(output, p2);
p.add_instruction(pass_op{}, p2, output);
......@@ -451,11 +451,11 @@ TEST_CASE(test30)
TEST_CASE(test31)
{
migraph::program p;
auto output = p.add_parameter("output", {migraph::shape::float_type, {8}});
auto a1 = add_alloc(p, {migraph::shape::float_type, {8}});
migraphx::program p;
auto output = p.add_parameter("output", {migraphx::shape::float_type, {8}});
auto a1 = add_alloc(p, {migraphx::shape::float_type, {8}});
auto p1 = p.add_instruction(pass_op{}, a1);
auto a2 = add_alloc(p, {migraph::shape::float_type, {40}});
auto a2 = add_alloc(p, {migraphx::shape::float_type, {40}});
p.move_instruction(output, a2);
p.add_instruction(pass_op{}, a2, p1);
p.compile(memory_coloring_target{});
......@@ -465,12 +465,12 @@ TEST_CASE(test31)
TEST_CASE(test32)
{
migraph::program p;
auto a1 = add_alloc(p, {migraph::shape::float_type, {8}});
auto a2 = add_alloc(p, {migraph::shape::float_type, {40}});
auto a3 = add_alloc(p, {migraph::shape::float_type, {40}});
migraphx::program p;
auto a1 = add_alloc(p, {migraphx::shape::float_type, {8}});
auto a2 = add_alloc(p, {migraphx::shape::float_type, {40}});
auto a3 = add_alloc(p, {migraphx::shape::float_type, {40}});
auto p1 = p.add_instruction(pass_op{}, a2, a1, a3);
auto a5 = add_alloc(p, {migraph::shape::float_type, {40}});
auto a5 = add_alloc(p, {migraphx::shape::float_type, {40}});
p.add_instruction(pass_op{}, a5, p1);
p.compile(memory_coloring_target{});
CHECK(p.get_parameter_shape("scratch").bytes() == 352);
......@@ -479,12 +479,12 @@ TEST_CASE(test32)
TEST_CASE(test33)
{
migraph::program p;
auto a1 = add_alloc(p, {migraph::shape::float_type, {8}});
auto a2 = add_alloc(p, {migraph::shape::float_type, {8}});
auto a3 = add_alloc(p, {migraph::shape::float_type, {8}});
migraphx::program p;
auto a1 = add_alloc(p, {migraphx::shape::float_type, {8}});
auto a2 = add_alloc(p, {migraphx::shape::float_type, {8}});
auto a3 = add_alloc(p, {migraphx::shape::float_type, {8}});
auto p1 = p.add_instruction(pass_op{}, a2, a1, a3);
auto a5 = add_alloc(p, {migraph::shape::float_type, {40}});
auto a5 = add_alloc(p, {migraphx::shape::float_type, {40}});
p.add_instruction(pass_op{}, a5, p1);
p.compile(memory_coloring_target{});
CHECK(p.get_parameter_shape("scratch").bytes() == 224);
......@@ -493,12 +493,12 @@ TEST_CASE(test33)
TEST_CASE(test34)
{
migraph::program p;
auto a1 = add_alloc(p, {migraph::shape::float_type, {40}});
auto a2 = add_alloc(p, {migraph::shape::float_type, {40}});
auto a3 = add_alloc(p, {migraph::shape::float_type, {40}});
migraphx::program p;
auto a1 = add_alloc(p, {migraphx::shape::float_type, {40}});
auto a2 = add_alloc(p, {migraphx::shape::float_type, {40}});
auto a3 = add_alloc(p, {migraphx::shape::float_type, {40}});
auto p1 = p.add_instruction(pass_op{}, a2, a1, a3);
auto a5 = add_alloc(p, {migraph::shape::float_type, {8}});
auto a5 = add_alloc(p, {migraphx::shape::float_type, {8}});
p.add_instruction(pass_op{}, a5, p1);
p.compile(memory_coloring_target{});
CHECK(p.get_parameter_shape("scratch").bytes() == 480);
......@@ -507,12 +507,12 @@ TEST_CASE(test34)
TEST_CASE(test35)
{
migraph::program p;
auto a1 = add_alloc(p, {migraph::shape::float_type, {40}});
auto a2 = add_alloc(p, {migraph::shape::float_type, {8}});
auto a3 = add_alloc(p, {migraph::shape::float_type, {8}});
migraphx::program p;
auto a1 = add_alloc(p, {migraphx::shape::float_type, {40}});
auto a2 = add_alloc(p, {migraphx::shape::float_type, {8}});
auto a3 = add_alloc(p, {migraphx::shape::float_type, {8}});
auto p1 = p.add_instruction(pass_op{}, a2, a1, a3);
auto a5 = add_alloc(p, {migraph::shape::float_type, {8}});
auto a5 = add_alloc(p, {migraphx::shape::float_type, {8}});
p.add_instruction(pass_op{}, a5, p1);
p.compile(memory_coloring_target{});
CHECK(p.get_parameter_shape("scratch").bytes() == 224);
......@@ -521,14 +521,14 @@ TEST_CASE(test35)
TEST_CASE(test36)
{
migraph::program p;
auto output = p.add_parameter("output", {migraph::shape::float_type, {20}});
auto a1 = add_alloc(p, {migraph::shape::float_type, {0}});
auto a2 = add_alloc(p, {migraph::shape::float_type, {40}});
migraphx::program p;
auto output = p.add_parameter("output", {migraphx::shape::float_type, {20}});
auto a1 = add_alloc(p, {migraphx::shape::float_type, {0}});
auto a2 = add_alloc(p, {migraphx::shape::float_type, {40}});
auto p1 = p.add_instruction(pass_op{}, a2, a1);
auto a3 = add_alloc(p, {migraph::shape::float_type, {40}});
auto a3 = add_alloc(p, {migraphx::shape::float_type, {40}});
auto p2 = p.add_instruction(pass_op{}, a3, p1);
auto a4 = add_alloc(p, {migraph::shape::float_type, {40}});
auto a4 = add_alloc(p, {migraphx::shape::float_type, {40}});
auto p3 = p.add_instruction(pass_op{}, a4, p2);
p.add_instruction(pass_op{}, output, p3);
p.compile(memory_coloring_target{});
......@@ -538,14 +538,14 @@ TEST_CASE(test36)
TEST_CASE(test37)
{
migraph::program p;
auto output = p.add_parameter("output", {migraph::shape::float_type, {20}});
auto a1 = add_alloc(p, {migraph::shape::float_type, {4}});
auto a2 = add_alloc(p, {migraph::shape::float_type, {40}});
migraphx::program p;
auto output = p.add_parameter("output", {migraphx::shape::float_type, {20}});
auto a1 = add_alloc(p, {migraphx::shape::float_type, {4}});
auto a2 = add_alloc(p, {migraphx::shape::float_type, {40}});
auto p1 = p.add_instruction(pass_op{}, a2, a1);
auto a3 = add_alloc(p, {migraph::shape::float_type, {40}});
auto a3 = add_alloc(p, {migraphx::shape::float_type, {40}});
auto p2 = p.add_instruction(pass_op{}, a3, p1);
auto a4 = add_alloc(p, {migraph::shape::float_type, {40}});
auto a4 = add_alloc(p, {migraphx::shape::float_type, {40}});
auto p3 = p.add_instruction(pass_op{}, a4, p2);
p.add_instruction(pass_op{}, output, p3);
p.compile(memory_coloring_target{});
......@@ -555,42 +555,42 @@ TEST_CASE(test37)
TEST_CASE(test38)
{
migraph::program p;
auto output = p.add_parameter("output", {migraph::shape::float_type, {1, 64, 56, 56}});
auto p29 = add_alloc(p, {migraph::shape::float_type, {0}});
auto p30 = add_alloc(p, {migraph::shape::float_type, {1, 64, 112, 112}});
migraphx::program p;
auto output = p.add_parameter("output", {migraphx::shape::float_type, {1, 64, 56, 56}});
auto p29 = add_alloc(p, {migraphx::shape::float_type, {0}});
auto p30 = add_alloc(p, {migraphx::shape::float_type, {1, 64, 112, 112}});
auto p31 = p.add_instruction(pass_op{}, p30, p29);
auto p32 = add_alloc(p, {migraph::shape::float_type, {1, 64, 112, 112}});
auto p32 = add_alloc(p, {migraphx::shape::float_type, {1, 64, 112, 112}});
auto p37 = p.add_instruction(pass_op{}, p32, p31);
auto p38 = add_alloc(p, {migraph::shape::float_type, {1, 64, 112, 112}});
auto p38 = add_alloc(p, {migraphx::shape::float_type, {1, 64, 112, 112}});
auto p39 = p.add_instruction(pass_op{}, p38, p37);
auto p40 = add_alloc(p, {migraph::shape::float_type, {1, 64, 56, 56}});
auto p40 = add_alloc(p, {migraphx::shape::float_type, {1, 64, 56, 56}});
auto p41 = p.add_instruction(pass_op{}, p40, p39);
auto p42 = add_alloc(p, {migraph::shape::float_type, {0}});
auto p43 = add_alloc(p, {migraph::shape::float_type, {1, 64, 56, 56}});
auto p42 = add_alloc(p, {migraphx::shape::float_type, {0}});
auto p43 = add_alloc(p, {migraphx::shape::float_type, {1, 64, 56, 56}});
auto p44 = p.add_instruction(pass_op{}, p43, p41, p42);
auto p45 = add_alloc(p, {migraph::shape::float_type, {1, 64, 56, 56}});
auto p45 = add_alloc(p, {migraphx::shape::float_type, {1, 64, 56, 56}});
auto p50 = p.add_instruction(pass_op{}, p45, p44);
auto p51 = add_alloc(p, {migraph::shape::float_type, {1, 64, 56, 56}});
auto p51 = add_alloc(p, {migraphx::shape::float_type, {1, 64, 56, 56}});
auto p52 = p.add_instruction(pass_op{}, p51, p50);
auto p53 = add_alloc(p, {migraph::shape::float_type, {0}});
auto p54 = add_alloc(p, {migraph::shape::float_type, {1, 64, 56, 56}});
auto p53 = add_alloc(p, {migraphx::shape::float_type, {0}});
auto p54 = add_alloc(p, {migraphx::shape::float_type, {1, 64, 56, 56}});
auto p55 = p.add_instruction(pass_op{}, p54, p52, p53);
auto p56 = add_alloc(p, {migraph::shape::float_type, {1, 64, 56, 56}});
auto p56 = add_alloc(p, {migraphx::shape::float_type, {1, 64, 56, 56}});
auto p61 = p.add_instruction(pass_op{}, p56, p55);
auto p62 = add_alloc(p, {migraph::shape::float_type, {1, 64, 56, 56}});
auto p62 = add_alloc(p, {migraphx::shape::float_type, {1, 64, 56, 56}});
auto p63 = p.add_instruction(pass_op{}, p62, p61, p41);
auto p64 = add_alloc(p, {migraph::shape::float_type, {0}});
auto p65 = add_alloc(p, {migraph::shape::float_type, {1, 64, 56, 56}});
auto p64 = add_alloc(p, {migraphx::shape::float_type, {0}});
auto p65 = add_alloc(p, {migraphx::shape::float_type, {1, 64, 56, 56}});
auto p66 = p.add_instruction(pass_op{}, p65, p63, p64);
auto p67 = add_alloc(p, {migraph::shape::float_type, {1, 64, 56, 56}});
auto p67 = add_alloc(p, {migraphx::shape::float_type, {1, 64, 56, 56}});
auto p72 = p.add_instruction(pass_op{}, p67, p66);
auto p73 = add_alloc(p, {migraph::shape::float_type, {1, 64, 56, 56}});
auto p73 = add_alloc(p, {migraphx::shape::float_type, {1, 64, 56, 56}});
auto p74 = p.add_instruction(pass_op{}, p73, p72);
auto p75 = add_alloc(p, {migraph::shape::float_type, {0}});
auto p76 = add_alloc(p, {migraph::shape::float_type, {1, 64, 56, 56}});
auto p75 = add_alloc(p, {migraphx::shape::float_type, {0}});
auto p76 = add_alloc(p, {migraphx::shape::float_type, {1, 64, 56, 56}});
auto p77 = p.add_instruction(pass_op{}, p76, p74, p75);
auto p78 = add_alloc(p, {migraph::shape::float_type, {1, 64, 56, 56}});
auto p78 = add_alloc(p, {migraphx::shape::float_type, {1, 64, 56, 56}});
auto p83 = p.add_instruction(pass_op{}, p78, p77);
p.add_instruction(pass_op{}, output, p83, p63);
p.compile(memory_coloring_target{});
......@@ -600,8 +600,8 @@ TEST_CASE(test38)
TEST_CASE(literal_test)
{
migraph::program p;
auto lit = generate_literal(migraph::shape{migraph::shape::float_type, {4, 3, 3, 3}});
migraphx::program p;
auto lit = generate_literal(migraphx::shape{migraphx::shape::float_type, {4, 3, 3, 3}});
p.add_literal(lit);
p.compile(memory_coloring_target{});
auto result = p.eval({});
......
 acos-example:;
xy"Acos test_acosZ
x


b
y


B
\ No newline at end of file
add_bcast-example:
-
0
12"Add*
axis*
broadcasttest-add_bcastZ
0




Z
1


b
2




B
\ No newline at end of file
 asin-example:;
xy"Asin test_asinZ
x


b
y


B
\ No newline at end of file
 atan-example:;
xy"Atan test_atanZ
x


b
y


B
\ No newline at end of file
 cos-example:9
xy"Costest_cosZ
x


b
y


B
\ No newline at end of file
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