"src/targets/vscode:/vscode.git/clone" did not exist on "7e6137f134b2df242feaafa47430202421626016"
Commit 0369e974 authored by Khalique Ahmed's avatar Khalique Ahmed
Browse files

Merge branch 'batch_report' of https://github.com/ROCmSoftwarePlatform/AMDMIGraphX into mi100_opts

parents 3a474fca d70fd0df
#include <migraphx/decompose.hpp>
#include <migraphx/pass_manager.hpp>
#include <basic_ops.hpp>
#include <migraphx/make_op.hpp>
#include <test.hpp>
void run_pass(migraphx::module& m) { migraphx::run_passes(m, {migraphx::decompose{}}); }
TEST_CASE(dot_add)
{
migraphx::module m1;
{
auto x = m1.add_parameter("x", migraphx::shape{migraphx::shape::float_type, {2, 2}});
auto y = m1.add_parameter("y", migraphx::shape{migraphx::shape::float_type, {2, 2}});
auto z = m1.add_parameter("z", migraphx::shape{migraphx::shape::float_type, {2, 2}});
auto dot = m1.add_instruction(migraphx::make_op("dot"), x, y, z);
m1.add_instruction(migraphx::make_op("identity"), dot);
}
run_pass(m1);
migraphx::module m2;
{
auto x = m2.add_parameter("x", migraphx::shape{migraphx::shape::float_type, {2, 2}});
auto y = m2.add_parameter("y", migraphx::shape{migraphx::shape::float_type, {2, 2}});
auto z = m2.add_parameter("z", migraphx::shape{migraphx::shape::float_type, {2, 2}});
auto dot = m2.add_instruction(migraphx::make_op("dot", {{"alpha", 1}, {"beta", 0}}), x, y);
auto add = m2.add_instruction(migraphx::make_op("add"), dot, z);
m2.add_instruction(migraphx::make_op("identity"), add);
}
EXPECT(m1 == m2);
}
TEST_CASE(dot_add_beta_float)
{
migraphx::module m1;
{
auto x = m1.add_parameter("x", migraphx::shape{migraphx::shape::float_type, {2, 2}});
auto y = m1.add_parameter("y", migraphx::shape{migraphx::shape::float_type, {2, 2}});
auto z = m1.add_parameter("z", migraphx::shape{migraphx::shape::float_type, {2, 2}});
auto dot =
m1.add_instruction(migraphx::make_op("dot", {{"alpha", 1.0}, {"beta", 0.5}}), x, y, z);
m1.add_instruction(migraphx::make_op("identity"), dot);
}
run_pass(m1);
migraphx::module m2;
{
auto x = m2.add_parameter("x", migraphx::shape{migraphx::shape::float_type, {2, 2}});
auto y = m2.add_parameter("y", migraphx::shape{migraphx::shape::float_type, {2, 2}});
auto z = m2.add_parameter("z", migraphx::shape{migraphx::shape::float_type, {2, 2}});
auto dot = m2.add_instruction(migraphx::make_op("dot", {{"alpha", 1}, {"beta", 0}}), x, y);
auto beta =
m2.add_literal(migraphx::literal{migraphx::shape{migraphx::shape::float_type}, {0.5}});
auto beta_broadcast =
m2.add_instruction(migraphx::make_op("multibroadcast", {{"out_lens", {2, 2}}}), beta);
auto mul = m2.add_instruction(migraphx::make_op("mul"), z, beta_broadcast);
auto add = m2.add_instruction(migraphx::make_op("add"), dot, mul);
m2.add_instruction(migraphx::make_op("identity"), add);
}
EXPECT(m1 == m2);
}
TEST_CASE(dot_add_beta_half)
{
migraphx::module m1;
{
auto x = m1.add_parameter("x", migraphx::shape{migraphx::shape::half_type, {2, 2}});
auto y = m1.add_parameter("y", migraphx::shape{migraphx::shape::half_type, {2, 2}});
auto z = m1.add_parameter("z", migraphx::shape{migraphx::shape::half_type, {2, 2}});
auto dot =
m1.add_instruction(migraphx::make_op("dot", {{"alpha", 1.0}, {"beta", 0.5}}), x, y, z);
m1.add_instruction(migraphx::make_op("identity"), dot);
}
run_pass(m1);
migraphx::module m2;
{
auto x = m2.add_parameter("x", migraphx::shape{migraphx::shape::half_type, {2, 2}});
auto y = m2.add_parameter("y", migraphx::shape{migraphx::shape::half_type, {2, 2}});
auto z = m2.add_parameter("z", migraphx::shape{migraphx::shape::half_type, {2, 2}});
auto dot = m2.add_instruction(migraphx::make_op("dot", {{"alpha", 1}, {"beta", 0}}), x, y);
auto beta =
m2.add_literal(migraphx::literal{migraphx::shape{migraphx::shape::half_type}, {0.5}});
auto beta_broadcast =
m2.add_instruction(migraphx::make_op("multibroadcast", {{"out_lens", {2, 2}}}), beta);
auto mul = m2.add_instruction(migraphx::make_op("mul"), z, beta_broadcast);
auto add = m2.add_instruction(migraphx::make_op("add"), dot, mul);
m2.add_instruction(migraphx::make_op("identity"), add);
}
EXPECT(m1 == m2);
}
TEST_CASE(dot_add_beta_double)
{
migraphx::module m1;
{
auto x = m1.add_parameter("x", migraphx::shape{migraphx::shape::double_type, {2, 2}});
auto y = m1.add_parameter("y", migraphx::shape{migraphx::shape::double_type, {2, 2}});
auto z = m1.add_parameter("z", migraphx::shape{migraphx::shape::double_type, {2, 2}});
auto dot =
m1.add_instruction(migraphx::make_op("dot", {{"alpha", 1.0}, {"beta", 0.5}}), x, y, z);
m1.add_instruction(migraphx::make_op("identity"), dot);
}
run_pass(m1);
migraphx::module m2;
{
auto x = m2.add_parameter("x", migraphx::shape{migraphx::shape::double_type, {2, 2}});
auto y = m2.add_parameter("y", migraphx::shape{migraphx::shape::double_type, {2, 2}});
auto z = m2.add_parameter("z", migraphx::shape{migraphx::shape::double_type, {2, 2}});
auto dot = m2.add_instruction(migraphx::make_op("dot", {{"alpha", 1}, {"beta", 0}}), x, y);
auto beta =
m2.add_literal(migraphx::literal{migraphx::shape{migraphx::shape::double_type}, {0.5}});
auto beta_broadcast =
m2.add_instruction(migraphx::make_op("multibroadcast", {{"out_lens", {2, 2}}}), beta);
auto mul = m2.add_instruction(migraphx::make_op("mul"), z, beta_broadcast);
auto add = m2.add_instruction(migraphx::make_op("add"), dot, mul);
m2.add_instruction(migraphx::make_op("identity"), add);
}
EXPECT(m1 == m2);
}
TEST_CASE(dot_add_beta_int)
{
migraphx::module m1;
{
auto x = m1.add_parameter("x", migraphx::shape{migraphx::shape::int32_type, {2, 2}});
auto y = m1.add_parameter("y", migraphx::shape{migraphx::shape::int32_type, {2, 2}});
auto z = m1.add_parameter("z", migraphx::shape{migraphx::shape::int32_type, {2, 2}});
auto dot =
m1.add_instruction(migraphx::make_op("dot", {{"alpha", 1.0}, {"beta", 0.5}}), x, y, z);
m1.add_instruction(migraphx::make_op("identity"), dot);
}
run_pass(m1);
migraphx::module m2;
{
auto x = m2.add_parameter("x", migraphx::shape{migraphx::shape::int32_type, {2, 2}});
auto y = m2.add_parameter("y", migraphx::shape{migraphx::shape::int32_type, {2, 2}});
auto z = m2.add_parameter("z", migraphx::shape{migraphx::shape::int32_type, {2, 2}});
auto dot = m2.add_instruction(migraphx::make_op("dot", {{"alpha", 1}, {"beta", 0}}), x, y);
auto beta =
m2.add_literal(migraphx::literal{migraphx::shape{migraphx::shape::int32_type}, {0.5}});
auto beta_broadcast =
m2.add_instruction(migraphx::make_op("multibroadcast", {{"out_lens", {2, 2}}}), beta);
auto mul = m2.add_instruction(migraphx::make_op("mul"), z, beta_broadcast);
auto add = m2.add_instruction(migraphx::make_op("add"), dot, mul);
m2.add_instruction(migraphx::make_op("identity"), add);
}
EXPECT(m1 == m2);
}
int main(int argc, const char* argv[]) { test::run(argc, argv); }
#include <cstdint>
#include <migraphx/instruction.hpp>
#include <migraphx/apply_alpha_beta.hpp>
#include <basic_ops.hpp>
#include <migraphx/make_op.hpp>
#include <test.hpp>
TEST_CASE(dot_apply_alpha_beta_half)
{
migraphx::module m1;
{
auto x = m1.add_parameter("x", migraphx::shape{migraphx::shape::half_type, {2, 2}});
auto y = m1.add_parameter("y", migraphx::shape{migraphx::shape::half_type, {2, 2}});
auto z = m1.add_parameter("z", migraphx::shape{migraphx::shape::half_type, {2, 2}});
auto dot_res = migraphx::insert_apply_alpha_beta(
m1, m1.end(), {x, y, z}, migraphx::make_op("dot"), 3.0f, 2.0f);
m1.add_instruction(migraphx::make_op("identity"), dot_res);
}
migraphx::module m2;
{
auto ht = migraphx::shape::half_type;
auto ft = migraphx::shape::float_type;
auto x = m2.add_parameter("x", migraphx::shape{ht, {2, 2}});
auto y = m2.add_parameter("y", migraphx::shape{ht, {2, 2}});
auto z = m2.add_parameter("z", migraphx::shape{ht, {2, 2}});
auto alpha_literal = m2.add_literal(3.0f);
auto alpha_broadcast = m2.add_instruction(
migraphx::make_op("multibroadcast", {{"out_lens", x->get_shape().lens()}}),
alpha_literal);
auto x_float = m2.add_instruction(migraphx::make_op("convert", {{"target_type", ft}}), x);
auto x_alpha_float = m2.add_instruction(migraphx::make_op("mul"), alpha_broadcast, x_float);
auto x_half =
m2.add_instruction(migraphx::make_op("convert", {{"target_type", ht}}), x_alpha_float);
auto dot_res = m2.add_instruction(migraphx::make_op("dot"), x_half, y);
auto beta_literal = m2.add_literal(2.0f);
auto z_float = m2.add_instruction(migraphx::make_op("convert", {{"target_type", ft}}), z);
auto beta_broadcast = m2.add_instruction(
migraphx::make_op("multibroadcast", {{"out_lens", z->get_shape().lens()}}),
beta_literal);
auto z_beta_float = m2.add_instruction(migraphx::make_op("mul"), z_float, beta_broadcast);
auto z_beta_half =
m2.add_instruction(migraphx::make_op("convert", {{"target_type", ht}}), z_beta_float);
auto z_add = m2.add_instruction(migraphx::make_op("add"), dot_res, z_beta_half);
m2.add_instruction(migraphx::make_op("identity"), z_add);
}
EXPECT(m1 == m2);
}
TEST_CASE(dot_apply_alpha_beta_double)
{
migraphx::module m1;
{
auto x = m1.add_parameter("x", migraphx::shape{migraphx::shape::double_type, {2, 2}});
auto y = m1.add_parameter("y", migraphx::shape{migraphx::shape::double_type, {2, 2}});
auto z = m1.add_parameter("z", migraphx::shape{migraphx::shape::double_type, {2, 1}});
auto dot_res =
migraphx::add_apply_alpha_beta(m1, {x, y, z}, migraphx::make_op("dot"), 3.0f, 2.0f);
m1.add_instruction(migraphx::make_op("identity"), dot_res);
}
migraphx::module m2;
{
auto dt = migraphx::shape::double_type;
auto x = m2.add_parameter("x", migraphx::shape{dt, {2, 2}});
auto y = m2.add_parameter("y", migraphx::shape{dt, {2, 2}});
auto z = m2.add_parameter("z", migraphx::shape{dt, {2, 1}});
auto alpha_literal = m2.add_literal(3.0f);
auto alpha_broadcast = m2.add_instruction(
migraphx::make_op("multibroadcast", {{"out_lens", x->get_shape().lens()}}),
alpha_literal);
auto alpha_double = m2.add_instruction(migraphx::make_op("convert", {{"target_type", dt}}),
alpha_broadcast);
auto x_alpha_double = m2.add_instruction(migraphx::make_op("mul"), alpha_double, x);
auto dot_res = m2.add_instruction(migraphx::make_op("dot"), x_alpha_double, y);
auto z_broadcast =
m2.add_instruction(migraphx::make_op("multibroadcast", {{"out_lens", {2, 2}}}), z);
auto beta_literal = m2.add_literal(2.0f);
auto beta_broadcast = m2.add_instruction(
migraphx::make_op("multibroadcast", {{"out_lens", z_broadcast->get_shape().lens()}}),
beta_literal);
auto beta_double =
m2.add_instruction(migraphx::make_op("convert", {{"target_type", dt}}), beta_broadcast);
auto z_beta_double = m2.add_instruction(migraphx::make_op("mul"), z_broadcast, beta_double);
auto z_add = m2.add_instruction(migraphx::make_op("add"), dot_res, z_beta_double);
m2.add_instruction(migraphx::make_op("identity"), z_add);
}
EXPECT(m1 == m2);
}
TEST_CASE(quant_dot_apply_alpha_beta)
{
migraphx::module m1;
{
auto x = m1.add_parameter("x", migraphx::shape{migraphx::shape::int8_type, {2, 2}});
auto y = m1.add_parameter("y", migraphx::shape{migraphx::shape::int8_type, {2, 2}});
auto z = m1.add_parameter("z", migraphx::shape{migraphx::shape::int32_type, {2, 2}});
auto dot_res = migraphx::insert_apply_alpha_beta(m1,
m1.end(),
{x, y, z},
migraphx::make_op("quant_dot"),
migraphx::literal{int32_t{3}},
migraphx::literal{int32_t{2}});
m1.add_instruction(migraphx::make_op("identity"), dot_res);
}
migraphx::module m2;
{
auto i8 = migraphx::shape::int8_type;
auto i32 = migraphx::shape::int32_type;
auto x = m2.add_parameter("x", migraphx::shape{i8, {2, 2}});
auto y = m2.add_parameter("y", migraphx::shape{i8, {2, 2}});
auto z = m2.add_parameter("z", migraphx::shape{i32, {2, 2}});
auto alpha_literal = m2.add_literal(int32_t(3));
auto alpha_broadcast = m2.add_instruction(
migraphx::make_op("multibroadcast", {{"out_lens", x->get_shape().lens()}}),
alpha_literal);
auto x_i32 = m2.add_instruction(migraphx::make_op("convert", {{"target_type", i32}}), x);
auto x_alpha_i32 = m2.add_instruction(migraphx::make_op("mul"), alpha_broadcast, x_i32);
auto x_i8 =
m2.add_instruction(migraphx::make_op("convert", {{"target_type", i8}}), x_alpha_i32);
auto dot_res = m2.add_instruction(migraphx::make_op("quant_dot"), x_i8, y);
auto beta_literal = m2.add_literal(int32_t(2));
auto beta_broadcast = m2.add_instruction(
migraphx::make_op("multibroadcast", {{"out_lens", z->get_shape().lens()}}),
beta_literal);
auto z_beta_i32 = m2.add_instruction(migraphx::make_op("mul"), z, beta_broadcast);
auto z_add = m2.add_instruction(migraphx::make_op("add"), dot_res, z_beta_i32);
m2.add_instruction(migraphx::make_op("identity"), z_add);
}
EXPECT(m1 == m2);
}
int main(int argc, const char* argv[]) { test::run(argc, argv); }
#include "migraphx/dead_code_elimination.hpp"
#include <migraphx/fuse_pointwise.hpp>
#include <migraphx/instruction.hpp>
#include <migraphx/pass_manager.hpp>
#include <migraphx/program.hpp>
#include <basic_ops.hpp>
#include <migraphx/make_op.hpp>
#include <test.hpp>
void run_pass(migraphx::program& p)
{
migraphx::run_passes(p, {migraphx::fuse_pointwise{}, migraphx::dead_code_elimination{}});
}
template <class F>
migraphx::instruction_ref add_pointwise(migraphx::program& p,
const std::string& name,
std::vector<migraphx::instruction_ref> inputs,
F f)
{
auto* pm = p.create_module(name);
auto* mm = p.get_main_module();
pm->set_bypass();
std::vector<migraphx::instruction_ref> params;
std::transform(inputs.begin(), inputs.end(), std::back_inserter(params), [&](auto input) {
return pm->add_parameter("x" + std::to_string(params.size()),
migraphx::shape{input->get_shape().type()});
});
auto r = f(pm, params);
pm->add_return({r});
return mm->add_instruction(migraphx::make_op("pointwise"), inputs, {pm});
}
auto single_pointwise(const std::string& name)
{
return [=](auto* pm, const auto& inputs) {
return pm->add_instruction(migraphx::make_op(name), inputs);
};
}
TEST_CASE(single)
{
migraphx::shape s{migraphx::shape::float_type, {2, 3}};
migraphx::program p1;
{
auto* mm = p1.get_main_module();
auto x = mm->add_parameter("x", s);
auto y = mm->add_parameter("y", s);
auto z = mm->add_parameter("z", s);
auto add1 = mm->add_instruction(migraphx::make_op("add"), x, y);
auto pass = mm->add_instruction(pass_op{}, add1);
auto add2 = mm->add_instruction(migraphx::make_op("add"), pass, z);
mm->add_return({add2});
}
run_pass(p1);
migraphx::program p2;
{
auto* mm = p2.get_main_module();
auto x = mm->add_parameter("x", s);
auto y = mm->add_parameter("y", s);
auto z = mm->add_parameter("z", s);
auto add1 = add_pointwise(p2, "pointwise0", {x, y}, single_pointwise("add"));
auto pass = mm->add_instruction(pass_op{}, add1);
auto add2 = add_pointwise(p2, "pointwise1", {pass, z}, single_pointwise("add"));
mm->add_return({add2});
}
EXPECT(p1 == p2);
}
TEST_CASE(double_add)
{
migraphx::shape s{migraphx::shape::float_type, {2, 3}};
migraphx::program p1;
{
auto* mm = p1.get_main_module();
auto x = mm->add_parameter("x", s);
auto y = mm->add_parameter("y", s);
auto z = mm->add_parameter("z", s);
auto add1 = mm->add_instruction(migraphx::make_op("add"), x, y);
auto add2 = mm->add_instruction(migraphx::make_op("add"), add1, z);
mm->add_return({add2});
}
run_pass(p1);
migraphx::program p2;
{
auto* mm = p2.get_main_module();
auto x = mm->add_parameter("x", s);
auto y = mm->add_parameter("y", s);
auto z = mm->add_parameter("z", s);
auto fadd = add_pointwise(p2, "pointwise0", {x, y, z}, [=](auto* pm, const auto& inputs) {
auto add1 = pm->add_instruction(migraphx::make_op("add"), inputs[0], inputs[1]);
return pm->add_instruction(migraphx::make_op("add"), add1, inputs[2]);
});
mm->add_return({fadd});
}
EXPECT(p1.sort() == p2.sort());
}
TEST_CASE(used_twice_not_fused)
{
migraphx::shape s{migraphx::shape::float_type, {2, 3}};
migraphx::program p1;
{
auto* mm = p1.get_main_module();
auto x = mm->add_parameter("x", s);
auto y = mm->add_parameter("y", s);
auto add1 = mm->add_instruction(migraphx::make_op("add"), x, y);
auto pass = mm->add_instruction(pass_op{}, add1);
auto add2 = mm->add_instruction(migraphx::make_op("add"), add1, y);
auto add3 = mm->add_instruction(migraphx::make_op("add"), pass, add2);
mm->add_return({add3});
}
run_pass(p1);
migraphx::program p2;
{
auto* mm = p2.get_main_module();
auto x = mm->add_parameter("x", s);
auto y = mm->add_parameter("y", s);
auto add1 = add_pointwise(p2, "pointwise0", {x, y}, single_pointwise("add"));
auto pass = mm->add_instruction(pass_op{}, add1);
auto fadd =
add_pointwise(p2, "pointwise1", {add1, y, pass}, [=](auto* pm, const auto& inputs) {
auto add2 = pm->add_instruction(migraphx::make_op("add"), inputs[0], inputs[1]);
return pm->add_instruction(migraphx::make_op("add"), inputs[2], add2);
});
mm->add_return({fadd});
}
EXPECT(p1 == p2);
}
TEST_CASE(used_twice_fused)
{
migraphx::shape s{migraphx::shape::float_type, {2, 3}};
migraphx::program p1;
{
auto* mm = p1.get_main_module();
auto x = mm->add_parameter("x", s);
auto y = mm->add_parameter("y", s);
auto add1 = mm->add_instruction(migraphx::make_op("add"), x, y);
auto add2 = mm->add_instruction(migraphx::make_op("add"), add1, x);
auto add3 = mm->add_instruction(migraphx::make_op("add"), add1, y);
auto add4 = mm->add_instruction(migraphx::make_op("add"), add2, add3);
mm->add_return({add4});
}
run_pass(p1);
migraphx::program p2;
{
auto* mm = p2.get_main_module();
auto x = mm->add_parameter("x", s);
auto y = mm->add_parameter("y", s);
auto fadd = add_pointwise(p2, "pointwise0", {x, y}, [=](auto* pm, const auto& inputs) {
auto add1 = pm->add_instruction(migraphx::make_op("add"), inputs[0], inputs[1]);
auto add2 = pm->add_instruction(migraphx::make_op("add"), add1, inputs[0]);
auto add3 = pm->add_instruction(migraphx::make_op("add"), add1, inputs[1]);
return pm->add_instruction(migraphx::make_op("add"), add2, add3);
});
mm->add_return({fadd});
}
EXPECT(p1.sort() == p2.sort());
}
TEST_CASE(duplicate_inputs)
{
migraphx::shape s{migraphx::shape::float_type, {2, 3}};
migraphx::program p1;
{
auto* mm = p1.get_main_module();
auto x = mm->add_parameter("x", s);
auto y = mm->add_parameter("y", s);
auto add1 = mm->add_instruction(migraphx::make_op("add"), x, x);
auto pass = mm->add_instruction(pass_op{}, add1);
auto add2 = mm->add_instruction(migraphx::make_op("add"), pass, y);
mm->add_return({add2});
}
run_pass(p1);
migraphx::program p2;
{
auto* mm = p2.get_main_module();
auto x = mm->add_parameter("x", s);
auto y = mm->add_parameter("y", s);
auto add1 = add_pointwise(p2, "pointwise0", {x}, [=](auto* pm, const auto& inputs) {
return pm->add_instruction(migraphx::make_op("add"), inputs[0], inputs[0]);
});
auto pass = mm->add_instruction(pass_op{}, add1);
auto add2 = add_pointwise(p2, "pointwise1", {pass, y}, single_pointwise("add"));
mm->add_return({add2});
}
EXPECT(p1.sort() == p2.sort());
}
TEST_CASE(scalar_input)
{
migraphx::shape s{migraphx::shape::float_type, {2, 3}};
migraphx::program p1;
{
auto* mm = p1.get_main_module();
auto x = mm->add_parameter("x", s);
auto one = mm->add_literal(1.0f);
auto y =
mm->add_instruction(migraphx::make_op("scalar", {{"scalar_bcst_dims", s.lens()}}), one);
auto add1 = mm->add_instruction(migraphx::make_op("add"), x, y);
mm->add_return({add1});
}
run_pass(p1);
migraphx::program p2;
{
auto* mm = p2.get_main_module();
auto x = mm->add_parameter("x", s);
auto add1 = add_pointwise(p2, "pointwise0", {x}, [=](auto* pm, const auto& inputs) {
auto y = pm->add_literal(1.0f);
return pm->add_instruction(migraphx::make_op("add"), inputs[0], y);
});
mm->add_return({add1});
}
EXPECT(p1 == p2);
}
int main(int argc, const char* argv[]) { test::run(argc, argv); }
......@@ -2,6 +2,7 @@
#include <migraphx/gpu/context.hpp>
#include <migraphx/gpu/lowering.hpp>
#include <migraphx/gpu/target.hpp>
#include <migraphx/apply_alpha_beta.hpp>
#include <migraphx/adjust_allocation.hpp>
#include <migraphx/gpu/pack_int8_args.hpp>
#include <migraphx/gpu/rocblas.hpp>
......@@ -48,7 +49,8 @@ TEST_CASE(quant_dot)
auto l1 = m.add_parameter("a", m1_shape);
auto l2 = m.add_parameter("b", m2_shape);
auto l3 = m.add_parameter("c", m3_shape);
auto r = m.add_instruction(migraphx::make_op("quant_dot"), l1, l2, l3);
auto r =
migraphx::add_apply_alpha_beta(m, {l1, l2, l3}, migraphx::make_op("quant_dot"), 1, 1);
m.add_return({r});
return m;
};
......@@ -59,12 +61,14 @@ TEST_CASE(quant_dot)
migraphx::shape m2_shape{migraphx::shape::int8_type, {8, 7}};
migraphx::shape m3_shape{migraphx::shape::int32_type, {5, 7}};
auto l1 = m.add_parameter("a", m1_shape);
auto l2 = m.add_parameter("b", m2_shape);
auto l3 = m.add_parameter("c", m3_shape);
auto output = m.add_parameter("test:#output_0", m3_shape);
auto l1 = m.add_parameter("a", m1_shape);
auto l2 = m.add_parameter("b", m2_shape);
auto l3 = m.add_parameter("c", m3_shape);
auto beta = m.add_literal(1);
auto output = m.add_parameter("test:#output_0", m3_shape);
auto gemm_alloc = m.add_instruction(
migraphx::make_op("hip::allocate", {{"shape", migraphx::to_value(m3_shape)}}));
auto cout = m.add_instruction(migraphx::make_op("hip::copy"), l3, output);
auto packa = l2;
if(int8_x4)
{
......@@ -72,14 +76,24 @@ TEST_CASE(quant_dot)
migraphx::make_op("hip::allocate", {{"shape", migraphx::to_value(m2_shape)}}));
packa = m.add_instruction(migraphx::make_op("gpu::int8_gemm_pack_a"), l2, alloc);
}
auto gemm = m.add_instruction(
migraphx::make_op("gpu::quant_gemm",
{{"alpha", 1}, {"beta", 1}, {"int8_x4_format", int8_x4}}),
l1,
packa,
cout,
cout);
m.add_return({gemm});
auto gemm =
m.add_instruction(migraphx::make_op("gpu::quant_gemm", {{"int8_x4_format", int8_x4}}),
l1,
packa,
gemm_alloc);
auto beta_broadcast = m.add_instruction(
migraphx::make_op("multibroadcast", {{"out_lens", m3_shape.lens()}}), beta);
auto beta_alloc = m.add_instruction(
migraphx::make_op("hip::allocate", {{"shape", migraphx::to_value(m3_shape)}}));
auto beta_contiguous =
m.add_instruction(migraphx::make_op("gpu::contiguous"), beta_broadcast, beta_alloc);
auto mul_alloc = m.add_instruction(
migraphx::make_op("hip::allocate", {{"shape", migraphx::to_value(m3_shape)}}));
auto m3_beta =
m.add_instruction(migraphx::make_op("gpu::mul"), l3, beta_contiguous, mul_alloc);
auto gemm_add = m.add_instruction(migraphx::make_op("gpu::add"), gemm, m3_beta, output);
m.add_return({gemm_add});
return m;
};
......@@ -89,7 +103,6 @@ TEST_CASE(quant_dot)
bool flag = get_int8_x4_format();
auto m2 = create_optimized_int8_x4(flag);
EXPECT(m1 == m2);
}
......@@ -106,8 +119,7 @@ TEST_CASE(quant_dot_trans)
auto l2 = m.add_parameter("b", s2);
auto tl2 =
m.add_instruction(migraphx::make_op("transpose", {{"permutation", {0, 1, 3, 2}}}), l2);
auto r = m.add_instruction(
migraphx::make_op("quant_dot", {{"alpha", 3}, {"beta", 2}}), tl1, tl2);
auto r = migraphx::add_apply_alpha_beta(m, {tl1, tl2}, migraphx::make_op("quant_dot"), 3);
m.add_return({r});
return m;
};
......@@ -120,6 +132,7 @@ TEST_CASE(quant_dot_trans)
auto l1 = m.add_parameter("a", s1);
auto l2 = m.add_parameter("b", s2);
auto alpha = m.add_literal(3);
auto output = m.add_parameter("test:#output_0", s3);
auto tl1 =
......@@ -136,6 +149,34 @@ TEST_CASE(quant_dot_trans)
migraphx::make_op("hip::allocate", {{"shape", migraphx::to_value(ts2)}}));
auto contb = m.add_instruction(migraphx::make_op("gpu::contiguous"), tl2, allocb);
auto alpha_broadcast = m.add_instruction(
migraphx::make_op("multibroadcast", {{"out_lens", conta->get_shape().lens()}}), alpha);
auto alpha_alloc = m.add_instruction(migraphx::make_op(
"hip::allocate",
{{"shape",
migraphx::to_value(migraphx::shape(migraphx::shape::int32_type, {3, 2, 5, 8}))}}));
auto alpha_contiguous =
m.add_instruction(migraphx::make_op("gpu::contiguous"), alpha_broadcast, alpha_alloc);
// alpha = int32 and tl1 = int8, convert tl1 to int32 for multiplication and then convert
// back result to int8
auto tl1_convert_alloc = m.add_instruction(migraphx::make_op(
"hip::allocate", {{"shape", migraphx::to_value(alpha_contiguous->get_shape())}}));
auto tl1_convert = m.add_instruction(
migraphx::make_op("gpu::convert", {{"target_type", alpha->get_shape().type()}}),
conta,
tl1_convert_alloc);
auto mul_alloc = m.add_instruction(migraphx::make_op(
"hip::allocate", {{"shape", migraphx::to_value(tl1_convert->get_shape())}}));
auto tl1_alpha_int32 = m.add_instruction(
migraphx::make_op("gpu::mul"), alpha_contiguous, tl1_convert, mul_alloc);
// convert mul_res to int8
auto tl1_alpha_int8_alloc = m.add_instruction(migraphx::make_op(
"hip::allocate", {{"shape", migraphx::to_value(conta->get_shape())}}));
auto tl1_alpha_int8 = m.add_instruction(
migraphx::make_op("gpu::convert", {{"target_type", conta->get_shape().type()}}),
tl1_alpha_int32,
tl1_alpha_int8_alloc);
auto packb = contb;
if(int8_x4)
{
......@@ -143,12 +184,12 @@ TEST_CASE(quant_dot_trans)
migraphx::make_op("hip::allocate", {{"shape", migraphx::to_value(ts2)}}));
packb = m.add_instruction(migraphx::make_op("gpu::int8_gemm_pack_a"), contb, allocpb);
}
auto gemm = m.add_instruction(
migraphx::make_op("gpu::quant_gemm",
{{"alpha", 3}, {"beta", 0}, {"int8_x4_format", int8_x4}}),
conta,
packb,
output);
auto gemm =
m.add_instruction(migraphx::make_op("gpu::quant_gemm", {{"int8_x4_format", int8_x4}}),
tl1_alpha_int8,
packb,
output);
m.add_return({gemm});
return m;
......@@ -174,7 +215,8 @@ TEST_CASE(quant_dot_pad)
auto l1 = m.add_parameter("a", s1);
auto l2 = m.add_parameter("b", s2);
auto l3 = m.add_parameter("c", s3);
auto r = m.add_instruction(migraphx::make_op("quant_dot"), l1, l2, l3);
auto r =
migraphx::add_apply_alpha_beta(m, {l1, l2, l3}, migraphx::make_op("quant_dot"), 1, 1);
m.add_return({r});
return m;
};
......@@ -190,6 +232,7 @@ TEST_CASE(quant_dot_pad)
auto l1 = m.add_parameter("a", s1);
auto l2 = m.add_parameter("b", s2);
auto l3 = m.add_parameter("c", s3);
auto beta = m.add_literal(1);
auto output = m.add_parameter("test:#output_0", s3);
auto pl1 = l1;
......@@ -213,7 +256,9 @@ TEST_CASE(quant_dot_pad)
po2);
}
auto cout = m.add_instruction(migraphx::make_op("hip::copy"), l3, output);
auto gemm_alloc = m.add_instruction(
migraphx::make_op("hip::allocate", {{"shape", migraphx::to_value(s3)}}));
if(int8_x4)
{
auto alloc = m.add_instruction(
......@@ -221,15 +266,24 @@ TEST_CASE(quant_dot_pad)
packa = m.add_instruction(migraphx::make_op("gpu::int8_gemm_pack_a"), pl2, alloc);
}
auto gemm = m.add_instruction(
migraphx::make_op("gpu::quant_gemm",
{{"alpha", 1}, {"beta", 1}, {"int8_x4_format", int8_x4}}),
pl1,
packa,
cout,
cout);
m.add_return({gemm});
auto gemm =
m.add_instruction(migraphx::make_op("gpu::quant_gemm", {{"int8_x4_format", int8_x4}}),
pl1,
packa,
gemm_alloc);
auto beta_broadcast =
m.add_instruction(migraphx::make_op("multibroadcast", {{"out_lens", s3.lens()}}), beta);
auto beta_alloc = m.add_instruction(
migraphx::make_op("hip::allocate", {{"shape", migraphx::to_value(s3)}}));
auto beta_contiguous =
m.add_instruction(migraphx::make_op("gpu::contiguous"), beta_broadcast, beta_alloc);
auto mul_alloc = m.add_instruction(
migraphx::make_op("hip::allocate", {{"shape", migraphx::to_value(s3)}}));
auto m3_beta =
m.add_instruction(migraphx::make_op("gpu::mul"), l3, beta_contiguous, mul_alloc);
auto gemm_add = m.add_instruction(migraphx::make_op("gpu::add"), gemm, m3_beta, output);
m.add_return({gemm_add});
return m;
};
......@@ -255,8 +309,7 @@ TEST_CASE(quant_dot_trans_pad)
auto l2 = m.add_parameter("b", s2);
auto tl2 =
m.add_instruction(migraphx::make_op("transpose", {{"permutation", {0, 1, 3, 2}}}), l2);
auto r = m.add_instruction(
migraphx::make_op("quant_dot", {{"alpha", 3}, {"beta", 2}}), tl1, tl2);
auto r = migraphx::add_apply_alpha_beta(m, {tl1, tl2}, migraphx::make_op("quant_dot"), 3);
m.add_return({r});
return m;
};
......@@ -271,6 +324,7 @@ TEST_CASE(quant_dot_trans_pad)
auto l1 = m.add_parameter("a", s1);
auto l2 = m.add_parameter("b", s2);
auto alpha = m.add_literal(3);
auto output = m.add_parameter("test:#output_0", s3);
auto tl1 =
......@@ -278,27 +332,14 @@ TEST_CASE(quant_dot_trans_pad)
migraphx::shape ts1{migraphx::shape::int8_type, {3, 2, 5, 9}};
auto ta = m.add_instruction(
migraphx::make_op("hip::allocate", {{"shape", migraphx::to_value(ts1)}}));
migraphx::instruction_ref pta{};
if(int8_x4)
{
pta = m.add_instruction(
migraphx::make_op("hip::allocate", {{"shape", migraphx::to_value(ps1)}}));
}
auto conta = m.add_instruction(migraphx::make_op("gpu::contiguous"), tl1, ta);
auto pa = conta;
if(int8_x4)
{
pa = m.add_instruction(
migraphx::make_op("gpu::pad", {{"mode", 0}, {"pads", {0, 0, 0, 3, 0, 0, 0, 0}}}),
conta,
pta);
}
auto tl2 =
m.add_instruction(migraphx::make_op("transpose", {{"permutation", {0, 1, 3, 2}}}), l2);
migraphx::shape ts2{migraphx::shape::int8_type, {3, 2, 9, 7}};
auto tb = m.add_instruction(
migraphx::make_op("hip::allocate", {{"shape", migraphx::to_value(ts2)}}));
migraphx::instruction_ref ptb{};
if(int8_x4)
{
......@@ -306,24 +347,72 @@ TEST_CASE(quant_dot_trans_pad)
migraphx::make_op("hip::allocate", {{"shape", migraphx::to_value(ps2)}}));
}
auto contb = m.add_instruction(migraphx::make_op("gpu::contiguous"), tl2, tb);
auto packb = contb;
auto pb = contb;
if(int8_x4)
{
auto pb = m.add_instruction(
pb = m.add_instruction(
migraphx::make_op("gpu::pad", {{"mode", 0}, {"pads", {0, 0, 3, 0, 0, 0, 0, 0}}}),
contb,
ptb);
}
auto alpha_broadcast = m.add_instruction(
migraphx::make_op("multibroadcast", {{"out_lens", conta->get_shape().lens()}}), alpha);
auto alpha_alloc = m.add_instruction(
migraphx::make_op("hip::allocate",
{{"shape",
migraphx::to_value(migraphx::shape(migraphx::shape::int32_type,
conta->get_shape().lens()))}}));
auto alpha_contiguous =
m.add_instruction(migraphx::make_op("gpu::contiguous"), alpha_broadcast, alpha_alloc);
// alpha = int32 and tl1 = int8, convert tl1 to int32 for multiplication and then convert
// back result to int8
auto tl1_convert_alloc = m.add_instruction(migraphx::make_op(
"hip::allocate", {{"shape", migraphx::to_value(alpha_contiguous->get_shape())}}));
auto tl1_convert = m.add_instruction(
migraphx::make_op("gpu::convert", {{"target_type", alpha->get_shape().type()}}),
conta,
tl1_convert_alloc);
auto mul_alloc = m.add_instruction(migraphx::make_op(
"hip::allocate", {{"shape", migraphx::to_value(tl1_convert->get_shape())}}));
auto tl1_alpha_int32 = m.add_instruction(
migraphx::make_op("gpu::mul"), alpha_contiguous, tl1_convert, mul_alloc);
// convert mul_res to int8
auto tl1_alpha_int8_alloc = m.add_instruction(migraphx::make_op(
"hip::allocate", {{"shape", migraphx::to_value(conta->get_shape())}}));
migraphx::instruction_ref pta{};
if(int8_x4)
{
pta = m.add_instruction(
migraphx::make_op("hip::allocate", {{"shape", migraphx::to_value(ps1)}}));
}
auto tl1_alpha_int8 = m.add_instruction(
migraphx::make_op("gpu::convert", {{"target_type", conta->get_shape().type()}}),
tl1_alpha_int32,
tl1_alpha_int8_alloc);
auto pa = tl1_alpha_int8;
if(int8_x4)
{
pa = m.add_instruction(
migraphx::make_op("gpu::pad", {{"mode", 0}, {"pads", {0, 0, 0, 3, 0, 0, 0, 0}}}),
tl1_alpha_int8,
pta);
}
auto packb = pb;
if(int8_x4)
{
auto allocpb = m.add_instruction(
migraphx::make_op("hip::allocate", {{"shape", migraphx::to_value(ps2)}}));
packb = m.add_instruction(migraphx::make_op("gpu::int8_gemm_pack_a"), pb, allocpb);
}
auto gemm = m.add_instruction(
migraphx::make_op("gpu::quant_gemm",
{{"alpha", 3}, {"beta", 0}, {"int8_x4_format", int8_x4}}),
pa,
packb,
output);
migraphx::make_op("gpu::quant_gemm", {{"int8_x4_format", int8_x4}}), pa, packb, output);
m.add_return({gemm});
return m;
......
#include <migraphx/program.hpp>
#include <migraphx/ref/target.hpp>
#include <migraphx/ranges.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/marker.hpp>
#include <migraphx/instruction.hpp>
#include "test.hpp"
struct mock_marker
{
std::shared_ptr<std::stringstream> ss = std::make_shared<std::stringstream>();
void mark_start(migraphx::instruction_ref ins_ref)
{
std::string text = "Mock marker instruction start:" + ins_ref->name();
(*ss) << text;
}
void mark_stop(migraphx::instruction_ref)
{
std::string text = "Mock marker instruction stop.";
(*ss) << text;
}
void mark_start(const migraphx::program&)
{
std::string text = "Mock marker program start.";
(*ss) << text;
}
void mark_stop(const migraphx::program&)
{
std::string text = "Mock marker program stop.";
(*ss) << text;
}
};
TEST_CASE(marker)
{
migraphx::program p;
auto* mm = p.get_main_module();
auto one = mm->add_literal(1);
auto two = mm->add_literal(2);
mm->add_instruction(migraphx::make_op("add"), one, two);
p.compile(migraphx::ref::target{});
mock_marker temp_marker;
p.mark({}, temp_marker);
std::string output = temp_marker.ss->str();
EXPECT(migraphx::contains(output, "Mock marker instruction start:@literal"));
EXPECT(migraphx::contains(output, "Mock marker instruction start:ref::op"));
EXPECT(migraphx::contains(output, "Mock marker instruction stop."));
EXPECT(migraphx::contains(output, "Mock marker program start."));
EXPECT(migraphx::contains(output, "Mock marker program stop."));
}
int main(int argc, const char* argv[]) { test::run(argc, argv); }
......@@ -11,7 +11,7 @@ std::vector<char> msgpack_buffer(const T& src)
msgpack::pack(buffer, src);
buffer.seekg(0);
std::string str = buffer.str();
return std::vector<char>(str.data(), str.data() + str.size());
return std::vector<char>(str.data(), str.data() + str.size()); // NOLINT
}
TEST_CASE(test_msgpack_empty_value)
......
......@@ -1061,6 +1061,62 @@ def depthtospace_crd_test():
return ([node], [x], [y])
@onnx_test
def spacetodepth_test():
x = helper.make_tensor_value_info('x', TensorProto.float, [2, 2, 10, 10])
y = helper.make_tensor_value_info('y', TensorProto.float, [2, 8, 5, 5])
node = onnx.helper.make_node('spacetodepth',
inputs=['x'],
outputs=['y'],
blocksize=2)
return ([node], [x], [y])
@onnx_test
def spacetodepth_simple_test():
x = helper.make_tensor_value_info('x', TensorProto.FLOAT, [1, 2, 4, 6])
y = helper.make_tensor_value_info('y', TensorProto.FLOAT, [1, 8, 2, 3])
node = onnx.helper.make_node('SpaceToDepth',
inputs=['x'],
outputs=['y'],
blocksize=2)
return ([node], [x], [y])
@onnx_test
def spacetodepth_invalid_blocksize_test():
x = helper.make_tensor_value_info('x', TensorProto.FLOAT, [1, 2, 4, 6])
y = helper.make_tensor_value_info('y', TensorProto.FLOAT, [1, 8, 2, 3])
node = onnx.helper.make_node('SpaceToDepth',
inputs=['x'],
outputs=['y'],
blocksize=0.3)
return ([node], [x], [y])
@onnx_test
def spacetodepth_nondivisibility_test():
x = helper.make_tensor_value_info('x', TensorProto.FLOAT, [1, 2, 5, 5])
y = helper.make_tensor_value_info('y', TensorProto.FLOAT, [1, 8, 2, 2])
node = onnx.helper.make_node('SpaceToDepth',
inputs=['x'],
outputs=['y'],
blocksize=2)
return ([node], [x], [y])
@onnx_test
def dequantizelinear_test():
arg0 = helper.make_tensor_value_info('0', TensorProto.INT8, [5])
......@@ -2715,6 +2771,31 @@ def neg_test():
return ([node], [x], [y])
@onnx_test
def nms_test():
b = helper.make_tensor_value_info('boxes', TensorProto.FLOAT, [1, 6, 4])
s = helper.make_tensor_value_info('scores', TensorProto.FLOAT, [1, 1, 6])
mo = helper.make_tensor_value_info('max_output_boxes_per_class',
TensorProto.INT64, [1])
iou = helper.make_tensor_value_info('iou_threshold', TensorProto.FLOAT,
[1])
st = helper.make_tensor_value_info('score_threshold', TensorProto.FLOAT,
[1])
out = helper.make_tensor_value_info('selected_indices', TensorProto.INT64,
[6, 3])
node = onnx.helper.make_node('NonMaxSuppression',
inputs=[
'boxes', 'scores',
'max_output_boxes_per_class',
'iou_threshold', 'score_threshold'
],
outputs=['selected_indices'],
center_point_box=1)
return ([node], [b, s, mo, iou, st], [out])
@onnx_test
def not_test():
x = helper.make_tensor_value_info('0', TensorProto.INT32, [4])
......@@ -2748,6 +2829,18 @@ def no_pad_test():
return ([node], [x], [y])
@onnx_test
def nonzero_dynamic_test():
x = helper.make_tensor_value_info('data', TensorProto.BOOL, [2, 2])
y = helper.make_tensor_value_info('indices', TensorProto.INT64, [2, 3])
node = onnx.helper.make_node('NonZero',
inputs=['data'],
outputs=['indices'])
return ([node], [x], [y])
@onnx_test
def nonzero_test():
data1 = np.array([[1., 0.], [1., 1.]])
......@@ -3767,6 +3860,7 @@ def resize_upsample_pf_test():
return ([node], [X], [Y], [scale_tensor])
@onnx_test
def resize_upsample_pc_test():
scales = np.array([1.0, 1.0, 2.0, 1.5], dtype=np.float32)
scale_tensor = helper.make_tensor(name='scales',
......@@ -3789,6 +3883,41 @@ def resize_upsample_pc_test():
return ([node], [X], [Y], [scale_tensor])
@onnx_test
def roialign_default_test():
x = helper.make_tensor_value_info('x', TensorProto.FLOAT, [10, 4, 7, 8])
roi = helper.make_tensor_value_info('rois', TensorProto.FLOAT, [8, 4])
bi = helper.make_tensor_value_info('batch_ind', TensorProto.INT64, [8])
y = helper.make_tensor_value_info('y', TensorProto.FLOAT, [8, 4, 1, 1])
node = onnx.helper.make_node('RoiAlign',
inputs=['x', 'rois', 'batch_ind'],
outputs=['y'])
return ([node], [x, roi, bi], [y])
@onnx_test
def roialign_test():
x = helper.make_tensor_value_info('x', TensorProto.FLOAT, [10, 5, 4, 7])
roi = helper.make_tensor_value_info('rois', TensorProto.FLOAT, [8, 4])
bi = helper.make_tensor_value_info('batch_ind', TensorProto.INT64, [8])
y = helper.make_tensor_value_info('y', TensorProto.FLOAT, [8, 4, 5, 5])
node = onnx.helper.make_node(
'RoiAlign',
inputs=['x', 'rois', 'batch_ind'],
outputs=['y'],
spatial_scale=2.0,
output_height=5,
output_width=5,
sampling_ratio=3,
mode="avg",
coordinate_transformation_mode="output_half_pixel")
return ([node], [x, roi, bi], [y])
@onnx_test
def scatter_test():
x = helper.make_tensor_value_info('data', TensorProto.FLOAT, [3, 4, 5, 6])
......
nms_test:

boxes
scores
max_output_boxes_per_class
iou_threshold
score_thresholdselected_indices"NonMaxSuppression*
center_point_boxnms_testZ
boxes



Z
scores



Z(
max_output_boxes_per_class

Z
iou_threshold

Z
score_threshold

b"
selected_indices


B
\ No newline at end of file
nonzero_dynamic_test:c

dataindices"NonZerononzero_dynamic_testZ
data
 

b
indices


B
\ No newline at end of file
......@@ -3,6 +3,7 @@
#include <vector>
#include <random>
#include <migraphx/common.hpp>
#include <migraphx/apply_alpha_beta.hpp>
#include <migraphx/literal.hpp>
#include <migraphx/program.hpp>
#include <migraphx/instruction.hpp>
......@@ -964,6 +965,46 @@ TEST_CASE(depthtospace_simple_test)
EXPECT(p == prog);
}
TEST_CASE(spacetodepth_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
auto l0 = mm->add_parameter("x", {migraphx::shape::float_type, {2, 2, 10, 10}});
auto tmp1 =
mm->add_instruction(migraphx::make_op("reshape", {{"dims", {2, 2, 5, 2, 5, 2}}}), l0);
auto tmp2 = mm->add_instruction(
migraphx::make_op("transpose", {{"permutation", {0, 3, 5, 1, 2, 4}}}), tmp1);
auto tmp3 = mm->add_instruction(migraphx::make_op("contiguous"), tmp2);
mm->add_instruction(migraphx::make_op("reshape", {{"dims", {2, 8, 5, 5}}}), tmp3);
auto prog = optimize_onnx("spacetodepth_test.onnx");
EXPECT(p == prog);
}
TEST_CASE(spacetodepth_simple_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
auto l0 = mm->add_parameter("x", {migraphx::shape::float_type, {1, 2, 4, 6}});
auto tmp1 =
mm->add_instruction(migraphx::make_op("reshape", {{"dims", {1, 2, 2, 2, 3, 2}}}), l0);
auto tmp2 = mm->add_instruction(
migraphx::make_op("transpose", {{"permutation", {0, 3, 5, 1, 2, 4}}}), tmp1);
auto tmp3 = mm->add_instruction(migraphx::make_op("contiguous"), tmp2);
mm->add_instruction(migraphx::make_op("reshape", {{"dims", {1, 8, 2, 3}}}), tmp3);
auto prog = optimize_onnx("spacetodepth_simple_test.onnx");
EXPECT(p == prog);
}
TEST_CASE(spacetodepth_invalid_blocksize)
{
EXPECT(test::throws([&] { migraphx::parse_onnx("spacetodepth_invalid_blocksize_test.onnx"); }));
}
TEST_CASE(spacetodepth_nondivisibility_test)
{
EXPECT(test::throws([&] { migraphx::parse_onnx("spacetodepth_nondivisibility_test.onnx"); }));
}
TEST_CASE(dequantizelinear_test)
{
migraphx::program p;
......@@ -1340,11 +1381,9 @@ TEST_CASE(gemm_test)
auto beta = 2.0f;
auto a_l = mm->add_literal(alpha);
auto t_a = add_common_op(*mm, migraphx::make_op("mul"), {a_l, l0});
t_a = mm->add_instruction(migraphx::make_op("transpose", {{"permutation", {1, 0}}}), t_a);
auto t1 = mm->add_instruction(migraphx::make_op("transpose", {{"permutation", {1, 0}}}), l1);
auto dot =
mm->add_instruction(migraphx::make_op("dot", {{"alpha", 1.0f}, {"beta", 0.0f}}), t_a, t1);
t_a = mm->add_instruction(migraphx::make_op("transpose", {{"permutation", {1, 0}}}), t_a);
auto t1 = mm->add_instruction(migraphx::make_op("transpose", {{"permutation", {1, 0}}}), l1);
auto dot = migraphx::add_apply_alpha_beta(*mm, {t_a, t1}, migraphx::make_op("dot"), 1.0f, 0.0f);
auto b_l = mm->add_literal(beta);
auto l2_b =
mm->add_instruction(migraphx::make_op("multibroadcast", {{"out_lens", {7, 11}}}), l2);
......@@ -1369,9 +1408,7 @@ TEST_CASE(gemm_ex_test)
auto a_l = mm->add_literal(alpha);
auto t_a = add_common_op(*mm, migraphx::make_op("mul"), {a_l, l0});
t_a = mm->add_instruction(migraphx::make_op("transpose", {{"permutation", {0, 1, 3, 2}}}), t_a);
auto dot =
mm->add_instruction(migraphx::make_op("dot", {{"alpha", 1.0f}, {"beta", 0.0f}}), t_a, l1);
auto dot = migraphx::add_apply_alpha_beta(*mm, {t_a, l1}, migraphx::make_op("dot"), 1.0f, 0.0f);
auto b_l = mm->add_literal(beta);
auto b_b = mm->add_instruction(
migraphx::make_op("multibroadcast", {{"out_lens", l2->get_shape().lens()}}), b_l);
......@@ -1395,9 +1432,7 @@ TEST_CASE(gemm_ex_brcst_test)
auto a_l = mm->add_literal(alpha);
auto t_a = add_common_op(*mm, migraphx::make_op("mul"), {a_l, l0});
t_a = mm->add_instruction(migraphx::make_op("transpose", {{"permutation", {0, 1, 3, 2}}}), t_a);
auto dot =
mm->add_instruction(migraphx::make_op("dot", {{"alpha", 1.0f}, {"beta", 0.0f}}), t_a, l1);
auto dot = migraphx::add_apply_alpha_beta(*mm, {t_a, l1}, migraphx::make_op("dot"), 1.0f, 0.0f);
auto b_l = mm->add_literal(beta);
auto l2_b =
mm->add_instruction(migraphx::make_op("multibroadcast", {{"out_lens", out_lens}}), l2);
......@@ -1425,10 +1460,9 @@ TEST_CASE(gemm_half_test)
migraphx::make_op("convert", {{"target_type", migraphx::shape::half_type}}), t_a);
t_a = mm->add_instruction(migraphx::make_op("transpose", {{"permutation", {0, 1, 3, 2}}}), t_a);
std::vector<std::size_t> lens = {1, 1, 6, 7};
auto dot =
mm->add_instruction(migraphx::make_op("dot", {{"alpha", 1.0f}, {"beta", 0.0f}}), t_a, l1);
l2 = mm->add_instruction(migraphx::make_op("multibroadcast", {{"out_lens", lens}}), l2);
l2 = mm->add_instruction(
auto dot = migraphx::add_apply_alpha_beta(*mm, {t_a, l1}, migraphx::make_op("dot"), 1.0f, 0.0f);
l2 = mm->add_instruction(migraphx::make_op("multibroadcast", {{"out_lens", lens}}), l2);
l2 = mm->add_instruction(
migraphx::make_op("convert", {{"target_type", migraphx::shape::float_type}}), l2);
auto b_l = mm->add_literal(beta);
auto b_b = mm->add_instruction(migraphx::make_op("multibroadcast", {{"out_lens", lens}}), b_l);
......@@ -1857,8 +1891,7 @@ TEST_CASE(initializer_not_an_input)
std::vector<float> w = {1, 2, 3, 4, 5, 6, 7, 8};
auto l1 = mm->add_literal(migraphx::literal({migraphx::shape::float_type, {2, 4}}, w));
auto l0 = mm->add_parameter("x", migraphx::shape{migraphx::shape::float_type, {5, 2}});
mm->add_instruction(migraphx::make_op("dot", {{"alpha", 1.0f}, {"beta", 0.0f}}), l0, l1);
migraphx::add_apply_alpha_beta(*mm, {l0, l1}, migraphx::make_op("dot"), 1.0f, 0.0f);
auto prog = optimize_onnx("initializer_not_an_input.onnx");
EXPECT(p == prog);
......@@ -2159,8 +2192,7 @@ TEST_CASE(matmul_bmbm_test)
migraphx::make_op("multibroadcast", {{"out_lens", {5, 2, 3, 6, 7}}}), l0);
auto bl1 = mm->add_instruction(
migraphx::make_op("multibroadcast", {{"out_lens", {5, 2, 3, 7, 8}}}), l1);
mm->add_instruction(migraphx::make_op("dot", {{"alpha", 1.0f}, {"beta", 0.0f}}), bl0, bl1);
migraphx::add_apply_alpha_beta(*mm, {bl0, bl1}, migraphx::make_op("dot"), 1.0f, 0.0f);
auto prog = optimize_onnx("matmul_bmbm_test.onnx");
EXPECT(p == prog);
......@@ -2176,7 +2208,7 @@ TEST_CASE(matmul_bmv_test)
auto bsl1 =
mm->add_instruction(migraphx::make_op("multibroadcast", {{"out_lens", {3, 7, 1}}}), sl1);
auto res =
mm->add_instruction(migraphx::make_op("dot", {{"alpha", 1.0f}, {"beta", 0.0f}}), l0, bsl1);
migraphx::add_apply_alpha_beta(*mm, {l0, bsl1}, migraphx::make_op("dot"), 1.0f, 0.0f);
mm->add_instruction(migraphx::make_op("squeeze", {{"axes", {2}}}), res);
auto prog = optimize_onnx("matmul_bmv_test.onnx");
......@@ -2191,8 +2223,7 @@ TEST_CASE(matmul_mv_test)
auto l0 = mm->add_parameter("1", migraphx::shape{migraphx::shape::float_type, {6, 7}});
auto l1 = mm->add_parameter("2", migraphx::shape{migraphx::shape::float_type, {7}});
auto sl1 = mm->add_instruction(migraphx::make_op("unsqueeze", {{"axes", {1}}}), l1);
auto res =
mm->add_instruction(migraphx::make_op("dot", {{"alpha", 1.0f}, {"beta", 0.0f}}), l0, sl1);
auto res = migraphx::add_apply_alpha_beta(*mm, {l0, sl1}, migraphx::make_op("dot"), 1.0f, 0.0f);
mm->add_instruction(migraphx::make_op("squeeze", {{"axes", {1}}}), res);
auto prog = optimize_onnx("matmul_mv_test.onnx");
......@@ -2210,7 +2241,7 @@ TEST_CASE(matmul_vbm_test)
auto bsl0 =
mm->add_instruction(migraphx::make_op("multibroadcast", {{"out_lens", {5, 1, 7}}}), sl0);
auto res =
mm->add_instruction(migraphx::make_op("dot", {{"alpha", 1.0f}, {"beta", 0.0f}}), bsl0, l1);
migraphx::add_apply_alpha_beta(*mm, {bsl0, l1}, migraphx::make_op("dot"), 1.0f, 0.0f);
mm->add_instruction(migraphx::make_op("squeeze", {{"axes", {1}}}), res);
auto prog = optimize_onnx("matmul_vbm_test.onnx");
......@@ -2225,8 +2256,7 @@ TEST_CASE(matmul_vm_test)
auto l0 = mm->add_parameter("1", migraphx::shape{migraphx::shape::float_type, {7}});
auto l1 = mm->add_parameter("2", migraphx::shape{migraphx::shape::float_type, {7, 8}});
auto sl0 = mm->add_instruction(migraphx::make_op("unsqueeze", {{"axes", {0}}}), l0);
auto res =
mm->add_instruction(migraphx::make_op("dot", {{"alpha", 1.0f}, {"beta", 0.0f}}), sl0, l1);
auto res = migraphx::add_apply_alpha_beta(*mm, {sl0, l1}, migraphx::make_op("dot"), 1.0f, 0.0f);
mm->add_instruction(migraphx::make_op("squeeze", {{"axes", {0}}}), res);
auto prog = optimize_onnx("matmul_vm_test.onnx");
......@@ -2243,7 +2273,7 @@ TEST_CASE(matmul_vv_test)
auto sl0 = mm->add_instruction(migraphx::make_op("unsqueeze", {{"axes", {0}}}), l0);
auto sl1 = mm->add_instruction(migraphx::make_op("unsqueeze", {{"axes", {1}}}), l1);
auto res =
mm->add_instruction(migraphx::make_op("dot", {{"alpha", 1.0f}, {"beta", 0.0f}}), sl0, sl1);
migraphx::add_apply_alpha_beta(*mm, {sl0, sl1}, migraphx::make_op("dot"), 1.0f, 0.0f);
auto sr0 = mm->add_instruction(migraphx::make_op("squeeze", {{"axes", {0}}}), res);
mm->add_instruction(migraphx::make_op("squeeze", {{"axes", {0}}}), sr0);
......@@ -2258,7 +2288,7 @@ TEST_CASE(matmulinteger_test)
auto* mm = p.get_main_module();
auto l0 = mm->add_parameter("1", migraphx::shape{migraphx::shape::int8_type, {3, 6, 16}});
auto l1 = mm->add_parameter("2", migraphx::shape{migraphx::shape::int8_type, {3, 16, 8}});
mm->add_instruction(migraphx::make_op("quant_dot", {{"alpha", 1}, {"beta", 0}}), l0, l1);
mm->add_instruction(migraphx::make_op("quant_dot"), l0, l1);
auto prog = optimize_onnx("matmulinteger_test.onnx");
......@@ -2414,6 +2444,46 @@ TEST_CASE(neg_test)
EXPECT(p == prog);
}
TEST_CASE(nms_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape sb{migraphx::shape::float_type, {1, 6, 4}};
auto b = mm->add_parameter("boxes", sb);
migraphx::shape ss{migraphx::shape::float_type, {1, 1, 6}};
auto s = mm->add_parameter("scores", ss);
migraphx::shape smo{migraphx::shape::int64_type, {1}};
auto mo = mm->add_parameter("max_output_boxes_per_class", smo);
migraphx::shape siou{migraphx::shape::float_type, {1}};
auto iou = mm->add_parameter("iou_threshold", siou);
migraphx::shape sst{migraphx::shape::float_type, {1}};
auto st = mm->add_parameter("score_threshold", sst);
auto ret = mm->add_instruction(
migraphx::make_op("nonmaxsuppression", {{"center_point_box", 1}}), b, s, mo, iou, st);
mm->add_return({ret});
auto prog = migraphx::parse_onnx("nms_test.onnx");
EXPECT(p == prog);
}
TEST_CASE(nonzero_dynamic_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape s{migraphx::shape::bool_type, {2, 2}};
auto data = mm->add_parameter("data", s);
auto r = mm->add_instruction(migraphx::make_op("nonzero"), data);
mm->add_return({r});
auto prog = migraphx::parse_onnx("nonzero_dynamic_test.onnx");
EXPECT(p == prog);
}
TEST_CASE(nonzero_test)
{
migraphx::program p;
......@@ -3597,6 +3667,55 @@ TEST_CASE(resize_upsample_pf_test)
EXPECT(p == prog);
}
TEST_CASE(roialign_default_test)
{
migraphx::shape sx{migraphx::shape::float_type, {10, 4, 7, 8}};
migraphx::shape srois{migraphx::shape::float_type, {8, 4}};
migraphx::shape sbi{migraphx::shape::int64_type, {8}};
migraphx::program p;
auto* mm = p.get_main_module();
auto x = mm->add_parameter("x", sx);
auto rois = mm->add_parameter("rois", srois);
auto bi = mm->add_parameter("batch_ind", sbi);
auto r = mm->add_instruction(migraphx::make_op("roialign"), x, rois, bi);
mm->add_return({r});
auto prog = migraphx::parse_onnx("roialign_default_test.onnx");
EXPECT(p == prog);
}
TEST_CASE(roialign_test)
{
migraphx::shape sx{migraphx::shape::float_type, {10, 5, 4, 7}};
migraphx::shape srois{migraphx::shape::float_type, {8, 4}};
migraphx::shape sbi{migraphx::shape::int64_type, {8}};
migraphx::program p;
auto* mm = p.get_main_module();
auto x = mm->add_parameter("x", sx);
auto rois = mm->add_parameter("rois", srois);
auto bi = mm->add_parameter("batch_ind", sbi);
auto r = mm->add_instruction(
migraphx::make_op("roialign",
{{"coordinate_transformation_mode", "output_half_pixel"},
{"spatial_scale", 2.0f},
{"output_height", 5},
{"output_width", 5},
{"sampling_ratio", 3}}),
x,
rois,
bi);
mm->add_return({r});
auto prog = migraphx::parse_onnx("roialign_test.onnx");
EXPECT(p == prog);
}
TEST_CASE(round_test)
{
migraphx::program p;
......
roialign_default_test:
!
x
rois
batch_indy"RoiAlignroialign_default_testZ
x




Z
rois


Z
batch_ind

b
y




B
\ No newline at end of file
#spacetodepth_invalid_blocksize_test:
)
xy" SpaceToDepth*
blocksize>#spacetodepth_invalid_blocksize_testZ
x




b
y




B
\ No newline at end of file
!spacetodepth_nondivisibility_test:
&
xy" SpaceToDepth*
blocksize!spacetodepth_nondivisibility_testZ
x




b
y




B
\ No newline at end of file
spacetodepth_simple_test:|
&
xy" SpaceToDepth*
blocksizespacetodepth_simple_testZ
x




b
y




B
\ No newline at end of file
spacetodepth_test:u
&
xy" SpaceToDepth*
blocksizespacetodepth_testZ
x





b
y




B
\ No newline at end of file
......@@ -63,6 +63,46 @@ TEST_CASE(depthtospace_simple_test)
EXPECT(migraphx::verify_range(result_vector, gold));
}
TEST_CASE(spacetodepth_simple_test)
{
auto p = migraphx::parse_onnx("spacetodepth_simple_test.onnx");
p.compile(migraphx::ref::target{});
std::vector<float> data_in(48);
std::iota(std::begin(data_in), std::end(data_in), 0);
migraphx::shape s_x{migraphx::shape::float_type, {1, 2, 4, 6}};
migraphx::parameter_map pp;
pp["x"] = migraphx::argument(s_x, data_in.data());
auto result = p.eval(pp).back();
std::vector<float> result_vector;
result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); });
std::vector<float> gold = {0, 2, 4, 12, 14, 16, 24, 26, 28, 36, 38, 40, 1, 3, 5, 13,
15, 17, 25, 27, 29, 37, 39, 41, 6, 8, 10, 18, 20, 22, 30, 32,
34, 42, 44, 46, 7, 9, 11, 19, 21, 23, 31, 33, 35, 43, 45, 47};
EXPECT(migraphx::verify_range(result_vector, gold));
}
TEST_CASE(spacetodepth_depthtospace_test)
{
// space to depth
auto p1 = migraphx::parse_onnx("spacetodepth_simple_test.onnx");
p1.compile(migraphx::ref::target{});
std::vector<float> data_in(48);
std::iota(std::begin(data_in), std::end(data_in), 0);
migraphx::shape s_x_1{migraphx::shape::float_type, {1, 2, 4, 6}};
migraphx::parameter_map pp1;
pp1["x"] = migraphx::argument(s_x_1, data_in.data());
auto result1 = p1.eval(pp1).back();
// depth to space
auto p2 = migraphx::parse_onnx("depthtospace_simple_test.onnx");
p2.compile(migraphx::ref::target{});
migraphx::parameter_map pp2;
pp2["x"] = result1;
auto result2 = p2.eval(pp2).back();
std::vector<float> result_vector2;
result2.visit([&](auto output) { result_vector2.assign(output.begin(), output.end()); });
EXPECT(migraphx::verify_range(result_vector2, data_in));
}
TEST_CASE(gather_elements)
{
migraphx::program p = migraphx::parse_onnx("gather_elements_axis0_test.onnx");
......@@ -308,6 +348,25 @@ TEST_CASE(lessorequal_test)
EXPECT(migraphx::verify_range(result_vector, gold));
}
TEST_CASE(nonzero_test)
{
migraphx::program p = migraphx::parse_onnx("nonzero_dynamic_test.onnx");
p.compile(migraphx::ref::target{});
migraphx::shape s{migraphx::shape::bool_type, {2, 2}};
std::vector<char> data = {1, 1, 1, 0};
migraphx::parameter_map pp;
pp["data"] = migraphx::argument(s, data.data());
auto result = p.eval(pp).back();
std::vector<float> result_vector;
result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); });
std::vector<float> gold = {0, 0, 1, 0, 0, 1, 0, 0};
EXPECT(migraphx::verify_range(result_vector, gold));
}
TEST_CASE(resize_downsample_f_test)
{
migraphx::program p = migraphx::parse_onnx("resize_downsample_f_test.onnx");
......
......@@ -312,87 +312,38 @@ TEST_CASE(gemm)
{
{
migraphx::shape s_m1{migraphx::shape::float_type, {4, 5}};
migraphx::shape s_m2{migraphx::shape::float_type, {5, 8}};
migraphx::shape s_m3{migraphx::shape::float_type, {1}};
throws_shape(migraphx::make_op("dot"), s_m1, s_m2, s_m3);
}
{
migraphx::shape s_m1{migraphx::shape::float_type, {4, 5}};
migraphx::shape s_m2{migraphx::shape::float_type, {5, 8}};
migraphx::shape s_m3{migraphx::shape::float_type, {1, 1}};
throws_shape(migraphx::make_op("dot"), s_m1, s_m2, s_m3);
}
{
migraphx::shape s_m1{migraphx::shape::float_type, {4, 5}};
migraphx::shape s_m2{migraphx::shape::float_type, {5, 8}};
migraphx::shape s_m3{migraphx::shape::float_type, {8}};
throws_shape(migraphx::make_op("dot"), s_m1, s_m2, s_m3);
}
{
migraphx::shape s_m1{migraphx::shape::float_type, {4, 5}};
migraphx::shape s_m2{migraphx::shape::float_type, {5, 8}};
migraphx::shape s_m3{migraphx::shape::float_type, {4, 1}};
throws_shape(migraphx::make_op("dot"), s_m1, s_m2, s_m3);
migraphx::shape s_m2{migraphx::shape::float_type, {10, 8}};
throws_shape(migraphx::make_op("dot"), s_m1, s_m2);
}
{
migraphx::shape s_m1{migraphx::shape::float_type, {4, 6}};
migraphx::shape s_m2{migraphx::shape::float_type, {5, 8}};
migraphx::shape s_m3{migraphx::shape::float_type, {4, 8}};
throws_shape(migraphx::make_op("dot"), s_m1, s_m2, s_m3);
}
{
migraphx::shape s_m1{migraphx::shape::float_type, {4, 5}};
migraphx::shape s_m2{migraphx::shape::float_type, {5, 8}};
migraphx::shape s_m3{migraphx::shape::float_type, {4}};
throws_shape(migraphx::make_op("dot"), s_m1, s_m2, s_m3);
throws_shape(migraphx::make_op("dot"), s_m1, s_m2);
}
{
migraphx::shape s_m1{migraphx::shape::float_type, {4, 5}};
migraphx::shape s_m2{migraphx::shape::float_type, {5, 8}};
migraphx::shape s_m3{migraphx::shape::float_type, {4, 8}};
expect_shape(migraphx::shape{migraphx::shape::float_type, {4, 8}},
migraphx::make_op("dot"),
s_m1,
s_m2,
s_m3);
s_m2);
}
{
migraphx::shape s_m1{migraphx::shape::float_type, {1, 4, 5}};
migraphx::shape s_m2{migraphx::shape::float_type, {1, 5, 8}};
migraphx::shape s_m3{migraphx::shape::float_type, {1, 4, 8}};
expect_shape(migraphx::shape{migraphx::shape::float_type, {1, 4, 8}},
migraphx::make_op("dot"),
s_m1,
s_m2,
s_m3);
s_m2);
}
{
migraphx::shape s_m1{migraphx::shape::float_type, {1, 4, 6}};
migraphx::shape s_m2{migraphx::shape::float_type, {1, 5, 8}};
migraphx::shape s_m3{migraphx::shape::float_type, {1, 4, 8}};
throws_shape(migraphx::make_op("dot"), s_m1, s_m2, s_m3);
}
{
migraphx::shape s_m1{migraphx::shape::float_type, {1, 4, 5}};
migraphx::shape s_m2{migraphx::shape::float_type, {1, 5, 8}};
migraphx::shape s_m3{migraphx::shape::float_type, {4, 8}};
throws_shape(migraphx::make_op("dot"), s_m1, s_m2, s_m3);
}
{
migraphx::shape s_m1{migraphx::shape::float_type, {1, 4, 5}};
migraphx::shape s_m2{migraphx::shape::float_type, {1, 5, 8}};
migraphx::shape s_m3{migraphx::shape::float_type};
throws_shape(migraphx::make_op("dot"), s_m1, s_m2, s_m3);
migraphx::shape s_m2{migraphx::shape::float_type, {2, 5, 8}};
throws_shape(migraphx::make_op("dot"), s_m1, s_m2);
}
}
......@@ -1115,7 +1066,7 @@ TEST_CASE(quant_dot_2args)
migraphx::shape s_m1{migraphx::shape::int8_type, {3, 8}};
migraphx::shape s_m2{migraphx::shape::int8_type, {8, 7}};
expect_shape(migraphx::shape{migraphx::shape::int32_type, {3, 7}},
migraphx::make_op("quant_dot", {{"alpha", 1}, {"beta", 0}}),
migraphx::make_op("quant_dot"),
s_m1,
s_m2);
}
......@@ -1127,27 +1078,6 @@ TEST_CASE(quant_dot_2args)
}
}
TEST_CASE(quant_dot_3args)
{
{
migraphx::shape s_m1{migraphx::shape::int8_type, {2, 4}};
migraphx::shape s_m2{migraphx::shape::int8_type, {4, 8}};
migraphx::shape s_m3{migraphx::shape::int32_type, {2, 8}};
expect_shape(migraphx::shape{migraphx::shape::int32_type, {2, 8}},
migraphx::make_op("quant_dot"),
s_m1,
s_m2,
s_m3);
}
{
migraphx::shape s_m1{migraphx::shape::int8_type, {2, 4}};
migraphx::shape s_m2{migraphx::shape::int8_type, {4, 8}};
migraphx::shape s_m3{migraphx::shape::int8_type, {2, 8}};
throws_shape(migraphx::make_op("quant_dot", {{"alpha", 1}, {"beta", 2}}), s_m1, s_m2, s_m3);
}
}
template <class T>
void test_reduce_ops()
{
......@@ -1614,4 +1544,26 @@ TEST_CASE(where_broadcast_input)
expect_shape(s2, migraphx::make_op("where"), s3, s1, s2);
}
TEST_CASE(roialign_test)
{
migraphx::shape sx{migraphx::shape::float_type, {3, 4, 5, 6}};
migraphx::shape srois{migraphx::shape::float_type, {2, 4}};
migraphx::shape sbi{migraphx::shape::int64_type, {2}};
migraphx::shape sout{migraphx::shape::float_type, {2, 4, 1, 1}};
expect_shape(sout, migraphx::make_op("roialign"), sx, srois, sbi);
migraphx::shape sbi1{migraphx::shape::int64_type, {2, 3}};
throws_shape(migraphx::make_op("roialign"), sx, srois, sbi1);
migraphx::shape sbi2{migraphx::shape::int64_type, {3}};
throws_shape(migraphx::make_op("roialign"), sx, srois, sbi2);
migraphx::shape srois1{migraphx::shape::float_type, {2, 4, 3}};
throws_shape(migraphx::make_op("roialign"), sx, srois1, sbi);
migraphx::shape srois2{migraphx::shape::float_type, {2, 3}};
throws_shape(migraphx::make_op("roialign"), sx, srois2, sbi);
}
int main(int argc, const char* argv[]) { test::run(argc, argv); }
......@@ -19,6 +19,7 @@ TEST_CASE(perf_report)
std::string output = ss.str();
EXPECT(migraphx::contains(output, "Summary:"));
EXPECT(migraphx::contains(output, "Batch size:"));
EXPECT(migraphx::contains(output, "Rate:"));
EXPECT(migraphx::contains(output, "Total time:"));
EXPECT(migraphx::contains(output, "Total instructions time:"));
......
......@@ -4,6 +4,7 @@
#include <migraphx/instruction.hpp>
#include <migraphx/ref/target.hpp>
#include <sstream>
#include <migraphx/apply_alpha_beta.hpp>
#include "test.hpp"
#include <migraphx/make_op.hpp>
......@@ -160,9 +161,8 @@ TEST_CASE(program_copy)
auto para1 = mm1->add_parameter("m1", s1);
auto para2 = mm1->add_parameter("m2", s2);
auto para3 = mm1->add_parameter("m3", s3);
mm1->add_instruction(
migraphx::make_op("dot", {{"alpha", 0.31f}, {"beta", 0.28f}}), para1, para2, para3);
migraphx::add_apply_alpha_beta(
*mm1, {para1, para2, para3}, migraphx::make_op("dot"), 0.31f, 0.28f);
migraphx::program p2{};
p2 = p1;
EXPECT(p2 == p1);
......
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