Commit 7e297b13 authored by Paul's avatar Paul
Browse files

Merge

parents 86ea5e91 aa7ff911
softplus_nd_test:V

xy"Softplussoftplus_nd_testZ
x




b
y




B
\ No newline at end of file
 softplus_test:C

xy"Softplus softplus_testZ
x

b
y

B
\ No newline at end of file
softsign_nd_test:V

xy"Softsignsoftsign_nd_testZ
x




b
y




B
\ No newline at end of file
 softsign_test:C

xy"Softsign softsign_testZ
x

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
thresholdedrelu_default_test:i

xy"ThresholdedReluthresholdedrelu_default_testZ
x



b
y



B
\ No newline at end of file
topk_attrk_test:
$
datavalindices"TopK*
ktopk_attrk_testZ
data




b
val




b!
indices




B
\ No newline at end of file
transpose_default_perm_test:j

01" Transposetranspose_default_perm_testZ
0




b
1




B
\ No newline at end of file
......@@ -45,6 +45,138 @@ TEST_CASE(averagepool_nt_cip_test)
EXPECT(migraphx::verify_range(result_vector, gold));
}
TEST_CASE(celu_verify_test)
{
migraphx::program p = migraphx::parse_onnx("celu_verify_test.onnx");
p.compile(migraphx::ref::target{});
migraphx::shape s{migraphx::shape::float_type, {2, 3}};
std::vector<float> data = {-5.5, 2.0, 100., 7.0, 0., -1.};
migraphx::parameter_map pp;
pp["x"] = 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> correct(6);
float alpha = 0.5;
std::transform(data.begin(), data.end(), correct.begin(), [&](auto x) {
return std::max(0.0f, x) + std::min(0.0f, alpha * std::expm1(x / alpha));
});
EXPECT(migraphx::verify_range(result_vector, correct));
}
TEST_CASE(clip_args_type_mismatch)
{
auto p = migraphx::parse_onnx("clip_test_args_type_mismatch.onnx");
p.compile(migraphx::ref::target{});
migraphx::shape s_0{migraphx::shape::float_type, {3, 3}};
migraphx::parameter_map pp;
std::vector<float> data_0 = {0.9, 1.2, 1.7, 1.9, 2.2, 2.7, 2.9, 3.2, 3.7};
pp["0"] = migraphx::argument(s_0, data_0.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 = {1.5, 2, 2, 1.9, 2.5, 3, 2.9, 3.2, 3.7};
EXPECT(migraphx::verify_range(result_vector, gold));
}
TEST_CASE(depthtospace_simple_test)
{
auto p = migraphx::parse_onnx("depthtospace_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, 8, 2, 3}};
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, 12, 1, 13, 2, 14, 24, 36, 25, 37, 26, 38, 3, 15, 4, 16,
5, 17, 27, 39, 28, 40, 29, 41, 6, 18, 7, 19, 8, 20, 30, 42,
31, 43, 32, 44, 9, 21, 10, 22, 11, 23, 33, 45, 34, 46, 35, 47};
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(eyelike_verify_test)
{
migraphx::program p = migraphx::parse_onnx("eyelike_verify_test.onnx");
p.compile(migraphx::ref::target{});
migraphx::shape s{migraphx::shape::float_type, {3, 4}};
std::vector<float> data{12, 0};
migraphx::parameter_map pp;
pp["T1"] = 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> eyelike_mat = {0., 1., 0., 0., 0., 0., 1., 0., 0., 0., 0., 1.};
EXPECT(migraphx::verify_range(result_vector, eyelike_mat));
}
TEST_CASE(eyelike_verify_negk_test)
{
migraphx::program p = migraphx::parse_onnx("eyelike_verify_negk_test.onnx");
p.compile(migraphx::ref::target{});
migraphx::shape s{migraphx::shape::float_type, {3, 4}};
std::vector<float> data{12, 0};
migraphx::parameter_map pp;
pp["T1"] = 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> eyelike_mat = {0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0.};
EXPECT(migraphx::verify_range(result_vector, eyelike_mat));
}
TEST_CASE(gather_elements)
{
migraphx::program p = migraphx::parse_onnx("gather_elements_axis0_test.onnx");
......@@ -68,6 +200,51 @@ TEST_CASE(gather_elements)
EXPECT(migraphx::verify_range(result_vector, gold));
}
TEST_CASE(greaterorequal_test)
{
migraphx::program p = migraphx::parse_onnx("greaterorequal_test.onnx");
p.compile(migraphx::ref::target{});
migraphx::shape s{migraphx::shape::float_type, {3}};
std::vector<float> data1 = {0.25, 0.75, 0.9375};
std::vector<float> data2 = {0.25, 0.74, 0.9411};
migraphx::parameter_map pp;
pp["x1"] = migraphx::argument(s, data1.data());
pp["x2"] = migraphx::argument(s, data2.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 = {1.0, 1.0, 0.0};
EXPECT(migraphx::verify_range(result_vector, gold));
}
TEST_CASE(hardsigmoid_verify_test)
{
migraphx::program p = migraphx::parse_onnx("hardsigmoid_verify_test.onnx");
p.compile(migraphx::ref::target{});
migraphx::shape s{migraphx::shape::float_type, {2, 5}};
std::vector<float> data = {-10.0, -2.5, -1.0, -0.5, 0, 1.0, 2.0, 2.5, 2.6, 100.0};
float alpha = 0.2;
float beta = 0.5;
migraphx::parameter_map pp;
pp["x"] = 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(10);
std::transform(data.begin(), data.end(), gold.begin(), [&](auto x) {
return std::max(0.0f, std::min(x * alpha + beta, 1.0f));
});
EXPECT(migraphx::verify_range(result_vector, gold));
}
TEST_CASE(if_else_test)
{
migraphx::program p = migraphx::parse_onnx("if_else_test.onnx");
......@@ -290,6 +467,166 @@ TEST_CASE(lessorequal_test)
EXPECT(migraphx::verify_range(result_vector, gold));
}
TEST_CASE(lpnormalization_1norm)
{
migraphx::program p = migraphx::parse_onnx("lpnormalization_l1_test.onnx");
p.compile(migraphx::ref::target{});
migraphx::shape s{migraphx::shape::float_type, {3, 4}};
std::vector<float> data{0.f, 2.f, -2.f, 1.f, 1.f, -5.f, 3.f, -1.f, -4.f, 3.f, 0.f, 0.f};
migraphx::parameter_map pp;
pp["x"] = 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.f,
2.f / 5.f,
-2.f / 5.f,
1.f / 5.f,
1.f / 10.f,
-5.f / 10.f,
3.f / 10.f,
-1.f / 10.f,
-4.f / 7.f,
3.f / 7.f,
0.f,
0.f};
EXPECT(migraphx::verify_range(result_vector, gold));
}
TEST_CASE(lpnormalization_2norm)
{
migraphx::program p = migraphx::parse_onnx("lpnormalization_l2_test.onnx");
p.compile(migraphx::ref::target{});
migraphx::shape s{migraphx::shape::float_type, {3, 4}};
std::vector<float> data{0.f, 2.f, -2.f, 1.f, 1.f, -5.f, 3.f, -1.f, -4.f, 3.f, 0.f, 0.f};
migraphx::parameter_map pp;
pp["x"] = 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> correct{0.f,
2.f / 3.f,
-2.f / 3.f,
1.f / 3.f,
1.f / 6.f,
-5.f / 6.f,
3.f / 6.f,
-1.f / 6.f,
-4.f / 5.f,
3.f / 5.f,
0.f,
0.f};
EXPECT(migraphx::verify_range(result_vector, correct));
}
TEST_CASE(mean_broadcast_test)
{
migraphx::program p = migraphx::parse_onnx("mean_broadcast_test.onnx");
p.compile(migraphx::ref::target{});
migraphx::shape s0{migraphx::shape::float_type, {1, 3, 4}};
std::vector<float> data0(12, 1);
migraphx::shape s1{migraphx::shape::float_type, {1, 2, 3, 4}};
std::vector<float> data1(24, 2);
migraphx::shape s2{migraphx::shape::float_type, {4}};
std::vector<float> data2(4, 3);
migraphx::shape s3{migraphx::shape::float_type, {1}};
std::vector<float> data3(1, 4);
migraphx::shape s4{migraphx::shape::float_type, {2, 3, 1}};
std::vector<float> data4(6, 5);
migraphx::parameter_map pp;
pp["0"] = migraphx::argument(s0, data0.data());
pp["1"] = migraphx::argument(s1, data1.data());
pp["2"] = migraphx::argument(s2, data2.data());
pp["3"] = migraphx::argument(s3, data3.data());
pp["4"] = migraphx::argument(s4, data4.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(24, 3);
EXPECT(migraphx::verify_range(result_vector, gold));
}
TEST_CASE(mean_test)
{
migraphx::program p = migraphx::parse_onnx("mean_test.onnx");
p.compile(migraphx::ref::target{});
migraphx::shape s{migraphx::shape::double_type, {2, 2, 2}};
const int num_elms = 8;
const int num_data = 10;
const std::vector<double> scalars{1.0, 2.0, -2.5, 3.3, 10.7, -1.0, 100.0, 7.9, 0.01, -56.8};
std::vector<std::vector<double>> data;
std::transform(scalars.begin(), scalars.end(), std::back_inserter(data), [&](const auto& i) {
return std::vector<double>(num_elms, i);
});
migraphx::parameter_map pp;
for(std::size_t i = 0; i < num_data; ++i)
pp[std::to_string(i)] = migraphx::argument(s, data[i].data());
auto result = p.eval(pp).back();
std::vector<double> result_vector;
result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); });
const auto mean = std::accumulate(scalars.begin(), scalars.end(), 0.0) / num_data;
std::vector<double> gold(num_elms, mean);
EXPECT(migraphx::verify_range(result_vector, gold));
}
TEST_CASE(mean_integral_test)
{
migraphx::program p = migraphx::parse_onnx("mean_integral_test.onnx");
p.compile(migraphx::ref::target{});
migraphx::shape s{migraphx::shape::int32_type, {2, 2, 2}};
const int num_elms = 8;
const int num_data = 10;
const std::vector<int> scalars{1, 5, 14, 2, 6, 21, 101, 0, -4, -11};
std::vector<std::vector<int>> data;
std::transform(scalars.begin(), scalars.end(), std::back_inserter(data), [&](const auto i) {
return std::vector<int>(num_elms, i);
});
migraphx::parameter_map pp;
for(std::size_t i = 0; i < num_data; ++i)
pp[std::to_string(i)] = migraphx::argument(s, data[i].data());
auto result = p.eval(pp).back();
std::vector<double> result_vector;
result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); });
const auto mean = std::accumulate(scalars.begin(), scalars.end(), 0) / num_data;
std::vector<int> gold(num_elms, mean);
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");
......@@ -388,6 +725,69 @@ TEST_CASE(resize_upsample_pf_test)
EXPECT(migraphx::verify_range(result_vector, gold));
}
TEST_CASE(reversesequence_4D_verify_test)
{
migraphx::program p = migraphx::parse_onnx("reversesequence_4D_test.onnx");
p.compile(migraphx::ref::target{});
migraphx::shape xs{migraphx::shape::float_type, {2, 2, 2, 2}};
std::vector<float> x_data = {
0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0};
migraphx::parameter_map param_map;
param_map["x"] = migraphx::argument(xs, x_data.data());
auto result = p.eval(param_map).back();
std::vector<float> result_vector;
result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); });
std::vector<float> gold = {
8.0, 9.0, 10.0, 11.0, 4.0, 5.0, 6.0, 7.0, 0.0, 1.0, 2.0, 3.0, 12.0, 13.0, 14.0, 15.0};
EXPECT(migraphx::verify_range(result_vector, gold));
}
TEST_CASE(reversesequence_batch_verify_test)
{
migraphx::program p = migraphx::parse_onnx("reversesequence_batch_test.onnx");
p.compile(migraphx::ref::target{});
migraphx::shape xs{migraphx::shape::float_type, {4, 4}};
std::vector<float> x_data = {
0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0};
migraphx::parameter_map param_map;
param_map["x"] = migraphx::argument(xs, x_data.data());
auto result = p.eval(param_map).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, 2.0, 3.0, 5.0, 4.0, 6.0, 7.0, 10.0, 9.0, 8.0, 11.0, 15.0, 14.0, 13.0, 12.0};
EXPECT(migraphx::verify_range(result_vector, gold));
}
TEST_CASE(reversesequence_time_verify_test)
{
migraphx::program p = migraphx::parse_onnx("reversesequence_time_test.onnx");
p.compile(migraphx::ref::target{});
migraphx::shape xs{migraphx::shape::float_type, {4, 4}};
std::vector<float> x_data = {
0.0, 4.0, 8.0, 12.0, 1.0, 5.0, 9.0, 13.0, 2.0, 6.0, 10.0, 14.0, 3.0, 7.0, 11.0, 15.0};
migraphx::parameter_map param_map;
param_map["x"] = migraphx::argument(xs, x_data.data());
auto result = p.eval(param_map).back();
std::vector<float> result_vector;
result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); });
std::vector<float> gold = {
3.0, 6.0, 9.0, 12.0, 2.0, 5.0, 8.0, 13.0, 1.0, 4.0, 10.0, 14.0, 0.0, 7.0, 11.0, 15.0};
EXPECT(migraphx::verify_range(result_vector, gold));
}
TEST_CASE(selu_test)
{
migraphx::program p = migraphx::parse_onnx("selu_test.onnx");
......@@ -408,6 +808,21 @@ TEST_CASE(selu_test)
EXPECT(migraphx::verify_range(result_vector, gold));
}
TEST_CASE(size_verify_test)
{
migraphx::program p = migraphx::parse_onnx("size_verify_test.onnx");
p.compile(migraphx::ref::target{});
migraphx::shape s{migraphx::shape::float_type, {2, 5, 3}};
std::vector<float> data(30, 1.);
migraphx::parameter_map pp;
pp["x"] = migraphx::argument(s, data.data());
auto result = p.eval(pp).back();
auto size_result = result.at<int64_t>();
EXPECT(size_result == int64_t{30});
}
TEST_CASE(slice_test)
{
migraphx::program p = migraphx::parse_onnx("slice_test.onnx");
......@@ -487,6 +902,48 @@ TEST_CASE(slice_step_test)
EXPECT(migraphx::verify_range(result_vector, gold));
}
TEST_CASE(softplus_test)
{
migraphx::program p = migraphx::parse_onnx("softplus_test.onnx");
p.compile(migraphx::ref::target{});
migraphx::shape s{migraphx::shape::float_type, {5}};
std::vector<float> data = {0, 1, 2, 3, 4};
migraphx::parameter_map pp;
pp["x"] = 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(5);
std::transform(
data.begin(), data.end(), gold.begin(), [](auto x) { return std::log1p(std::exp(x)); });
EXPECT(migraphx::verify_range(result_vector, gold));
}
TEST_CASE(softsign_test)
{
migraphx::program p = migraphx::parse_onnx("softsign_test.onnx");
p.compile(migraphx::ref::target{});
migraphx::shape s{migraphx::shape::float_type, {5}};
std::vector<float> data = {0, 1, 2, 3, 4};
migraphx::parameter_map pp;
pp["x"] = 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(5);
std::transform(
data.begin(), data.end(), gold.begin(), [](auto x) { return x / (1.0 + std::abs(x)); });
EXPECT(migraphx::verify_range(result_vector, gold));
}
TEST_CASE(upsample_test)
{
migraphx::program p = migraphx::parse_onnx("upsample_test.onnx");
......
......@@ -74,7 +74,7 @@ TEST_CASE(broadcast)
std::vector<std::size_t> lens{1, 1};
migraphx::shape input{migraphx::shape::float_type, {1}, {0}};
expect_shape(migraphx::shape{migraphx::shape::float_type, {1, 1}, {0, 0}},
migraphx::make_op("broadcast", {{"axis", 0}, {"dims", lens}}),
migraphx::make_op("broadcast", {{"axis", 0}, {"out_lens", lens}}),
input);
}
......@@ -94,14 +94,14 @@ TEST_CASE(broadcast)
std::vector<std::size_t> lens{3, 2, 4, 3};
migraphx::shape input{migraphx::shape::float_type, {4, 3}};
expect_shape(migraphx::shape{migraphx::shape::float_type, {3, 2, 4, 3}, {0, 0, 3, 1}},
migraphx::make_op("broadcast", {{"axis", 2}, {"dims", lens}}),
migraphx::make_op("broadcast", {{"axis", 2}, {"out_lens", lens}}),
input);
}
{
std::vector<std::size_t> lens{3, 2, 4, 3};
migraphx::shape input{migraphx::shape::float_type, {4, 4}};
throws_shape(migraphx::make_op("broadcast", {{"axis", 2}, {"dims", lens}}), input);
throws_shape(migraphx::make_op("broadcast", {{"axis", 2}, {"out_lens", lens}}), input);
}
}
......@@ -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);
}
}
......@@ -619,10 +570,12 @@ TEST_CASE(inconsistent_attr_shape)
{{"padding", {1, 1}}, {"stride", {2}}, {"dilation", {3, 3, 3}}}),
input,
weights);
throws_shape(
migraphx::make_op(
"pooling", {{"mode", "max"}, {"padding", {1}}, {"stride", {0}}, {"lengths", {1, 1}}}),
input);
throws_shape(migraphx::make_op("pooling",
{{"mode", migraphx::op::pooling_mode::max},
{"padding", {1}},
{"stride", {0}},
{"lengths", {1, 1}}}),
input);
}
template <class T>
......@@ -953,92 +906,103 @@ TEST_CASE(multibroadcast)
std::vector<std::size_t> lens{4, 2, 5, 3};
migraphx::shape input{migraphx::shape::float_type, {2, 1, 3}};
expect_shape(migraphx::shape{migraphx::shape::float_type, lens, {0, 3, 0, 1}},
migraphx::make_op("multibroadcast", {{"output_lens", lens}}),
migraphx::make_op("multibroadcast", {{"out_lens", lens}}),
input);
}
{
std::vector<std::size_t> lens{4, 2, 5, 3};
migraphx::shape input{migraphx::shape::float_type, {2, 1, 1}};
expect_shape(migraphx::shape{migraphx::shape::float_type, lens, {0, 1, 0, 0}},
migraphx::make_op("multibroadcast", {{"output_lens", lens}}),
migraphx::make_op("multibroadcast", {{"out_lens", lens}}),
input);
}
{
std::vector<std::size_t> lens{4, 2, 5, 3};
migraphx::shape input{migraphx::shape::float_type, {5, 1}};
expect_shape(migraphx::shape{migraphx::shape::float_type, lens, {0, 0, 1, 0}},
migraphx::make_op("multibroadcast", {{"output_lens", lens}}),
migraphx::make_op("multibroadcast", {{"out_lens", lens}}),
input);
}
{
std::vector<std::size_t> lens{4, 2, 5, 3};
migraphx::shape input{migraphx::shape::float_type, {4, 1, 1, 1}};
expect_shape(migraphx::shape{migraphx::shape::float_type, lens, {1, 0, 0, 0}},
migraphx::make_op("multibroadcast", {{"output_lens", lens}}),
migraphx::make_op("multibroadcast", {{"out_lens", lens}}),
input);
}
{
std::vector<std::size_t> lens{4, 2, 5, 3};
migraphx::shape input{migraphx::shape::float_type, {3}};
expect_shape(migraphx::shape{migraphx::shape::float_type, lens, {0, 0, 0, 1}},
migraphx::make_op("multibroadcast", {{"output_lens", lens}}),
migraphx::make_op("multibroadcast", {{"out_lens", lens}}),
input);
}
{
std::vector<std::size_t> lens{4, 4, 1, 3};
migraphx::shape input{migraphx::shape::float_type, {4, 1, 3}};
expect_shape(migraphx::shape{migraphx::shape::float_type, lens, {0, 3, 3, 1}},
migraphx::make_op("multibroadcast", {{"output_lens", lens}}),
migraphx::make_op("multibroadcast", {{"out_lens", lens}}),
input);
}
{
std::vector<std::size_t> lens{4, 1, 1, 3};
migraphx::shape input{migraphx::shape::float_type, {4, 1, 1, 1}};
expect_shape(migraphx::shape{migraphx::shape::float_type, lens, {1, 1, 1, 0}},
migraphx::make_op("multibroadcast", {{"output_lens", lens}}),
migraphx::make_op("multibroadcast", {{"out_lens", lens}}),
input);
}
{
std::vector<std::size_t> lens{4, 1, 3};
migraphx::shape input{migraphx::shape::float_type, {4, 1, 1, 1}};
throws_shape(migraphx::make_op("multibroadcast", {{"output_lens", lens}}), input);
throws_shape(migraphx::make_op("multibroadcast", {{"out_lens", lens}}), input);
}
{
std::vector<std::size_t> lens{4, 1, 3};
migraphx::shape input{migraphx::shape::float_type, {}};
throws_shape(migraphx::make_op("multibroadcast", {{"output_lens", lens}}), input);
throws_shape(migraphx::make_op("multibroadcast", {{"out_lens", lens}}), input);
}
{
std::vector<std::size_t> lens{2, 3, 4, 5};
migraphx::shape input{migraphx::shape::float_type, {3, 4}};
throws_shape(migraphx::make_op("multibroadcast", {{"output_lens", lens}}), input);
throws_shape(migraphx::make_op("multibroadcast", {{"out_lens", lens}}), input);
}
{
std::vector<std::size_t> lens{2, 3, 4, 5};
migraphx::shape input{migraphx::shape::float_type, {2, 3, 4}};
throws_shape(migraphx::make_op("multibroadcast", {{"output_lens", lens}}), input);
throws_shape(migraphx::make_op("multibroadcast", {{"out_lens", lens}}), input);
}
}
TEST_CASE(multinomial)
{
migraphx::shape s{migraphx::shape::float_type, {2, 5}};
int dtype = 0;
throws_shape(migraphx::make_op("multinomial", {{"dtype", dtype}}), s, s);
}
TEST_CASE(pooling_shape)
{
migraphx::shape output{migraphx::shape::float_type, {4, 3, 1, 1}};
migraphx::shape input{migraphx::shape::float_type, {4, 3, 3, 3}};
throws_shape(
migraphx::make_op("pooling",
{{"mode", "max"}, {"padding", {1}}, {"stride", {0}}, {"lengths", {1}}}),
input);
expect_shape(
output,
migraphx::make_op(
"pooling",
{{"mode", "max"}, {"padding", {0, 0}}, {"stride", {3, 3}}, {"lengths", {1, 1}}}),
input);
throws_shape(migraphx::make_op("pooling",
{{"mode", migraphx::op::pooling_mode::max},
{"padding", {1}},
{"stride", {0}},
{"lengths", {1}}}),
input);
expect_shape(output,
migraphx::make_op("pooling",
{{"mode", migraphx::op::pooling_mode::max},
{"padding", {0, 0}},
{"stride", {3, 3}},
{"lengths", {1, 1}}}),
input);
migraphx::shape output1{migraphx::shape::float_type, {4, 3, 2, 2}};
expect_shape(output1,
migraphx::make_op("pooling",
{{"mode", "max"},
{{"mode", migraphx::op::pooling_mode::max},
{"padding", {0, 0}},
{"stride", {3, 3}},
{"lengths", {1, 1}},
......@@ -1107,7 +1071,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);
}
......@@ -1119,27 +1083,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()
{
......@@ -1494,6 +1437,29 @@ TEST_CASE(test_scalar_nelemnts)
throws_shape(migraphx::make_op("scalar", {{"scalar_bcst_dims", {2, 3, 4, 5}}}), input);
}
TEST_CASE(test_scatternd)
{
{
// k > r
auto dtype = migraphx::shape::float_type;
auto itype = migraphx::shape::int64_type;
migraphx::shape ds{dtype, {8}};
migraphx::shape is{itype, {4, 2}};
migraphx::shape us{dtype, {4}};
throws_shape(migraphx::make_op("scatternd_none"), ds, is, us);
}
{
// update.lens != indices.lens[0:q-1] ++ data.lens[k:r-1]
auto dtype = migraphx::shape::float_type;
auto itype = migraphx::shape::int64_type;
migraphx::shape ds{dtype, {8}};
migraphx::shape is{itype, {4, 1}};
migraphx::shape us{dtype, {2, 2}};
throws_shape(migraphx::make_op("scatternd_none"), ds, is, us);
}
}
TEST_CASE(test_squeeze)
{
migraphx::shape s1{migraphx::shape::float_type, {4, 1, 3, 1, 3}};
......@@ -1508,6 +1474,27 @@ TEST_CASE(test_squeeze_all)
expect_shape(s2, migraphx::make_op("squeeze", {{"axes", {0}}}), s1);
}
TEST_CASE(test_squeeze_transpose)
{
migraphx::shape s1{migraphx::shape::float_type, {4, 4, 1}, {4, 1, 4}};
migraphx::shape s2{migraphx::shape::float_type, {4, 4}, {4, 1}};
expect_shape(s2, migraphx::make_op("squeeze", {{"axes", {2}}}), s1);
}
TEST_CASE(test_squeeze_multibroadcast)
{
migraphx::shape s1{migraphx::shape::float_type, {2, 3, 1, 4}, {0, 1, 1, 0}};
migraphx::shape s2{migraphx::shape::float_type, {2, 3, 4}, {0, 1, 0}};
expect_shape(s2, migraphx::make_op("squeeze", {{"axes", {2}}}), s1);
}
TEST_CASE(test_squeeze_slice)
{
migraphx::shape s1{migraphx::shape::float_type, {2, 3, 1, 4}, {108, 36, 6, 1}};
migraphx::shape s2{migraphx::shape::float_type, {2, 3, 4}, {108, 36, 1}};
expect_shape(s2, migraphx::make_op("squeeze", {{"axes", {2}}}), s1);
}
TEST_CASE(test_squeeze_negative_axis)
{
migraphx::shape s1{migraphx::shape::float_type, {4, 1, 3, 1, 3}};
......@@ -1554,14 +1541,62 @@ TEST_CASE(test_unsqueeze_scalar_tensor2)
throws_shape(migraphx::make_op("unsqueeze", {{"axes", {-2}}}), s);
}
TEST_CASE(test_unsqueeze_transpose)
{
migraphx::shape s1{migraphx::shape::float_type, {4, 4, 3}, {12, 1, 4}};
migraphx::shape s2{migraphx::shape::float_type, {4, 4, 1, 3}, {12, 1, 1, 4}};
expect_shape(s2, migraphx::make_op("unsqueeze", {{"axes", {2}}}), s1);
}
TEST_CASE(test_unsqueeze_multibroadcast)
{
migraphx::shape s1{migraphx::shape::float_type, {2, 3, 4}, {0, 1, 0}};
migraphx::shape s2{migraphx::shape::float_type, {2, 3, 1, 4}, {0, 1, 1, 0}};
expect_shape(s2, migraphx::make_op("unsqueeze", {{"axes", {2}}}), s1);
}
TEST_CASE(test_unsqueeze_slice)
{
migraphx::shape s1{migraphx::shape::float_type, {2, 3, 4}, {108, 36, 1}};
migraphx::shape s2{migraphx::shape::float_type, {2, 3, 1, 4}, {108, 36, 36, 1}};
expect_shape(s2, migraphx::make_op("unsqueeze", {{"axes", {2}}}), s1);
}
TEST_CASE(test_unsqueeze_axis_zero)
{
migraphx::shape s1{migraphx::shape::float_type, {2, 3, 4}};
migraphx::shape s2{migraphx::shape::float_type, {1, 2, 3, 4}};
expect_shape(s2, migraphx::make_op("unsqueeze", {{"axes", {0}}}), s1);
}
TEST_CASE(test_unsqueeze_axis_last)
{
migraphx::shape s1{migraphx::shape::float_type, {2, 3, 4}};
migraphx::shape s2{migraphx::shape::float_type, {2, 3, 4, 1}};
expect_shape(s2, migraphx::make_op("unsqueeze", {{"axes", {-1}}}), s1);
}
TEST_CASE(test_unsqueeze_multiple_axes_1)
{
migraphx::shape s1{migraphx::shape::float_type, {2, 3, 4}};
migraphx::shape s2{migraphx::shape::float_type, {1, 2, 3, 4, 1}};
expect_shape(s2, migraphx::make_op("unsqueeze", {{"axes", {0, -1}}}), s1);
}
TEST_CASE(test_unsqueeze_multiple_axes_2)
{
migraphx::shape s1{migraphx::shape::float_type, {2, 3, 4}};
migraphx::shape s2{migraphx::shape::float_type, {1, 1, 2, 3, 4}};
expect_shape(s2, migraphx::make_op("unsqueeze", {{"axes", {0, 1}}}), s1);
}
TEST_CASE(transpose_shape)
{
migraphx::shape input{migraphx::shape::float_type, {2, 2}};
migraphx::shape output{migraphx::shape::float_type, {2, 2}, {1, 2}};
expect_shape(input, migraphx::make_op("transpose", {{"dims", {0, 1}}}), input);
expect_shape(output, migraphx::make_op("transpose", {{"dims", {1, 0}}}), input);
expect_shape(output, migraphx::make_op("transpose"), input);
throws_shape(migraphx::make_op("transpose", {{"dims", {1, 2}}}), input);
expect_shape(input, migraphx::make_op("transpose", {{"permutation", {0, 1}}}), input);
expect_shape(output, migraphx::make_op("transpose", {{"permutation", {1, 0}}}), input);
throws_shape(migraphx::make_op("transpose", {{"permutation", {1, 2}}}), input);
}
TEST_CASE(step_test)
......@@ -1583,4 +1618,50 @@ TEST_CASE(step_test)
}
}
TEST_CASE(unary_scalar_input)
{
migraphx::shape ss{migraphx::shape::half_type};
expect_shape(ss, migraphx::make_op("sin"), ss);
migraphx::shape s{migraphx::shape::float_type, {1}};
expect_shape(s, migraphx::make_op("sin"), s);
}
TEST_CASE(unary_broadcast_input)
{
migraphx::shape ss{migraphx::shape::half_type, {2, 3}, {1, 0}};
migraphx::shape s{migraphx::shape::half_type, {2, 3}};
expect_shape(s, migraphx::make_op("sin"), ss);
}
TEST_CASE(where_broadcast_input)
{
migraphx::shape s1{migraphx::shape::float_type, {2, 2}, {3, 0}};
migraphx::shape s2{migraphx::shape::float_type, {2, 2}};
migraphx::shape s3{migraphx::shape::bool_type, {2, 2}};
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:"));
......
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