Commit 93c89587 authored by Paul's avatar Paul
Browse files

Split onnx tests

parent d2532d0e
#include <onnx_test.hpp>
TEST_CASE(elu_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
auto input = mm->add_parameter("0", migraphx::shape{migraphx::shape::float_type, {3}});
mm->add_instruction(migraphx::make_op("elu", {{"alpha", 0.01}}), input);
auto prog = optimize_onnx("elu_test.onnx");
EXPECT(p == prog);
}
#include <onnx_test.hpp>
TEST_CASE(embedding_bag_offset_test)
{
EXPECT(test::throws([&] { migraphx::parse_onnx("embedding_bag_offset_test.onnx"); }));
}
#include <onnx_test.hpp>
TEST_CASE(embedding_bag_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
auto l0 = mm->add_parameter("weight", migraphx::shape{migraphx::shape::float_type, {4, 2}});
migraphx::literal l{migraphx::shape{migraphx::shape::int32_type, {3}}, {1, 0, 2}};
auto l1 = mm->add_literal(l);
mm->add_literal(0);
auto l4 = mm->add_instruction(migraphx::make_op("gather"), l0, l1);
auto r1 = mm->add_instruction(migraphx::make_op("reduce_sum", {{"axes", {0}}}), l4);
auto l5 = mm->add_instruction(migraphx::make_op("gather"), l0, l1);
auto r2 = mm->add_instruction(migraphx::make_op("reduce_mean", {{"axes", {0}}}), l5);
auto l6 = mm->add_instruction(migraphx::make_op("gather"), l0, l1);
auto r3 = mm->add_instruction(migraphx::make_op("reduce_max", {{"axes", {0}}}), l6);
mm->add_return({r1, r2, r3});
auto prog = migraphx::parse_onnx("embedding_bag_test.onnx");
EXPECT(p == prog);
}
#include <onnx_test.hpp>
TEST_CASE(equal_bool_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape sf{migraphx::shape::float_type, {2, 3}};
migraphx::shape sb{migraphx::shape::bool_type, {2, 3}};
auto input1 = mm->add_parameter("x1", sf);
auto input2 = mm->add_parameter("x2", sb);
auto cin1 = mm->add_instruction(
migraphx::make_op("convert",
{{"target_type", migraphx::to_value(migraphx::shape::bool_type)}}),
input1);
auto ret = mm->add_instruction(migraphx::make_op("equal"), cin1, input2);
mm->add_return({ret});
auto prog = migraphx::parse_onnx("equal_bool_test.onnx");
EXPECT(p == prog);
}
#include <onnx_test.hpp>
TEST_CASE(equal_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape s{migraphx::shape::float_type, {2, 3}};
std::vector<float> data = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
auto input1 = mm->add_literal(migraphx::literal(s, data));
auto input2 = mm->add_parameter("x2", migraphx::shape{migraphx::shape::float_type, {2, 3}});
auto eq = mm->add_instruction(migraphx::make_op("equal"), input1, input2);
auto ret = mm->add_instruction(
migraphx::make_op("convert",
{{"target_type", migraphx::to_value(migraphx::shape::bool_type)}}),
eq);
mm->add_return({ret});
auto prog = migraphx::parse_onnx("equal_test.onnx");
EXPECT(p == prog);
}
#include <onnx_test.hpp>
TEST_CASE(erf_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
auto input = mm->add_parameter("x", migraphx::shape{migraphx::shape::float_type, {10, 15}});
mm->add_instruction(migraphx::make_op("erf"), input);
auto prog = optimize_onnx("erf_test.onnx");
EXPECT(p == prog);
}
#include <onnx_test.hpp>
TEST_CASE(exp_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
auto input = mm->add_parameter("x", migraphx::shape{migraphx::shape::float_type, {10}});
mm->add_instruction(migraphx::make_op("exp"), input);
auto prog = optimize_onnx("exp_test.onnx");
EXPECT(p == prog);
}
#include <onnx_test.hpp>
TEST_CASE(expand_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape s(migraphx::shape::float_type, {3, 1, 1});
auto param = mm->add_parameter("x", s);
migraphx::shape ss(migraphx::shape::int32_type, {4});
mm->add_literal(migraphx::literal(ss, {2, 3, 4, 5}));
mm->add_instruction(migraphx::make_op("multibroadcast", {{"out_lens", {2, 3, 4, 5}}}), param);
auto prog = optimize_onnx("expand_test.onnx");
EXPECT(p == prog);
}
#include <onnx_test.hpp>
#include <onnx_test_utils.hpp>
TEST_CASE(external_data_diff_path_test)
{
migraphx::program p = create_external_data_prog();
auto prog = optimize_onnx("ext_path/external_data_test.onnx");
EXPECT(p == prog);
}
#include <onnx_test.hpp>
TEST_CASE(external_constant_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
mm->add_literal(migraphx::literal{{migraphx::shape::int64_type, {3}}, {0, 1, 2}});
auto prog = optimize_onnx("external_constant_test.onnx");
EXPECT(p == prog);
}
#include <onnx_test.hpp>
#include <onnx_test_utils.hpp>
TEST_CASE(external_data_test)
{
migraphx::program p = create_external_data_prog();
auto prog = optimize_onnx("external_data_test.onnx");
EXPECT(p == prog);
}
#include <onnx_test.hpp>
#include <onnx_test_utils.hpp>
TEST_CASE(eyelike_default_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
std::vector<std::size_t> input_lens{3, 4};
const size_t k = 0;
auto num_rows = input_lens.front();
auto num_cols = input_lens.back();
auto input_type = migraphx::shape::float_type;
auto output_type = migraphx::shape::float_type;
migraphx::shape s{input_type, input_lens};
mm->add_parameter("T1", s);
auto eyelike_mat = make_r_eyelike(num_rows, num_cols, k);
mm->add_literal(migraphx::literal{migraphx::shape{output_type, input_lens}, eyelike_mat});
auto prog = optimize_onnx("eyelike_default_test.onnx");
EXPECT(p == prog);
}
#include <onnx_test.hpp>
#include <onnx_test_utils.hpp>
TEST_CASE(eyelike_double_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
std::vector<std::size_t> input_lens{6, 15};
const size_t k = 0;
auto num_rows = input_lens.front();
auto num_cols = input_lens.back();
auto input_type = migraphx::shape::double_type;
auto output_type = migraphx::shape::double_type;
migraphx::shape s{input_type, input_lens};
mm->add_parameter("T1", s);
auto eyelike_mat = make_r_eyelike(num_rows, num_cols, k);
mm->add_literal(migraphx::literal{migraphx::shape{output_type, input_lens}, eyelike_mat});
auto prog = optimize_onnx("eyelike_double_test.onnx");
EXPECT(p == prog);
}
#include <onnx_test.hpp>
#include <onnx_test_utils.hpp>
TEST_CASE(eyelike_half_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
std::vector<std::size_t> input_lens{8, 8};
const size_t k = 0;
auto num_rows = input_lens.front();
auto num_cols = input_lens.back();
auto input_type = migraphx::shape::half_type;
auto output_type = migraphx::shape::half_type;
migraphx::shape s{input_type, input_lens};
mm->add_parameter("T1", s);
auto eyelike_mat = make_r_eyelike(num_rows, num_cols, k);
mm->add_literal(migraphx::literal{migraphx::shape{output_type, input_lens}, eyelike_mat});
auto prog = optimize_onnx("eyelike_half_test.onnx");
EXPECT(p == prog);
}
#include <onnx_test.hpp>
TEST_CASE(eyelike_k_outofbounds_neg_test)
{
EXPECT(test::throws([&] { migraphx::parse_onnx("eyelike_k_outofbounds_neg_test.onnx"); }));
}
#include <onnx_test.hpp>
TEST_CASE(eyelike_k_outofbounds_pos_test)
{
EXPECT(test::throws([&] { migraphx::parse_onnx("eyelike_k_outofbounds_pos_test.onnx"); }));
}
#include <onnx_test.hpp>
#include <onnx_test_utils.hpp>
TEST_CASE(eyelike_k_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
std::vector<std::size_t> input_lens{3, 4};
const size_t k = 1;
auto num_rows = input_lens.front();
auto num_cols = input_lens.back();
auto input_type = migraphx::shape::float_type;
auto output_type = migraphx::shape::float_type;
migraphx::shape s{input_type, input_lens};
mm->add_parameter("T1", s);
auto eyelike_mat = make_r_eyelike(num_rows, num_cols, k);
mm->add_literal(migraphx::literal{migraphx::shape{output_type, input_lens}, eyelike_mat});
auto prog = optimize_onnx("eyelike_k_test.onnx");
EXPECT(p == prog);
}
#include <onnx_test.hpp>
TEST_CASE(eyelike_not_rank2_test)
{
EXPECT(test::throws([&] { migraphx::parse_onnx("eyelike_not_rank2_test.onnx"); }));
}
#include <onnx_test.hpp>
#include <onnx_test_utils.hpp>
TEST_CASE(eyelike_set_dtype_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
std::vector<std::size_t> input_lens{3, 4};
const size_t k = 0;
auto num_rows = input_lens.front();
auto num_cols = input_lens.back();
auto input_type = migraphx::shape::float_type;
auto output_type = migraphx::shape::double_type;
migraphx::shape s{input_type, input_lens};
mm->add_parameter("T1", s);
auto eyelike_mat = make_r_eyelike(num_rows, num_cols, k);
mm->add_literal(migraphx::literal{migraphx::shape{output_type, input_lens}, eyelike_mat});
auto prog = optimize_onnx("eyelike_set_dtype_test.onnx");
EXPECT(p == prog);
}
#include <onnx_test.hpp>
TEST_CASE(flatten_dyn_test)
{
migraphx::program p;
auto* mm = p.get_main_module();
auto l0 = mm->add_parameter(
"0", migraphx::shape{migraphx::shape::float_type, {{1, 4}, {3, 3}, {4, 4}, {5, 5}}});
auto c0 = mm->add_instruction(migraphx::make_op("contiguous"), l0);
auto ret = mm->add_instruction(migraphx::make_op("flatten", {{"axis", 2}}), c0);
mm->add_return({ret});
migraphx::onnx_options options;
options.default_dyn_dim_value = {1, 4};
auto prog = parse_onnx("flatten_dyn_test.onnx", options);
EXPECT(p == prog);
}
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