1 //*****************************************************************************
2 // Copyright 2017-2020 Intel Corporation
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //*****************************************************************************
29 #ifdef ${BACKEND_NAME}_FLOAT_TOLERANCE_BITS
30 #define DEFAULT_FLOAT_TOLERANCE_BITS ${BACKEND_NAME}_FLOAT_TOLERANCE_BITS
32 #ifdef ${BACKEND_NAME}_DOUBLE_TOLERANCE_BITS
33 #define DEFAULT_DOUBLE_TOLERANCE_BITS ${BACKEND_NAME}_DOUBLE_TOLERANCE_BITS
37 #include "gtest/gtest.h"
38 #include "onnx_import/core/null_node.hpp"
39 #include "onnx_import/onnx.hpp"
40 #include "onnx_import/onnx_utils.hpp"
41 #include "onnx_import/default_opset.hpp"
42 #include "ngraph/ngraph.hpp"
43 #include "ngraph/pass/manager.hpp"
44 #include "ngraph/pass/constant_folding.hpp"
45 #include "util/all_close.hpp"
46 #include "util/all_close_f.hpp"
47 #include "util/ndarray.hpp"
48 #include "util/test_case.hpp"
49 #include "util/test_control.hpp"
50 #include "util/engine/test_engines.hpp"
51 #include "util/test_tools.hpp"
52 #include "util/type_prop.hpp"
54 NGRAPH_SUPPRESS_DEPRECATED_START
56 using namespace ngraph;
58 static std::string s_manifest = "${MANIFEST}";
60 using Inputs = std::vector<std::vector<float>>;
61 using Outputs = std::vector<std::vector<float>>;
63 using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME});
65 // ############################################################################ CORE TESTS
66 NGRAPH_TEST(${BACKEND_NAME}, onnx_test_test_case)
68 auto function = onnx_import::import_onnx_model(
69 file_util::path_join(SERIALIZED_ZOO, "onnx/add_abc.prototxt"));
71 auto test_case = test::TestCase<TestEngine>(function);
72 test_case.add_input<float>({1});
73 test_case.add_input<float>({2});
74 test_case.add_input<float>({3});
75 test_case.add_expected_output<float>(Shape{1}, {6});
79 NGRAPH_TEST(${BACKEND_NAME}, onnx_test_test_case_mutliple_inputs)
81 auto function = onnx_import::import_onnx_model(
82 file_util::path_join(SERIALIZED_ZOO, "onnx/add_abc.prototxt"));
84 auto test_case = test::TestCase<TestEngine>(function);
85 test_case.add_multiple_inputs(Inputs{{1}, {2}, {3}});
86 test_case.add_expected_output(Shape{1}, std::vector<float>{6});
90 NGRAPH_TEST(${BACKEND_NAME}, onnx_output_names_check)
92 auto function = onnx_import::import_onnx_model(
93 file_util::path_join(SERIALIZED_ZOO, "onnx/split_equal_parts_default.prototxt"));
95 std::size_t size = function->get_output_size();
96 for (std::size_t i{0}; i < size; ++i)
98 std::shared_ptr<Node> node = function->get_output_op(i);
99 EXPECT_EQ(node->get_friendly_name(), "output_" + std::to_string(i + 1));
103 NGRAPH_TEST(${BACKEND_NAME}, onnx_node_names_check)
105 auto function = onnx_import::import_onnx_model(
106 file_util::path_join(SERIALIZED_ZOO, "onnx/add_abc.prototxt"));
108 // Filter out Add nodes from the function graph
109 std::vector<std::shared_ptr<Node>> additions;
110 auto ordered_ops = function->get_ordered_ops();
114 std::back_inserter(additions),
115 [](std::shared_ptr<Node> op) { return std::string(op->get_type_name()) == "Add"; });
117 EXPECT_EQ(additions.size(), 2);
118 EXPECT_EQ(additions.at(0)->get_friendly_name(), "X");
119 EXPECT_EQ(additions.at(1)->get_friendly_name(), "Y");
122 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_add_abc)
124 auto function = onnx_import::import_onnx_model(
125 file_util::path_join(SERIALIZED_ZOO, "onnx/add_abc.prototxt"));
127 auto test_case = test::TestCase<TestEngine>(function);
128 test_case.add_multiple_inputs(Inputs{{1}, {2}, {3}});
129 test_case.add_expected_output(Shape{1}, std::vector<float>{6});
133 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_binary_add_abc)
136 onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/add_abc.onnx"));
138 auto test_case = test::TestCase<TestEngine>(function);
139 test_case.add_multiple_inputs(Inputs{{1}, {2}, {3}});
140 test_case.add_expected_output(Shape{1}, std::vector<float>{6});
144 NGRAPH_TEST(${BACKEND_NAME}, onnx_bool_const_op)
146 auto function = onnx_import::import_onnx_model(
147 file_util::path_join(SERIALIZED_ZOO, "onnx/bool_const_op.prototxt"));
149 auto test_case = test::TestCase<TestEngine>(function);
150 test_case.add_expected_output(std::vector<bool>{1, 0, 0, 1});
154 NGRAPH_TEST(${BACKEND_NAME}, onnx_bool_init_and)
156 auto function = onnx_import::import_onnx_model(
157 file_util::path_join(SERIALIZED_ZOO, "onnx/bool_init_and.prototxt"));
159 auto test_case = test::TestCase<TestEngine>(function);
160 test_case.add_expected_output(std::vector<bool>{1});
164 NGRAPH_TEST(${BACKEND_NAME}, onnx_bool_input_or)
166 auto function = onnx_import::import_onnx_model(
167 file_util::path_join(SERIALIZED_ZOO, "onnx/bool_input_or.prototxt"));
169 auto test_case = test::TestCase<TestEngine>(function);
170 test_case.add_input(std::vector<bool>{true, false, true, false});
171 test_case.add_input(std::vector<bool>{false, false, true, true});
172 test_case.add_expected_output(std::vector<bool>{1, 0, 1, 1});
176 NGRAPH_TEST(${BACKEND_NAME}, onnx_bool_init_raw)
178 auto function = onnx_import::import_onnx_model(
179 file_util::path_join(SERIALIZED_ZOO, "onnx/bool_init_raw.prototxt"));
181 auto test_case = test::TestCase<TestEngine>(function);
182 test_case.add_expected_output(std::vector<bool>{true, false, true});
186 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_add_abc_initializers)
188 auto function = onnx_import::import_onnx_model(
189 file_util::path_join(SERIALIZED_ZOO, "onnx/add_abc_initializers.prototxt"));
191 auto test_case = test::TestCase<TestEngine>(function);
192 test_case.add_input<float>({1, 2, 3, 4});
193 test_case.add_expected_output<float>({3, 6, 9, 12});
197 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_override_op)
199 onnx_import::register_operator(
200 "FalseAdd", 1, "", [](const onnx_import::Node& node) -> OutputVector {
201 OutputVector ng_inputs{node.get_ng_inputs()};
202 return {std::make_shared<ngraph::op::Add>(ng_inputs.at(0), ng_inputs.at(1))};
205 onnx_import::register_operator(
206 "FalseAdd", 1, "", [](const onnx_import::Node& node) -> OutputVector {
207 OutputVector ng_inputs{node.get_ng_inputs()};
208 return {std::make_shared<ngraph::op::Subtract>(ng_inputs.at(0), ng_inputs.at(1))};
211 auto function = onnx_import::import_onnx_model(
212 file_util::path_join(SERIALIZED_ZOO, "onnx/override_op.prototxt"));
215 inputs.emplace_back(std::vector<float>{0.f, 1.f, 2.f, 3.f});
216 inputs.emplace_back(std::vector<float>{3.f, 2.f, 1.f, 0.f});
218 auto test_case = test::TestCase<TestEngine>(function);
219 test_case.add_multiple_inputs(inputs);
220 test_case.add_expected_output<float>({-3.f, -1.f, 1.f, 3.f});
224 NGRAPH_TEST(${BACKEND_NAME}, onnx_import_non_existing_file)
228 onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/i.dont.exist"));
230 catch (const std::runtime_error& exc)
232 // asserts that an exception was thrown and that the error message contains the file name
233 std::string msg{exc.what()};
234 EXPECT_TRUE(msg.find("i.dont.exist") != std::string::npos);
238 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_unsupported_op)
242 onnx_import::import_onnx_model(
243 file_util::path_join(SERIALIZED_ZOO, "onnx/unsupported_op.prototxt"));
244 FAIL() << "Expected ngraph::ngraph_error";
246 catch (ngraph::ngraph_error const& err)
248 std::string what{err.what()};
249 EXPECT_NE(what.find("nGraph does not support"), std::string::npos);
250 EXPECT_NE(what.find("FakeOpName"), std::string::npos);
251 EXPECT_NE(what.find("AnotherFakeOpName"), std::string::npos);
255 FAIL() << "Expected ngraph::ngraph_error";
259 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_custom_op)
261 onnx_import::register_operator(
262 "AddQ", 1, "com.intel.ai", [](const onnx_import::Node& node) -> OutputVector {
263 OutputVector ng_inputs{node.get_ng_inputs()};
264 return {std::make_shared<ngraph::op::Add>(ng_inputs.at(0), ng_inputs.at(1))};
267 auto function = onnx_import::import_onnx_model(
268 file_util::path_join(SERIALIZED_ZOO, "onnx/custom_operator.prototxt"));
270 auto test_case = test::TestCase<TestEngine>(function);
271 test_case.add_input<float>({1.f, 2.f, 3.f, 4.f});
272 test_case.add_expected_output<float>({3.f, 6.f, 9.f, 12.f});
276 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_custom_op_register_unregister)
278 onnx_import::register_operator(
279 "AddQ", 1, "com.intel.ai", [](const onnx_import::Node& node) -> OutputVector {
280 OutputVector ng_inputs{node.get_ng_inputs()};
281 return {std::make_shared<ngraph::op::Add>(ng_inputs.at(0), ng_inputs.at(1))};
284 auto function = onnx_import::import_onnx_model(
285 file_util::path_join(SERIALIZED_ZOO, "onnx/custom_operator.prototxt"));
287 auto test_case = test::TestCase<TestEngine>(function);
288 test_case.add_input<float>({1.f, 2.f, 3.f, 4.f});
289 test_case.add_expected_output<float>({3.f, 6.f, 9.f, 12.f});
292 onnx_import::unregister_operator("AddQ", 1, "com.intel.ai");
295 auto function = onnx_import::import_onnx_model(
296 file_util::path_join(SERIALIZED_ZOO, "onnx/custom_operator.prototxt"));
297 FAIL() << "Expected ngraph::ngraph_error";
299 catch (ngraph::ngraph_error const& err)
301 std::string what{err.what()};
302 EXPECT_NE(what.find("Check 'unknown_operators.empty()' failed"), std::string::npos);
306 FAIL() << "Expected ngraph::ngraph_error";
310 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_custom_op_default_domain)
312 onnx_import::register_operator(
313 "AddQ", 1, "com.intel.ai", [](const onnx_import::Node& node) -> OutputVector {
314 OutputVector ng_inputs{node.get_ng_inputs()};
315 return {std::make_shared<ngraph::op::Add>(ng_inputs.at(0), ng_inputs.at(1))};
318 auto function = onnx_import::import_onnx_model(
319 file_util::path_join(SERIALIZED_ZOO, "onnx/custom_operator_default_domain.prototxt"));
321 auto test_case = test::TestCase<TestEngine>(function);
322 test_case.add_input<float>({1.f, 2.f, 3.f, 4.f});
323 test_case.add_expected_output<float>({3.f, 6.f, 9.f, 12.f});
327 NGRAPH_TEST(${BACKEND_NAME}, onnx_is_op_supported)
330 EXPECT_TRUE(onnx_import::is_operator_supported("Sum", 1, "ai.onnx"));
332 EXPECT_TRUE(onnx_import::is_operator_supported("Sum", 100, "ai.onnx"));
334 // Different opset versions
335 EXPECT_TRUE(onnx_import::is_operator_supported("Add", 1, "ai.onnx"));
336 EXPECT_TRUE(onnx_import::is_operator_supported("Add", 7, "ai.onnx"));
338 // Default domain name
339 EXPECT_TRUE(onnx_import::is_operator_supported("Sum", 1));
341 // Unregistered operator
342 EXPECT_FALSE(onnx_import::is_operator_supported("DummyOp", 1));
343 EXPECT_FALSE(onnx_import::is_operator_supported("DummyOp", 1, "ai.onnx"));
344 EXPECT_FALSE(onnx_import::is_operator_supported("DummyOp", 10, "ai.onnx"));
346 // Operator with bad domain name
347 EXPECT_FALSE(onnx_import::is_operator_supported("Sum", 1, "bad.domain"));
349 // Registered custom operator
350 onnx_import::register_operator(
351 "AddQ", 1, "com.intel.ai", [](const onnx_import::Node& node) -> OutputVector {
352 OutputVector ng_inputs{node.get_ng_inputs()};
353 return {std::make_shared<ngraph::op::Add>(ng_inputs.at(0), ng_inputs.at(1))};
355 EXPECT_TRUE(onnx_import::is_operator_supported("AddQ", 1, "com.intel.ai"));
358 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_missing_op_domain)
360 onnx_import::register_operator(
361 "CustomAdd", 1, "custom.op", [](const onnx_import::Node& node) -> OutputVector {
362 OutputVector ng_inputs{node.get_ng_inputs()};
363 return {std::make_shared<ngraph::op::Add>(ng_inputs.at(0), ng_inputs.at(1))};
366 EXPECT_TRUE(onnx_import::is_operator_supported("CustomAdd", 1, "custom.op"));
368 auto function = onnx_import::import_onnx_model(
369 file_util::path_join(SERIALIZED_ZOO, "onnx/missing_op_domain.prototxt"));
372 inputs.emplace_back(std::vector<float>{0.f, 1.f, 2.f, 3.f});
373 inputs.emplace_back(std::vector<float>{0.f, 1.f, 2.f, 3.f});
375 auto test_case = test::TestCase<TestEngine>(function);
376 test_case.add_multiple_inputs(inputs);
377 test_case.add_expected_output<float>({0.f, 2.f, 4.f, 6.f});
381 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_unknown_domain)
383 // the importer should not throw when it encounters an unknown domain in the model
384 EXPECT_NO_THROW(onnx_import::import_onnx_model(
385 file_util::path_join(SERIALIZED_ZOO, "onnx/unknown_domain.prototxt")));
388 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_op_in_unknown_domain)
392 onnx_import::import_onnx_model(
393 file_util::path_join(SERIALIZED_ZOO, "onnx/unknown_domain_add.prototxt"));
395 FAIL() << "The onnx_importer did not throw for unknown domain and op";
397 catch (const ngraph::ngraph_error& e)
399 const std::string msg = e.what();
401 EXPECT_NE(msg.find("unknown.domain.Add"), std::string::npos)
402 << "The error message should contain domain and op name: unknown.domain.Add";
406 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_missing_input)
408 onnx_import::register_operator(
409 "TestMissingInOut", 1, "com.intel.ai", [](const onnx_import::Node& node) -> OutputVector {
410 OutputVector ng_inputs{node.get_ng_inputs()};
411 Output<ngraph::Node> A = ng_inputs.at(0);
412 Output<ngraph::Node> B = ng_inputs.at(1);
413 Output<ngraph::Node> C = ng_inputs.at(2);
416 if (!ngraph::op::is_null(B))
425 onnx_import::register_operator(
426 "TestMissingIn", 1, "com.intel.ai", [](const onnx_import::Node& node) -> OutputVector {
427 OutputVector ng_inputs{node.get_ng_inputs()};
428 std::shared_ptr<ngraph::Node> result = std::make_shared<ngraph::op::Constant>(
429 element::f32, ngraph::Shape{2, 2}, std::vector<float>{1, 1, 1, 1});
431 for (const auto& ng_input : ng_inputs)
433 if (!ngraph::op::is_null(ng_input))
435 result = ng_input * result;
442 auto function = onnx_import::import_onnx_model(
443 file_util::path_join(SERIALIZED_ZOO, "onnx/missing_input.prototxt"));
445 Inputs inputs{{1, 2, 3, 4}, {5, 6, 7, 8}};
447 auto test_case = test::TestCase<TestEngine>(function);
448 test_case.add_multiple_inputs(inputs);
449 test_case.add_expected_output<float>({50, 144, 294, 512});
453 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_initializer_wo_input)
455 // This test checks a model which has an initializer, but no input with the same name
456 auto function = onnx_import::import_onnx_model(
457 file_util::path_join(SERIALIZED_ZOO, "onnx/initializer_wo_input.prototxt"));
459 auto test_case = test::TestCase<TestEngine>(function);
460 test_case.add_input<float>({0, 1, 2, 3, 4, 5});
461 test_case.add_expected_output<float>({0, 2, 6, 12, 20, 30});
465 // ############################################################################ OPERATOR TESTS
466 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_addmul_abc)
468 auto function = onnx_import::import_onnx_model(
469 file_util::path_join(SERIALIZED_ZOO, "onnx/addmul_abc.prototxt"));
471 auto test_case = test::TestCase<TestEngine>(function);
472 test_case.add_input<float>({9, 10, 11, 12});
473 test_case.add_input<float>({5, 6, 7, 8});
474 test_case.add_input<float>({1, 2, 3, 4});
475 test_case.add_expected_output<float>(Shape{1, 2, 2}, {46, 62, 80, 100});
479 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_argmin_no_keepdims)
481 auto function = onnx_import::import_onnx_model(
482 file_util::path_join(SERIALIZED_ZOO, "onnx/argmin_no_keepdims.prototxt"));
484 auto test_case = test::TestCase<TestEngine>(function);
485 test_case.add_input<float>({2, 1, 3, 10});
486 test_case.add_expected_output<float>(Shape{2}, {1, 0});
490 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_batch_norm_default)
492 // Batch Normalization with default parameters
493 auto function = onnx_import::import_onnx_model(
494 file_util::path_join(SERIALIZED_ZOO, "onnx/batchnorm_default.prototxt"));
496 auto test_case = test::TestCase<TestEngine>(function);
497 test_case.add_input<float>({-1.f, 0.f, 1.f, 2.f, 3.f, 4.f}); // data {1, 2, 1, 3}
498 test_case.add_input<float>({1.f, 1.5f}); // scale
499 test_case.add_input<float>({0.f, 1.f}); // bias
500 test_case.add_input<float>({0.f, 3.f}); // mean
501 test_case.add_input<float>({1.f, 1.5f}); // var
502 test_case.add_expected_output<float>(
503 Shape{1, 2, 1, 3}, {-0.999995f, 0.f, 0.999995f, -0.22474074f, 1.f, 2.2247407f});
507 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_relu)
511 onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/relu.prototxt"));
513 auto test_case = test::TestCase<TestEngine>(function);
514 test_case.add_input<float>({-1, -2, 0, 1, 2, 3});
515 test_case.add_expected_output<float>({0, 0, 0, 1, 2, 3});
519 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_sum_opset1)
521 // Simple Sum test for opset1.
522 auto function = onnx_import::import_onnx_model(
523 file_util::path_join(SERIALIZED_ZOO, "onnx/sum_opset1.prototxt"));
525 auto test_case = test::TestCase<TestEngine>(function);
526 test_case.add_input<float>({3.f, 0.f, 2.f});
527 test_case.add_input<float>({1.f, 3.f, 4.f});
528 test_case.add_input<float>({2.f, 6.f, 6.f});
529 test_case.add_expected_output<float>(Shape{3}, {6.f, 9.f, 12.f});
533 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_sum)
535 // Simple Sum test for opset8.
537 onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/sum.prototxt"));
539 auto test_case = test::TestCase<TestEngine>(function);
540 test_case.add_input<float>({3.f});
541 test_case.add_input<float>({1.f, 3.f, 4.f});
542 test_case.add_input<float>({2.f, 6.f, 6.f});
543 test_case.add_expected_output<float>(Shape{3}, {6.f, 12.f, 13.f});
547 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_sum_one_input)
549 auto function = onnx_import::import_onnx_model(
550 file_util::path_join(SERIALIZED_ZOO, "onnx/sum_one_input.prototxt"));
552 // input data shape (3, )
553 auto test_case = test::TestCase<TestEngine>(function);
554 test_case.add_input<float>({3.f, 0.f, 2.f});
555 test_case.add_expected_output<float>({3.f, 0.f, 2.f});
559 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_cum_sum_1d)
561 auto function = onnx_import::import_onnx_model(
562 file_util::path_join(SERIALIZED_ZOO, "onnx/cum_sum_1d.prototxt"));
564 auto test_case = test::TestCase<TestEngine>(function);
565 test_case.add_input<float>({1.f, 2.f, 3.f});
566 test_case.add_expected_output<float>(Shape{3}, {1.f, 3.f, 6.f});
570 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_cum_sum_2d_axis_input)
572 auto function = onnx_import::import_onnx_model(
573 file_util::path_join(SERIALIZED_ZOO, "onnx/cum_sum_2d_axis_input.prototxt"));
575 auto test_case = test::TestCase<TestEngine>(function);
576 test_case.add_input<float>({1.f, 2.f, 3.f, 4.f, 5.f, 6.f});
577 test_case.add_expected_output<float>(Shape{2, 3}, {1.f, 3.f, 6.f, 4.f, 9.f, 15.f});
581 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_cum_sum_2d_dynamic_axis_input)
583 auto function = onnx_import::import_onnx_model(
584 file_util::path_join(SERIALIZED_ZOO, "onnx/cum_sum_2d_dynamic_axis_input.prototxt"));
586 auto test_case = test::TestCase<TestEngine>(function);
587 test_case.add_input<float>({1.f, 2.f, 3.f, 4.f, 5.f, 6.f});
588 test_case.add_input<std::int32_t>({1});
589 test_case.add_expected_output<float>(Shape{2, 3}, {1.f, 3.f, 6.f, 4.f, 9.f, 15.f});
593 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_cum_sum_3d_exclusive_reverse)
595 auto function = onnx_import::import_onnx_model(
596 file_util::path_join(SERIALIZED_ZOO, "onnx/cum_sum_3d_exclusive_reverse.prototxt"));
598 auto test_case = test::TestCase<TestEngine>(function);
599 test_case.add_input<float>({1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f,
600 9.f, 10.f, 11.f, 12.f, 13.f, 14.f, 15.f, 16.f,
601 17.f, 18.f, 19.f, 20.f, 21.f, 22.f, 23.f, 24.f});
602 test_case.add_expected_output<float>(
603 Shape{2, 3, 4}, {13.f, 14.f, 15.f, 16.f, 17.f, 18.f, 19.f, 20.f, 21.f, 22.f, 23.f, 24.f,
604 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f});
608 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_min_two_inputs_opset1)
610 auto function = onnx_import::import_onnx_model(
611 file_util::path_join(SERIALIZED_ZOO, "onnx/min_two_inputs_opset1.prototxt"));
613 // input data shape (3, )
614 auto test_case = test::TestCase<TestEngine>(function);
615 test_case.add_input<float>({1.f, 2.f, 1.f});
616 test_case.add_input<float>({1.f, 4.f, 4.f});
617 test_case.add_expected_output<float>({1.f, 2.f, 1.f});
621 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_min_two_inputs)
623 auto function = onnx_import::import_onnx_model(
624 file_util::path_join(SERIALIZED_ZOO, "onnx/min_two_inputs.prototxt"));
626 // input data shape (3, )
627 auto test_case = test::TestCase<TestEngine>(function);
628 test_case.add_input<float>({2.f});
629 test_case.add_input<float>({1.f, 4.f, 4.f});
630 test_case.add_expected_output<float>({1.f, 2.f, 2.f});
634 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_max_opset1)
636 auto function = onnx_import::import_onnx_model(
637 file_util::path_join(SERIALIZED_ZOO, "onnx/max_opset1.prototxt"));
639 // input data shape (3, )
640 auto test_case = test::TestCase<TestEngine>(function);
641 test_case.add_input<float>({3.f, 2.f, 1.f});
642 test_case.add_input<float>({1.f, 4.f, 4.f});
643 test_case.add_input<float>({2.f, 5.f, 3.f});
645 test_case.add_expected_output<float>({3.f, 5.f, 4.f});
649 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_max)
652 onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/max.prototxt"));
654 // input data shape (3, )
655 auto test_case = test::TestCase<TestEngine>(function);
656 test_case.add_input<float>({1.f, 4.f, 4.f});
657 test_case.add_input<float>({3.f});
658 test_case.add_input<float>({2.f, 5.f, 3.f});
660 test_case.add_expected_output<float>({3.f, 5.f, 4.f});
664 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_mean_opset1)
666 auto function = onnx_import::import_onnx_model(
667 file_util::path_join(SERIALIZED_ZOO, "onnx/mean_opset1.prototxt"));
669 // input data shape (3, )
670 auto test_case = test::TestCase<TestEngine>(function);
671 test_case.add_input<float>({3.f, 0.f, 2.f});
672 test_case.add_input<float>({1.f, 3.f, 4.f});
673 test_case.add_input<float>({2.f, 6.f, 6.f});
675 test_case.add_expected_output<float>({2.f, 3.f, 4.f});
679 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_mean)
682 onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/mean.prototxt"));
684 // input data shape (3, )
685 auto test_case = test::TestCase<TestEngine>(function);
686 test_case.add_input<float>({3.f});
687 test_case.add_input<float>({1.f, 2.f, 5.f});
688 test_case.add_input<float>({2.f, 7.f, 7.f});
690 test_case.add_expected_output<float>({2.f, 4.f, 5.f});
694 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_gemm_abc)
696 auto function = onnx_import::import_onnx_model(
697 file_util::path_join(SERIALIZED_ZOO, "onnx/gemm_abc.prototxt"));
700 inputs.emplace_back(test::NDArray<float, 2>(
701 {{1, 2, 3, 4, 5, 6}, {7, 8, 9, 10, 11, 12}, {13, 14, 15, 16, 17, 18}})
704 inputs.emplace_back(test::NDArray<float, 2>({{19, 20, 21, 22},
713 test::NDArray<float, 2>({{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}}).get_vector());
715 auto expected_output =
716 test::NDArray<float, 2>(
717 {{340, 350.5, 361, 371.5}, {862, 890.5, 919, 947.5}, {1384, 1430.5, 1477, 1523.5}})
720 auto test_case = test::TestCase<TestEngine>(function);
721 test_case.add_multiple_inputs(inputs);
722 test_case.add_expected_output(expected_output);
726 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_matmul)
728 auto function = onnx_import::import_onnx_model(
729 file_util::path_join(SERIALIZED_ZOO, "onnx/matmul.prototxt"));
731 std::vector<std::vector<float>> inputs;
734 test::NDArray<float, 2>({{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}}).get_vector());
737 test::NDArray<float, 2>({{13, 14, 15}, {16, 17, 18}, {19, 20, 21}, {22, 23, 24}})
740 auto expected_output =
741 test::NDArray<float, 2>({{190, 200, 210}, {470, 496, 522}, {750, 792, 834}}).get_vector();
743 auto test_case = test::TestCase<TestEngine>(function);
744 test_case.add_multiple_inputs(inputs);
745 test_case.add_expected_output(expected_output);
749 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_softmax_0D)
751 auto function = onnx_import::import_onnx_model(
752 file_util::path_join(SERIALIZED_ZOO, "onnx/softmax_0D.prototxt"));
754 auto test_case = test::TestCase<TestEngine>(function);
755 test_case.add_input<float>({3.141592});
756 test_case.add_expected_output<float>({1.0});
760 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_softmax_1D)
762 auto function = onnx_import::import_onnx_model(
763 file_util::path_join(SERIALIZED_ZOO, "onnx/softmax_1D.prototxt"));
765 auto test_case = test::TestCase<TestEngine>(function);
766 test_case.add_input<float>({-1.0, 0.0, 1.0});
767 test_case.add_expected_output<float>({0.09003058, 0.24472848, 0.66524094});
772 // common input for all Softmax 3D test cases (Shape = {3,4,5})
773 const std::vector<float> SOFTMAX_INPUT = {
774 2.75793882, -0.50841322, 0.82013929, -0.62409912, -0.96136118, 0.21004745, 1.38337255,
775 1.19030397, 2.0940445, -0.03551657, -0.78686039, 1.992782, 0.04300319, -0.29230777,
776 -0.56797112, -1.26732165, -0.61935399, 0.57670432, 0.92844898, 2.82469233,
778 0.98721677, -0.05100663, -1.21178917, -0.17530157, 1.40051805, -0.13259761, -1.14313018,
779 0.2673723, -0.87996154, 1.29053106, 1.55, 0.8396538, 1.20729817, 0.23727845,
780 -0.89113606, -1.70909842, 0.26460363, -0.70566808, 2.383518, 1.07024615,
782 -1.21722605, 0.82919357, 0.55765697, 0.12657686, 0.63432172, 0.75425957, -2.43721014,
783 -1.24478184, 2.65316853, 1.19509542, -0.95523998, 0.5149006, -0.01151649, 0.68327026,
784 -0.4589638, -0.46554745, 0.21055324, 0.39266729, 2.05098086, 1.83207919};
787 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_softmax_axis_0)
789 auto function = onnx_import::import_onnx_model(
790 file_util::path_join(SERIALIZED_ZOO, "onnx/softmax_axis_0.prototxt"));
792 auto test_case = test::TestCase<TestEngine>(function);
793 test_case.add_input<float>(SOFTMAX_INPUT);
795 test_case.add_expected_output<float>(
796 {0.09683057, 0.00369363, 0.01394559, 0.00329012, 0.00234823, 0.00757665, 0.02449322,
797 0.02019284, 0.04985249, 0.00592694, 0.00279593, 0.04505148, 0.00641108, 0.00458466,
798 0.00348007, 0.00172928, 0.00330577, 0.01093237, 0.01554086, 0.10351497,
800 0.01648154, 0.00583583, 0.00182802, 0.00515374, 0.02491679, 0.00537859, 0.00195794,
801 0.00802367, 0.00254737, 0.0223216, 0.02893419, 0.0142204, 0.02053893, 0.00778581,
802 0.00251907, 0.00111174, 0.00800149, 0.0030324, 0.06658917, 0.0179084,
804 0.00181811, 0.01407243, 0.01072611, 0.0069699, 0.01158077, 0.01305647, 0.00053677,
805 0.0017687, 0.08719896, 0.02028982, 0.00236265, 0.01027717, 0.0060709, 0.01216173,
806 0.00388087, 0.00385541, 0.00758048, 0.00909469, 0.04775123, 0.03836337});
811 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_softmax_axis_1)
813 auto function = onnx_import::import_onnx_model(
814 file_util::path_join(SERIALIZED_ZOO, "onnx/softmax_axis_1.prototxt"));
816 auto test_case = test::TestCase<TestEngine>(function);
817 test_case.add_input<float>(SOFTMAX_INPUT);
819 test_case.add_expected_output<float>(
820 {0.22757064, 0.00868076, 0.03277484, 0.00773243, 0.0055188, 0.0178066, 0.05756383,
821 0.04745709, 0.11716303, 0.01392945, 0.00657097, 0.10587974, 0.01506727, 0.01077484,
822 0.00817884, 0.00406413, 0.00776921, 0.0256932, 0.03652405, 0.24328028,
824 0.06217413, 0.02201481, 0.00689594, 0.01944171, 0.09399488, 0.02028993, 0.00738604,
825 0.03026811, 0.00960958, 0.08420492, 0.10914991, 0.05364435, 0.07748005, 0.02937079,
826 0.0095028, 0.00419387, 0.03018442, 0.01143929, 0.2511977, 0.06755678,
828 0.00587593, 0.04548053, 0.0346656, 0.02252594, 0.03742775, 0.04219705, 0.00173478,
829 0.00571623, 0.2818174, 0.06557446, 0.00763582, 0.03321466, 0.01962049, 0.03930537,
830 0.01254255, 0.01246025, 0.02449929, 0.02939305, 0.15432668, 0.12398617});
835 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_softmax_invalid_axis_1D)
837 ASSERT_THROW(onnx_import::import_onnx_model(
838 file_util::path_join(SERIALIZED_ZOO, "onnx/softmax_invalid_axis_1D.prototxt")),
839 ngraph::ngraph_error)
840 << "Softmax model with invalid axis was successfully imported while it should have thrown.";
843 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_softmax_invalid_axis_3D)
845 ASSERT_THROW(onnx_import::import_onnx_model(
846 file_util::path_join(SERIALIZED_ZOO, "onnx/softmax_invalid_axis_3D.prototxt")),
847 ngraph::ngraph_error)
848 << "Softmax model with invalid axis was successfully imported while it should have thrown.";
851 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_sub)
854 onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/sub.prototxt"));
857 inputs.emplace_back(test::NDArray<float, 3>({{{1, 2, 3}}}).get_vector());
859 inputs.emplace_back(test::NDArray<float, 3>({{{4, 5, 7}}}).get_vector());
861 auto expected_output = test::NDArray<float, 3>({{{-3, -3, -4}}}).get_vector();
863 auto test_case = test::TestCase<TestEngine>(function);
864 test_case.add_multiple_inputs(inputs);
865 test_case.add_expected_output(expected_output);
869 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_div)
872 onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/div.prototxt"));
875 inputs.emplace_back(test::NDArray<float, 3>({{{1, 2, 3}}}).get_vector());
876 inputs.emplace_back(test::NDArray<float, 3>({{{1, 4, 12}}}).get_vector());
878 auto expected_output = test::NDArray<float, 3>({{{1, 0.5, 0.25}}}).get_vector();
880 auto test_case = test::TestCase<TestEngine>(function);
881 test_case.add_multiple_inputs(inputs);
882 test_case.add_expected_output(expected_output);
886 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_add_bcast)
888 auto function = onnx_import::import_onnx_model(
889 file_util::path_join(SERIALIZED_ZOO, "onnx/add_bcast.prototxt"));
892 inputs.emplace_back(test::NDArray<float, 3>(
893 {{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}},
894 {{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}},
895 {{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}}})
898 inputs.emplace_back(test::NDArray<float, 1>({1, 2, 3, 4, 5}).get_vector());
900 auto expected_output =
901 test::NDArray<float, 4>(
902 {{{{2, 3, 4, 5, 6}, {2, 3, 4, 5, 6}, {2, 3, 4, 5, 6}, {2, 3, 4, 5, 6}},
903 {{2, 3, 4, 5, 6}, {2, 3, 4, 5, 6}, {2, 3, 4, 5, 6}, {2, 3, 4, 5, 6}},
904 {{2, 3, 4, 5, 6}, {2, 3, 4, 5, 6}, {2, 3, 4, 5, 6}, {2, 3, 4, 5, 6}}}})
907 auto test_case = test::TestCase<TestEngine>(function);
908 test_case.add_multiple_inputs(inputs);
909 test_case.add_expected_output(expected_output);
913 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_reduce_log_sum)
915 auto function = onnx_import::import_onnx_model(
916 file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_log_sum.prototxt"));
918 // input data shape (1, 1, 4, 4)
920 test::NDArray<float, 4>({{{{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}}}})
923 // output data shape (1,)
924 auto expected_output = test::NDArray<float, 4>({{{{2.77258872f}}}}).get_vector();
926 auto test_case = test::TestCase<TestEngine>(function);
927 test_case.add_multiple_inputs(inputs);
928 test_case.add_expected_output(expected_output);
932 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_reduce_log_sum_exp)
934 auto function = onnx_import::import_onnx_model(
935 file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_log_sum_exp.prototxt"));
937 // input data shape (1, 1, 4, 4)
939 test::NDArray<float, 4>({{{{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}}}})
942 // output data shape (1,)
943 auto expected_output = test::NDArray<float, 4>({{{{3.77258872f}}}}).get_vector();
945 auto test_case = test::TestCase<TestEngine>(function);
946 test_case.add_multiple_inputs(inputs);
947 test_case.add_expected_output(expected_output);
951 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_reduce_l1)
953 auto function = onnx_import::import_onnx_model(
954 file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_l1.prototxt"));
956 // input data shape (1, 1, 4, 4)
958 test::NDArray<float, 4>({{{{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}}}})
961 // output data shape (1,)
962 auto expected_output = test::NDArray<float, 4>({{{{16}}}}).get_vector();
964 auto test_case = test::TestCase<TestEngine>(function);
965 test_case.add_multiple_inputs(inputs);
966 test_case.add_expected_output(expected_output);
970 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_reduce_l2)
972 auto function = onnx_import::import_onnx_model(
973 file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_l2.prototxt"));
975 // input data shape (1, 1, 4, 4)
977 test::NDArray<float, 4>({{{{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}}}})
980 // output data shape (1,)
981 auto expected_output = test::NDArray<float, 4>({{{{4}}}}).get_vector();
983 auto test_case = test::TestCase<TestEngine>(function);
984 test_case.add_multiple_inputs(inputs);
985 test_case.add_expected_output(expected_output);
989 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_reduce_max)
991 auto function = onnx_import::import_onnx_model(
992 file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_max.prototxt"));
994 // input data shape (1, 1, 4, 4)
996 test::NDArray<float, 4>({{{{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}}}})
999 // output data shape (1,)
1000 auto expected_output = test::NDArray<float, 4>({{{{16}}}}).get_vector();
1002 auto test_case = test::TestCase<TestEngine>(function);
1003 test_case.add_multiple_inputs(inputs);
1004 test_case.add_expected_output(expected_output);
1008 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_reduce_mean)
1010 auto function = onnx_import::import_onnx_model(
1011 file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_mean.prototxt"));
1013 // input data shape (1, 1, 4, 4)
1015 test::NDArray<float, 4>({{{{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}}}})
1018 // output data shape (1,)
1019 auto expected_output = test::NDArray<float, 4>({{{{1}}}}).get_vector();
1021 auto test_case = test::TestCase<TestEngine>(function);
1022 test_case.add_multiple_inputs(inputs);
1023 test_case.add_expected_output(Shape{}, expected_output);
1027 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_reduce_min)
1029 auto function = onnx_import::import_onnx_model(
1030 file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_min.prototxt"));
1032 // input data shape (1, 1, 4, 4)
1034 test::NDArray<float, 4>({{{{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}}}})
1037 // output data shape (1,)
1038 auto expected_output = test::NDArray<float, 4>({{{{1}}}}).get_vector();
1040 auto test_case = test::TestCase<TestEngine>(function);
1041 test_case.add_multiple_inputs(inputs);
1042 test_case.add_expected_output(expected_output);
1046 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_reduce_prod)
1048 auto function = onnx_import::import_onnx_model(
1049 file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_prod.prototxt"));
1051 // input data shape (1, 1, 4, 4)
1053 test::NDArray<float, 4>({{{{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}}}})
1056 // output data shape (1,)
1057 auto expected_output = test::NDArray<float, 4>({{{{1}}}}).get_vector();
1059 auto test_case = test::TestCase<TestEngine>(function);
1060 test_case.add_multiple_inputs(inputs);
1061 test_case.add_expected_output(expected_output);
1065 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_reduce_sum)
1067 auto function = onnx_import::import_onnx_model(
1068 file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_sum.prototxt"));
1070 // input data shape (1, 1, 4, 4)
1072 test::NDArray<float, 4>({{{{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}}}})
1075 // output data shape (1,)
1076 auto expected_output = test::NDArray<float, 4>({{{{16}}}}).get_vector();
1078 auto test_case = test::TestCase<TestEngine>(function);
1079 test_case.add_multiple_inputs(inputs);
1080 test_case.add_expected_output(expected_output);
1084 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_reduce_sum_square)
1086 auto function = onnx_import::import_onnx_model(
1087 file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_sum_square.prototxt"));
1089 // input data shape (1, 1, 4, 4)
1091 test::NDArray<float, 4>({{{{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}}}})
1094 // output data shape (1,)
1095 auto expected_output = test::NDArray<float, 4>({{{{16}}}}).get_vector();
1097 auto test_case = test::TestCase<TestEngine>(function);
1098 test_case.add_multiple_inputs(inputs);
1099 test_case.add_expected_output(expected_output);
1103 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_resize10_import_only)
1105 const auto resize_fn = onnx_import::import_onnx_model(
1106 file_util::path_join(SERIALIZED_ZOO, "onnx/resize_opset10.prototxt"));
1108 // Input data shape (1, 2, 3, 4)
1109 // Scales input constant values {4, 3, 2, 1}
1111 Shape expected_output_shape{4, 6, 6, 4};
1112 EXPECT_EQ(resize_fn->get_output_size(), 1);
1113 EXPECT_EQ(resize_fn->get_output_shape(0), expected_output_shape);
1114 EXPECT_EQ(count_ops_of_type<op::v0::Interpolate>(resize_fn), 1);
1115 EXPECT_EQ(count_ops_of_type<onnx_import::default_opset::Constant>(resize_fn), 1);
1118 NGRAPH_TEST(${BACKEND_NAME}, onnx_resize10_down_scales_const_nearest)
1120 const auto function = onnx_import::import_onnx_model(
1121 file_util::path_join(SERIALIZED_ZOO, "onnx/resize10_down_scales_const_nearest.prototxt"));
1123 // Input data shape (1, 1, 2, 4)
1124 // Input const scales values {1.0, 1.0, 0.6, 0.6}
1127 Shape expected_output_shape{1, 1, 1, 2};
1128 auto test_case = test::TestCase<TestEngine>(function);
1129 test_case.add_input<float>({1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0});
1130 test_case.add_expected_output<float>(expected_output_shape, {1.0, 3.0});
1134 NGRAPH_TEST(${BACKEND_NAME}, onnx_resize10_up_scales_const_linear)
1136 const auto function = onnx_import::import_onnx_model(
1137 file_util::path_join(SERIALIZED_ZOO, "onnx/resize10_up_scales_const_linear.prototxt"));
1139 // Input data shape (1, 1, 2, 2)
1140 // Input const scales values {1.0, 1.0, 2.0, 2.0}
1143 Shape expected_output_shape{1, 1, 4, 4};
1144 auto test_case = test::TestCase<TestEngine>(function);
1145 test_case.add_input<float>({1.0, 2.0, 3.0, 4.0});
1146 test_case.add_expected_output<float>(
1147 expected_output_shape,
1148 {1.0, 1.5, 2.0, 2.0, 2.0, 2.5, 3.0, 3.0, 3.0, 3.5, 4.0, 4.0, 3.0, 3.5, 4.0, 4.0});
1152 NGRAPH_TEST(${BACKEND_NAME}, onnx_resize10_up_scales_const_nearest)
1154 const auto function = onnx_import::import_onnx_model(
1155 file_util::path_join(SERIALIZED_ZOO, "onnx/resize10_up_scales_const_nearest.prototxt"));
1157 // Input data shape (1, 1, 2, 2)
1158 // Input const scales values {1.0, 1.0, 2.0, 3.0}
1161 Shape expected_output_shape{1, 1, 4, 6};
1162 auto test_case = test::TestCase<TestEngine>(function);
1163 test_case.add_input<float>({1.0, 2.0, 3.0, 4.0});
1164 test_case.add_expected_output<float>(
1165 expected_output_shape, {1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0,
1166 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, 3.0, 3.0, 3.0, 4.0, 4.0, 4.0});
1171 NGRAPH_TEST(${BACKEND_NAME}, onnx_resize11_scales_down_linear)
1173 const auto function = onnx_import::import_onnx_model(
1174 file_util::path_join(SERIALIZED_ZOO, "onnx/resize11_scales_down_linear.prototxt"));
1176 const Shape expected_output_shape{1, 1, 1, 2};
1177 auto test_case = test::TestCase<TestEngine>(function);
1178 const size_t input_size = 8;
1179 std::vector<float> input_data(input_size);
1180 std::iota(std::begin(input_data), std::end(input_data), 1.0f);
1181 test_case.add_input<float>(input_data);
1182 test_case.add_expected_output<float>(expected_output_shape, {1.0f, 2.66666651f});
1184 test_case.run_with_tolerance_as_fp();
1187 NGRAPH_TEST(${BACKEND_NAME}, onnx_resize11_scales_nearest_asymmetric_floor_dynamic_sizes)
1189 const auto function = onnx_import::import_onnx_model(file_util::path_join(
1190 SERIALIZED_ZOO, "onnx/resize11_scales_nearest_asymmetric_floor_dynamic_scales.prototxt"));
1192 const Shape expected_output_shape{2, 1, 4, 1};
1193 auto test_case = test::TestCase<TestEngine>(function);
1194 const std::vector<float> input_data{1.0f, 3.0f, 4.0f, 8.0f, 6.0f, 2.0f, 7.0f, 11.0f};
1195 test_case.add_input<float>(input_data);
1196 test_case.add_input<float>(
1197 std::vector<float>{1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f}); // roi
1198 test_case.add_input<float>(std::vector<float>{1.0f, 1.0f, 2.0f, 0.5f}); // scales
1199 test_case.add_expected_output<float>(expected_output_shape,
1200 {1.0f, 1.0f, 4.0f, 4.0f, 6.0f, 6.0f, 7.0f, 7.0f});
1202 test_case.run_with_tolerance_as_fp();
1205 NGRAPH_TEST(${BACKEND_NAME}, onnx_resize11_sizes_nearest_asymmetric_floor)
1207 const auto function = onnx_import::import_onnx_model(file_util::path_join(
1208 SERIALIZED_ZOO, "onnx/resize11_sizes_nearest_asymmetric_floor.prototxt"));
1210 const Shape expected_output_shape{2, 1, 4, 1};
1211 auto test_case = test::TestCase<TestEngine>(function);
1212 std::vector<float> input_data{1.0f, 3.0f, 4.0f, 8.0f, 6.0f, 2.0f, 7.0f, 11.0f};
1213 test_case.add_input<float>(input_data);
1214 test_case.add_expected_output<float>(expected_output_shape,
1215 {1.0f, 1.0f, 4.0f, 4.0f, 6.0f, 6.0f, 7.0f, 7.0f});
1217 test_case.run_with_tolerance_as_fp();
1220 NGRAPH_TEST(${BACKEND_NAME}, onnx_resize11_sizes_linear)
1222 const auto function = onnx_import::import_onnx_model(
1223 file_util::path_join(SERIALIZED_ZOO, "onnx/resize11_sizes_linear.prototxt"));
1225 const Shape expected_output_shape{2, 1, 4, 8};
1226 auto test_case = test::TestCase<TestEngine>(function);
1227 std::vector<float> input_data{2.0f, 4.0f, 1.0f, 3.0f, 7.0f, 8.0f, 9.0f, 6.0f};
1228 test_case.add_input<float>(input_data);
1229 test_case.add_expected_output<float>(
1230 expected_output_shape,
1231 {2.0f, 2.5f, 3.0f, 3.5f, 4.0f, 4.0f, 4.0f, 4.0f, 1.5f, 2.0f, 2.5f, 3.0f, 3.5f,
1232 3.5f, 3.5f, 3.5f, 1.0f, 1.5f, 2.0f, 2.5f, 3.0f, 3.0f, 3.0f, 3.0f, 1.0f, 1.5f,
1233 2.0f, 2.5f, 3.0f, 3.0f, 3.0f, 3.0f, 7.0f, 7.25f, 7.5f, 7.75f, 8.0f, 8.0f, 8.0f,
1234 8.0f, 8.0f, 7.75f, 7.5f, 7.25f, 7.0f, 7.0f, 7.0f, 7.0f, 9.0f, 8.25f, 7.5f, 6.75f,
1235 6.0f, 6.0f, 6.0f, 6.0f, 9.0f, 8.25f, 7.5f, 6.75f, 6.0f, 6.0f, 6.0f, 6.0f});
1237 test_case.run_with_tolerance_as_fp(2.0e-5f);
1240 NGRAPH_TEST(${BACKEND_NAME}, onnx_resize11_scales_up_linear_asymmetric)
1242 const auto function = onnx_import::import_onnx_model(
1243 file_util::path_join(SERIALIZED_ZOO, "onnx/resize11_scales_up_linear_asymmetric.prototxt"));
1245 const Shape expected_output_shape{2, 1, 4, 8};
1246 auto test_case = test::TestCase<TestEngine>(function);
1247 const size_t input_size = 8;
1248 std::vector<float> input_data{1.0f, 3.0f, 4.0f, 8.0f, 6.0f, 2.0f, 7.0f, 11.0f};
1249 test_case.add_input<float>(input_data);
1250 test_case.add_expected_output<float>(
1251 expected_output_shape,
1252 {1.0f, 1.5f, 2.0f, 2.5f, 3.0f, 3.0f, 3.0f, 3.0f, 2.5f, 3.25f, 4.0f,
1253 4.75f, 5.5f, 5.5f, 5.5f, 5.5f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 8.0f,
1254 8.0f, 8.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 8.0f, 8.0f, 8.0f,
1256 6.0f, 5.0f, 4.0f, 3.0f, 2.0f, 2.0f, 2.0f, 2.0f, 6.5f, 6.5f, 6.5f,
1257 6.5f, 6.5f, 6.5f, 6.5f, 6.5f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 11.0f,
1258 11.0f, 11.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 11.0f, 11.0f, 11.0f});
1263 NGRAPH_TEST(${BACKEND_NAME}, onnx_resize11_scales_nearest_asymmetric_floor)
1265 const auto function = onnx_import::import_onnx_model(file_util::path_join(
1266 SERIALIZED_ZOO, "onnx/resize11_scales_nearest_asymmetric_floor.prototxt"));
1268 const Shape expected_output_shape{2, 1, 4, 1};
1269 auto test_case = test::TestCase<TestEngine>(function);
1270 const std::vector<float> input_data{1.0f, 3.0f, 4.0f, 8.0f, 6.0f, 2.0f, 7.0f, 11.0f};
1271 test_case.add_input<float>(input_data);
1272 test_case.add_expected_output<float>(expected_output_shape,
1273 {1.0f, 1.0f, 4.0f, 4.0f, 6.0f, 6.0f, 7.0f, 7.0f});
1278 NGRAPH_TEST(${BACKEND_NAME}, onnx_resize11_empty_constant_as_input)
1280 // this model contains a Constant node with an empty underlying tensor
1281 // this node is connected to the "roi" input of the Resize op but this input should be
1282 // ignored since the Resize coordinate_transformation_mode is set to asymmetric
1283 const auto function = onnx_import::import_onnx_model(
1284 file_util::path_join(SERIALIZED_ZOO, "onnx/resize11_empty_constant_as_input.prototxt"));
1286 auto test_case = test::TestCase<TestEngine>(function);
1287 std::vector<float> input_data{1.0f, 3.0f, 4.0f, 8.0f, 6.0f, 2.0f, 7.0f, 11.0f};
1288 test_case.add_input<float>(input_data);
1289 test_case.add_expected_output<float>(
1291 {1.0f, 1.5f, 2.0f, 2.5f, 3.0f, 3.0f, 3.0f, 3.0f, 2.5f, 3.25f, 4.0f,
1292 4.75f, 5.5f, 5.5f, 5.5f, 5.5f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 8.0f,
1293 8.0f, 8.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 8.0f, 8.0f, 8.0f,
1295 6.0f, 5.0f, 4.0f, 3.0f, 2.0f, 2.0f, 2.0f, 2.0f, 6.5f, 6.5f, 6.5f,
1296 6.5f, 6.5f, 6.5f, 6.5f, 6.5f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 11.0f,
1297 11.0f, 11.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 11.0f, 11.0f, 11.0f});
1302 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_shape)
1305 onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/shape.prototxt"));
1308 inputs.emplace_back(test::NDArray<float, 3>(
1309 {{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}},
1310 {{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}},
1311 {{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}}})
1314 auto test_case = test::TestCase<TestEngine>(function);
1315 test_case.add_multiple_inputs(inputs);
1316 test_case.add_expected_output<int64_t>({3, 4, 5});
1320 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_elu)
1323 onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/elu.prototxt"));
1326 inputs.emplace_back(
1327 test::NDArray<float, 3>(
1328 {{{-9, -8, -7, -6, -5}, {-4, -3, -2, -1, 0}, {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}},
1329 {{-4, -3, -2, -1, 0}, {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}},
1330 {{1, 1, 1, 1, 1}, {-1, -1, -1, -1, -1}, {0, 0, 0, 0, 0}, {2, 2, 2, 2, 2}}})
1333 auto expected_output = test::NDArray<float, 3>({{{-1.999753180391830f,
1334 -1.999329074744190f,
1335 -1.998176236068890f,
1336 -1.995042495646670f,
1337 -1.986524106001830f},
1338 {-1.963368722222530f,
1339 -1.900425863264270f,
1340 -1.729329433526770f,
1341 -1.264241117657120f,
1345 {{-1.963368722222530f,
1346 -1.900425863264270f,
1347 -1.729329433526770f,
1348 -1.264241117657120f,
1352 {11, 12, 13, 14, 15}},
1354 {-1.264241117657120f,
1355 -1.264241117657120f,
1356 -1.264241117657120f,
1357 -1.264241117657120f,
1358 -1.264241117657120f},
1363 auto test_case = test::TestCase<TestEngine>(function);
1364 test_case.add_multiple_inputs(inputs);
1365 test_case.add_expected_output(expected_output);
1369 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_leaky_relu)
1371 auto function = onnx_import::import_onnx_model(
1372 file_util::path_join(SERIALIZED_ZOO, "onnx/leaky_relu.prototxt"));
1375 inputs.emplace_back(
1376 test::NDArray<float, 3>(
1377 {{{-9, -8, -7, -6, -5}, {-4, -3, -2, -1, 0}, {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}},
1378 {{-4, -3, -2, -1, 0}, {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}},
1379 {{1, 1, 1, 1, 1}, {-1, -1, -1, -1, -1}, {0, 0, 0, 0, 0}, {2, 2, 2, 2, 2}}})
1382 auto expected_output = test::NDArray<float, 3>({{{-0.9f, -0.8f, -0.7f, -0.6f, -0.5f},
1383 {-0.4f, -0.3f, -0.2f, -0.1f, 0},
1386 {{-0.4f, -0.3f, -0.2f, -0.1f, 0},
1389 {11, 12, 13, 14, 15}},
1391 {-0.1f, -0.1f, -0.1f, -0.1f, -0.1f},
1396 auto test_case = test::TestCase<TestEngine>(function);
1397 test_case.add_multiple_inputs(inputs);
1398 test_case.add_expected_output(expected_output);
1402 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_prelu)
1405 onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/prelu.prototxt"));
1408 inputs.emplace_back(
1409 test::NDArray<float, 3>(
1410 {{{-9, -8, -7, -6, -5}, {-4, -3, -2, -1, 0}, {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}},
1411 {{-4, -3, -2, -1, 0}, {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}},
1412 {{1, 1, 1, 1, 1}, {-1, -1, -1, -1, -1}, {0, 0, 0, 0, 0}, {2, 2, 2, 2, 2}}})
1415 inputs.emplace_back(test::NDArray<float, 3>(
1416 {{{1, 0, 1, 0, 1}, {0, 1, 0, 1, 0}, {1, 0, 1, 0, 1}, {0, 1, 0, 1, 0}},
1417 {{0, 1, 0, 1, 0}, {1, 0, 1, 0, 1}, {0, 1, 0, 1, 0}, {1, 0, 1, 0, 1}},
1418 {{1, 0, 1, 0, 1}, {0, 1, 0, 1, 0}, {1, 0, 1, 0, 1}, {0, 1, 0, 1, 0}}})
1421 auto expected_output =
1422 test::NDArray<float, 3>(
1423 {{{-9, 0, -7, 0, -5}, {0, -3, 0, -1, 0}, {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}},
1424 {{0, -3, 0, -1, 0}, {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}},
1425 {{1, 1, 1, 1, 1}, {0, -1, 0, -1, 0}, {0, 0, 0, 0, 0}, {2, 2, 2, 2, 2}}})
1428 auto test_case = test::TestCase<TestEngine>(function);
1429 test_case.add_multiple_inputs(inputs);
1430 test_case.add_expected_output(expected_output);
1434 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_selu)
1437 onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/selu.prototxt"));
1440 inputs.emplace_back(
1441 test::NDArray<float, 3>(
1442 {{{-9, -8, -7, -6, -5}, {-4, -3, -2, -1, 0}, {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}},
1443 {{-4, -3, -2, -1, 0}, {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}},
1444 {{1, 1, 1, 1, 1}, {-1, -1, -1, -1, -1}, {0, 0, 0, 0, 0}, {2, 2, 2, 2, 2}}})
1447 auto expected_output =
1448 test::NDArray<float, 3>(
1449 {{{-5.99925954117548f,
1453 -5.95957231800549f},
1454 {-5.89010616666759f, -5.70127758979282f, -5.18798830058032f, -3.79272335297135f, 0},
1456 {18, 21, 24, 27, 30}},
1457 {{-5.89010616666759f, -5.70127758979282f, -5.18798830058032f, -3.79272335297135f, 0},
1459 {18, 21, 24, 27, 30},
1460 {33, 36, 39, 42, 45}},
1462 {-3.79272335297135f,
1466 -3.79272335297135f},
1471 auto test_case = test::TestCase<TestEngine>(function);
1472 test_case.add_multiple_inputs(inputs);
1473 test_case.add_expected_output(expected_output);
1477 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_sigmoid)
1479 auto function = onnx_import::import_onnx_model(
1480 file_util::path_join(SERIALIZED_ZOO, "onnx/sigmoid.prototxt"));
1483 inputs.emplace_back(
1484 test::NDArray<float, 3>(
1485 {{{-9, -8, -7, -6, -5}, {-4, -3, -2, -1, 0}, {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}},
1486 {{-4, -3, -2, -1, 0}, {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}},
1487 {{1, 1, 1, 1, 1}, {-1, -1, -1, -1, -1}, {0, 0, 0, 0, 0}, {2, 2, 2, 2, 2}}})
1490 auto expected_output = test::NDArray<float, 3>({{{0.00012339457598623f,
1491 0.00033535013046648f,
1492 0.00091105119440065f,
1493 0.00247262315663477f,
1494 0.00669285092428486f},
1495 {0.01798620996209160f,
1496 0.04742587317756680f,
1500 {0.731058578630005f,
1504 0.993307149075715f},
1505 {0.997527376843365f,
1509 0.999954602131298f}},
1510 {{0.01798620996209160f,
1511 0.04742587317756680f,
1515 {0.731058578630005f,
1519 0.993307149075715f},
1520 {0.997527376843365f,
1524 0.999954602131298f},
1525 {0.999983298578152f,
1529 0.999999694097773f}},
1530 {{0.731058578630005f,
1534 0.731058578630005f},
1535 {0.268941421369995f,
1539 0.268941421369995f},
1540 {0.5f, 0.5f, 0.5f, 0.5f, 0.5f},
1541 {0.880797077977882f,
1545 0.880797077977882f}}})
1548 auto test_case = test::TestCase<TestEngine>(function);
1549 test_case.add_multiple_inputs(inputs);
1550 test_case.add_expected_output(expected_output);
1554 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_tanh)
1557 onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/tanh.prototxt"));
1560 inputs.emplace_back(
1561 test::NDArray<float, 3>(
1562 {{{-9, -8, -7, -6, -5}, {-4, -3, -2, -1, 0}, {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}},
1563 {{-4, -3, -2, -1, 0}, {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}},
1564 {{1, 1, 1, 1, 1}, {-1, -1, -1, -1, -1}, {0, 0, 0, 0, 0}, {2, 2, 2, 2, 2}}})
1567 auto expected_output = test::NDArray<float, 3>({{{-0.999999969540041f,
1568 -0.999999774929676f,
1569 -0.999998336943945f,
1570 -0.999987711650796f,
1571 -0.999909204262595f},
1572 {-0.999329299739067f,
1573 -0.995054753686731f,
1574 -0.964027580075817f,
1575 -0.761594155955765f,
1577 {0.761594155955765f,
1581 0.999909204262595f},
1582 {0.999987711650796f,
1586 0.999999995877693f}},
1587 {{-0.999329299739067f,
1588 -0.995054753686731f,
1589 -0.964027580075817f,
1590 -0.761594155955765f,
1592 {0.761594155955765f,
1596 0.999909204262595f},
1597 {0.999987711650796f,
1601 0.999999995877693f},
1602 {0.999999999442106f,
1606 0.999999999999813f}},
1607 {{0.761594155955765f,
1611 0.761594155955765f},
1612 {-0.761594155955765f,
1613 -0.761594155955765f,
1614 -0.761594155955765f,
1615 -0.761594155955765f,
1616 -0.761594155955765f},
1618 {0.964027580075817f,
1622 0.964027580075817f}}})
1625 auto test_case = test::TestCase<TestEngine>(function);
1626 test_case.add_multiple_inputs(inputs);
1627 test_case.add_expected_output(expected_output);
1631 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_thresholded_relu)
1633 auto function = onnx_import::import_onnx_model(
1634 file_util::path_join(SERIALIZED_ZOO, "onnx/thresholded_relu.prototxt"));
1637 inputs.emplace_back(
1638 test::NDArray<float, 3>(
1639 {{{-9, -8, -7, -6, -5}, {-4, -3, -2, -1, 0}, {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}},
1640 {{-4, -3, -2, -1, 0}, {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}},
1641 {{1, 1, 1, 1, 1}, {-1, -1, -1, -1, -1}, {0, 0, 0, 0, 0}, {2, 2, 2, 2, 2}}})
1644 auto expected_output =
1645 test::NDArray<float, 3>(
1646 {{{0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 3, 4, 5}, {6, 7, 8, 9, 10}},
1647 {{0, 0, 0, 0, 0}, {0, 0, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}},
1648 {{0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}}})
1651 auto test_case = test::TestCase<TestEngine>(function);
1652 test_case.add_multiple_inputs(inputs);
1653 test_case.add_expected_output(expected_output);
1657 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_matmul_vec_ten3d)
1659 auto function = onnx_import::import_onnx_model(
1660 file_util::path_join(SERIALIZED_ZOO, "onnx/matmul_vec_ten3d.prototxt"));
1663 inputs.emplace_back(std::vector<float>{0.f, 1.f});
1664 inputs.emplace_back(
1665 test::NDArray<float, 3>{{{0.f}, {1.f}}, {{2.f}, {3.f}}, {{4.f}, {5.f}}}.get_vector());
1667 auto expected_output = test::NDArray<float, 2>{{1.f}, {3.f}, {5.f}}.get_vector();
1669 auto test_case = test::TestCase<TestEngine>(function);
1670 test_case.add_multiple_inputs(inputs);
1671 test_case.add_expected_output(expected_output);
1675 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_softplus)
1677 auto function = onnx_import::import_onnx_model(
1678 file_util::path_join(SERIALIZED_ZOO, "onnx/softplus.prototxt"));
1680 // -1.0f, 0, 1.0f, 10.f, normal input values for activation
1681 // 100.0f, -100.0f, 1000.0f, -1000.0f, input values that leads to exp() overflow
1682 // FLT_MIN, FLT_MIN / 16, -FLT_MIN / 16, min, denorm, -denorm
1683 // FLT_MAX, -FLT_MAX, max, -max;
1684 Inputs inputs{std::vector<float>{-1.0f,
1698 const auto inf = std::numeric_limits<float>::infinity();
1699 std::vector<float> output{0.3132616579532623291,
1700 0.6931471824645996094,
1701 1.313261628150939941,
1702 10.0000457763671875,
1707 0.6931471824645996094,
1708 0.6931471824645996094,
1709 0.6931471824645996094,
1713 auto test_case = test::TestCase<TestEngine>(function);
1714 test_case.add_multiple_inputs(inputs);
1715 test_case.add_expected_output(output);
1719 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_softplus_infinity)
1721 auto function = onnx_import::import_onnx_model(
1722 file_util::path_join(SERIALIZED_ZOO, "onnx/softplus.prototxt"));
1724 std::vector<float> input(13, std::numeric_limits<float>::infinity());
1725 std::vector<float> expected_output(13, std::numeric_limits<float>::infinity());
1727 auto test_case = test::TestCase<TestEngine>(function);
1728 test_case.add_input(input);
1729 test_case.add_expected_output(expected_output);
1733 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_sum_opset8)
1735 auto function = onnx_import::import_onnx_model(
1736 file_util::path_join(SERIALIZED_ZOO, "onnx/sum_opset8.prototxt"));
1739 inputs.emplace_back(std::vector<float>{1.0f, 2.0f, 3.0f});
1740 inputs.emplace_back(test::NDArray<float, 2>{{10.0f}, {20.0f}, {30.0f}}.get_vector());
1741 inputs.emplace_back(test::NDArray<float, 3>{{{100.0f}}, {{200.0f}}, {{300.0f}}}.get_vector());
1743 auto expected_output =
1744 test::NDArray<float, 3>{
1745 {{111.0f, 112.0f, 113.0f}, {121.0f, 122.0f, 123.0f}, {131.0f, 132.0f, 133.0f}},
1747 {{211.0f, 212.0f, 213.0f}, {221.0f, 222.0f, 223.0f}, {231.0f, 232.0f, 233.0f}},
1749 {{311.0f, 312.0f, 313.0f}, {321.0f, 322.0f, 323.0f}, {331.0f, 332.0f, 333.0f}}}
1752 auto test_case = test::TestCase<TestEngine>(function);
1753 test_case.add_multiple_inputs(inputs);
1754 test_case.add_expected_output(expected_output);
1758 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_argmax_int32)
1760 auto function = onnx_import::import_onnx_model(
1761 file_util::path_join(SERIALIZED_ZOO, "onnx/argmax_int32.prototxt"));
1763 auto test_case = test::TestCase<TestEngine>(function);
1764 test_case.add_input<std::int32_t>({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12});
1765 test_case.add_expected_output<std::int32_t>({1, 1, 1, 1, 1, 1});
1769 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_argmin_int32)
1771 auto function = onnx_import::import_onnx_model(
1772 file_util::path_join(SERIALIZED_ZOO, "onnx/argmin_int32.prototxt"));
1774 auto test_case = test::TestCase<TestEngine>(function);
1775 test_case.add_input<std::int32_t>({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12});
1776 test_case.add_expected_output<std::int32_t>({0, 0, 0, 0});
1780 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_argmax_float)
1782 auto function = onnx_import::import_onnx_model(
1783 file_util::path_join(SERIALIZED_ZOO, "onnx/argmax_float.prototxt"));
1785 auto test_case = test::TestCase<TestEngine>(function);
1786 test_case.add_input<float>({4, 0.1, 2, 3, -3, 1, -0.9, 0, 1, 2, 3, 0});
1787 test_case.add_expected_output<std::int64_t>({0, 3, 0});
1791 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_argmin_float)
1793 auto function = onnx_import::import_onnx_model(
1794 file_util::path_join(SERIALIZED_ZOO, "onnx/argmin_float.prototxt"));
1796 auto test_case = test::TestCase<TestEngine>(function);
1797 test_case.add_input<float>({4, 0.1, 2, 3, -3, 1, -0.9, 0, 1, 2, 3, 0});
1798 test_case.add_expected_output<std::int64_t>({1, 1, 0, 2});
1802 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_top_k)
1805 onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/top_k.prototxt"));
1807 auto test_case = test::TestCase<TestEngine>(function);
1808 test_case.add_input<float>({0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11});
1809 test_case.add_expected_output<float>(Shape{3, 3}, {3, 2, 1, 7, 6, 5, 11, 10, 9}); // values
1810 test_case.add_expected_output<std::int64_t>(Shape{3, 3},
1811 {3, 2, 1, 3, 2, 1, 3, 2, 1}); // indices
1815 NGRAPH_TEST(${BACKEND_NAME}, onnx_top_k_opset_10)
1817 auto function = onnx_import::import_onnx_model(
1818 file_util::path_join(SERIALIZED_ZOO, "onnx/top_k_opset_10.prototxt"));
1820 auto test_case = test::TestCase<TestEngine>(function);
1821 test_case.add_input<float>({0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11});
1822 test_case.add_input<int64_t>({3});
1824 test_case.add_expected_output<float>(Shape{3, 3}, {3, 2, 1, 7, 6, 5, 11, 10, 9}); // values
1825 test_case.add_expected_output<std::int64_t>(Shape{3, 3},
1826 {3, 2, 1, 3, 2, 1, 3, 2, 1}); // indices
1830 NGRAPH_TEST(${BACKEND_NAME}, onnx_top_k_opset_10_const_k)
1832 auto function = onnx_import::import_onnx_model(
1833 file_util::path_join(SERIALIZED_ZOO, "onnx/top_k_opset_10_const_k.prototxt"));
1835 auto test_case = test::TestCase<TestEngine>(function);
1836 test_case.add_input<float>({0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11});
1838 test_case.add_expected_output<float>(Shape{3, 3}, {3, 2, 1, 7, 6, 5, 11, 10, 9}); // values
1839 test_case.add_expected_output<std::int64_t>(Shape{3, 3},
1840 {3, 2, 1, 3, 2, 1, 3, 2, 1}); // indices
1844 NGRAPH_TEST(${BACKEND_NAME}, onnx_top_k_opset_11_const_k_smallest)
1846 auto function = onnx_import::import_onnx_model(
1847 file_util::path_join(SERIALIZED_ZOO, "onnx/top_k_opset_11_const_k_smallest.prototxt"));
1849 auto test_case = test::TestCase<TestEngine>(function);
1850 test_case.add_input<float>({0, 1, 2, 3, 4, 5, 6, 7, 11, 10, 9, 8});
1852 test_case.add_expected_output<float>(Shape{3, 3}, {0, 1, 2, 4, 5, 6, 8, 9, 10}); // values
1853 test_case.add_expected_output<std::int64_t>(Shape{3, 3},
1854 {0, 1, 2, 0, 1, 2, 3, 2, 1}); // indices
1858 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_acosh)
1861 onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/acosh.prototxt"));
1863 auto test_case = test::TestCase<TestEngine>(function);
1864 test_case.add_input<float>(Shape{1, 3}, {1.0f, 2.5f, 4.3f});
1865 test_case.add_expected_output<float>(Shape{1, 3}, {0.0f, 1.5667993f, 2.13795861f});
1870 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_asinh)
1873 onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/asinh.prototxt"));
1875 auto test_case = test::TestCase<TestEngine>(function);
1876 test_case.add_input<float>(Shape{1, 3}, {-1.0f, 0.0f, 1.0f});
1877 test_case.add_expected_output<float>(Shape{1, 3}, {-0.88137358f, 0.0f, 0.88137358f});
1882 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_atanh)
1885 onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/atanh.prototxt"));
1887 auto test_case = test::TestCase<TestEngine>(function);
1888 test_case.add_input<float>(Shape{1, 3}, {-0.9f, 0.0f, 0.9f});
1889 test_case.add_expected_output<float>(Shape{1, 3}, {-1.4722194f, 0.0f, 1.4722194f});
1894 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_sinh)
1897 onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/sinh.prototxt"));
1899 auto test_case = test::TestCase<TestEngine>(function);
1900 test_case.add_input<float>({-1.0f, 0.0f, 1.0f});
1901 test_case.add_expected_output<float>({-1.1752012f, 0.f, 1.1752012f});
1905 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_cosh)
1908 onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/cosh.prototxt"));
1910 auto test_case = test::TestCase<TestEngine>(function);
1911 test_case.add_input<float>({-1.0f, 0.0f, 1.0f});
1912 test_case.add_expected_output<float>({1.54308069f, 1.f, 1.54308069f});
1916 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_sign)
1919 onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/sign.prototxt"));
1921 Inputs inputs{std::vector<float>{-std::numeric_limits<float>::infinity(),
1925 std::numeric_limits<float>::infinity()}};
1927 auto test_case = test::TestCase<TestEngine>(function);
1928 test_case.add_multiple_inputs(inputs);
1929 test_case.add_expected_output<float>({-1.0f, -1.0f, 0.0f, 1.0f, 1.0f});
1933 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_one_hot_with_axis)
1935 auto function = onnx_import::import_onnx_model(
1936 file_util::path_join(SERIALIZED_ZOO, "onnx/one_hot_axis.prototxt"));
1938 Inputs inputs{{1.0, 9.0, 2.0, 4.0}, {1.0, 3.0}};
1939 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,
1940 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 3.0,
1941 1.0, 1.0, 1.0, 1.0, 3.0, 1.0, 1.0, 1.0, 1.0, 3.0,
1942 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}};
1944 auto test_case = test::TestCase<TestEngine>(function);
1945 test_case.add_multiple_inputs(inputs);
1946 test_case.add_expected_output(expected_output);
1950 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_one_hot_without_axis)
1952 auto function = onnx_import::import_onnx_model(
1953 file_util::path_join(SERIALIZED_ZOO, "onnx/one_hot_no_axis.prototxt"));
1955 std::vector<std::vector<std::int64_t>> inputs{{0, 7, 8}, {2, 5}};
1956 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,
1957 2, 5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 5, 2, 2, 2};
1959 auto test_case = test::TestCase<TestEngine>(function);
1960 test_case.add_multiple_inputs(inputs);
1961 test_case.add_expected_output(expected_output);
1965 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_where)
1968 onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/where.prototxt"));
1970 // conditions tensor - 3x3x3
1971 auto condition = std::vector<int>{
1972 {0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0}};
1974 // 1x3 tensor of "1"
1975 auto x1 = std::vector<int>{1, 1, 1};
1976 // 3x1 tensor of "2"
1977 auto x2 = std::vector<int>{2, 2, 2};
1979 std::vector<std::vector<int>> inputs;
1980 inputs.push_back(std::move(condition));
1981 inputs.push_back(std::move(x1));
1982 inputs.push_back(std::move(x2));
1985 std::vector<int> expected_output{2, 1, 2, 1, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2,
1986 1, 2, 1, 2, 2, 1, 2, 1, 2, 1, 2, 1, 2};
1988 auto test_case = test::TestCase<TestEngine>(function);
1989 test_case.add_multiple_inputs(inputs);
1990 test_case.add_expected_output(expected_output);
1994 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_erf)
1996 const auto function =
1997 onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/erf.prototxt"));
2000 inputs.emplace_back(test::NDArray<float, 2>{
2001 {-std::numeric_limits<float>::infinity(), std::numeric_limits<float>::infinity()},
2003 {0.5f, 1.0f}}.get_vector());
2005 const std::vector<float> expected_output = test::NDArray<float, 2>{
2007 {-0.99999112f, 0.0f},
2008 {0.52049988f, 0.84270079f}}.get_vector();
2010 auto test_case = test::TestCase<TestEngine>(function);
2011 test_case.add_multiple_inputs(inputs);
2012 test_case.add_expected_output(expected_output);
2016 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_erf_int32)
2018 const auto function = onnx_import::import_onnx_model(
2019 file_util::path_join(SERIALIZED_ZOO, "onnx/erf_int32.prototxt"));
2021 const std::vector<std::vector<int32_t>> inputs{
2022 {-std::numeric_limits<int32_t>::max(), -1, 0, 1, std::numeric_limits<int32_t>::max()}};
2024 const std::vector<int32_t> expected_output{-1, 0, 0, 0, 1};
2026 auto test_case = test::TestCase<TestEngine>(function);
2027 test_case.add_multiple_inputs(inputs);
2028 test_case.add_expected_output(expected_output);
2032 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_shrink_float)
2034 const auto function = onnx_import::import_onnx_model(
2035 file_util::path_join(SERIALIZED_ZOO, "onnx/shrink_float.prototxt"));
2037 auto test_case = test::TestCase<TestEngine>(function);
2038 test_case.add_input<float>(
2039 {-2.0f, -1.6f, -1.5f, -1.4f, -1.0f, 0.0f, 1.0f, 1.4f, 1.5f, 1.6f, 2.0f});
2040 test_case.add_expected_output<float>(
2041 Shape{11}, {-1.5f, -1.1f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.1f, 1.5f});
2046 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_shrink_int)
2048 const auto function = onnx_import::import_onnx_model(
2049 file_util::path_join(SERIALIZED_ZOO, "onnx/shrink_int.prototxt"));
2051 auto test_case = test::TestCase<TestEngine>(function);
2052 test_case.add_input<int>({-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5});
2053 test_case.add_expected_output<int>(Shape{11}, {-4, -3, -2, -1, 0, 0, 0, 1, 2, 3, 4});
2058 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_lp_norm_p1)
2060 const auto function = onnx_import::import_onnx_model(
2061 file_util::path_join(SERIALIZED_ZOO, "onnx/lp_norm_p1.prototxt"));
2063 Shape data_shape{2, 3, 4};
2064 std::vector<float> data(shape_size(data_shape));
2065 std::iota(std::begin(data), std::end(data), 1);
2067 auto test_case = test::TestCase<TestEngine>(function);
2068 test_case.add_input<float>(data);
2069 test_case.add_expected_output<float>(
2070 data_shape, {0.07142857f, 0.125f, 0.16666667f, 0.2f, 0.22727273f, 0.25f,
2071 0.26923078f, 0.2857143f, 0.3f, 0.3125f, 0.32352942f, 0.33333334f,
2072 0.9285714f, 0.875f, 0.8333333f, 0.8f, 0.77272725f, 0.75f,
2073 0.7307692f, 0.71428573f, 0.7f, 0.6875f, 0.6764706f, 0.6666667f});
2078 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_lp_norm_p2)
2080 const auto function = onnx_import::import_onnx_model(
2081 file_util::path_join(SERIALIZED_ZOO, "onnx/lp_norm_p2.prototxt"));
2083 Shape data_shape{2, 3, 4};
2084 std::vector<float> data(shape_size(data_shape));
2085 std::iota(std::begin(data), std::end(data), 1);
2087 auto test_case = test::TestCase<TestEngine>(function);
2088 test_case.add_input<float>(data);
2089 test_case.add_expected_output<float>(
2090 data_shape, {0.0766965f, 0.14142136f, 0.19611613f, 0.24253564f, 0.28216633f, 0.31622776f,
2091 0.34570536f, 0.37139067f, 0.39391932f, 0.41380295f, 0.4314555f, 0.4472136f,
2092 0.9970545f, 0.98994946f, 0.9805807f, 0.97014254f, 0.9593655f, 0.9486833f,
2093 0.9383431f, 0.9284767f, 0.91914505f, 0.9103665f, 0.9021342f, 0.8944272f});
2098 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_lp_norm_default)
2100 const auto function = onnx_import::import_onnx_model(
2101 file_util::path_join(SERIALIZED_ZOO, "onnx/lp_norm_default.prototxt"));
2103 Shape data_shape{2, 3, 4};
2104 std::vector<float> data(shape_size(data_shape));
2105 std::iota(std::begin(data), std::end(data), 1);
2107 auto test_case = test::TestCase<TestEngine>(function);
2108 test_case.add_input<float>(data);
2109 test_case.add_expected_output<float>(
2110 data_shape, {0.18257418f, 0.36514837f, 0.5477225f, 0.73029673f, 0.37904903f, 0.45485884f,
2111 0.5306686f, 0.60647845f, 0.42616236f, 0.47351375f, 0.5208651f, 0.5682165f,
2112 0.4469492f, 0.48132992f, 0.51571065f, 0.5500913f, 0.45862272f, 0.48560053f,
2113 0.5125783f, 0.53955615f, 0.46609157f, 0.4882864f, 0.51048124f, 0.5326761f});
2118 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_instance_normalization)
2120 const auto function = onnx_import::import_onnx_model(
2121 file_util::path_join(SERIALIZED_ZOO, "onnx/instance_norm.prototxt"));
2123 Shape data_shape{1, 2, 3, 4};
2124 std::vector<float> data(shape_size(data_shape));
2125 std::iota(std::begin(data), std::end(data), 1);
2127 auto test_case = test::TestCase<TestEngine>(function);
2129 test_case.add_input<float>(data);
2130 test_case.add_input<float>(std::vector<float>{2.134f, 3.256f});
2131 test_case.add_input<float>(std::vector<float>{0.765f, 1.055f});
2132 test_case.add_expected_output<float>(
2133 data_shape, {-2.6335807f, -2.015657f, -1.3977331f, -0.77980936f, -0.16188562f, 0.45603812f,
2134 1.0739619f, 1.6918856f, 2.3098092f, 2.927733f, 3.5456567f, 4.1635804f,
2135 -4.130463f, -3.1876516f, -2.2448401f, -1.3020288f, -0.35921717f, 0.5835942f,
2136 1.5264057f, 2.469217f, 3.4120288f, 4.35484f, 5.2976513f, 6.240463f});
2140 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_eye_like)
2142 const auto function = onnx_import::import_onnx_model(
2143 file_util::path_join(SERIALIZED_ZOO, "onnx/eye_like.prototxt"));
2145 auto test_case = test::TestCase<TestEngine>(function);
2146 test_case.add_input<float>({0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f});
2147 test_case.add_expected_output<float>(
2148 Shape{3, 4}, {0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f});
2153 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_reverse_sequence_0_batch_1)
2155 const auto function = onnx_import::import_onnx_model(
2156 file_util::path_join(SERIALIZED_ZOO, "onnx/reverse_sequence_time_0_batch_1.prototxt"));
2157 auto test_case = test::TestCase<TestEngine>(function);
2159 test_case.add_input<float>(
2160 {0.f, 4.f, 8.f, 12.f, 1.f, 5.f, 9.f, 13.f, 2.f, 6.f, 10.f, 14.f, 3.f, 7.f, 11.f, 15.f});
2161 test_case.add_input<int>({4, 3, 2, 1});
2162 test_case.add_expected_output<float>(
2164 {3.f, 6.f, 9.f, 12.f, 2.f, 5.f, 8.f, 13.f, 1.f, 4.f, 10.f, 14.f, 0.f, 7.f, 11.f, 15.f});
2169 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_reverse_sequence_1_batch_0)
2171 const auto function = onnx_import::import_onnx_model(
2172 file_util::path_join(SERIALIZED_ZOO, "onnx/reverse_sequence_time_1_batch_0.prototxt"));
2173 auto test_case = test::TestCase<TestEngine>(function);
2175 test_case.add_input<float>(
2176 {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});
2177 test_case.add_input<int>({1, 2, 3, 4});
2178 test_case.add_expected_output<float>(
2180 {0.f, 1.f, 2.f, 3.f, 5.f, 4.f, 6.f, 7.f, 10.f, 9.f, 8.f, 11.f, 15.f, 14.f, 13.f, 12.f});
2185 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_reverse_sequence_incorrect_batch_axis)
2187 EXPECT_THROW(onnx_import::import_onnx_model(file_util::path_join(
2188 SERIALIZED_ZOO, "onnx/reverse_sequence_incorrect_batch_axis.prototxt")),
2190 << "ReverseSequence batch_axis attribute can only equal 0 or 1. Value of '2' is not "
2194 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_reverse_sequence_incorrect_time_axis)
2196 EXPECT_THROW(onnx_import::import_onnx_model(file_util::path_join(
2197 SERIALIZED_ZOO, "onnx/reverse_sequence_incorrect_time_axis.prototxt")),
2199 << "ReverseSequence time_axis attribute can only equal 0 or 1. Value of '2' is not "
2203 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_reverse_sequence_time_and_batch_axis_equal)
2205 EXPECT_THROW(onnx_import::import_onnx_model(file_util::path_join(
2206 SERIALIZED_ZOO, "onnx/reverse_sequence_time_and_batch_axis_equal.prototxt")),
2208 << "ReverseSequence 'time_axis' and 'batch_axis' can't be equal.";
2211 NGRAPH_TEST(${BACKEND_NAME}, onnx_matmul_float_type)
2213 auto function = onnx_import::import_onnx_model(
2214 file_util::path_join(SERIALIZED_ZOO, "onnx/matmul_float.prototxt"));
2216 auto test_case = test::TestCase<TestEngine>(function);
2217 test_case.add_input<float>(std::vector<float>{0, 1, 2, 3, 4, 5});
2218 test_case.add_input<float>(std::vector<float>{0, 1});
2219 test_case.add_expected_output<float>(Shape{3, 1}, std::vector<float>{1, 3, 5});
2224 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_mod)
2226 const auto function = onnx_import::import_onnx_model(
2227 file_util::path_join(SERIALIZED_ZOO, "onnx/mod_sign.prototxt"));
2228 auto test_case = test::TestCase<TestEngine>(function);
2230 test_case.add_input<int64_t>({-8, 3, 4, 9, -17, 1});
2231 test_case.add_input<int64_t>({22, -13, 8, -3, 7, 2});
2232 test_case.add_expected_output<int64_t>(Shape{6}, {-8, 3, 4, 0, -3, 1});
2237 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_scatterND_param_i64_indices)
2239 const auto function = onnx_import::import_onnx_model(
2240 file_util::path_join(SERIALIZED_ZOO, "onnx/scatter_nd_param_i64_indices.prototxt"));
2241 auto test_case = test::TestCase<TestEngine>(function);
2243 test_case.add_input<float>({1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f});
2244 test_case.add_input<int64_t>({4, 3, 1, 7});
2245 test_case.add_input<float>({9.f, 10.f, 11.f, 12.f});
2246 test_case.add_expected_output<float>(Shape{8}, {1.f, 11.f, 3.f, 10.f, 9.f, 6.f, 7.f, 12.f});
2251 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_scatterND_const_i32_indices)
2253 const auto function = onnx_import::import_onnx_model(
2254 file_util::path_join(SERIALIZED_ZOO, "onnx/scatter_nd_const_i32_indices.prototxt"));
2255 auto test_case = test::TestCase<TestEngine>(function);
2257 test_case.add_input<float>({1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f});
2258 test_case.add_input<float>({9.f, 10.f, 11.f, 12.f});
2259 test_case.add_expected_output<float>(Shape{8}, {1.f, 11.f, 3.f, 10.f, 9.f, 6.f, 7.f, 12.f});
2264 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_gatherND_int32)
2266 const auto function = onnx_import::import_onnx_model(
2267 file_util::path_join(SERIALIZED_ZOO, "onnx/gatherND_int32.prototxt"));
2268 auto test_case = test::TestCase<TestEngine>(function);
2270 test_case.add_input<int32_t>({0, 1, 2, 3});
2271 test_case.add_input<int64_t>({1, 0});
2272 test_case.add_expected_output<int32_t>(Shape{2, 2}, {2, 3, 0, 1});
2277 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_gatherND_float)
2279 const auto function = onnx_import::import_onnx_model(
2280 file_util::path_join(SERIALIZED_ZOO, "onnx/gatherND_float.prototxt"));
2281 auto test_case = test::TestCase<TestEngine>(function);
2283 test_case.add_input<float>({0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f});
2284 test_case.add_input<int64_t>({0, 1, 1, 0});
2285 test_case.add_expected_output<float>(Shape{2, 2}, {2.f, 3.f, 4.f, 5.f});
2290 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_pad_constant)
2292 const auto function = onnx_import::import_onnx_model(
2293 file_util::path_join(SERIALIZED_ZOO, "onnx/pad_constant.prototxt"));
2294 auto test_case = test::TestCase<TestEngine>(function);
2296 test_case.add_input<float>({1.f, 1.2f, 2.3f, 3.4f, 4.5f, 5.7f});
2297 test_case.add_expected_output<float>(
2298 Shape{3, 4}, {0.f, 0.f, 1.f, 1.2f, 0.f, 0.f, 2.3f, 3.4f, 0.f, 0.f, 4.5f, 5.7f});
2303 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_pow_float32_float32)
2305 const auto function = onnx_import::import_onnx_model(
2306 file_util::path_join(SERIALIZED_ZOO, "onnx/pow_float32_float32.prototxt"));
2307 auto test_case = test::TestCase<TestEngine>(function);
2309 test_case.add_input<float>({1.f, 2.f, 3.f, 4.f}); // base
2310 test_case.add_input<float>({3.5f}); // exponent
2312 test_case.add_expected_output<float>(Shape{1, 4}, {1.f, 11.313708f, 46.765373f, 128.f});
2317 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_pow_float32_int32)
2319 const auto function = onnx_import::import_onnx_model(
2320 file_util::path_join(SERIALIZED_ZOO, "onnx/pow_float32_int32.prototxt"));
2321 auto test_case = test::TestCase<TestEngine>(function);
2323 test_case.add_input<float>({1.f, 2.f, 3.f, 4.f}); // base
2324 test_case.add_input<int>({3}); // exponent
2326 test_case.add_expected_output<float>(Shape{1, 4}, {1.f, 8.f, 27.f, 64.f});
2331 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_pow_int32_float32)
2333 const auto function = onnx_import::import_onnx_model(
2334 file_util::path_join(SERIALIZED_ZOO, "onnx/pow_int32_float32.prototxt"));
2335 auto test_case = test::TestCase<TestEngine>(function);
2337 test_case.add_input<int>({1, 2, 3, 4}); // base
2338 test_case.add_input<float>({3.5f}); // exponent
2340 test_case.add_expected_output<int>(Shape{1, 4}, {1, 11, 46, 128});
2345 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_reciprocal)
2347 const auto function = onnx_import::import_onnx_model(
2348 file_util::path_join(SERIALIZED_ZOO, "onnx/reciprocal.prototxt"));
2349 auto test_case = test::TestCase<TestEngine>(function);
2351 test_case.add_input<float>({1.f, 2.f, 3.f, 4.f, 5.f, 6.f});
2352 test_case.add_expected_output<float>(Shape{3, 2},
2353 {1.f, 1 / 2.f, 1 / 3.f, 1 / 4.f, 1 / 5.f, 1 / 6.f});
2358 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_round)
2360 const auto function =
2361 onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/round.prototxt"));
2362 auto test_case = test::TestCase<TestEngine>(function);
2364 test_case.add_input<float>(
2365 {0.1f, 0.9f, 1.2f, 1.5f, 1.8f, 2.3f, 2.7f, -1.1f, -1.9f, -2.2f, -2.8f});
2366 test_case.add_expected_output<float>(
2367 {0.f, 1.f, 1.f, 2.f, 2.f, 2.f, 3.f, -1.f, -2.f, -2.f, -3.f});
2372 // CASES NOT CORRECTLY HANDLED BY CURRENT IMPLEMENTATION OF ROUND
2373 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_round_half_nearest_even)
2375 const auto function = onnx_import::import_onnx_model(
2376 file_util::path_join(SERIALIZED_ZOO, "onnx/round_half_nearest_even.prototxt"));
2377 auto test_case = test::TestCase<TestEngine>(function);
2379 test_case.add_input<float>({0.5f, 2.5f, -1.5f, -2.5f});
2380 test_case.add_expected_output<float>({0.f, 2.f, -2.f, -2.f});
2385 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_scatter10_import_only)
2387 const auto scatter_fn = onnx_import::import_onnx_model(
2388 file_util::path_join(SERIALIZED_ZOO, "onnx/scatter_opset10.prototxt"));
2390 const Shape data_shape{2, 2};
2392 EXPECT_EQ(scatter_fn->get_output_size(), 1);
2393 EXPECT_EQ(scatter_fn->get_output_shape(0), data_shape);
2394 EXPECT_EQ(count_ops_of_type<op::v3::ScatterElementsUpdate>(scatter_fn), 1);
2395 EXPECT_EQ(count_ops_of_type<op::v0::Constant>(scatter_fn), 4);
2398 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_scatter_elements_import_only)
2400 const auto scatter_fn = onnx_import::import_onnx_model(
2401 file_util::path_join(SERIALIZED_ZOO, "onnx/scatter_elements_opset11.prototxt"));
2403 const Shape data_shape{1, 5};
2405 EXPECT_EQ(scatter_fn->get_output_size(), 1);
2406 EXPECT_EQ(scatter_fn->get_output_shape(0), data_shape);
2407 EXPECT_EQ(count_ops_of_type<op::v3::ScatterElementsUpdate>(scatter_fn), 1);
2408 EXPECT_EQ(count_ops_of_type<op::v0::Constant>(scatter_fn), 4);
2411 NGRAPH_TEST(${BACKEND_NAME}, onnx_upsample8_import_only)
2413 const auto function = onnx_import::import_onnx_model(
2414 file_util::path_join(SERIALIZED_ZOO, "onnx/upsample8_nearest.prototxt"));
2416 // Input data shape (1, 1, 2, 2)
2417 // Scales attribute values {1.0, 1.0, 2.0, 3.0}
2419 const Shape expected_output_shape{1, 1, 4, 6};
2420 EXPECT_EQ(function->get_output_size(), 1);
2421 EXPECT_EQ(function->get_output_shape(0), expected_output_shape);
2422 EXPECT_EQ(count_ops_of_type<onnx_import::default_opset::Interpolate>(function), 1);
2423 EXPECT_EQ(count_ops_of_type<onnx_import::default_opset::Constant>(function), 2);
2426 NGRAPH_TEST(${BACKEND_NAME}, onnx_upsample8_nearest_infer)
2428 const auto function = onnx_import::import_onnx_model(
2429 file_util::path_join(SERIALIZED_ZOO, "onnx/upsample8_nearest.prototxt"));
2431 // Input data shape (1, 1, 2, 2)
2432 // Scales attribute values {1.0, 1.0, 2.0, 3.0}
2435 const Shape expected_output_shape{1, 1, 4, 6};
2436 auto test_case = test::TestCase<TestEngine>(function);
2437 test_case.add_input<float>({1.0, 2.0, 3.0, 4.0});
2438 test_case.add_expected_output<float>(
2439 expected_output_shape, {1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0,
2440 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, 3.0, 3.0, 3.0, 4.0, 4.0, 4.0});
2444 NGRAPH_TEST(${BACKEND_NAME}, onnx_upsample8_linear_infer)
2446 const auto function = onnx_import::import_onnx_model(
2447 file_util::path_join(SERIALIZED_ZOO, "onnx/upsample8_linear.prototxt"));
2449 // Input data shape (1, 1, 2, 2)
2450 // Scales attribute values {1.0, 1.0, 2.0, 2.0}
2453 const Shape expected_output_shape{1, 1, 4, 4};
2454 auto test_case = test::TestCase<TestEngine>(function);
2455 test_case.add_input<float>({1.0, 2.0, 3.0, 4.0});
2456 test_case.add_expected_output<float>(
2457 expected_output_shape,
2458 {1.0, 1.5, 2.0, 2.0, 2.0, 2.5, 3.0, 3.0, 3.0, 3.5, 4.0, 4.0, 3.0, 3.5, 4.0, 4.0});
2462 NGRAPH_TEST(${BACKEND_NAME}, onnx_upsample9_scales_const_import_only)
2464 const auto function = onnx_import::import_onnx_model(
2465 file_util::path_join(SERIALIZED_ZOO, "onnx/upsample9_scales_const_nearest.prototxt"));
2467 // Input data shape (1, 1, 2, 2)
2468 // Input const scales values {1.0, 1.0, 2.0, 3.0}
2469 const Shape expected_output_shape{1, 1, 4, 6};
2470 EXPECT_EQ(function->get_output_size(), 1);
2471 EXPECT_EQ(function->get_output_shape(0), expected_output_shape);
2472 EXPECT_EQ(count_ops_of_type<onnx_import::default_opset::Interpolate>(function), 1);
2473 EXPECT_EQ(count_ops_of_type<onnx_import::default_opset::Constant>(function), 2);
2476 NGRAPH_TEST(${BACKEND_NAME}, onnx_upsample9_scales_const_nearest_infer)
2478 const auto function = onnx_import::import_onnx_model(
2479 file_util::path_join(SERIALIZED_ZOO, "onnx/upsample9_scales_const_nearest.prototxt"));
2481 // Input data shape (1, 1, 2, 2)
2482 // Input const scales values {1.0, 1.0, 2.0, 3.0}
2485 const Shape expected_output_shape{1, 1, 4, 6};
2486 auto test_case = test::TestCase<TestEngine>(function);
2487 test_case.add_input<float>({1.0, 2.0, 3.0, 4.0});
2488 test_case.add_expected_output<float>(
2489 expected_output_shape, {1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0,
2490 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, 3.0, 3.0, 3.0, 4.0, 4.0, 4.0});
2494 NGRAPH_TEST(${BACKEND_NAME}, onnx_upsample9_scales_const_linear_infer)
2496 const auto function = onnx_import::import_onnx_model(
2497 file_util::path_join(SERIALIZED_ZOO, "onnx/upsample9_scales_const_linear.prototxt"));
2499 // Input data shape (1, 1, 2, 2)
2500 // Input const scales values {1.0, 1.0, 2.0, 2.0}
2503 const Shape expected_output_shape{1, 1, 4, 4};
2504 auto test_case = test::TestCase<TestEngine>(function);
2505 test_case.add_input<float>({1.0, 2.0, 3.0, 4.0});
2506 test_case.add_expected_output<float>(
2507 expected_output_shape,
2508 {1.0, 1.5, 2.0, 2.0, 2.0, 2.5, 3.0, 3.0, 3.0, 3.5, 4.0, 4.0, 3.0, 3.5, 4.0, 4.0});
2512 NGRAPH_TEST(${BACKEND_NAME}, onnx_image_scaler)
2514 const auto function = onnx_import::import_onnx_model(
2515 file_util::path_join(SERIALIZED_ZOO, "onnx/image_scaler.prototxt"));
2517 auto test_case = test::TestCase<TestEngine>(function);
2518 test_case.add_input<float>({1.0, 2.0, 3.0, 4.0, 10.0, 20.0, 30.0, 40.0});
2519 test_case.add_expected_output<float>(Shape{1, 2, 2, 2},
2520 {12.0, 14.0, 16.0, 18.0, 21.0, 41.0, 61.0, 81.0});
2524 NGRAPH_TEST(${BACKEND_NAME}, onnx_empty_initializers_handling)
2526 // int this test the "scales" input of the Resize operator is set to an empty initializer
2527 // this input should be ignored since the "sizes" optional input is provided
2528 // and the inference should use the data from the latter
2529 const auto function = onnx_import::import_onnx_model(
2530 file_util::path_join(SERIALIZED_ZOO, "onnx/empty_initializers_handling.prototxt"));
2532 const Shape expected_output_shape{2, 1, 4, 8};
2533 auto test_case = test::TestCase<TestEngine>(function);
2534 std::vector<float> input_data{2.0f, 4.0f, 1.0f, 3.0f, 7.0f, 8.0f, 9.0f, 6.0f};
2535 test_case.add_input<float>(input_data);
2536 test_case.add_expected_output<float>(
2537 expected_output_shape,
2538 {2.0f, 2.5f, 3.0f, 3.5f, 4.0f, 4.0f, 4.0f, 4.0f, 1.5f, 2.0f, 2.5f, 3.0f, 3.5f,
2539 3.5f, 3.5f, 3.5f, 1.0f, 1.5f, 2.0f, 2.5f, 3.0f, 3.0f, 3.0f, 3.0f, 1.0f, 1.5f,
2540 2.0f, 2.5f, 3.0f, 3.0f, 3.0f, 3.0f, 7.0f, 7.25f, 7.5f, 7.75f, 8.0f, 8.0f, 8.0f,
2541 8.0f, 8.0f, 7.75f, 7.5f, 7.25f, 7.0f, 7.0f, 7.0f, 7.0f, 9.0f, 8.25f, 7.5f, 6.75f,
2542 6.0f, 6.0f, 6.0f, 6.0f, 9.0f, 8.25f, 7.5f, 6.75f, 6.0f, 6.0f, 6.0f, 6.0f});
2544 test_case.run_with_tolerance_as_fp(2.0e-5f);
2547 NGRAPH_TEST(${BACKEND_NAME}, onnx_roi_align_f32)
2549 const auto function = onnx_import::import_onnx_model(
2550 file_util::path_join(SERIALIZED_ZOO, "onnx/roi_align_f32.prototxt"));
2552 auto test_case = test::TestCase<TestEngine>(function);
2553 test_case.add_input<float>({0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12.,
2554 13., 14., 15., 16., 17., 18., 19., 20., 21., 22., 23., 24., 25.,
2555 26., 27., 28., 29., 30., 31., 32., 33., 34., 35., 36., 37., 38.,
2556 39., 40., 41., 42., 43., 44., 45., 46., 47., 48., 49., 50., 51.,
2557 52., 53., 54., 55., 56., 57., 58., 59., 60., 61., 62., 63., 64.,
2558 65., 66., 67., 68., 69., 70., 71., 72., 73., 74.});
2560 test_case.add_input<float>({7., 5., 7., 5., -15., -15., -15., -15., -10., 21.,
2561 -10., 21., 13., 8., 13., 8., -14., 19., -14., 19.});
2563 test_case.add_input<int32_t>({0, 0, 0, 0, 0});
2564 test_case.add_expected_output<float>(
2566 {2.95833f, 3.20833f, 3.45833f, 3.70833f, 4.625f, 4.875f, 5.125f, 5.375f, 6.29167f,
2567 6.54167f, 6.79167f, 7.04167f, 27.9583f, 28.2083f, 28.4583f, 28.7083f, 29.625f, 29.875f,
2568 30.125f, 30.375f, 31.2917f, 31.5417f, 31.7917f, 32.0417f, 52.9583f, 53.2083f, 53.4583f,
2569 53.7083f, 54.625f, 54.875f, 55.125f, 55.375f, 56.2917f, 56.5417f, 56.7917f, 57.0417f,
2570 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
2571 0.f, 0.f, 0.f, 25.f, 25.f, 25.f, 25.f, 25.f, 25.f,
2572 25.f, 25.f, 25.f, 25.f, 25.f, 25.f, 50.f, 50.f, 50.f,
2573 50.f, 50.f, 50.f, 50.f, 50.f, 50.f, 50.f, 50.f, 50.f,
2574 7.39583f, 7.39583f, 7.42708f, 7.64583f, 9.0625f, 9.0625f, 9.09375f, 9.3125f, 10.7292f,
2575 10.7292f, 10.7604f, 10.9792f, 32.3958f, 32.3958f, 32.4271f, 32.6458f, 34.0625f, 34.0625f,
2576 34.0938f, 34.3125f, 35.7292f, 35.7292f, 35.7604f, 35.9792f, 57.3958f, 57.3958f, 57.4271f,
2577 57.6458f, 59.0625f, 59.0625f, 59.0938f, 59.3125f, 60.7292f, 60.7292f, 60.7604f, 60.9792f,
2578 4.27083f, 4.52083f, 4.77083f, 5.02083f, 5.9375f, 6.1875f, 6.4375f, 6.6875f, 7.60417f,
2579 7.85417f, 8.10417f, 8.35417f, 29.2708f, 29.5208f, 29.7708f, 30.0208f, 30.9375f, 31.1875f,
2580 31.4375f, 31.6875f, 32.6042f, 32.8542f, 33.1042f, 33.3542f, 54.2708f, 54.5208f, 54.7708f,
2581 55.0208f, 55.9375f, 56.1875f, 56.4375f, 56.6875f, 57.6042f, 57.8542f, 58.1042f, 58.3542f,
2582 6.77083f, 6.77083f, 6.77083f, 6.80208f, 8.4375f, 8.4375f, 8.4375f, 8.46875f, 10.1042f,
2583 10.1042f, 10.1042f, 10.1354f, 31.7708f, 31.7708f, 31.7708f, 31.8021f, 33.4375f, 33.4375f,
2584 33.4375f, 33.4688f, 35.1042f, 35.1042f, 35.1042f, 35.1354f, 56.7708f, 56.7708f, 56.7708f,
2585 56.8021f, 58.4375f, 58.4375f, 58.4375f, 58.4688f, 60.1042f, 60.1042f, 60.1042f, 60.1354f});
2586 test_case.run_with_tolerance_as_fp(1.0e-4f);
2589 NGRAPH_TEST(${BACKEND_NAME}, quant_dequant_pattern)
2591 const auto function = onnx_import::import_onnx_model(
2592 file_util::path_join(SERIALIZED_ZOO, "onnx/quant_dequant_pattern.prototxt"));
2593 auto test_case = test::TestCase<TestEngine>(function);
2596 test_case.add_input<float>({9.0, 10.0, 15.0, 20.0, 30.0});
2597 test_case.add_input<float>({1});
2598 test_case.add_expected_output<float>(Shape{5}, {9.0, 9.0, 15.0, 21.0, 30.0});
2602 NGRAPH_TEST(${BACKEND_NAME}, quant_dequant_pattern_axis)
2604 const auto function = onnx_import::import_onnx_model(
2605 file_util::path_join(SERIALIZED_ZOO, "onnx/quant_dequant_pattern_axis.prototxt"));
2606 auto test_case = test::TestCase<TestEngine>(function);
2608 // scale == {2.0, 3.0, 4.0}
2609 // zero point == {10, 20, 30}
2610 test_case.add_input<float>({1.0, 2.0, 3.0, 10.0, 20.0, 30.0, 40.0, 50.0, 100.0});
2611 test_case.add_expected_output<float>(Shape{3, 3}, {0, 3, 4, 10, 21, 32, 40, 51, 100});
2612 test_case.add_input<float>({1});
2616 NGRAPH_TEST(${BACKEND_NAME}, onnx_detection_output)
2618 const auto function = onnx_import::import_onnx_model(
2619 file_util::path_join(SERIALIZED_ZOO, "onnx/detection_output.prototxt"));
2620 auto test_case = test::TestCase<TestEngine>(function);
2622 auto gen_vector = [](size_t size, float min, float max) -> std::vector<float> {
2623 float step = (max - min) / size;
2624 float next = min - step;
2626 std::vector<float> out(size);
2627 std::generate(out.begin(), out.end(), [&next, &step] { return next += step; });
2631 std::vector<float> logits = gen_vector(12, -2, 2);
2632 std::vector<float> class_preds = gen_vector(9, 0, 1);
2633 std::vector<float> proposals = gen_vector(15 * 2, 0, 1);
2634 std::vector<float> output = {0, 1, 0.777778, 0.241012, 0.260378, 0.418248, 0.499622,
2635 0, 1, 0.444444, 0.10963, 0.146239, 0.176296, 0.228576,
2636 0, 2, 0.888889, 0.241012, 0.260378, 0.418248, 0.499622,
2637 0, 2, 0.555556, 0.10963, 0.146239, 0.176296, 0.228576,
2638 0, 2, 0.222222, -0.0378917, -0.00169918, -0.00210832, 0.0387362};
2639 test_case.add_input<float>(logits);
2640 test_case.add_input<float>(class_preds);
2641 test_case.add_input<float>(proposals);
2642 test_case.add_expected_output<float>(Shape{1, 1, 5, 7}, output);
2643 int tolerance_bits = 6;
2644 test_case.run(tolerance_bits);
2647 NGRAPH_TEST(${BACKEND_NAME}, onnx_prior_box)
2649 const auto function = onnx_import::import_onnx_model(
2650 file_util::path_join(SERIALIZED_ZOO, "onnx/prior_box.prototxt"));
2651 auto test_case = test::TestCase<TestEngine, test::TestCaseType::DYNAMIC>(function);
2652 std::vector<float> A(3 * 2 * 2);
2653 std::vector<float> B(3 * 6 * 6);
2654 std::vector<float> output = {
2655 -2.3200002, -2.3200002, 3.6533334, 3.6533334, -3.7053659, -3.7053659, 5.0386992,
2656 5.0386992, -0.98666668, -2.3200002, 4.9866667, 3.6533334, -2.3720326, -3.7053659,
2657 6.3720322, 5.0386992, -2.3200002, -0.98666668, 3.6533334, 4.9866667, -3.7053659,
2658 -2.3720326, 5.0386992, 6.3720322, -0.98666668, -0.98666668, 4.9866667, 4.9866667,
2659 -2.3720326, -2.3720326, 6.3720322, 6.3720322, 0.1, 0.1, 0.2,
2660 0.2, 0.1, 0.1, 0.2, 0.2, 0.1, 0.1,
2661 0.2, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1,
2662 0.1, 0.2, 0.2, 0.1, 0.1, 0.2, 0.2,
2663 0.1, 0.1, 0.2, 0.2, 0.1, 0.1, 0.2,
2666 test_case.add_input<float>(A);
2667 test_case.add_input<float>(B);
2668 test_case.add_expected_output<float>(Shape{1, 2, 32}, output);
2672 NGRAPH_TEST(${BACKEND_NAME}, onnx_normalize)
2674 const auto function = onnx_import::import_onnx_model(
2675 file_util::path_join(SERIALIZED_ZOO, "onnx/normalize.prototxt"));
2676 auto test_case = test::TestCase<TestEngine>(function);
2677 std::vector<float> data(12);
2678 std::iota(data.begin(), data.end(), 1);
2679 std::vector<float> output = {
2693 test_case.add_input<float>(data);
2694 test_case.add_expected_output<float>(Shape{1, 3, 2, 2}, output);
2698 NGRAPH_TEST(${BACKEND_NAME}, onnx_group_norm)
2700 const auto function = onnx_import::import_onnx_model(
2701 file_util::path_join(SERIALIZED_ZOO, "onnx/group_norm.prototxt"));
2702 auto test_case = test::TestCase<TestEngine>(function);
2703 Shape shape{2, 8, 2, 2};
2704 int size = shape_size(shape);
2705 std::vector<float> data(size);
2706 std::iota(data.begin(), data.end(), 0);
2707 std::vector<float> output = {
2708 -0.52752507, -0.09108937, 0.3453464, 0.78178215, 2.4364357, 3.309307, 4.1821785, 5.05505,
2709 -1.5825753, -0.27326822, 1.0360391, 2.3453465, 4.8728714, 6.618614, 8.364357, 10.1101,
2710 -2.6376252, -0.45544672, 1.726732, 3.9089108, 7.309307, 9.927921, 12.546536, 15.165151,
2711 -3.6926756, -0.6376257, 2.4174247, 5.472475, 9.745743, 13.237228, 16.728714, 20.2202,
2712 -0.52752507, -0.09108937, 0.3453464, 0.78178215, 2.4364357, 3.309307, 4.1821785, 5.05505,
2713 -1.5825753, -0.27326822, 1.0360391, 2.3453465, 4.8728714, 6.618614, 8.364357, 10.1101,
2714 -2.6376252, -0.45544672, 1.726732, 3.9089108, 7.309307, 9.927921, 12.546536, 15.165151,
2715 -3.6926756, -0.6376257, 2.4174247, 5.472475, 9.745743, 13.237228, 16.728714, 20.2202,
2718 test_case.add_input<float>(data);
2719 test_case.add_expected_output<float>(shape, output);