Unverified Commit 1f69da4e authored by Katarzyna Mitrus's avatar Katarzyna Mitrus Committed by GitHub

[ONNX] ONNX importer tests refactor (#4310)

* Use test case in quant tests

* Reshape test refactor

* Reshape tests refactor

* Test case refactor onnx_import

* onnx import_in test case refactor

* onnx reshape test case refactor

* onnx convpool test case refactor

* onnx import in test case refactor

* onnx reshape test case refactor

* Style apply

* Style apply

* Removed commented code

* Infinity check softplus test refactor
Co-authored-by: 's avatarRobert Kimball <robert.kimball@intel.com>
parent 6a560768
......@@ -95,11 +95,10 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_add_abc)
auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/add_abc.prototxt"));
Inputs inputs{{1}, {2}, {3}};
Outputs expected_outputs{{6}};
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(Inputs{{1}, {2}, {3}});
test_case.add_expected_output(Shape{1}, std::vector<float>{6});
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_binary_add_abc)
......@@ -107,11 +106,10 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_binary_add_abc)
auto function =
onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/add_abc.onnx"));
Inputs inputs{{1}, {2}, {3}};
Outputs expected_outputs{{6}};
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(Inputs{{1}, {2}, {3}});
test_case.add_expected_output(Shape{1}, std::vector<float>{6});
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_add_abc_initializers)
......@@ -119,11 +117,10 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_add_abc_initializers)
auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/add_abc_initializers.prototxt"));
Inputs inputs{{1, 2, 3, 4}};
Outputs expected_outputs{{3, 6, 9, 12}};
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_input<float>({1, 2, 3, 4});
test_case.add_expected_output<float>({3, 6, 9, 12});
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_override_op)
......@@ -147,10 +144,10 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_override_op)
inputs.emplace_back(std::vector<float>{0.f, 1.f, 2.f, 3.f});
inputs.emplace_back(std::vector<float>{3.f, 2.f, 1.f, 0.f});
Outputs expected_output{std::vector<float>{-3.f, -1.f, 1.f, 3.f}};
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output<float>({-3.f, -1.f, 1.f, 3.f});
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, import_non_existing_file)
......@@ -199,11 +196,10 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_custom_op)
auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/custom_operator.prototxt"));
Inputs inputs{{1, 2, 3, 4}};
Outputs expected_outputs{{3, 6, 9, 12}};
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_input<float>({1.f, 2.f, 3.f, 4.f});
test_case.add_expected_output<float>({3.f, 6.f, 9.f, 12.f});
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_custom_op_default_domain)
......@@ -217,11 +213,10 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_custom_op_default_domain)
auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/custom_operator_default_domain.prototxt"));
Inputs inputs{{1, 2, 3, 4}};
Outputs expected_outputs{{3, 6, 9, 12}};
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_input<float>({1.f, 2.f, 3.f, 4.f});
test_case.add_expected_output<float>({3.f, 6.f, 9.f, 12.f});
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, is_op_supported)
......@@ -272,10 +267,10 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_missing_op_domain)
inputs.emplace_back(std::vector<float>{0.f, 1.f, 2.f, 3.f});
inputs.emplace_back(std::vector<float>{0.f, 1.f, 2.f, 3.f});
Outputs expected_output{std::vector<float>{0.f, 2.f, 4.f, 6.f}};
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output<float>({0.f, 2.f, 4.f, 6.f});
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_unknown_domain)
......@@ -343,11 +338,11 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_missing_input)
file_util::path_join(SERIALIZED_ZOO, "onnx/missing_input.prototxt"));
Inputs inputs{{1, 2, 3, 4}, {5, 6, 7, 8}};
Outputs expected_outputs{{50, 144, 294, 512}};
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output<float>({50, 144, 294, 512});
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_initializer_wo_input)
......@@ -356,13 +351,10 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_initializer_wo_input)
auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/initializer_wo_input.prototxt"));
Inputs inputs;
inputs.emplace_back(std::vector<float>{0, 1, 2, 3, 4, 5});
std::vector<float> expected_output{0, 2, 6, 12, 20, 30};
Outputs output{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output, output.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_input<float>({0, 1, 2, 3, 4, 5});
test_case.add_expected_output<float>({0, 2, 6, 12, 20, 30});
test_case.run();
}
// ############################################################################ OPERATOR TESTS
......@@ -413,11 +405,10 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_relu)
auto function =
onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/relu.prototxt"));
Inputs inputs{{-1, -2, 0, 1, 2, 3}};
Outputs expected_outputs{{0, 0, 0, 1, 2, 3}};
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_input<float>({-1, -2, 0, 1, 2, 3});
test_case.add_expected_output<float>({0, 0, 0, 1, 2, 3});
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_sum_opset1)
......@@ -454,10 +445,10 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_sum_one_input)
file_util::path_join(SERIALIZED_ZOO, "onnx/sum_one_input.prototxt"));
// input data shape (3, )
Inputs inputs{{3.f, 0.f, 2.f}};
Outputs expected_outputs{{3.f, 0.f, 2.f}};
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_input<float>({3.f, 0.f, 2.f});
test_case.add_expected_output<float>({3.f, 0.f, 2.f});
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_cum_sum_1d)
......@@ -515,13 +506,11 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_min_two_inputs_opset1)
file_util::path_join(SERIALIZED_ZOO, "onnx/min_two_inputs_opset1.prototxt"));
// input data shape (3, )
Inputs inputs;
inputs.emplace_back(std::vector<float>{1.f, 2.f, 1.f});
inputs.emplace_back(std::vector<float>{1.f, 4.f, 4.f});
Outputs expected_outputs{{1.f, 2.f, 1.f}};
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_input<float>({1.f, 2.f, 1.f});
test_case.add_input<float>({1.f, 4.f, 4.f});
test_case.add_expected_output<float>({1.f, 2.f, 1.f});
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_min_two_inputs)
......@@ -530,13 +519,11 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_min_two_inputs)
file_util::path_join(SERIALIZED_ZOO, "onnx/min_two_inputs.prototxt"));
// input data shape (3, )
Inputs inputs;
inputs.emplace_back(std::vector<float>{2.f});
inputs.emplace_back(std::vector<float>{1.f, 4.f, 4.f});
Outputs expected_outputs{{1.f, 2.f, 2.f}};
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_input<float>({2.f});
test_case.add_input<float>({1.f, 4.f, 4.f});
test_case.add_expected_output<float>({1.f, 2.f, 2.f});
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_max_opset1)
......@@ -545,14 +532,13 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_max_opset1)
file_util::path_join(SERIALIZED_ZOO, "onnx/max_opset1.prototxt"));
// input data shape (3, )
Inputs inputs;
inputs.emplace_back(std::vector<float>{3.f, 2.f, 1.f});
inputs.emplace_back(std::vector<float>{1.f, 4.f, 4.f});
inputs.emplace_back(std::vector<float>{2.f, 5.f, 3.f});
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_input<float>({3.f, 2.f, 1.f});
test_case.add_input<float>({1.f, 4.f, 4.f});
test_case.add_input<float>({2.f, 5.f, 3.f});
Outputs expected_outputs{{3.f, 5.f, 4.f}};
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
test_case.add_expected_output<float>({3.f, 5.f, 4.f});
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_max)
......@@ -561,15 +547,13 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_max)
onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/max.prototxt"));
// input data shape (3, )
Inputs inputs;
inputs.emplace_back(std::vector<float>{1.f, 4.f, 4.f});
inputs.emplace_back(std::vector<float>{3.f});
inputs.emplace_back(std::vector<float>{2.f, 5.f, 3.f});
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_input<float>({1.f, 4.f, 4.f});
test_case.add_input<float>({3.f});
test_case.add_input<float>({2.f, 5.f, 3.f});
Outputs expected_outputs{{3.f, 5.f, 4.f}};
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
test_case.add_expected_output<float>({3.f, 5.f, 4.f});
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_mean_opset1)
......@@ -578,14 +562,13 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_mean_opset1)
file_util::path_join(SERIALIZED_ZOO, "onnx/mean_opset1.prototxt"));
// input data shape (3, )
Inputs inputs;
inputs.emplace_back(std::vector<float>{3.f, 0.f, 2.f});
inputs.emplace_back(std::vector<float>{1.f, 3.f, 4.f});
inputs.emplace_back(std::vector<float>{2.f, 6.f, 6.f});
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_input<float>({3.f, 0.f, 2.f});
test_case.add_input<float>({1.f, 3.f, 4.f});
test_case.add_input<float>({2.f, 6.f, 6.f});
Outputs expected_outputs{{2.f, 3.f, 4.f}};
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
test_case.add_expected_output<float>({2.f, 3.f, 4.f});
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_mean)
......@@ -594,14 +577,13 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_mean)
onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/mean.prototxt"));
// input data shape (3, )
Inputs inputs;
inputs.emplace_back(std::vector<float>{3.f});
inputs.emplace_back(std::vector<float>{1.f, 2.f, 5.f});
inputs.emplace_back(std::vector<float>{2.f, 7.f, 7.f});
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_input<float>({3.f});
test_case.add_input<float>({1.f, 2.f, 5.f});
test_case.add_input<float>({2.f, 7.f, 7.f});
Outputs expected_outputs{{2.f, 4.f, 5.f}};
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
test_case.add_expected_output<float>({2.f, 4.f, 5.f});
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_gemm_abc)
......@@ -625,13 +607,15 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_gemm_abc)
inputs.emplace_back(
test::NDArray<float, 2>({{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}}).get_vector());
Outputs expected_outputs{
auto expected_output =
test::NDArray<float, 2>(
{{340, 350.5, 361, 371.5}, {862, 890.5, 919, 947.5}, {1384, 1430.5, 1477, 1523.5}})
.get_vector()};
.get_vector();
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_matmul)
......@@ -648,11 +632,13 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_matmul)
test::NDArray<float, 2>({{13, 14, 15}, {16, 17, 18}, {19, 20, 21}, {22, 23, 24}})
.get_vector());
Outputs expected_outputs{
test::NDArray<float, 2>({{190, 200, 210}, {470, 496, 522}, {750, 792, 834}}).get_vector()};
auto expected_output =
test::NDArray<float, 2>({{190, 200, 210}, {470, 496, 522}, {750, 792, 834}}).get_vector();
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_softmax)
......@@ -706,8 +692,10 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_softmax)
6.32120559e-01f}}})
.get_vector();
auto result_vectors = execute(function, inputs, "${BACKEND_NAME}");
EXPECT_TRUE(test::all_close_f(expected_output, result_vectors.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_sub)
......@@ -722,8 +710,10 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_sub)
auto expected_output = test::NDArray<float, 3>({{{-3, -3, -4}}}).get_vector();
auto result_vectors = execute(function, inputs, "${BACKEND_NAME}");
EXPECT_TRUE(test::all_close_f(expected_output, result_vectors.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_div)
......@@ -733,13 +723,14 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_div)
Inputs inputs;
inputs.emplace_back(test::NDArray<float, 3>({{{1, 2, 3}}}).get_vector());
inputs.emplace_back(test::NDArray<float, 3>({{{1, 4, 12}}}).get_vector());
auto expected_output = test::NDArray<float, 3>({{{1, 0.5, 0.25}}}).get_vector();
auto result_vectors = execute(function, inputs, "${BACKEND_NAME}");
EXPECT_TRUE(test::all_close_f(expected_output, result_vectors.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_add_bcast)
......@@ -756,15 +747,17 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_add_bcast)
inputs.emplace_back(test::NDArray<float, 1>({1, 2, 3, 4, 5}).get_vector());
Outputs expected_output{
auto expected_output =
test::NDArray<float, 4>(
{{{{2, 3, 4, 5, 6}, {2, 3, 4, 5, 6}, {2, 3, 4, 5, 6}, {2, 3, 4, 5, 6}},
{{2, 3, 4, 5, 6}, {2, 3, 4, 5, 6}, {2, 3, 4, 5, 6}, {2, 3, 4, 5, 6}},
{{2, 3, 4, 5, 6}, {2, 3, 4, 5, 6}, {2, 3, 4, 5, 6}, {2, 3, 4, 5, 6}}}})
.get_vector()};
.get_vector();
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_reduce_log_sum)
......@@ -778,10 +771,12 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_reduce_log_sum)
.get_vector()};
// output data shape (1,)
Outputs expected_outputs{test::NDArray<float, 4>({{{{2.77258872f}}}}).get_vector()};
auto expected_output = test::NDArray<float, 4>({{{{2.77258872f}}}}).get_vector();
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_reduce_log_sum_exp)
......@@ -795,10 +790,12 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_reduce_log_sum_exp)
.get_vector()};
// output data shape (1,)
Outputs expected_outputs{test::NDArray<float, 4>({{{{3.77258872f}}}}).get_vector()};
auto expected_output = test::NDArray<float, 4>({{{{3.77258872f}}}}).get_vector();
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_reduce_l1)
......@@ -812,10 +809,12 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_reduce_l1)
.get_vector()};
// output data shape (1,)
Outputs expected_outputs{test::NDArray<float, 4>({{{{16}}}}).get_vector()};
auto expected_output = test::NDArray<float, 4>({{{{16}}}}).get_vector();
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_reduce_l2)
......@@ -829,10 +828,12 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_reduce_l2)
.get_vector()};
// output data shape (1,)
Outputs expected_outputs{test::NDArray<float, 4>({{{{4}}}}).get_vector()};
auto expected_output = test::NDArray<float, 4>({{{{4}}}}).get_vector();
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_reduce_max)
......@@ -846,10 +847,12 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_reduce_max)
.get_vector()};
// output data shape (1,)
Outputs expected_outputs{test::NDArray<float, 4>({{{{16}}}}).get_vector()};
auto expected_output = test::NDArray<float, 4>({{{{16}}}}).get_vector();
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_reduce_mean)
......@@ -863,10 +866,12 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_reduce_mean)
.get_vector()};
// output data shape (1,)
Outputs expected_outputs{test::NDArray<float, 4>({{{{1}}}}).get_vector()};
auto expected_output = test::NDArray<float, 4>({{{{1}}}}).get_vector();
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_reduce_min)
......@@ -880,10 +885,12 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_reduce_min)
.get_vector()};
// output data shape (1,)
Outputs expected_outputs{test::NDArray<float, 4>({{{{1}}}}).get_vector()};
auto expected_output = test::NDArray<float, 4>({{{{1}}}}).get_vector();
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_reduce_prod)
......@@ -897,10 +904,12 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_reduce_prod)
.get_vector()};
// output data shape (1,)
Outputs expected_outputs{test::NDArray<float, 4>({{{{1}}}}).get_vector()};
auto expected_output = test::NDArray<float, 4>({{{{1}}}}).get_vector();
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_reduce_sum)
......@@ -914,10 +923,12 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_reduce_sum)
.get_vector()};
// output data shape (1,)
Outputs expected_outputs{test::NDArray<float, 4>({{{{16}}}}).get_vector()};
auto expected_output = test::NDArray<float, 4>({{{{16}}}}).get_vector();
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_reduce_sum_square)
......@@ -931,10 +942,12 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_reduce_sum_square)
.get_vector()};
// output data shape (1,)
Outputs expected_outputs{test::NDArray<float, 4>({{{{16}}}}).get_vector()};
auto expected_output = test::NDArray<float, 4>({{{{16}}}}).get_vector();
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_shape)
......@@ -949,11 +962,10 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_shape)
{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}}})
.get_vector());
std::vector<std::vector<int64_t>> expected_output{{3, 4, 5}};
std::vector<std::vector<int64_t>> outputs =
execute<float, int64_t>(function, inputs, "${BACKEND_NAME}");
EXPECT_TRUE(test::all_close(expected_output.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output<int64_t>({3, 4, 5});
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_elu)
......@@ -969,38 +981,40 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_elu)
{{1, 1, 1, 1, 1}, {-1, -1, -1, -1, -1}, {0, 0, 0, 0, 0}, {2, 2, 2, 2, 2}}})
.get_vector());
Outputs expected_output{test::NDArray<float, 3>({{{-1.999753180391830f,
-1.999329074744190f,
-1.998176236068890f,
-1.995042495646670f,
-1.986524106001830f},
{-1.963368722222530f,
-1.900425863264270f,
-1.729329433526770f,
-1.264241117657120f,
0},
{1, 2, 3, 4, 5},
{6, 7, 8, 9, 10}},
{{-1.963368722222530f,
-1.900425863264270f,
-1.729329433526770f,
-1.264241117657120f,
0},
{1, 2, 3, 4, 5},
{6, 7, 8, 9, 10},
{11, 12, 13, 14, 15}},
{{1, 1, 1, 1, 1},
{-1.264241117657120f,
-1.264241117657120f,
-1.264241117657120f,
-1.264241117657120f,
-1.264241117657120f},
{0, 0, 0, 0, 0},
{2, 2, 2, 2, 2}}})
.get_vector()};
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
auto expected_output = test::NDArray<float, 3>({{{-1.999753180391830f,
-1.999329074744190f,
-1.998176236068890f,
-1.995042495646670f,
-1.986524106001830f},
{-1.963368722222530f,
-1.900425863264270f,
-1.729329433526770f,
-1.264241117657120f,
0},
{1, 2, 3, 4, 5},
{6, 7, 8, 9, 10}},
{{-1.963368722222530f,
-1.900425863264270f,
-1.729329433526770f,
-1.264241117657120f,
0},
{1, 2, 3, 4, 5},
{6, 7, 8, 9, 10},
{11, 12, 13, 14, 15}},
{{1, 1, 1, 1, 1},
{-1.264241117657120f,
-1.264241117657120f,
-1.264241117657120f,
-1.264241117657120f,
-1.264241117657120f},
{0, 0, 0, 0, 0},
{2, 2, 2, 2, 2}}})
.get_vector();
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_leaky_relu)
......@@ -1016,22 +1030,24 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_leaky_relu)
{{1, 1, 1, 1, 1}, {-1, -1, -1, -1, -1}, {0, 0, 0, 0, 0}, {2, 2, 2, 2, 2}}})
.get_vector());
Outputs expected_output{test::NDArray<float, 3>({{{-0.9f, -0.8f, -0.7f, -0.6f, -0.5f},
{-0.4f, -0.3f, -0.2f, -0.1f, 0},
{1, 2, 3, 4, 5},
{6, 7, 8, 9, 10}},
{{-0.4f, -0.3f, -0.2f, -0.1f, 0},
{1, 2, 3, 4, 5},
{6, 7, 8, 9, 10},
{11, 12, 13, 14, 15}},
{{1, 1, 1, 1, 1},
{-0.1f, -0.1f, -0.1f, -0.1f, -0.1f},
{0, 0, 0, 0, 0},
{2, 2, 2, 2, 2}}})
.get_vector()};
auto expected_output = test::NDArray<float, 3>({{{-0.9f, -0.8f, -0.7f, -0.6f, -0.5f},
{-0.4f, -0.3f, -0.2f, -0.1f, 0},
{1, 2, 3, 4, 5},
{6, 7, 8, 9, 10}},
{{-0.4f, -0.3f, -0.2f, -0.1f, 0},
{1, 2, 3, 4, 5},
{6, 7, 8, 9, 10},
{11, 12, 13, 14, 15}},
{{1, 1, 1, 1, 1},
{-0.1f, -0.1f, -0.1f, -0.1f, -0.1f},
{0, 0, 0, 0, 0},
{2, 2, 2, 2, 2}}})
.get_vector();
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_prelu)
......@@ -1053,15 +1069,17 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_prelu)
{{1, 0, 1, 0, 1}, {0, 1, 0, 1, 0}, {1, 0, 1, 0, 1}, {0, 1, 0, 1, 0}}})
.get_vector());
Outputs expected_output{
auto expected_output =
test::NDArray<float, 3>(
{{{-9, 0, -7, 0, -5}, {0, -3, 0, -1, 0}, {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}},
{{0, -3, 0, -1, 0}, {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}},
{{1, 1, 1, 1, 1}, {0, -1, 0, -1, 0}, {0, 0, 0, 0, 0}, {2, 2, 2, 2, 2}}})
.get_vector()};
.get_vector();
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_selu)
......@@ -1077,7 +1095,7 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_selu)
{{1, 1, 1, 1, 1}, {-1, -1, -1, -1, -1}, {0, 0, 0, 0, 0}, {2, 2, 2, 2, 2}}})
.get_vector());
Outputs expected_output{
auto expected_output =
test::NDArray<float, 3>(
{{{-5.99925954117548f,
-5.99798722423258f,
......@@ -1099,10 +1117,12 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_selu)
-3.79272335297135f},
{0, 0, 0, 0, 0},
{6, 6, 6, 6, 6}}})
.get_vector()};
.get_vector();
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_sigmoid)
......@@ -1118,66 +1138,68 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_sigmoid)
{{1, 1, 1, 1, 1}, {-1, -1, -1, -1, -1}, {0, 0, 0, 0, 0}, {2, 2, 2, 2, 2}}})
.get_vector());
Outputs expected_output{test::NDArray<float, 3>({{{0.00012339457598623f,
0.00033535013046648f,
0.00091105119440065f,
0.00247262315663477f,
0.00669285092428486f},
{0.01798620996209160f,
0.04742587317756680f,
0.119202922022118f,
0.268941421369995f,
0.5f},
{0.731058578630005f,
0.880797077977882f,
0.952574126822433f,
0.982013790037908f,
0.993307149075715f},
{0.997527376843365f,
0.999088948805599f,
0.999664649869534f,
0.999876605424014f,
0.999954602131298f}},
{{0.01798620996209160f,
0.04742587317756680f,
0.119202922022118f,
0.268941421369995f,
0.5f},
{0.731058578630005f,
0.880797077977882f,
0.952574126822433f,
0.982013790037908f,
0.993307149075715f},
{0.997527376843365f,
0.999088948805599f,
0.999664649869534f,
0.999876605424014f,
0.999954602131298f},
{0.999983298578152f,
0.999993855825398f,
0.999997739675702f,
0.999999168471972f,
0.999999694097773f}},
{{0.731058578630005f,
0.731058578630005f,
0.731058578630005f,
0.731058578630005f,
0.731058578630005f},
{0.268941421369995f,
0.268941421369995f,
0.268941421369995f,
0.268941421369995f,
0.268941421369995f},
{0.5f, 0.5f, 0.5f, 0.5f, 0.5f},
{0.880797077977882f,
0.880797077977882f,
0.880797077977882f,
0.880797077977882f,
0.880797077977882f}}})
.get_vector()};
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
auto expected_output = test::NDArray<float, 3>({{{0.00012339457598623f,
0.00033535013046648f,
0.00091105119440065f,
0.00247262315663477f,
0.00669285092428486f},
{0.01798620996209160f,
0.04742587317756680f,
0.119202922022118f,
0.268941421369995f,
0.5f},
{0.731058578630005f,
0.880797077977882f,
0.952574126822433f,
0.982013790037908f,
0.993307149075715f},
{0.997527376843365f,
0.999088948805599f,
0.999664649869534f,
0.999876605424014f,
0.999954602131298f}},
{{0.01798620996209160f,
0.04742587317756680f,
0.119202922022118f,
0.268941421369995f,
0.5f},
{0.731058578630005f,
0.880797077977882f,
0.952574126822433f,
0.982013790037908f,
0.993307149075715f},
{0.997527376843365f,
0.999088948805599f,
0.999664649869534f,
0.999876605424014f,
0.999954602131298f},
{0.999983298578152f,
0.999993855825398f,
0.999997739675702f,
0.999999168471972f,
0.999999694097773f}},
{{0.731058578630005f,
0.731058578630005f,
0.731058578630005f,
0.731058578630005f,
0.731058578630005f},
{0.268941421369995f,
0.268941421369995f,
0.268941421369995f,
0.268941421369995f,
0.268941421369995f},
{0.5f, 0.5f, 0.5f, 0.5f, 0.5f},
{0.880797077977882f,
0.880797077977882f,
0.880797077977882f,
0.880797077977882f,
0.880797077977882f}}})
.get_vector();
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_tanh)
......@@ -1193,66 +1215,68 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_tanh)
{{1, 1, 1, 1, 1}, {-1, -1, -1, -1, -1}, {0, 0, 0, 0, 0}, {2, 2, 2, 2, 2}}})
.get_vector());
Outputs expected_output{test::NDArray<float, 3>({{{-0.999999969540041f,
-0.999999774929676f,
-0.999998336943945f,
-0.999987711650796f,
-0.999909204262595f},
{-0.999329299739067f,
-0.995054753686731f,
-0.964027580075817f,
-0.761594155955765f,
0},
{0.761594155955765f,
0.964027580075817f,
0.995054753686731f,
0.999329299739067f,
0.999909204262595f},
{0.999987711650796f,
0.999998336943945f,
0.999999774929676f,
0.999999969540041f,
0.999999995877693f}},
{{-0.999329299739067f,
-0.995054753686731f,
-0.964027580075817f,
-0.761594155955765f,
0},
{0.761594155955765f,
0.964027580075817f,
0.995054753686731f,
0.999329299739067f,
0.999909204262595f},
{0.999987711650796f,
0.999998336943945f,
0.999999774929676f,
0.999999969540041f,
0.999999995877693f},
{0.999999999442106f,
0.999999999924497f,
0.999999999989782f,
0.999999999998617f,
0.999999999999813f}},
{{0.761594155955765f,
0.761594155955765f,
0.761594155955765f,
0.761594155955765f,
0.761594155955765f},
{-0.761594155955765f,
-0.761594155955765f,
-0.761594155955765f,
-0.761594155955765f,
-0.761594155955765f},
{0, 0, 0, 0, 0},
{0.964027580075817f,
0.964027580075817f,
0.964027580075817f,
0.964027580075817f,
0.964027580075817f}}})
.get_vector()};
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
auto expected_output = test::NDArray<float, 3>({{{-0.999999969540041f,
-0.999999774929676f,
-0.999998336943945f,
-0.999987711650796f,
-0.999909204262595f},
{-0.999329299739067f,
-0.995054753686731f,
-0.964027580075817f,
-0.761594155955765f,
0},
{0.761594155955765f,
0.964027580075817f,
0.995054753686731f,
0.999329299739067f,
0.999909204262595f},
{0.999987711650796f,
0.999998336943945f,
0.999999774929676f,
0.999999969540041f,
0.999999995877693f}},
{{-0.999329299739067f,
-0.995054753686731f,
-0.964027580075817f,
-0.761594155955765f,
0},
{0.761594155955765f,
0.964027580075817f,
0.995054753686731f,
0.999329299739067f,
0.999909204262595f},
{0.999987711650796f,
0.999998336943945f,
0.999999774929676f,
0.999999969540041f,
0.999999995877693f},
{0.999999999442106f,
0.999999999924497f,
0.999999999989782f,
0.999999999998617f,
0.999999999999813f}},
{{0.761594155955765f,
0.761594155955765f,
0.761594155955765f,
0.761594155955765f,
0.761594155955765f},
{-0.761594155955765f,
-0.761594155955765f,
-0.761594155955765f,
-0.761594155955765f,
-0.761594155955765f},
{0, 0, 0, 0, 0},
{0.964027580075817f,
0.964027580075817f,
0.964027580075817f,
0.964027580075817f,
0.964027580075817f}}})
.get_vector();
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_thresholded_relu)
......@@ -1268,15 +1292,17 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_thresholded_relu)
{{1, 1, 1, 1, 1}, {-1, -1, -1, -1, -1}, {0, 0, 0, 0, 0}, {2, 2, 2, 2, 2}}})
.get_vector());
Outputs expected_output{
auto expected_output =
test::NDArray<float, 3>(
{{{0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 3, 4, 5}, {6, 7, 8, 9, 10}},
{{0, 0, 0, 0, 0}, {0, 0, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}},
{{0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}}})
.get_vector()};
.get_vector();
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_matmul_vec_ten3d)
......@@ -1289,10 +1315,12 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_matmul_vec_ten3d)
inputs.emplace_back(
test::NDArray<float, 3>{{{0.f}, {1.f}}, {{2.f}, {3.f}}, {{4.f}, {5.f}}}.get_vector());
Outputs expected_output{test::NDArray<float, 2>{{1.f}, {3.f}, {5.f}}};
auto expected_output = test::NDArray<float, 2>{{1.f}, {3.f}, {5.f}}.get_vector();
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_softplus)
......@@ -1333,9 +1361,10 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_softplus)
std::transform(std::begin(input), std::end(input), std::back_inserter(output), softplus_impl);
Outputs expected_output{output};
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_softplus_infinity)
......@@ -1343,25 +1372,13 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_softplus_infinity)
auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/softplus.prototxt"));
Inputs inputs{std::vector<float>{std::numeric_limits<float>::infinity(),
std::numeric_limits<float>::infinity(),
std::numeric_limits<float>::infinity(),
std::numeric_limits<float>::infinity(),
std::numeric_limits<float>::infinity(),
std::numeric_limits<float>::infinity(),
std::numeric_limits<float>::infinity(),
std::numeric_limits<float>::infinity(),
std::numeric_limits<float>::infinity(),
std::numeric_limits<float>::infinity(),
std::numeric_limits<float>::infinity(),
std::numeric_limits<float>::infinity(),
std::numeric_limits<float>::infinity()}};
std::vector<float> input(13, std::numeric_limits<float>::infinity());
std::vector<float> expected_output(13, std::numeric_limits<float>::infinity());
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
for (float v : outputs.front())
{
EXPECT_TRUE(std::isinf(v));
}
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_input(input);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_sum_opset8)
......@@ -1374,16 +1391,19 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_sum_opset8)
inputs.emplace_back(test::NDArray<float, 2>{{10.0f}, {20.0f}, {30.0f}}.get_vector());
inputs.emplace_back(test::NDArray<float, 3>{{{100.0f}}, {{200.0f}}, {{300.0f}}}.get_vector());
Outputs expected_output{test::NDArray<float, 3>{
{{111.0f, 112.0f, 113.0f}, {121.0f, 122.0f, 123.0f}, {131.0f, 132.0f, 133.0f}},
auto expected_output =
test::NDArray<float, 3>{
{{111.0f, 112.0f, 113.0f}, {121.0f, 122.0f, 123.0f}, {131.0f, 132.0f, 133.0f}},
{{211.0f, 212.0f, 213.0f}, {221.0f, 222.0f, 223.0f}, {231.0f, 232.0f, 233.0f}},
{{211.0f, 212.0f, 213.0f}, {221.0f, 222.0f, 223.0f}, {231.0f, 232.0f, 233.0f}},
{{311.0f, 312.0f, 313.0f}, {321.0f, 322.0f, 323.0f}, {331.0f, 332.0f, 333.0f}}}
.get_vector()};
{{311.0f, 312.0f, 313.0f}, {321.0f, 322.0f, 323.0f}, {331.0f, 332.0f, 333.0f}}}
.get_vector();
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_argmax_int32)
......@@ -1391,15 +1411,10 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_argmax_int32)
auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/argmax_int32.prototxt"));
std::vector<std::vector<std::int32_t>> inputs{
std::vector<std::int32_t>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}};
std::vector<std::vector<std::int64_t>> expected_output{
std::vector<std::int64_t>{1, 1, 1, 1, 1, 1}};
std::vector<std::vector<std::int64_t>> outputs{
execute<std::int32_t, std::int64_t>(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close(expected_output.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_input<std::int32_t>({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12});
test_case.add_expected_output<std::int32_t>({1, 1, 1, 1, 1, 1});
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_argmin_int32)
......@@ -1407,14 +1422,10 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_argmin_int32)
auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/argmin_int32.prototxt"));
std::vector<std::vector<std::int32_t>> inputs{
std::vector<std::int32_t>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}};
std::vector<std::vector<std::int64_t>> expected_output{std::vector<std::int64_t>{0, 0, 0, 0}};
std::vector<std::vector<std::int64_t>> outputs{
execute<std::int32_t, std::int64_t>(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close(expected_output.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_input<std::int32_t>({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12});
test_case.add_expected_output<std::int32_t>({0, 0, 0, 0});
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_top_k)
......@@ -1514,12 +1525,10 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_sinh)
auto function =
onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/sinh.prototxt"));
Inputs inputs{std::vector<float>{-1.0f, 0.0f, 1.0f}};
Outputs expected_outputs{std::vector<float>{-1.1752012f, 0.f, 1.1752012f}};
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_input<float>({-1.0f, 0.0f, 1.0f});
test_case.add_expected_output<float>({-1.1752012f, 0.f, 1.1752012f});
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_cosh)
......@@ -1527,12 +1536,10 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_cosh)
auto function =
onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/cosh.prototxt"));
Inputs inputs{std::vector<float>{-1.0f, 0.0f, 1.0f}};
Outputs expected_outputs{std::vector<float>{1.54308069f, 1.f, 1.54308069f}};
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_input<float>({-1.0f, 0.0f, 1.0f});
test_case.add_expected_output<float>({1.54308069f, 1.f, 1.54308069f});
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_sign)
......@@ -1546,11 +1553,10 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_sign)
2.71828f,
std::numeric_limits<float>::infinity()}};
Outputs expected_outputs{std::vector<float>{-1.0f, -1.0f, 0.0f, 1.0f, 1.0f}};
Outputs outputs{execute<float>(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output<float>({-1.0f, -1.0f, 0.0f, 1.0f, 1.0f});
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_one_hot_with_axis)
......@@ -1559,13 +1565,15 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_one_hot_with_axis)
file_util::path_join(SERIALIZED_ZOO, "onnx/one_hot_axis.prototxt"));
Inputs inputs{{1.0, 9.0, 2.0, 4.0}, {1.0, 3.0}};
Outputs expected_outputs{{1.0, 1.0, 3.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 1.0, 1.0, 3.0, 1.0, 1.0, 1.0, 1.0, 3.0, 1.0, 1.0, 1.0,
1.0, 3.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}};
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
std::vector<float> expected_output{{1.0, 1.0, 3.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 3.0,
1.0, 1.0, 1.0, 1.0, 3.0, 1.0, 1.0, 1.0, 1.0, 3.0,
1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_one_hot_without_axis)
......@@ -1574,13 +1582,13 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_one_hot_without_axis)
file_util::path_join(SERIALIZED_ZOO, "onnx/one_hot_no_axis.prototxt"));
std::vector<std::vector<std::int64_t>> inputs{{0, 7, 8}, {2, 5}};
std::vector<std::vector<std::int64_t>> expected_outputs{{5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 5, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 5, 2, 2, 2}};
std::vector<std::vector<std::int64_t>> outputs{execute(function, inputs, "${BACKEND_NAME}")};
std::vector<std::int64_t> expected_output{5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 5, 2, 2, 2};
EXPECT_TRUE(test::all_close(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_where)
......@@ -1603,12 +1611,13 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_where)
inputs.push_back(std::move(x2));
// y = 3x3x3
std::vector<std::vector<int>> expected_outputs{
{2, 1, 2, 1, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2, 1, 2, 1, 2}};
std::vector<std::vector<int>> outputs{execute(function, inputs, "${BACKEND_NAME}")};
std::vector<int> expected_output{2, 1, 2, 1, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2,
1, 2, 1, 2, 2, 1, 2, 1, 2, 1, 2, 1, 2};
EXPECT_EQ(expected_outputs.front(), outputs.front());
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_erf)
......@@ -1622,14 +1631,15 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_erf)
{-3.141592f, 0.0f},
{0.5f, 1.0f}}.get_vector());
const std::vector<float> expected_outputs = test::NDArray<float, 2>{
const std::vector<float> expected_output = test::NDArray<float, 2>{
{-1.0f, 1.0f},
{-0.99999112f, 0.0f},
{0.52049988f, 0.84270079f}}.get_vector();
const Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs, outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_erf_int32)
......@@ -1640,11 +1650,12 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_erf_int32)
const std::vector<std::vector<int32_t>> inputs{
{-std::numeric_limits<int32_t>::max(), -1, 0, 1, std::numeric_limits<int32_t>::max()}};
const std::vector<int32_t> expected_outputs{-1, 0, 0, 0, 1};
const std::vector<std::vector<int32_t>> outputs{execute(function, inputs, "${BACKEND_NAME}")};
const std::vector<int32_t> expected_output{-1, 0, 0, 0, 1};
EXPECT_TRUE(test::all_close(expected_outputs, outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_hardmax)
......@@ -1865,10 +1876,12 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, matmul_float_type)
{
auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/matmul_float.prototxt"));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_input<float>(std::vector<float>{0, 1, 2, 3, 4, 5});
test_case.add_input<float>(std::vector<float>{0, 1});
test_case.add_expected_output<float>(Shape{3, 1}, std::vector<float>{1, 3, 5});
test_case.run();
}
......@@ -1895,6 +1908,7 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_scatterND)
test_case.add_input<int64_t>({4, 3, 1, 7});
test_case.add_input<float>({9.f, 10.f, 11.f, 12.f});
test_case.add_expected_output<float>(Shape{8}, {1.f, 11.f, 3.f, 10.f, 9.f, 6.f, 7.f, 12.f});
test_case.run();
}
......
......@@ -41,34 +41,28 @@ static std::string s_manifest = "${MANIFEST}";
using Inputs = std::vector<std::vector<float>>;
using Outputs = std::vector<std::vector<float>>;
static std::vector<std::vector<float>> conv2d_execute(const std::shared_ptr<Function>& function)
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_conv2d_strides_padding)
{
std::vector<std::vector<float>> args;
// Convolution with strides=2 and padding=1
auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/conv_with_strides_padding.prototxt"));
Inputs inputs;
// data (1, 1, 7, 5) input tensor
args.emplace_back(test::NDArray<float, 4>{{{{{0.f, 1.f, 2.f, 3.f, 4.f},
{5.f, 6.f, 7.f, 8.f, 9.f},
{10.f, 11.f, 12.f, 13.f, 14.f},
{15.f, 16.f, 17.f, 18.f, 19.f},
{20.f, 21.f, 22.f, 23.f, 24.f},
{25.f, 26.f, 27.f, 28.f, 29.f},
{30.f, 31.f, 32.f, 33.f, 34.f}}}}}
.get_vector());
inputs.emplace_back(test::NDArray<float, 4>{{{{{0.f, 1.f, 2.f, 3.f, 4.f},
{5.f, 6.f, 7.f, 8.f, 9.f},
{10.f, 11.f, 12.f, 13.f, 14.f},
{15.f, 16.f, 17.f, 18.f, 19.f},
{20.f, 21.f, 22.f, 23.f, 24.f},
{25.f, 26.f, 27.f, 28.f, 29.f},
{30.f, 31.f, 32.f, 33.f, 34.f}}}}}
.get_vector());
// filters (1, 1, 3, 3) aka convolution weights
args.emplace_back(
inputs.emplace_back(
test::NDArray<float, 4>{{{{{1.f, 1.f, 1.f}, {1.f, 1.f, 1.f}, {1.f, 1.f, 1.f}}}}}
.get_vector());
return execute(function, args, "${BACKEND_NAME}");
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_conv2d_strides_padding)
{
// Convolution with strides=2 and padding=1
auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/conv_with_strides_padding.prototxt"));
// (1, 1, 4, 3)
auto expected_output = test::NDArray<float, 4>({{{{12.f, 27.f, 24.f},
{63.f, 108.f, 81.f},
......@@ -76,8 +70,10 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_conv2d_strides_padding)
{112.f, 177.f, 124.f}}}})
.get_vector();
auto result = conv2d_execute(function);
EXPECT_EQ(expected_output, result.front());
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_conv2d_strides_no_padding)
......@@ -86,12 +82,30 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_conv2d_strides_no_padding)
auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/conv_with_strides_no_padding.prototxt"));
Inputs inputs;
// data (1, 1, 7, 5) input tensor
inputs.emplace_back(test::NDArray<float, 4>{{{{{0.f, 1.f, 2.f, 3.f, 4.f},
{5.f, 6.f, 7.f, 8.f, 9.f},
{10.f, 11.f, 12.f, 13.f, 14.f},
{15.f, 16.f, 17.f, 18.f, 19.f},
{20.f, 21.f, 22.f, 23.f, 24.f},
{25.f, 26.f, 27.f, 28.f, 29.f},
{30.f, 31.f, 32.f, 33.f, 34.f}}}}}
.get_vector());
// filters (1, 1, 3, 3) aka convolution weights
inputs.emplace_back(
test::NDArray<float, 4>{{{{{1.f, 1.f, 1.f}, {1.f, 1.f, 1.f}, {1.f, 1.f, 1.f}}}}}
.get_vector());
// (1, 1, 3, 2)
auto expected_output =
test::NDArray<float, 4>({{{{54.f, 72.f}, {144.f, 162.f}, {234.f, 252.f}}}}).get_vector();
auto result = conv2d_execute(function);
EXPECT_EQ(expected_output, result.front());
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_conv2d_strides_assymetric_padding)
......@@ -100,13 +114,31 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_conv2d_strides_assymetric_padding)
auto function = onnx_import::import_onnx_model(file_util::path_join(
SERIALIZED_ZOO, "onnx/conv_with_strides_and_asymmetric_padding.prototxt"));
Inputs inputs;
// data (1, 1, 7, 5) input tensor
inputs.emplace_back(test::NDArray<float, 4>{{{{{0.f, 1.f, 2.f, 3.f, 4.f},
{5.f, 6.f, 7.f, 8.f, 9.f},
{10.f, 11.f, 12.f, 13.f, 14.f},
{15.f, 16.f, 17.f, 18.f, 19.f},
{20.f, 21.f, 22.f, 23.f, 24.f},
{25.f, 26.f, 27.f, 28.f, 29.f},
{30.f, 31.f, 32.f, 33.f, 34.f}}}}}
.get_vector());
// filters (1, 1, 3, 3) aka convolution weights
inputs.emplace_back(
test::NDArray<float, 4>{{{{{1.f, 1.f, 1.f}, {1.f, 1.f, 1.f}, {1.f, 1.f, 1.f}}}}}
.get_vector());
// (1, 1, 4, 2)
auto expected_output =
test::NDArray<float, 4>({{{{21.f, 33.f}, {99.f, 117.f}, {189.f, 207.f}, {171.f, 183.f}}}})
.get_vector();
auto result = conv2d_execute(function);
EXPECT_EQ(expected_output, result.front());
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_conv2d_dilation_assymetric_pads_strides)
......@@ -138,15 +170,17 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_conv2d_dilation_assymetric_pads_strides)
.get_vector());
// {2, 2, 1, 2}
Outputs expected_output{
auto expected_output =
test::NDArray<float, 4>({{{{-0.012311071157455444f, 0.02822777070105076f}},
{{-0.028432954102754593f, -0.037657227367162704f}}},
{{{-0.04396762326359749f, 0.10081233829259872f}},
{{-0.10154513269662857f, -0.13448859751224518f}}}})
.get_vector()};
.get_vector();
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_conv3d_bias)
......@@ -230,7 +264,7 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_conv3d_bias)
inputs.emplace_back(std::vector<float>{0.4310183525085449f, -0.4564093053340912f});
// {2, 2, 3, 3, 3}
Outputs expected_output{std::vector<float>{
std::vector<float> expected_output{
0.5332361459732056f, 0.6628494262695312f, 0.544619083404541f, 0.4242798388004303f,
0.6271085739135742f, 0.6721994876861572f, 0.43064039945602417f, 0.4246789515018463f,
0.53834068775177f, 0.6932926177978516f, 0.42797625064849854f, 0.2218741625547409f,
......@@ -257,10 +291,12 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_conv3d_bias)
-0.3714444637298584f, -0.4888814687728882f, -0.6191370487213135f, -0.2640320658683777f,
-0.47542816400527954f, -0.5078460574150085f, -0.4205915927886963f, -0.5584549903869629f,
-0.39770257472991943f, -0.45317384600639343f, -0.5598302483558655f, -0.2542789578437805f,
-0.5359901785850525f, -0.48090484738349915f, -0.38603779673576355f, -0.4991581439971924f}};
-0.5359901785850525f, -0.48090484738349915f, -0.38603779673576355f, -0.4991581439971924f};
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_conv_transpose_w_groups)
......@@ -276,10 +312,12 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_conv_transpose_w_groups)
16.f, 17.f, 18.f, 19.f, 20.f, 21.f, 22.f, 23.f,
24.f, 25.f, 26.f, 27.f, 28.f, 29.f, 30.f, 31.0f});
Outputs expected_output{
std::vector<float>{28.f, 34.f, 252.f, 274.f, 732.f, 770.f, 1468.f, 1522.f}};
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
std::vector<float> expected_output{28.f, 34.f, 252.f, 274.f, 732.f, 770.f, 1468.f, 1522.f};
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_average_pool_2d)
......@@ -299,9 +337,10 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_average_pool_2d)
// (1, 1, 2, 2)
auto expected_output = test::NDArray<float, 4>({{{{2.5f, 4.5f}, {10.5f, 12.5f}}}}).get_vector();
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_EQ(expected_output, outputs.front());
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_average_pool_2d_pads)
......@@ -323,9 +362,10 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_average_pool_2d_pads)
test::NDArray<float, 4>({{{{0.f, 1.5f, 3.f}, {6.f, 7.5f, 9.f}, {12.f, 13.5f, 15.f}}}})
.get_vector();
Outputs outputs = execute(function, inputs, "${BACKEND_NAME}");
EXPECT_EQ(expected_output, outputs.front());
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_max_pool_2d_pads)
......@@ -347,9 +387,10 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_max_pool_2d_pads)
test::NDArray<float, 4>({{{{0.f, 2.f, 3.f}, {8.f, 10.f, 11.f}, {12.f, 14.f, 15.f}}}})
.get_vector();
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_EQ(expected_output, outputs.front());
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_global_lp_pool_p0)
......@@ -357,14 +398,15 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_global_lp_pool_p0)
auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/global_lp_pool_p0.prototxt"));
std::vector<std::vector<std::int64_t>> inputs{std::vector<std::int64_t>{
1, 0, -4, 0, 2, 1, -6, 1, 0, 0, 0, 0, -7, 1, -1, 0, -1, 8, 0, 10, 9, 0, 0, 5}};
std::vector<std::vector<std::int64_t>> expected_outputs{std::vector<std::int64_t>{6, 8}};
std::vector<std::int64_t> input{1, 0, -4, 0, 2, 1, -6, 1, 0, 0, 0, 0,
-7, 1, -1, 0, -1, 8, 0, 10, 9, 0, 0, 5};
std::vector<std::vector<std::int64_t>> outputs{execute(function, inputs, "${BACKEND_NAME}")};
std::vector<std::int64_t> expected_output{6, 8};
EXPECT_TRUE(test::all_close(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_input(input);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_global_lp_pool_p1)
......@@ -375,11 +417,12 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_global_lp_pool_p1)
Inputs inputs{std::vector<float>(2 * 3 * 4)};
std::iota(std::begin(inputs.front()), std::end(inputs.front()), 0.f);
Outputs expected_outputs{std::vector<float>{66.f, 210.f}};
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
std::vector<float> expected_output{66.f, 210.f};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_global_lp_pool_p2)
......@@ -390,10 +433,12 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_global_lp_pool_p2)
Inputs inputs{std::vector<float>(2 * 3 * 4)};
std::iota(std::begin(inputs.front()), std::end(inputs.front()), 0.f);
Outputs expected_outputs{std::vector<float>{22.494444f, 61.789967f}};
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
std::vector<float> expected_output{22.494444f, 61.789967f};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_global_lp_pool_p3)
......@@ -404,11 +449,12 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_global_lp_pool_p3)
Inputs inputs{std::vector<float>(2 * 3 * 4)};
std::iota(std::begin(inputs.front()), std::end(inputs.front()), 0.f);
Outputs expected_outputs{std::vector<float>{16.331620904278438f, 41.56697946707537f}};
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
std::vector<float> expected_output{16.331620904278438f, 41.56697946707537f};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front(), 18));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_convtranspose_output_shape)
......
......@@ -46,16 +46,12 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_quantize_linear)
auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/quantize_linear.prototxt"));
Inputs inputs;
inputs.emplace_back(std::vector<float>{32.25f, 48.34f, 50.f, 83.f});
inputs.emplace_back(std::vector<float>{0.5f});
std::vector<std::vector<std::uint8_t>> expected_output{
std::vector<std::uint8_t>{64, 97, 100, 166}};
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_input(std::vector<float>{32.25f, 48.34f, 50.f, 83.f});
test_case.add_input(std::vector<float>{0.5f});
std::vector<std::vector<std::uint8_t>> outputs{
execute<float, std::uint8_t>(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close(expected_output.front(), outputs.front()));
test_case.add_expected_output(std::vector<std::uint8_t>{64, 97, 100, 166});
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_quantize_linear_zero_point)
......@@ -116,13 +112,11 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_dequantize_linear)
auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/dequant_lin.prototxt"));
std::vector<std::vector<std::uint8_t>> inputs;
inputs.emplace_back(std::vector<std::uint8_t>{19, 210, 21, 10});
Outputs expected_output{std::vector<float>{76.f, 840.f, 84.f, 40.f}};
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_input(std::vector<std::uint8_t>{19, 210, 21, 10});
Outputs outputs{execute<std::uint8_t, float>(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
test_case.add_expected_output(std::vector<float>{76.f, 840.f, 84.f, 40.f});
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_dequantize_linear_scalar_zero_scale_uint8)
......
......@@ -47,18 +47,20 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_reshape_reduced_dims)
file_util::path_join(SERIALIZED_ZOO, "onnx/reshape_reduced_dims.prototxt"));
// input data shape (2, 3, 4)
Inputs inputs{test::NDArray<float, 3>({{{0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11}},
{{12, 13, 14, 15}, {16, 17, 18, 19}, {20, 21, 22, 23}}})
.get_vector()};
auto input = test::NDArray<float, 3>({{{0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11}},
{{12, 13, 14, 15}, {16, 17, 18, 19}, {20, 21, 22, 23}}})
.get_vector();
// output data shape (2, 12)
Outputs expected_outputs{
auto expected_output =
test::NDArray<float, 2>({{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11},
{12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23}})
.get_vector()};
.get_vector();
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_input(Shape{2, 3, 4}, input);
test_case.add_expected_output(Shape{2, 12}, expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_reshape_reordered_dims)
......@@ -67,19 +69,21 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_reshape_reordered_dims)
file_util::path_join(SERIALIZED_ZOO, "onnx/reshape_reordered_dims.prototxt"));
// input data shape (2, 3, 4)
Inputs inputs{test::NDArray<float, 3>({{{0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11}},
{{12, 13, 14, 15}, {16, 17, 18, 19}, {20, 21, 22, 23}}})
.get_vector()};
auto input = test::NDArray<float, 3>({{{0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11}},
{{12, 13, 14, 15}, {16, 17, 18, 19}, {20, 21, 22, 23}}})
.get_vector();
// output data shape (4, 2, 3)
Outputs expected_outputs{test::NDArray<float, 3>({{{0, 1, 2}, {3, 4, 5}},
{{6, 7, 8}, {9, 10, 11}},
{{12, 13, 14}, {15, 16, 17}},
{{18, 19, 20}, {21, 22, 23}}})
.get_vector()};
auto expected_output = test::NDArray<float, 3>({{{0, 1, 2}, {3, 4, 5}},
{{6, 7, 8}, {9, 10, 11}},
{{12, 13, 14}, {15, 16, 17}},
{{18, 19, 20}, {21, 22, 23}}})
.get_vector();
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_input(Shape{2, 3, 4}, input);
test_case.add_expected_output(Shape{4, 2, 3}, expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_reshape_extended_dims)
......@@ -88,18 +92,20 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_reshape_extended_dims)
file_util::path_join(SERIALIZED_ZOO, "onnx/reshape_extended_dims.prototxt"));
// input data shape (2, 3, 4)
Inputs inputs{test::NDArray<float, 3>({{{0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11}},
{{12, 13, 14, 15}, {16, 17, 18, 19}, {20, 21, 22, 23}}})
.get_vector()};
auto input = test::NDArray<float, 3>({{{0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11}},
{{12, 13, 14, 15}, {16, 17, 18, 19}, {20, 21, 22, 23}}})
.get_vector();
// output data shape (3, 2, 2, 2)
Outputs expected_outputs{test::NDArray<float, 4>({{{{0, 1}, {2, 3}}, {{4, 5}, {6, 7}}},
{{{8, 9}, {10, 11}}, {{12, 13}, {14, 15}}},
{{{16, 17}, {18, 19}}, {{20, 21}, {22, 23}}}})
.get_vector()};
auto expected_output = test::NDArray<float, 4>({{{{0, 1}, {2, 3}}, {{4, 5}, {6, 7}}},
{{{8, 9}, {10, 11}}, {{12, 13}, {14, 15}}},
{{{16, 17}, {18, 19}}, {{20, 21}, {22, 23}}}})
.get_vector();
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_input(Shape{2, 3, 4}, input);
test_case.add_expected_output(Shape{3, 2, 2, 2}, expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_reshape_single_dim)
......@@ -108,18 +114,19 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_reshape_single_dim)
file_util::path_join(SERIALIZED_ZOO, "onnx/reshape_single_dim.prototxt"));
// input data shape (2, 3, 4)
Inputs inputs{test::NDArray<float, 3>({{{0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11}},
{{12, 13, 14, 15}, {16, 17, 18, 19}, {20, 21, 22, 23}}})
.get_vector()};
auto input = test::NDArray<float, 3>({{{0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11}},
{{12, 13, 14, 15}, {16, 17, 18, 19}, {20, 21, 22, 23}}})
.get_vector();
// output data shape (24, )
Outputs expected_outputs{
test::NDArray<float, 1>(
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23})
.get_vector()};
auto expected_output = test::NDArray<float, 1>({0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23})
.get_vector();
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_input(Shape{2, 3, 4}, input);
test_case.add_expected_output(Shape{24}, expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_reshape_negative_dim)
......@@ -129,33 +136,35 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_reshape_negative_dim)
file_util::path_join(SERIALIZED_ZOO, "onnx/reshape_negative_dim.prototxt"));
// 2x3x4
Inputs inputs{test::NDArray<float, 3>({{{0.5488135, 0.71518934, 0.60276335, 0.5448832},
{0.4236548, 0.6458941, 0.4375872, 0.891773},
{0.96366274, 0.3834415, 0.79172504, 0.5288949}},
auto input = test::NDArray<float, 3>({{{0.5488135, 0.71518934, 0.60276335, 0.5448832},
{0.4236548, 0.6458941, 0.4375872, 0.891773},
{0.96366274, 0.3834415, 0.79172504, 0.5288949}},
{{0.56804454, 0.92559665, 0.07103606, 0.0871293},
{0.0202184, 0.83261985, 0.77815676, 0.87001216},
{0.9786183, 0.7991586, 0.46147937, 0.7805292}}})
.get_vector()};
{{0.56804454, 0.92559665, 0.07103606, 0.0871293},
{0.0202184, 0.83261985, 0.77815676, 0.87001216},
{0.9786183, 0.7991586, 0.46147937, 0.7805292}}})
.get_vector();
// 2x6x2
Outputs expected_outputs{test::NDArray<float, 3>({{{0.5488135, 0.71518934},
{0.60276335, 0.5448832},
{0.4236548, 0.6458941},
{0.4375872, 0.891773},
{0.96366274, 0.3834415},
{0.79172504, 0.5288949}},
{{0.56804454, 0.92559665},
{0.07103606, 0.0871293},
{0.0202184, 0.83261985},
{0.77815676, 0.87001216},
{0.9786183, 0.7991586},
{0.46147937, 0.7805292}}})
.get_vector()};
auto expected_output = test::NDArray<float, 3>({{{0.5488135, 0.71518934},
{0.60276335, 0.5448832},
{0.4236548, 0.6458941},
{0.4375872, 0.891773},
{0.96366274, 0.3834415},
{0.79172504, 0.5288949}},
{{0.56804454, 0.92559665},
{0.07103606, 0.0871293},
{0.0202184, 0.83261985},
{0.77815676, 0.87001216},
{0.9786183, 0.7991586},
{0.46147937, 0.7805292}}})
.get_vector();
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_input(Shape{2, 3, 4}, input);
test_case.add_expected_output(Shape{2, 6, 2}, expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_reshape_negative_with_zero_dim)
......@@ -164,18 +173,20 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_reshape_negative_with_zero_dim)
file_util::path_join(SERIALIZED_ZOO, "onnx/reshape_negative_with_zero_dims.prototxt"));
// input data shape (2, 3, 4)
Inputs inputs{test::NDArray<float, 3>({{{0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11}},
{{12, 13, 14, 15}, {16, 17, 18, 19}, {20, 21, 22, 23}}})
.get_vector()};
auto input = test::NDArray<float, 3>({{{0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11}},
{{12, 13, 14, 15}, {16, 17, 18, 19}, {20, 21, 22, 23}}})
.get_vector();
// output data shape (2, 6, 2)
Outputs expected_outputs{
auto expected_output =
test::NDArray<float, 3>({{{0, 1}, {2, 3}, {4, 5}, {6, 7}, {8, 9}, {10, 11}},
{{12, 13}, {14, 15}, {16, 17}, {18, 19}, {20, 21}, {22, 23}}})
.get_vector()};
.get_vector();
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_input(Shape{2, 3, 4}, input);
test_case.add_expected_output(Shape{2, 6, 2}, expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_reshape_output_shape_as_input)
......@@ -184,18 +195,20 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_reshape_output_shape_as_input)
file_util::path_join(SERIALIZED_ZOO, "onnx/reshape_output_shape_as_input.prototxt"));
// input data shape (2, 3, 4)
Inputs inputs{test::NDArray<float, 3>({{{0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11}},
{{12, 13, 14, 15}, {16, 17, 18, 19}, {20, 21, 22, 23}}})
.get_vector()};
auto input = test::NDArray<float, 3>({{{0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11}},
{{12, 13, 14, 15}, {16, 17, 18, 19}, {20, 21, 22, 23}}})
.get_vector();
// output data shape (2, 6, 2)
Outputs expected_outputs{
auto expected_output =
test::NDArray<float, 3>({{{0, 1}, {2, 3}, {4, 5}, {6, 7}, {8, 9}, {10, 11}},
{{12, 13}, {14, 15}, {16, 17}, {18, 19}, {20, 21}, {22, 23}}})
.get_vector()};
.get_vector();
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_input(Shape{2, 3, 4}, input);
test_case.add_expected_output(Shape{2, 6, 2}, expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_depth_to_space)
......@@ -203,15 +216,16 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_depth_to_space)
auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/depth_to_space.prototxt"));
Inputs inputs;
inputs.emplace_back(std::vector<float>{
0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f, 10.f, 11.f, 12.f, 13.f, 14.f, 15.f});
std::vector<float> input{
0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f, 10.f, 11.f, 12.f, 13.f, 14.f, 15.f};
Outputs expected_output{std::vector<float>{
0.f, 4.f, 1.f, 5.f, 8.f, 12.f, 9.f, 13.f, 2.f, 6.f, 3.f, 7.f, 10.f, 14.f, 11.f, 15.f}};
std::vector<float> expected_output{
0.f, 4.f, 1.f, 5.f, 8.f, 12.f, 9.f, 13.f, 2.f, 6.f, 3.f, 7.f, 10.f, 14.f, 11.f, 15.f};
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_input(input);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_depth_to_space_chw)
......@@ -219,15 +233,16 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_depth_to_space_chw)
auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/depth_to_space_chw.prototxt"));
Inputs inputs;
inputs.emplace_back(std::vector<float>{
0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f, 10.f, 11.f, 12.f, 13.f, 14.f, 15.f});
std::vector<float> input{
0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f, 10.f, 11.f, 12.f, 13.f, 14.f, 15.f};
Outputs expected_output{std::vector<float>{
0.f, 4.f, 1.f, 5.f, 8.f, 12.f, 9.f, 13.f, 2.f, 6.f, 3.f, 7.f, 10.f, 14.f, 11.f, 15.f}};
std::vector<float> expected_output{
0.f, 4.f, 1.f, 5.f, 8.f, 12.f, 9.f, 13.f, 2.f, 6.f, 3.f, 7.f, 10.f, 14.f, 11.f, 15.f};
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_input(input);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_depth_to_space_bad_blocksize)
......@@ -252,19 +267,19 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_space_to_depth)
auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/space_to_depth.prototxt"));
Inputs inputs;
inputs.emplace_back(std::vector<float>{0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f,
8.f, 9.f, 10.f, 11.f, 12.f, 13.f, 14.f, 15.f,
16.f, 17.f, 18.f, 19.f, 20.f, 21.f, 22.f, 23.f,
24.f, 25.f, 26.f, 27.f, 28.f, 29.f, 30.f, 31.f});
std::vector<float> input{0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f, 10.f,
11.f, 12.f, 13.f, 14.f, 15.f, 16.f, 17.f, 18.f, 19.f, 20.f, 21.f,
22.f, 23.f, 24.f, 25.f, 26.f, 27.f, 28.f, 29.f, 30.f, 31.f};
Outputs expected_output{std::vector<float>{
std::vector<float> expected_output{
0.f, 2.f, 8.f, 10.f, 16.f, 18.f, 24.f, 26.f, 1.f, 3.f, 9.f, 11.f, 17.f, 19.f, 25.f, 27.f,
4.f, 6.f, 12.f, 14.f, 20.f, 22.f, 28.f, 30.f, 5.f, 7.f, 13.f, 15.f, 21.f, 23.f, 29.f, 31.f,
}};
};
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_input(input);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_space_to_depth_chw)
......@@ -272,19 +287,19 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_space_to_depth_chw)
auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/space_to_depth_chw.prototxt"));
Inputs inputs;
inputs.emplace_back(std::vector<float>{0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f,
8.f, 9.f, 10.f, 11.f, 12.f, 13.f, 14.f, 15.f,
16.f, 17.f, 18.f, 19.f, 20.f, 21.f, 22.f, 23.f,
24.f, 25.f, 26.f, 27.f, 28.f, 29.f, 30.f, 31.f});
std::vector<float> input{0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f, 10.f,
11.f, 12.f, 13.f, 14.f, 15.f, 16.f, 17.f, 18.f, 19.f, 20.f, 21.f,
22.f, 23.f, 24.f, 25.f, 26.f, 27.f, 28.f, 29.f, 30.f, 31.f};
Outputs expected_output{std::vector<float>{
std::vector<float> expected_output{
0.f, 2.f, 8.f, 10.f, 16.f, 18.f, 24.f, 26.f, 1.f, 3.f, 9.f, 11.f, 17.f, 19.f, 25.f, 27.f,
4.f, 6.f, 12.f, 14.f, 20.f, 22.f, 28.f, 30.f, 5.f, 7.f, 13.f, 15.f, 21.f, 23.f, 29.f, 31.f,
}};
};
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_input(input);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_space_to_depth_bad_blocksize)
......@@ -310,17 +325,19 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_squeeze)
file_util::path_join(SERIALIZED_ZOO, "onnx/squeeze_duplicate_axes.prototxt"));
// {1, 4, 1, 1, 2}
Inputs inputs{test::NDArray<float, 5>(
{{{{{1.0f, 2.0f}}}, {{{3.0f, 4.0f}}}, {{{5.0f, 6.0f}}}, {{{7.0f, 8.0f}}}}})
.get_vector()};
auto input = test::NDArray<float, 5>(
{{{{{1.0f, 2.0f}}}, {{{3.0f, 4.0f}}}, {{{5.0f, 6.0f}}}, {{{7.0f, 8.0f}}}}})
.get_vector();
// {4, 2}
Outputs expected_output{
auto expected_output =
test::NDArray<float, 2>({{1.0f, 2.0f}, {3.0f, 4.0f}, {5.0f, 6.0f}, {7.0f, 8.0f}})
.get_vector()};
.get_vector();
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_input(Shape{1, 4, 1, 1, 2}, input);
test_case.add_expected_output(Shape{4, 2}, expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_unsqueeze)
......@@ -328,22 +345,23 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_unsqueeze)
auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/unsqueeze.prototxt"));
Inputs inputs;
inputs.emplace_back(test::NDArray<float, 3>(
{{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}},
{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}},
{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}}})
.get_vector());
auto input = test::NDArray<float, 3>(
{{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}},
{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}},
{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}}})
.get_vector();
Outputs expected_output{
auto expected_output =
test::NDArray<float, 4>(
{{{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}},
{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}},
{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}}}})
.get_vector()};
.get_vector();
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_output.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_input(input);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_concat)
......@@ -356,10 +374,12 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_concat)
inputs.emplace_back(test::NDArray<float, 1>({1, 2}).get_vector());
inputs.emplace_back(test::NDArray<float, 1>({3, 4}).get_vector());
Outputs expected_outputs{test::NDArray<float, 1>({1, 2, 3, 4}).get_vector()};
auto expected_output = test::NDArray<float, 1>({1, 2, 3, 4}).get_vector();
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_multiple_inputs(inputs);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_flatten)
......@@ -367,15 +387,13 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_flatten)
auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/flatten.prototxt"));
Inputs inputs;
auto input = test::NDArray<float, 4>({{{{1, 2}, {3, 4}}, {{5, 6}, {7, 8}}}}).get_vector();
auto expected_output = test::NDArray<float, 3>({{{1, 2, 3, 4}, {5, 6, 7, 8}}}).get_vector();
inputs.emplace_back(
test::NDArray<float, 4>({{{{1, 2}, {3, 4}}, {{5, 6}, {7, 8}}}}).get_vector());
Outputs expected_outputs{test::NDArray<float, 3>({{{1, 2, 3, 4}, {5, 6, 7, 8}}}).get_vector()};
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_TRUE(test::all_close_f(expected_outputs.front(), outputs.front()));
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_input(input);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_split_equal_parts_default)
......@@ -402,17 +420,11 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_split_equal_parts_2d)
auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/split_equal_parts_2d.prototxt"));
Inputs inputs{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}};
Outputs expected_outputs{{0, 1, 2, 6, 7, 8}, {3, 4, 5, 9, 10, 11}};
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_EQ(outputs.size(), expected_outputs.size());
for (std::size_t i = 0; i < expected_outputs.size(); ++i)
{
EXPECT_EQ(outputs[i].size(), expected_outputs[i].size());
EXPECT_TRUE(test::all_close_f(outputs[i], expected_outputs[i]));
}
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_input<float>({0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11});
test_case.add_expected_output<float>({0, 1, 2, 6, 7, 8});
test_case.add_expected_output<float>({3, 4, 5, 9, 10, 11});
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_split_variable_parts_2d)
......@@ -421,17 +433,11 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_split_variable_parts_2d)
auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/split_variable_parts_2d.prototxt"));
Inputs inputs{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}};
Outputs expected_outputs{{0, 1, 6, 7}, {2, 3, 4, 5, 8, 9, 10, 11}};
Outputs outputs{execute(function, inputs, "${BACKEND_NAME}")};
EXPECT_EQ(outputs.size(), expected_outputs.size());
for (std::size_t i = 0; i < expected_outputs.size(); ++i)
{
EXPECT_EQ(outputs[i].size(), expected_outputs[i].size());
EXPECT_TRUE(test::all_close_f(outputs[i], expected_outputs[i]));
}
auto test_case = ngraph::test::NgraphTestCase(function, "${BACKEND_NAME}");
test_case.add_input<float>({0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11});
test_case.add_expected_output<float>({0, 1, 6, 7});
test_case.add_expected_output<float>({2, 3, 4, 5, 8, 9, 10, 11});
test_case.run();
}
NGRAPH_TEST(onnx_${BACKEND_NAME}, model_expand_static_shape)
......
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