Deprecate nGraph v0 ops and builders (#1856)
[platform/upstream/dldt.git] / ngraph / test / onnx / onnx_import.in.cpp
1 //*****************************************************************************
2 // Copyright 2017-2020 Intel Corporation
3 //
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
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
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 //*****************************************************************************
16
17 #include <algorithm>
18 #include <cmath>
19 #include <cstdint>
20 #include <fstream>
21 #include <iterator>
22 #include <limits>
23 #include <numeric>
24 #include <sstream>
25 #include <stdexcept>
26 #include <vector>
27
28 // clang-format off
29 #ifdef ${BACKEND_NAME}_FLOAT_TOLERANCE_BITS
30 #define DEFAULT_FLOAT_TOLERANCE_BITS ${BACKEND_NAME}_FLOAT_TOLERANCE_BITS
31 #endif
32 #ifdef ${BACKEND_NAME}_DOUBLE_TOLERANCE_BITS
33 #define DEFAULT_DOUBLE_TOLERANCE_BITS ${BACKEND_NAME}_DOUBLE_TOLERANCE_BITS
34 #endif
35 // clang-format on
36
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"
53
54 NGRAPH_SUPPRESS_DEPRECATED_START
55
56 using namespace ngraph;
57
58 static std::string s_manifest = "${MANIFEST}";
59
60 using Inputs = std::vector<std::vector<float>>;
61 using Outputs = std::vector<std::vector<float>>;
62
63 using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME});
64
65 // ############################################################################ CORE TESTS
66 NGRAPH_TEST(${BACKEND_NAME}, onnx_test_test_case)
67 {
68     auto function = onnx_import::import_onnx_model(
69         file_util::path_join(SERIALIZED_ZOO, "onnx/add_abc.prototxt"));
70
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});
76     test_case.run();
77 }
78
79 NGRAPH_TEST(${BACKEND_NAME}, onnx_test_test_case_mutliple_inputs)
80 {
81     auto function = onnx_import::import_onnx_model(
82         file_util::path_join(SERIALIZED_ZOO, "onnx/add_abc.prototxt"));
83
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});
87     test_case.run();
88 }
89
90 NGRAPH_TEST(${BACKEND_NAME}, onnx_output_names_check)
91 {
92     auto function = onnx_import::import_onnx_model(
93         file_util::path_join(SERIALIZED_ZOO, "onnx/split_equal_parts_default.prototxt"));
94
95     std::size_t size = function->get_output_size();
96     for (std::size_t i{0}; i < size; ++i)
97     {
98         std::shared_ptr<Node> node = function->get_output_op(i);
99         EXPECT_EQ(node->get_friendly_name(), "output_" + std::to_string(i + 1));
100     }
101 }
102
103 NGRAPH_TEST(${BACKEND_NAME}, onnx_node_names_check)
104 {
105     auto function = onnx_import::import_onnx_model(
106         file_util::path_join(SERIALIZED_ZOO, "onnx/add_abc.prototxt"));
107
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();
111     std::copy_if(
112         ordered_ops.begin(),
113         ordered_ops.end(),
114         std::back_inserter(additions),
115         [](std::shared_ptr<Node> op) { return std::string(op->get_type_name()) == "Add"; });
116
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");
120 }
121
122 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_add_abc)
123 {
124     auto function = onnx_import::import_onnx_model(
125         file_util::path_join(SERIALIZED_ZOO, "onnx/add_abc.prototxt"));
126
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});
130     test_case.run();
131 }
132
133 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_binary_add_abc)
134 {
135     auto function =
136         onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/add_abc.onnx"));
137
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});
141     test_case.run();
142 }
143
144 NGRAPH_TEST(${BACKEND_NAME}, onnx_bool_const_op)
145 {
146     auto function = onnx_import::import_onnx_model(
147         file_util::path_join(SERIALIZED_ZOO, "onnx/bool_const_op.prototxt"));
148
149     auto test_case = test::TestCase<TestEngine>(function);
150     test_case.add_expected_output(std::vector<bool>{1, 0, 0, 1});
151     test_case.run();
152 }
153
154 NGRAPH_TEST(${BACKEND_NAME}, onnx_bool_init_and)
155 {
156     auto function = onnx_import::import_onnx_model(
157         file_util::path_join(SERIALIZED_ZOO, "onnx/bool_init_and.prototxt"));
158
159     auto test_case = test::TestCase<TestEngine>(function);
160     test_case.add_expected_output(std::vector<bool>{1});
161     test_case.run();
162 }
163
164 NGRAPH_TEST(${BACKEND_NAME}, onnx_bool_input_or)
165 {
166     auto function = onnx_import::import_onnx_model(
167         file_util::path_join(SERIALIZED_ZOO, "onnx/bool_input_or.prototxt"));
168
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});
173     test_case.run();
174 }
175
176 NGRAPH_TEST(${BACKEND_NAME}, onnx_bool_init_raw)
177 {
178     auto function = onnx_import::import_onnx_model(
179         file_util::path_join(SERIALIZED_ZOO, "onnx/bool_init_raw.prototxt"));
180
181     auto test_case = test::TestCase<TestEngine>(function);
182     test_case.add_expected_output(std::vector<bool>{true, false, true});
183     test_case.run();
184 }
185
186 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_add_abc_initializers)
187 {
188     auto function = onnx_import::import_onnx_model(
189         file_util::path_join(SERIALIZED_ZOO, "onnx/add_abc_initializers.prototxt"));
190
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});
194     test_case.run();
195 }
196
197 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_override_op)
198 {
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))};
203         });
204
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))};
209         });
210
211     auto function = onnx_import::import_onnx_model(
212         file_util::path_join(SERIALIZED_ZOO, "onnx/override_op.prototxt"));
213
214     Inputs inputs;
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});
217
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});
221     test_case.run();
222 }
223
224 NGRAPH_TEST(${BACKEND_NAME}, onnx_import_non_existing_file)
225 {
226     try
227     {
228         onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/i.dont.exist"));
229     }
230     catch (const std::runtime_error& exc)
231     {
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);
235     }
236 }
237
238 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_unsupported_op)
239 {
240     try
241     {
242         onnx_import::import_onnx_model(
243             file_util::path_join(SERIALIZED_ZOO, "onnx/unsupported_op.prototxt"));
244         FAIL() << "Expected ngraph::ngraph_error";
245     }
246     catch (ngraph::ngraph_error const& err)
247     {
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);
252     }
253     catch (...)
254     {
255         FAIL() << "Expected ngraph::ngraph_error";
256     }
257 }
258
259 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_custom_op)
260 {
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))};
265         });
266
267     auto function = onnx_import::import_onnx_model(
268         file_util::path_join(SERIALIZED_ZOO, "onnx/custom_operator.prototxt"));
269
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});
273     test_case.run();
274 }
275
276 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_custom_op_default_domain)
277 {
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))};
282         });
283
284     auto function = onnx_import::import_onnx_model(
285         file_util::path_join(SERIALIZED_ZOO, "onnx/custom_operator_default_domain.prototxt"));
286
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});
290     test_case.run();
291 }
292
293 NGRAPH_TEST(${BACKEND_NAME}, onnx_is_op_supported)
294 {
295     // Simple case
296     EXPECT_TRUE(onnx_import::is_operator_supported("Sum", 1, "ai.onnx"));
297     // With fallback
298     EXPECT_TRUE(onnx_import::is_operator_supported("Sum", 100, "ai.onnx"));
299
300     // Different opset versions
301     EXPECT_TRUE(onnx_import::is_operator_supported("Add", 1, "ai.onnx"));
302     EXPECT_TRUE(onnx_import::is_operator_supported("Add", 7, "ai.onnx"));
303
304     // Default domain name
305     EXPECT_TRUE(onnx_import::is_operator_supported("Sum", 1));
306
307     // Unregistered operator
308     EXPECT_FALSE(onnx_import::is_operator_supported("DummyOp", 1));
309     EXPECT_FALSE(onnx_import::is_operator_supported("DummyOp", 1, "ai.onnx"));
310     EXPECT_FALSE(onnx_import::is_operator_supported("DummyOp", 10, "ai.onnx"));
311
312     // Operator with bad domain name
313     EXPECT_FALSE(onnx_import::is_operator_supported("Sum", 1, "bad.domain"));
314
315     // Registered custom operator
316     onnx_import::register_operator(
317         "AddQ", 1, "com.intel.ai", [](const onnx_import::Node& node) -> OutputVector {
318             OutputVector ng_inputs{node.get_ng_inputs()};
319             return {std::make_shared<ngraph::op::Add>(ng_inputs.at(0), ng_inputs.at(1))};
320         });
321     EXPECT_TRUE(onnx_import::is_operator_supported("AddQ", 1, "com.intel.ai"));
322 }
323
324 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_missing_op_domain)
325 {
326     onnx_import::register_operator(
327         "CustomAdd", 1, "custom.op", [](const onnx_import::Node& node) -> OutputVector {
328             OutputVector ng_inputs{node.get_ng_inputs()};
329             return {std::make_shared<ngraph::op::Add>(ng_inputs.at(0), ng_inputs.at(1))};
330         });
331
332     EXPECT_TRUE(onnx_import::is_operator_supported("CustomAdd", 1, "custom.op"));
333
334     auto function = onnx_import::import_onnx_model(
335         file_util::path_join(SERIALIZED_ZOO, "onnx/missing_op_domain.prototxt"));
336
337     Inputs inputs;
338     inputs.emplace_back(std::vector<float>{0.f, 1.f, 2.f, 3.f});
339     inputs.emplace_back(std::vector<float>{0.f, 1.f, 2.f, 3.f});
340
341     auto test_case = test::TestCase<TestEngine>(function);
342     test_case.add_multiple_inputs(inputs);
343     test_case.add_expected_output<float>({0.f, 2.f, 4.f, 6.f});
344     test_case.run();
345 }
346
347 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_unknown_domain)
348 {
349     // the importer should not throw when it encounters an unknown domain in the model
350     EXPECT_NO_THROW(onnx_import::import_onnx_model(
351         file_util::path_join(SERIALIZED_ZOO, "onnx/unknown_domain.prototxt")));
352 }
353
354 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_op_in_unknown_domain)
355 {
356     try
357     {
358         onnx_import::import_onnx_model(
359             file_util::path_join(SERIALIZED_ZOO, "onnx/unknown_domain_add.prototxt"));
360
361         FAIL() << "The onnx_importer did not throw for unknown domain and op";
362     }
363     catch (const ngraph::ngraph_error& e)
364     {
365         const std::string msg = e.what();
366
367         EXPECT_NE(msg.find("unknown.domain.Add"), std::string::npos)
368             << "The error message should contain domain and op name: unknown.domain.Add";
369     }
370 }
371
372 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_missing_input)
373 {
374     onnx_import::register_operator(
375         "TestMissingInOut", 1, "com.intel.ai", [](const onnx_import::Node& node) -> OutputVector {
376             OutputVector ng_inputs{node.get_ng_inputs()};
377             Output<ngraph::Node> A = ng_inputs.at(0);
378             Output<ngraph::Node> B = ng_inputs.at(1);
379             Output<ngraph::Node> C = ng_inputs.at(2);
380
381             A = A * C;
382             if (!ngraph::op::is_null(B))
383             {
384                 B = B / C;
385             }
386
387             C = C + C;
388             return {A, B, C};
389         });
390
391     onnx_import::register_operator(
392         "TestMissingIn", 1, "com.intel.ai", [](const onnx_import::Node& node) -> OutputVector {
393             OutputVector ng_inputs{node.get_ng_inputs()};
394             std::shared_ptr<ngraph::Node> result = std::make_shared<ngraph::op::Constant>(
395                 element::f32, ngraph::Shape{2, 2}, std::vector<float>{1, 1, 1, 1});
396
397             for (const auto& ng_input : ng_inputs)
398             {
399                 if (!ngraph::op::is_null(ng_input))
400                 {
401                     result = ng_input * result;
402                 }
403             }
404
405             return {result};
406         });
407
408     auto function = onnx_import::import_onnx_model(
409         file_util::path_join(SERIALIZED_ZOO, "onnx/missing_input.prototxt"));
410
411     Inputs inputs{{1, 2, 3, 4}, {5, 6, 7, 8}};
412
413     auto test_case = test::TestCase<TestEngine>(function);
414     test_case.add_multiple_inputs(inputs);
415     test_case.add_expected_output<float>({50, 144, 294, 512});
416     test_case.run();
417 }
418
419 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_initializer_wo_input)
420 {
421     // This test checks a model which has an initializer, but no input with the same name
422     auto function = onnx_import::import_onnx_model(
423         file_util::path_join(SERIALIZED_ZOO, "onnx/initializer_wo_input.prototxt"));
424
425     auto test_case = test::TestCase<TestEngine>(function);
426     test_case.add_input<float>({0, 1, 2, 3, 4, 5});
427     test_case.add_expected_output<float>({0, 2, 6, 12, 20, 30});
428     test_case.run();
429 }
430
431 // ############################################################################ OPERATOR TESTS
432 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_addmul_abc)
433 {
434     auto function = onnx_import::import_onnx_model(
435         file_util::path_join(SERIALIZED_ZOO, "onnx/addmul_abc.prototxt"));
436
437     auto test_case = test::TestCase<TestEngine>(function);
438     test_case.add_input<float>({9, 10, 11, 12});
439     test_case.add_input<float>({5, 6, 7, 8});
440     test_case.add_input<float>({1, 2, 3, 4});
441     test_case.add_expected_output<float>(Shape{1, 2, 2}, {46, 62, 80, 100});
442     test_case.run();
443 }
444
445 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_argmin_no_keepdims)
446 {
447     auto function = onnx_import::import_onnx_model(
448         file_util::path_join(SERIALIZED_ZOO, "onnx/argmin_no_keepdims.prototxt"));
449
450     auto test_case = test::TestCase<TestEngine>(function);
451     test_case.add_input<float>({2, 1, 3, 10});
452     test_case.add_expected_output<float>(Shape{2}, {1, 0});
453     test_case.run();
454 }
455
456 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_batch_norm_default)
457 {
458     // Batch Normalization with default parameters
459     auto function = onnx_import::import_onnx_model(
460         file_util::path_join(SERIALIZED_ZOO, "onnx/batchnorm_default.prototxt"));
461
462     auto test_case = test::TestCase<TestEngine>(function);
463     test_case.add_input<float>({-1.f, 0.f, 1.f, 2.f, 3.f, 4.f}); // data {1, 2, 1, 3}
464     test_case.add_input<float>({1.f, 1.5f});                     // scale
465     test_case.add_input<float>({0.f, 1.f});                      // bias
466     test_case.add_input<float>({0.f, 3.f});                      // mean
467     test_case.add_input<float>({1.f, 1.5f});                     // var
468     test_case.add_expected_output<float>(
469         Shape{1, 2, 1, 3}, {-0.999995f, 0.f, 0.999995f, -0.22474074f, 1.f, 2.2247407f});
470     test_case.run();
471 }
472
473 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_relu)
474 {
475     // Simple ReLU test
476     auto function =
477         onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/relu.prototxt"));
478
479     auto test_case = test::TestCase<TestEngine>(function);
480     test_case.add_input<float>({-1, -2, 0, 1, 2, 3});
481     test_case.add_expected_output<float>({0, 0, 0, 1, 2, 3});
482     test_case.run();
483 }
484
485 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_sum_opset1)
486 {
487     // Simple Sum test for opset1.
488     auto function = onnx_import::import_onnx_model(
489         file_util::path_join(SERIALIZED_ZOO, "onnx/sum_opset1.prototxt"));
490
491     auto test_case = test::TestCase<TestEngine>(function);
492     test_case.add_input<float>({3.f, 0.f, 2.f});
493     test_case.add_input<float>({1.f, 3.f, 4.f});
494     test_case.add_input<float>({2.f, 6.f, 6.f});
495     test_case.add_expected_output<float>(Shape{3}, {6.f, 9.f, 12.f});
496     test_case.run();
497 }
498
499 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_sum)
500 {
501     // Simple Sum test for opset8.
502     auto function =
503         onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/sum.prototxt"));
504
505     auto test_case = test::TestCase<TestEngine>(function);
506     test_case.add_input<float>({3.f});
507     test_case.add_input<float>({1.f, 3.f, 4.f});
508     test_case.add_input<float>({2.f, 6.f, 6.f});
509     test_case.add_expected_output<float>(Shape{3}, {6.f, 12.f, 13.f});
510     test_case.run();
511 }
512
513 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_sum_one_input)
514 {
515     auto function = onnx_import::import_onnx_model(
516         file_util::path_join(SERIALIZED_ZOO, "onnx/sum_one_input.prototxt"));
517
518     // input data shape (3, )
519     auto test_case = test::TestCase<TestEngine>(function);
520     test_case.add_input<float>({3.f, 0.f, 2.f});
521     test_case.add_expected_output<float>({3.f, 0.f, 2.f});
522     test_case.run();
523 }
524
525 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_cum_sum_1d)
526 {
527     auto function = onnx_import::import_onnx_model(
528         file_util::path_join(SERIALIZED_ZOO, "onnx/cum_sum_1d.prototxt"));
529
530     auto test_case = test::TestCase<TestEngine>(function);
531     test_case.add_input<float>({1.f, 2.f, 3.f});
532     test_case.add_expected_output<float>(Shape{3}, {1.f, 3.f, 6.f});
533     test_case.run();
534 }
535
536 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_cum_sum_2d_axis_input)
537 {
538     auto function = onnx_import::import_onnx_model(
539         file_util::path_join(SERIALIZED_ZOO, "onnx/cum_sum_2d_axis_input.prototxt"));
540
541     auto test_case = test::TestCase<TestEngine>(function);
542     test_case.add_input<float>({1.f, 2.f, 3.f, 4.f, 5.f, 6.f});
543     test_case.add_expected_output<float>(Shape{2, 3}, {1.f, 3.f, 6.f, 4.f, 9.f, 15.f});
544     test_case.run();
545 }
546
547 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_cum_sum_2d_dynamic_axis_input)
548 {
549     auto function = onnx_import::import_onnx_model(
550         file_util::path_join(SERIALIZED_ZOO, "onnx/cum_sum_2d_dynamic_axis_input.prototxt"));
551
552     auto test_case = test::TestCase<TestEngine>(function);
553     test_case.add_input<float>({1.f, 2.f, 3.f, 4.f, 5.f, 6.f});
554     test_case.add_input<std::int32_t>({1});
555     test_case.add_expected_output<float>(Shape{2, 3}, {1.f, 3.f, 6.f, 4.f, 9.f, 15.f});
556     test_case.run();
557 }
558
559 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_cum_sum_3d_exclusive_reverse)
560 {
561     auto function = onnx_import::import_onnx_model(
562         file_util::path_join(SERIALIZED_ZOO, "onnx/cum_sum_3d_exclusive_reverse.prototxt"));
563
564     auto test_case = test::TestCase<TestEngine>(function);
565     test_case.add_input<float>({1.f,  2.f,  3.f,  4.f,  5.f,  6.f,  7.f,  8.f,
566                                 9.f,  10.f, 11.f, 12.f, 13.f, 14.f, 15.f, 16.f,
567                                 17.f, 18.f, 19.f, 20.f, 21.f, 22.f, 23.f, 24.f});
568     test_case.add_expected_output<float>(
569         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,
570                          0.f,  0.f,  0.f,  0.f,  0.f,  0.f,  0.f,  0.f,  0.f,  0.f,  0.f,  0.f});
571     test_case.run();
572 }
573
574 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_min_two_inputs_opset1)
575 {
576     auto function = onnx_import::import_onnx_model(
577         file_util::path_join(SERIALIZED_ZOO, "onnx/min_two_inputs_opset1.prototxt"));
578
579     // input data shape (3, )
580     auto test_case = test::TestCase<TestEngine>(function);
581     test_case.add_input<float>({1.f, 2.f, 1.f});
582     test_case.add_input<float>({1.f, 4.f, 4.f});
583     test_case.add_expected_output<float>({1.f, 2.f, 1.f});
584     test_case.run();
585 }
586
587 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_min_two_inputs)
588 {
589     auto function = onnx_import::import_onnx_model(
590         file_util::path_join(SERIALIZED_ZOO, "onnx/min_two_inputs.prototxt"));
591
592     // input data shape (3, )
593     auto test_case = test::TestCase<TestEngine>(function);
594     test_case.add_input<float>({2.f});
595     test_case.add_input<float>({1.f, 4.f, 4.f});
596     test_case.add_expected_output<float>({1.f, 2.f, 2.f});
597     test_case.run();
598 }
599
600 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_max_opset1)
601 {
602     auto function = onnx_import::import_onnx_model(
603         file_util::path_join(SERIALIZED_ZOO, "onnx/max_opset1.prototxt"));
604
605     // input data shape (3, )
606     auto test_case = test::TestCase<TestEngine>(function);
607     test_case.add_input<float>({3.f, 2.f, 1.f});
608     test_case.add_input<float>({1.f, 4.f, 4.f});
609     test_case.add_input<float>({2.f, 5.f, 3.f});
610
611     test_case.add_expected_output<float>({3.f, 5.f, 4.f});
612     test_case.run();
613 }
614
615 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_max)
616 {
617     auto function =
618         onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/max.prototxt"));
619
620     // input data shape (3, )
621     auto test_case = test::TestCase<TestEngine>(function);
622     test_case.add_input<float>({1.f, 4.f, 4.f});
623     test_case.add_input<float>({3.f});
624     test_case.add_input<float>({2.f, 5.f, 3.f});
625
626     test_case.add_expected_output<float>({3.f, 5.f, 4.f});
627     test_case.run();
628 }
629
630 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_mean_opset1)
631 {
632     auto function = onnx_import::import_onnx_model(
633         file_util::path_join(SERIALIZED_ZOO, "onnx/mean_opset1.prototxt"));
634
635     // input data shape (3, )
636     auto test_case = test::TestCase<TestEngine>(function);
637     test_case.add_input<float>({3.f, 0.f, 2.f});
638     test_case.add_input<float>({1.f, 3.f, 4.f});
639     test_case.add_input<float>({2.f, 6.f, 6.f});
640
641     test_case.add_expected_output<float>({2.f, 3.f, 4.f});
642     test_case.run();
643 }
644
645 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_mean)
646 {
647     auto function =
648         onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/mean.prototxt"));
649
650     // input data shape (3, )
651     auto test_case = test::TestCase<TestEngine>(function);
652     test_case.add_input<float>({3.f});
653     test_case.add_input<float>({1.f, 2.f, 5.f});
654     test_case.add_input<float>({2.f, 7.f, 7.f});
655
656     test_case.add_expected_output<float>({2.f, 4.f, 5.f});
657     test_case.run();
658 }
659
660 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_gemm_abc)
661 {
662     auto function = onnx_import::import_onnx_model(
663         file_util::path_join(SERIALIZED_ZOO, "onnx/gemm_abc.prototxt"));
664
665     Inputs inputs;
666     inputs.emplace_back(test::NDArray<float, 2>(
667                             {{1, 2, 3, 4, 5, 6}, {7, 8, 9, 10, 11, 12}, {13, 14, 15, 16, 17, 18}})
668                             .get_vector());
669
670     inputs.emplace_back(test::NDArray<float, 2>({{19, 20, 21, 22},
671                                                  {23, 24, 25, 26},
672                                                  {27, 28, 29, 30},
673                                                  {31, 32, 33, 34},
674                                                  {35, 36, 37, 38},
675                                                  {39, 40, 41, 42}})
676                             .get_vector());
677
678     inputs.emplace_back(
679         test::NDArray<float, 2>({{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}}).get_vector());
680
681     auto expected_output =
682         test::NDArray<float, 2>(
683             {{340, 350.5, 361, 371.5}, {862, 890.5, 919, 947.5}, {1384, 1430.5, 1477, 1523.5}})
684             .get_vector();
685
686     auto test_case = test::TestCase<TestEngine>(function);
687     test_case.add_multiple_inputs(inputs);
688     test_case.add_expected_output(expected_output);
689     test_case.run();
690 }
691
692 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_matmul)
693 {
694     auto function = onnx_import::import_onnx_model(
695         file_util::path_join(SERIALIZED_ZOO, "onnx/matmul.prototxt"));
696
697     std::vector<std::vector<float>> inputs;
698
699     inputs.emplace_back(
700         test::NDArray<float, 2>({{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}}).get_vector());
701
702     inputs.emplace_back(
703         test::NDArray<float, 2>({{13, 14, 15}, {16, 17, 18}, {19, 20, 21}, {22, 23, 24}})
704             .get_vector());
705
706     auto expected_output =
707         test::NDArray<float, 2>({{190, 200, 210}, {470, 496, 522}, {750, 792, 834}}).get_vector();
708
709     auto test_case = test::TestCase<TestEngine>(function);
710     test_case.add_multiple_inputs(inputs);
711     test_case.add_expected_output(expected_output);
712     test_case.run();
713 }
714
715 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_softmax_0D)
716 {
717     auto function = onnx_import::import_onnx_model(
718         file_util::path_join(SERIALIZED_ZOO, "onnx/softmax_0D.prototxt"));
719
720     auto test_case = test::TestCase<TestEngine>(function);
721     test_case.add_input<float>({3.141592});
722     test_case.add_expected_output<float>({1.0});
723     test_case.run();
724 }
725
726 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_softmax_1D)
727 {
728     auto function = onnx_import::import_onnx_model(
729         file_util::path_join(SERIALIZED_ZOO, "onnx/softmax_1D.prototxt"));
730
731     auto test_case = test::TestCase<TestEngine>(function);
732     test_case.add_input<float>({-1.0, 0.0, 1.0});
733     test_case.add_expected_output<float>({0.09003058, 0.24472848, 0.66524094});
734     test_case.run();
735 }
736 namespace
737 {
738     // common input for all Softmax 3D test cases (Shape = {3,4,5})
739     const std::vector<float> SOFTMAX_INPUT = {
740         2.75793882,  -0.50841322, 0.82013929,  -0.62409912, -0.96136118, 0.21004745,  1.38337255,
741         1.19030397,  2.0940445,   -0.03551657, -0.78686039, 1.992782,    0.04300319,  -0.29230777,
742         -0.56797112, -1.26732165, -0.61935399, 0.57670432,  0.92844898,  2.82469233,
743
744         0.98721677,  -0.05100663, -1.21178917, -0.17530157, 1.40051805,  -0.13259761, -1.14313018,
745         0.2673723,   -0.87996154, 1.29053106,  1.55,        0.8396538,   1.20729817,  0.23727845,
746         -0.89113606, -1.70909842, 0.26460363,  -0.70566808, 2.383518,    1.07024615,
747
748         -1.21722605, 0.82919357,  0.55765697,  0.12657686,  0.63432172,  0.75425957,  -2.43721014,
749         -1.24478184, 2.65316853,  1.19509542,  -0.95523998, 0.5149006,   -0.01151649, 0.68327026,
750         -0.4589638,  -0.46554745, 0.21055324,  0.39266729,  2.05098086,  1.83207919};
751 }
752
753 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_softmax_axis_0)
754 {
755     auto function = onnx_import::import_onnx_model(
756         file_util::path_join(SERIALIZED_ZOO, "onnx/softmax_axis_0.prototxt"));
757
758     auto test_case = test::TestCase<TestEngine>(function);
759     test_case.add_input<float>(SOFTMAX_INPUT);
760
761     test_case.add_expected_output<float>(
762         {0.09683057, 0.00369363, 0.01394559, 0.00329012, 0.00234823, 0.00757665, 0.02449322,
763          0.02019284, 0.04985249, 0.00592694, 0.00279593, 0.04505148, 0.00641108, 0.00458466,
764          0.00348007, 0.00172928, 0.00330577, 0.01093237, 0.01554086, 0.10351497,
765
766          0.01648154, 0.00583583, 0.00182802, 0.00515374, 0.02491679, 0.00537859, 0.00195794,
767          0.00802367, 0.00254737, 0.0223216,  0.02893419, 0.0142204,  0.02053893, 0.00778581,
768          0.00251907, 0.00111174, 0.00800149, 0.0030324,  0.06658917, 0.0179084,
769
770          0.00181811, 0.01407243, 0.01072611, 0.0069699,  0.01158077, 0.01305647, 0.00053677,
771          0.0017687,  0.08719896, 0.02028982, 0.00236265, 0.01027717, 0.0060709,  0.01216173,
772          0.00388087, 0.00385541, 0.00758048, 0.00909469, 0.04775123, 0.03836337});
773
774     test_case.run(6);
775 }
776
777 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_softmax_axis_1)
778 {
779     auto function = onnx_import::import_onnx_model(
780         file_util::path_join(SERIALIZED_ZOO, "onnx/softmax_axis_1.prototxt"));
781
782     auto test_case = test::TestCase<TestEngine>(function);
783     test_case.add_input<float>(SOFTMAX_INPUT);
784
785     test_case.add_expected_output<float>(
786         {0.22757064, 0.00868076, 0.03277484, 0.00773243, 0.0055188,  0.0178066,  0.05756383,
787          0.04745709, 0.11716303, 0.01392945, 0.00657097, 0.10587974, 0.01506727, 0.01077484,
788          0.00817884, 0.00406413, 0.00776921, 0.0256932,  0.03652405, 0.24328028,
789
790          0.06217413, 0.02201481, 0.00689594, 0.01944171, 0.09399488, 0.02028993, 0.00738604,
791          0.03026811, 0.00960958, 0.08420492, 0.10914991, 0.05364435, 0.07748005, 0.02937079,
792          0.0095028,  0.00419387, 0.03018442, 0.01143929, 0.2511977,  0.06755678,
793
794          0.00587593, 0.04548053, 0.0346656,  0.02252594, 0.03742775, 0.04219705, 0.00173478,
795          0.00571623, 0.2818174,  0.06557446, 0.00763582, 0.03321466, 0.01962049, 0.03930537,
796          0.01254255, 0.01246025, 0.02449929, 0.02939305, 0.15432668, 0.12398617});
797
798     test_case.run(4);
799 }
800
801 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_softmax_invalid_axis_1D)
802 {
803     ASSERT_THROW(onnx_import::import_onnx_model(
804                      file_util::path_join(SERIALIZED_ZOO, "onnx/softmax_invalid_axis_1D.prototxt")),
805                  ngraph::ngraph_error)
806         << "Softmax model with invalid axis was successfully imported while it should have thrown.";
807 }
808
809 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_softmax_invalid_axis_3D)
810 {
811     ASSERT_THROW(onnx_import::import_onnx_model(
812                      file_util::path_join(SERIALIZED_ZOO, "onnx/softmax_invalid_axis_3D.prototxt")),
813                  ngraph::ngraph_error)
814         << "Softmax model with invalid axis was successfully imported while it should have thrown.";
815 }
816
817 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_sub)
818 {
819     auto function =
820         onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/sub.prototxt"));
821
822     Inputs inputs;
823     inputs.emplace_back(test::NDArray<float, 3>({{{1, 2, 3}}}).get_vector());
824
825     inputs.emplace_back(test::NDArray<float, 3>({{{4, 5, 7}}}).get_vector());
826
827     auto expected_output = test::NDArray<float, 3>({{{-3, -3, -4}}}).get_vector();
828
829     auto test_case = test::TestCase<TestEngine>(function);
830     test_case.add_multiple_inputs(inputs);
831     test_case.add_expected_output(expected_output);
832     test_case.run();
833 }
834
835 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_div)
836 {
837     auto function =
838         onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/div.prototxt"));
839
840     Inputs inputs;
841     inputs.emplace_back(test::NDArray<float, 3>({{{1, 2, 3}}}).get_vector());
842     inputs.emplace_back(test::NDArray<float, 3>({{{1, 4, 12}}}).get_vector());
843
844     auto expected_output = test::NDArray<float, 3>({{{1, 0.5, 0.25}}}).get_vector();
845
846     auto test_case = test::TestCase<TestEngine>(function);
847     test_case.add_multiple_inputs(inputs);
848     test_case.add_expected_output(expected_output);
849     test_case.run();
850 }
851
852 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_add_bcast)
853 {
854     auto function = onnx_import::import_onnx_model(
855         file_util::path_join(SERIALIZED_ZOO, "onnx/add_bcast.prototxt"));
856
857     Inputs inputs;
858     inputs.emplace_back(test::NDArray<float, 3>(
859                             {{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}},
860                              {{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}},
861                              {{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}}})
862                             .get_vector());
863
864     inputs.emplace_back(test::NDArray<float, 1>({1, 2, 3, 4, 5}).get_vector());
865
866     auto expected_output =
867         test::NDArray<float, 4>(
868             {{{{2, 3, 4, 5, 6}, {2, 3, 4, 5, 6}, {2, 3, 4, 5, 6}, {2, 3, 4, 5, 6}},
869               {{2, 3, 4, 5, 6}, {2, 3, 4, 5, 6}, {2, 3, 4, 5, 6}, {2, 3, 4, 5, 6}},
870               {{2, 3, 4, 5, 6}, {2, 3, 4, 5, 6}, {2, 3, 4, 5, 6}, {2, 3, 4, 5, 6}}}})
871             .get_vector();
872
873     auto test_case = test::TestCase<TestEngine>(function);
874     test_case.add_multiple_inputs(inputs);
875     test_case.add_expected_output(expected_output);
876     test_case.run();
877 }
878
879 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_reduce_log_sum)
880 {
881     auto function = onnx_import::import_onnx_model(
882         file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_log_sum.prototxt"));
883
884     // input data shape (1, 1, 4, 4)
885     Inputs inputs{
886         test::NDArray<float, 4>({{{{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}}}})
887             .get_vector()};
888
889     // output data shape (1,)
890     auto expected_output = test::NDArray<float, 4>({{{{2.77258872f}}}}).get_vector();
891
892     auto test_case = test::TestCase<TestEngine>(function);
893     test_case.add_multiple_inputs(inputs);
894     test_case.add_expected_output(expected_output);
895     test_case.run();
896 }
897
898 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_reduce_log_sum_exp)
899 {
900     auto function = onnx_import::import_onnx_model(
901         file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_log_sum_exp.prototxt"));
902
903     // input data shape (1, 1, 4, 4)
904     Inputs inputs{
905         test::NDArray<float, 4>({{{{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}}}})
906             .get_vector()};
907
908     // output data shape (1,)
909     auto expected_output = test::NDArray<float, 4>({{{{3.77258872f}}}}).get_vector();
910
911     auto test_case = test::TestCase<TestEngine>(function);
912     test_case.add_multiple_inputs(inputs);
913     test_case.add_expected_output(expected_output);
914     test_case.run();
915 }
916
917 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_reduce_l1)
918 {
919     auto function = onnx_import::import_onnx_model(
920         file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_l1.prototxt"));
921
922     // input data shape (1, 1, 4, 4)
923     Inputs inputs{
924         test::NDArray<float, 4>({{{{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}}}})
925             .get_vector()};
926
927     // output data shape (1,)
928     auto expected_output = test::NDArray<float, 4>({{{{16}}}}).get_vector();
929
930     auto test_case = test::TestCase<TestEngine>(function);
931     test_case.add_multiple_inputs(inputs);
932     test_case.add_expected_output(expected_output);
933     test_case.run();
934 }
935
936 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_reduce_l2)
937 {
938     auto function = onnx_import::import_onnx_model(
939         file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_l2.prototxt"));
940
941     // input data shape (1, 1, 4, 4)
942     Inputs inputs{
943         test::NDArray<float, 4>({{{{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}}}})
944             .get_vector()};
945
946     // output data shape (1,)
947     auto expected_output = test::NDArray<float, 4>({{{{4}}}}).get_vector();
948
949     auto test_case = test::TestCase<TestEngine>(function);
950     test_case.add_multiple_inputs(inputs);
951     test_case.add_expected_output(expected_output);
952     test_case.run();
953 }
954
955 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_reduce_max)
956 {
957     auto function = onnx_import::import_onnx_model(
958         file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_max.prototxt"));
959
960     // input data shape (1, 1, 4, 4)
961     Inputs inputs{
962         test::NDArray<float, 4>({{{{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}}}})
963             .get_vector()};
964
965     // output data shape (1,)
966     auto expected_output = test::NDArray<float, 4>({{{{16}}}}).get_vector();
967
968     auto test_case = test::TestCase<TestEngine>(function);
969     test_case.add_multiple_inputs(inputs);
970     test_case.add_expected_output(expected_output);
971     test_case.run();
972 }
973
974 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_reduce_mean)
975 {
976     auto function = onnx_import::import_onnx_model(
977         file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_mean.prototxt"));
978
979     // input data shape (1, 1, 4, 4)
980     Inputs inputs{
981         test::NDArray<float, 4>({{{{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}}}})
982             .get_vector()};
983
984     // output data shape (1,)
985     auto expected_output = test::NDArray<float, 4>({{{{1}}}}).get_vector();
986
987     auto test_case = test::TestCase<TestEngine>(function);
988     test_case.add_multiple_inputs(inputs);
989     test_case.add_expected_output(Shape{}, expected_output);
990     test_case.run();
991 }
992
993 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_reduce_min)
994 {
995     auto function = onnx_import::import_onnx_model(
996         file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_min.prototxt"));
997
998     // input data shape (1, 1, 4, 4)
999     Inputs inputs{
1000         test::NDArray<float, 4>({{{{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}}}})
1001             .get_vector()};
1002
1003     // output data shape (1,)
1004     auto expected_output = test::NDArray<float, 4>({{{{1}}}}).get_vector();
1005
1006     auto test_case = test::TestCase<TestEngine>(function);
1007     test_case.add_multiple_inputs(inputs);
1008     test_case.add_expected_output(expected_output);
1009     test_case.run();
1010 }
1011
1012 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_reduce_prod)
1013 {
1014     auto function = onnx_import::import_onnx_model(
1015         file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_prod.prototxt"));
1016
1017     // input data shape (1, 1, 4, 4)
1018     Inputs inputs{
1019         test::NDArray<float, 4>({{{{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}}}})
1020             .get_vector()};
1021
1022     // output data shape (1,)
1023     auto expected_output = test::NDArray<float, 4>({{{{1}}}}).get_vector();
1024
1025     auto test_case = test::TestCase<TestEngine>(function);
1026     test_case.add_multiple_inputs(inputs);
1027     test_case.add_expected_output(expected_output);
1028     test_case.run();
1029 }
1030
1031 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_reduce_sum)
1032 {
1033     auto function = onnx_import::import_onnx_model(
1034         file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_sum.prototxt"));
1035
1036     // input data shape (1, 1, 4, 4)
1037     Inputs inputs{
1038         test::NDArray<float, 4>({{{{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}}}})
1039             .get_vector()};
1040
1041     // output data shape (1,)
1042     auto expected_output = test::NDArray<float, 4>({{{{16}}}}).get_vector();
1043
1044     auto test_case = test::TestCase<TestEngine>(function);
1045     test_case.add_multiple_inputs(inputs);
1046     test_case.add_expected_output(expected_output);
1047     test_case.run();
1048 }
1049
1050 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_reduce_sum_square)
1051 {
1052     auto function = onnx_import::import_onnx_model(
1053         file_util::path_join(SERIALIZED_ZOO, "onnx/reduce_sum_square.prototxt"));
1054
1055     // input data shape (1, 1, 4, 4)
1056     Inputs inputs{
1057         test::NDArray<float, 4>({{{{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}}}})
1058             .get_vector()};
1059
1060     // output data shape (1,)
1061     auto expected_output = test::NDArray<float, 4>({{{{16}}}}).get_vector();
1062
1063     auto test_case = test::TestCase<TestEngine>(function);
1064     test_case.add_multiple_inputs(inputs);
1065     test_case.add_expected_output(expected_output);
1066     test_case.run();
1067 }
1068
1069 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_resize10_import_only)
1070 {
1071     const auto resize_fn = onnx_import::import_onnx_model(
1072         file_util::path_join(SERIALIZED_ZOO, "onnx/resize_opset10.prototxt"));
1073
1074     // Input data shape (1, 2, 3, 4)
1075     // Scales input constant values {4, 3, 2, 1}
1076
1077     Shape expected_output_shape{4, 6, 6, 4};
1078     EXPECT_EQ(resize_fn->get_output_size(), 1);
1079     EXPECT_EQ(resize_fn->get_output_shape(0), expected_output_shape);
1080     EXPECT_EQ(count_ops_of_type<onnx_import::default_opset::Interpolate>(resize_fn), 1);
1081     EXPECT_EQ(count_ops_of_type<onnx_import::default_opset::Constant>(resize_fn), 1);
1082 }
1083
1084 NGRAPH_TEST(${BACKEND_NAME}, onnx_resize10_down_scales_const_linear)
1085 {
1086     const auto function = onnx_import::import_onnx_model(
1087         file_util::path_join(SERIALIZED_ZOO, "onnx/resize10_down_scales_const_linear.prototxt"));
1088
1089     // Input data shape (1, 1, 2, 4)
1090     // Input const scales values {1.0, 1.0, 0.6, 0.6}
1091     // mode: nearest
1092
1093     Shape expected_output_shape{1, 1, 1, 2};
1094     auto test_case = test::TestCase<TestEngine>(function);
1095     test_case.add_input<float>({1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0});
1096     test_case.add_expected_output<float>(expected_output_shape, {1.0, 2.66666651});
1097     test_case.run();
1098 }
1099
1100 NGRAPH_TEST(${BACKEND_NAME}, onnx_resize10_down_scales_const_nearest)
1101 {
1102     const auto function = onnx_import::import_onnx_model(
1103         file_util::path_join(SERIALIZED_ZOO, "onnx/resize10_down_scales_const_nearest.prototxt"));
1104
1105     // Input data shape (1, 1, 2, 4)
1106     // Input const scales values {1.0, 1.0, 0.6, 0.6}
1107     // mode: linear
1108
1109     Shape expected_output_shape{1, 1, 1, 2};
1110     auto test_case = test::TestCase<TestEngine>(function);
1111     test_case.add_input<float>({1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0});
1112     test_case.add_expected_output<float>(expected_output_shape, {1.0, 3.0});
1113     test_case.run();
1114 }
1115
1116 NGRAPH_TEST(${BACKEND_NAME}, onnx_resize10_up_scales_const_linear)
1117 {
1118     const auto function = onnx_import::import_onnx_model(
1119         file_util::path_join(SERIALIZED_ZOO, "onnx/resize10_up_scales_const_linear.prototxt"));
1120
1121     // Input data shape (1, 1, 2, 2)
1122     // Input const scales values {1.0, 1.0, 2.0, 2.0}
1123     // mode: nearest
1124
1125     Shape expected_output_shape{1, 1, 4, 4};
1126     auto test_case = test::TestCase<TestEngine>(function);
1127     test_case.add_input<float>({1.0, 2.0, 3.0, 4.0});
1128     test_case.add_expected_output<float>(
1129         expected_output_shape,
1130         {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});
1131     test_case.run();
1132 }
1133
1134 NGRAPH_TEST(${BACKEND_NAME}, onnx_resize10_up_scales_const_nearest)
1135 {
1136     const auto function = onnx_import::import_onnx_model(
1137         file_util::path_join(SERIALIZED_ZOO, "onnx/resize10_up_scales_const_nearest.prototxt"));
1138
1139     // Input data shape (1, 1, 2, 2)
1140     // Input const scales values {1.0, 1.0, 2.0, 3.0}
1141     // mode: linear
1142
1143     Shape expected_output_shape{1, 1, 4, 6};
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, {1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0,
1148                                 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, 3.0, 3.0, 3.0, 4.0, 4.0, 4.0});
1149
1150     test_case.run();
1151 }
1152
1153 NGRAPH_TEST(${BACKEND_NAME}, onnx_resize11_scales_down_linear)
1154 {
1155     const auto function = onnx_import::import_onnx_model(
1156         file_util::path_join(SERIALIZED_ZOO, "onnx/resize11_scales_down_linear.prototxt"));
1157
1158     const Shape expected_output_shape{1, 1, 1, 2};
1159     auto test_case = test::TestCase<TestEngine>(function);
1160     const size_t input_size = 8;
1161     std::vector<float> input_data(input_size);
1162     std::iota(std::begin(input_data), std::end(input_data), 1.0f);
1163     test_case.add_input<float>(input_data);
1164     test_case.add_expected_output<float>(expected_output_shape, {1.0f, 2.66666651f});
1165
1166     test_case.run();
1167 }
1168
1169 NGRAPH_TEST(${BACKEND_NAME}, onnx_resize11_scales_up_linear_asymmetric)
1170 {
1171     const auto function = onnx_import::import_onnx_model(
1172         file_util::path_join(SERIALIZED_ZOO, "onnx/resize11_scales_up_linear_asymmetric.prototxt"));
1173
1174     const Shape expected_output_shape{2, 1, 4, 8};
1175     auto test_case = test::TestCase<TestEngine>(function);
1176     const size_t input_size = 8;
1177     std::vector<float> input_data{1.0f, 3.0f, 4.0f, 8.0f, 6.0f, 2.0f, 7.0f, 11.0f};
1178     test_case.add_input<float>(input_data);
1179     test_case.add_expected_output<float>(
1180         expected_output_shape,
1181         {1.0f,  1.5f,  2.0f, 2.5f, 3.0f, 3.0f,  3.0f,  3.0f,  2.5f,  3.25f, 4.0f,
1182          4.75f, 5.5f,  5.5f, 5.5f, 5.5f, 4.0f,  5.0f,  6.0f,  7.0f,  8.0f,  8.0f,
1183          8.0f,  8.0f,  4.0f, 5.0f, 6.0f, 7.0f,  8.0f,  8.0f,  8.0f,  8.0f,
1184
1185          6.0f,  5.0f,  4.0f, 3.0f, 2.0f, 2.0f,  2.0f,  2.0f,  6.5f,  6.5f,  6.5f,
1186          6.5f,  6.5f,  6.5f, 6.5f, 6.5f, 7.0f,  8.0f,  9.0f,  10.0f, 11.0f, 11.0f,
1187          11.0f, 11.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 11.0f, 11.0f, 11.0f});
1188
1189     test_case.run();
1190 }
1191
1192 NGRAPH_TEST(${BACKEND_NAME}, onnx_resize11_scales_nearest_asymmetric_floor)
1193 {
1194     const auto function = onnx_import::import_onnx_model(file_util::path_join(
1195         SERIALIZED_ZOO, "onnx/resize11_scales_nearest_asymmetric_floor.prototxt"));
1196
1197     const Shape expected_output_shape{2, 1, 4, 1};
1198     auto test_case = test::TestCase<TestEngine>(function);
1199     const std::vector<float> input_data{1.0f, 3.0f, 4.0f, 8.0f, 6.0f, 2.0f, 7.0f, 11.0f};
1200     test_case.add_input<float>(input_data);
1201     test_case.add_expected_output<float>(expected_output_shape,
1202                                          {1.0f, 1.0f, 4.0f, 4.0f, 6.0f, 6.0f, 7.0f, 7.0f});
1203
1204     test_case.run();
1205 }
1206
1207 NGRAPH_TEST(${BACKEND_NAME}, onnx_resize11_scales_nearest_asymmetric_floor_dynamic_sizes)
1208 {
1209     const auto function = onnx_import::import_onnx_model(file_util::path_join(
1210         SERIALIZED_ZOO, "onnx/resize11_scales_nearest_asymmetric_floor_dynamic_scales.prototxt"));
1211
1212     const Shape expected_output_shape{2, 1, 4, 1};
1213     auto test_case = test::TestCase<TestEngine>(function);
1214     const std::vector<float> input_data{1.0f, 3.0f, 4.0f, 8.0f, 6.0f, 2.0f, 7.0f, 11.0f};
1215     test_case.add_input<float>(input_data);
1216     test_case.add_input<float>(
1217         std::vector<float>{1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f}); // roi
1218     test_case.add_input<float>(std::vector<float>{1.0f, 1.0f, 2.0f, 0.5f});  // scales
1219     test_case.add_expected_output<float>(expected_output_shape,
1220                                          {1.0f, 1.0f, 4.0f, 4.0f, 6.0f, 6.0f, 7.0f, 7.0f});
1221
1222     test_case.run();
1223 }
1224
1225 NGRAPH_TEST(${BACKEND_NAME}, onnx_resize11_sizes_nearest_asymmetric_floor)
1226 {
1227     const auto function = onnx_import::import_onnx_model(file_util::path_join(
1228         SERIALIZED_ZOO, "onnx/resize11_sizes_nearest_asymmetric_floor.prototxt"));
1229
1230     const Shape expected_output_shape{2, 1, 4, 1};
1231     auto test_case = test::TestCase<TestEngine>(function);
1232     std::vector<float> input_data{1.0f, 3.0f, 4.0f, 8.0f, 6.0f, 2.0f, 7.0f, 11.0f};
1233     test_case.add_input<float>(input_data);
1234     test_case.add_expected_output<float>(expected_output_shape,
1235                                          {1.0f, 1.0f, 4.0f, 4.0f, 6.0f, 6.0f, 7.0f, 7.0f});
1236
1237     test_case.run();
1238 }
1239
1240 NGRAPH_TEST(${BACKEND_NAME}, onnx_resize11_sizes_linear)
1241 {
1242     const auto function = onnx_import::import_onnx_model(
1243         file_util::path_join(SERIALIZED_ZOO, "onnx/resize11_sizes_linear.prototxt"));
1244
1245     const Shape expected_output_shape{2, 1, 4, 8};
1246     auto test_case = test::TestCase<TestEngine>(function);
1247     std::vector<float> input_data{2.0f, 4.0f, 1.0f, 3.0f, 7.0f, 8.0f, 9.0f, 6.0f};
1248     test_case.add_input<float>(input_data);
1249     test_case.add_expected_output<float>(
1250         expected_output_shape,
1251         {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,
1252          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,
1253          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,
1254          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,
1255          6.0f, 6.0f, 6.0f,  6.0f, 9.0f,  8.25f, 7.5f, 6.75f, 6.0f, 6.0f,  6.0f,  6.0f});
1256
1257     test_case.run();
1258 }
1259
1260 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_shape)
1261 {
1262     auto function =
1263         onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/shape.prototxt"));
1264
1265     Inputs inputs;
1266     inputs.emplace_back(test::NDArray<float, 3>(
1267                             {{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}},
1268                              {{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}},
1269                              {{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}}})
1270                             .get_vector());
1271
1272     auto test_case = test::TestCase<TestEngine>(function);
1273     test_case.add_multiple_inputs(inputs);
1274     test_case.add_expected_output<int64_t>({3, 4, 5});
1275     test_case.run();
1276 }
1277
1278 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_elu)
1279 {
1280     auto function =
1281         onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/elu.prototxt"));
1282
1283     Inputs inputs;
1284     inputs.emplace_back(
1285         test::NDArray<float, 3>(
1286             {{{-9, -8, -7, -6, -5}, {-4, -3, -2, -1, 0}, {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}},
1287              {{-4, -3, -2, -1, 0}, {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}},
1288              {{1, 1, 1, 1, 1}, {-1, -1, -1, -1, -1}, {0, 0, 0, 0, 0}, {2, 2, 2, 2, 2}}})
1289             .get_vector());
1290
1291     auto expected_output = test::NDArray<float, 3>({{{-1.999753180391830f,
1292                                                       -1.999329074744190f,
1293                                                       -1.998176236068890f,
1294                                                       -1.995042495646670f,
1295                                                       -1.986524106001830f},
1296                                                      {-1.963368722222530f,
1297                                                       -1.900425863264270f,
1298                                                       -1.729329433526770f,
1299                                                       -1.264241117657120f,
1300                                                       0},
1301                                                      {1, 2, 3, 4, 5},
1302                                                      {6, 7, 8, 9, 10}},
1303                                                     {{-1.963368722222530f,
1304                                                       -1.900425863264270f,
1305                                                       -1.729329433526770f,
1306                                                       -1.264241117657120f,
1307                                                       0},
1308                                                      {1, 2, 3, 4, 5},
1309                                                      {6, 7, 8, 9, 10},
1310                                                      {11, 12, 13, 14, 15}},
1311                                                     {{1, 1, 1, 1, 1},
1312                                                      {-1.264241117657120f,
1313                                                       -1.264241117657120f,
1314                                                       -1.264241117657120f,
1315                                                       -1.264241117657120f,
1316                                                       -1.264241117657120f},
1317                                                      {0, 0, 0, 0, 0},
1318                                                      {2, 2, 2, 2, 2}}})
1319                                .get_vector();
1320
1321     auto test_case = test::TestCase<TestEngine>(function);
1322     test_case.add_multiple_inputs(inputs);
1323     test_case.add_expected_output(expected_output);
1324     test_case.run();
1325 }
1326
1327 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_leaky_relu)
1328 {
1329     auto function = onnx_import::import_onnx_model(
1330         file_util::path_join(SERIALIZED_ZOO, "onnx/leaky_relu.prototxt"));
1331
1332     Inputs inputs;
1333     inputs.emplace_back(
1334         test::NDArray<float, 3>(
1335             {{{-9, -8, -7, -6, -5}, {-4, -3, -2, -1, 0}, {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}},
1336              {{-4, -3, -2, -1, 0}, {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}},
1337              {{1, 1, 1, 1, 1}, {-1, -1, -1, -1, -1}, {0, 0, 0, 0, 0}, {2, 2, 2, 2, 2}}})
1338             .get_vector());
1339
1340     auto expected_output = test::NDArray<float, 3>({{{-0.9f, -0.8f, -0.7f, -0.6f, -0.5f},
1341                                                      {-0.4f, -0.3f, -0.2f, -0.1f, 0},
1342                                                      {1, 2, 3, 4, 5},
1343                                                      {6, 7, 8, 9, 10}},
1344                                                     {{-0.4f, -0.3f, -0.2f, -0.1f, 0},
1345                                                      {1, 2, 3, 4, 5},
1346                                                      {6, 7, 8, 9, 10},
1347                                                      {11, 12, 13, 14, 15}},
1348                                                     {{1, 1, 1, 1, 1},
1349                                                      {-0.1f, -0.1f, -0.1f, -0.1f, -0.1f},
1350                                                      {0, 0, 0, 0, 0},
1351                                                      {2, 2, 2, 2, 2}}})
1352                                .get_vector();
1353
1354     auto test_case = test::TestCase<TestEngine>(function);
1355     test_case.add_multiple_inputs(inputs);
1356     test_case.add_expected_output(expected_output);
1357     test_case.run();
1358 }
1359
1360 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_prelu)
1361 {
1362     auto function =
1363         onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/prelu.prototxt"));
1364
1365     Inputs inputs;
1366     inputs.emplace_back(
1367         test::NDArray<float, 3>(
1368             {{{-9, -8, -7, -6, -5}, {-4, -3, -2, -1, 0}, {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}},
1369              {{-4, -3, -2, -1, 0}, {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}},
1370              {{1, 1, 1, 1, 1}, {-1, -1, -1, -1, -1}, {0, 0, 0, 0, 0}, {2, 2, 2, 2, 2}}})
1371             .get_vector());
1372
1373     inputs.emplace_back(test::NDArray<float, 3>(
1374                             {{{1, 0, 1, 0, 1}, {0, 1, 0, 1, 0}, {1, 0, 1, 0, 1}, {0, 1, 0, 1, 0}},
1375                              {{0, 1, 0, 1, 0}, {1, 0, 1, 0, 1}, {0, 1, 0, 1, 0}, {1, 0, 1, 0, 1}},
1376                              {{1, 0, 1, 0, 1}, {0, 1, 0, 1, 0}, {1, 0, 1, 0, 1}, {0, 1, 0, 1, 0}}})
1377                             .get_vector());
1378
1379     auto expected_output =
1380         test::NDArray<float, 3>(
1381             {{{-9, 0, -7, 0, -5}, {0, -3, 0, -1, 0}, {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}},
1382              {{0, -3, 0, -1, 0}, {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}},
1383              {{1, 1, 1, 1, 1}, {0, -1, 0, -1, 0}, {0, 0, 0, 0, 0}, {2, 2, 2, 2, 2}}})
1384             .get_vector();
1385
1386     auto test_case = test::TestCase<TestEngine>(function);
1387     test_case.add_multiple_inputs(inputs);
1388     test_case.add_expected_output(expected_output);
1389     test_case.run();
1390 }
1391
1392 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_selu)
1393 {
1394     auto function =
1395         onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/selu.prototxt"));
1396
1397     Inputs inputs;
1398     inputs.emplace_back(
1399         test::NDArray<float, 3>(
1400             {{{-9, -8, -7, -6, -5}, {-4, -3, -2, -1, 0}, {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}},
1401              {{-4, -3, -2, -1, 0}, {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}},
1402              {{1, 1, 1, 1, 1}, {-1, -1, -1, -1, -1}, {0, 0, 0, 0, 0}, {2, 2, 2, 2, 2}}})
1403             .get_vector());
1404
1405     auto expected_output =
1406         test::NDArray<float, 3>(
1407             {{{-5.99925954117548f,
1408                -5.99798722423258f,
1409                -5.99452870820667f,
1410                -5.98512748694000f,
1411                -5.95957231800549f},
1412               {-5.89010616666759f, -5.70127758979282f, -5.18798830058032f, -3.79272335297135f, 0},
1413               {3, 6, 9, 12, 15},
1414               {18, 21, 24, 27, 30}},
1415              {{-5.89010616666759f, -5.70127758979282f, -5.18798830058032f, -3.79272335297135f, 0},
1416               {3, 6, 9, 12, 15},
1417               {18, 21, 24, 27, 30},
1418               {33, 36, 39, 42, 45}},
1419              {{3, 3, 3, 3, 3},
1420               {-3.79272335297135f,
1421                -3.79272335297135f,
1422                -3.79272335297135f,
1423                -3.79272335297135f,
1424                -3.79272335297135f},
1425               {0, 0, 0, 0, 0},
1426               {6, 6, 6, 6, 6}}})
1427             .get_vector();
1428
1429     auto test_case = test::TestCase<TestEngine>(function);
1430     test_case.add_multiple_inputs(inputs);
1431     test_case.add_expected_output(expected_output);
1432     test_case.run();
1433 }
1434
1435 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_sigmoid)
1436 {
1437     auto function = onnx_import::import_onnx_model(
1438         file_util::path_join(SERIALIZED_ZOO, "onnx/sigmoid.prototxt"));
1439
1440     Inputs inputs;
1441     inputs.emplace_back(
1442         test::NDArray<float, 3>(
1443             {{{-9, -8, -7, -6, -5}, {-4, -3, -2, -1, 0}, {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}},
1444              {{-4, -3, -2, -1, 0}, {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}},
1445              {{1, 1, 1, 1, 1}, {-1, -1, -1, -1, -1}, {0, 0, 0, 0, 0}, {2, 2, 2, 2, 2}}})
1446             .get_vector());
1447
1448     auto expected_output = test::NDArray<float, 3>({{{0.00012339457598623f,
1449                                                       0.00033535013046648f,
1450                                                       0.00091105119440065f,
1451                                                       0.00247262315663477f,
1452                                                       0.00669285092428486f},
1453                                                      {0.01798620996209160f,
1454                                                       0.04742587317756680f,
1455                                                       0.119202922022118f,
1456                                                       0.268941421369995f,
1457                                                       0.5f},
1458                                                      {0.731058578630005f,
1459                                                       0.880797077977882f,
1460                                                       0.952574126822433f,
1461                                                       0.982013790037908f,
1462                                                       0.993307149075715f},
1463                                                      {0.997527376843365f,
1464                                                       0.999088948805599f,
1465                                                       0.999664649869534f,
1466                                                       0.999876605424014f,
1467                                                       0.999954602131298f}},
1468                                                     {{0.01798620996209160f,
1469                                                       0.04742587317756680f,
1470                                                       0.119202922022118f,
1471                                                       0.268941421369995f,
1472                                                       0.5f},
1473                                                      {0.731058578630005f,
1474                                                       0.880797077977882f,
1475                                                       0.952574126822433f,
1476                                                       0.982013790037908f,
1477                                                       0.993307149075715f},
1478                                                      {0.997527376843365f,
1479                                                       0.999088948805599f,
1480                                                       0.999664649869534f,
1481                                                       0.999876605424014f,
1482                                                       0.999954602131298f},
1483                                                      {0.999983298578152f,
1484                                                       0.999993855825398f,
1485                                                       0.999997739675702f,
1486                                                       0.999999168471972f,
1487                                                       0.999999694097773f}},
1488                                                     {{0.731058578630005f,
1489                                                       0.731058578630005f,
1490                                                       0.731058578630005f,
1491                                                       0.731058578630005f,
1492                                                       0.731058578630005f},
1493                                                      {0.268941421369995f,
1494                                                       0.268941421369995f,
1495                                                       0.268941421369995f,
1496                                                       0.268941421369995f,
1497                                                       0.268941421369995f},
1498                                                      {0.5f, 0.5f, 0.5f, 0.5f, 0.5f},
1499                                                      {0.880797077977882f,
1500                                                       0.880797077977882f,
1501                                                       0.880797077977882f,
1502                                                       0.880797077977882f,
1503                                                       0.880797077977882f}}})
1504                                .get_vector();
1505
1506     auto test_case = test::TestCase<TestEngine>(function);
1507     test_case.add_multiple_inputs(inputs);
1508     test_case.add_expected_output(expected_output);
1509     test_case.run();
1510 }
1511
1512 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_tanh)
1513 {
1514     auto function =
1515         onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/tanh.prototxt"));
1516
1517     Inputs inputs;
1518     inputs.emplace_back(
1519         test::NDArray<float, 3>(
1520             {{{-9, -8, -7, -6, -5}, {-4, -3, -2, -1, 0}, {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}},
1521              {{-4, -3, -2, -1, 0}, {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}},
1522              {{1, 1, 1, 1, 1}, {-1, -1, -1, -1, -1}, {0, 0, 0, 0, 0}, {2, 2, 2, 2, 2}}})
1523             .get_vector());
1524
1525     auto expected_output = test::NDArray<float, 3>({{{-0.999999969540041f,
1526                                                       -0.999999774929676f,
1527                                                       -0.999998336943945f,
1528                                                       -0.999987711650796f,
1529                                                       -0.999909204262595f},
1530                                                      {-0.999329299739067f,
1531                                                       -0.995054753686731f,
1532                                                       -0.964027580075817f,
1533                                                       -0.761594155955765f,
1534                                                       0},
1535                                                      {0.761594155955765f,
1536                                                       0.964027580075817f,
1537                                                       0.995054753686731f,
1538                                                       0.999329299739067f,
1539                                                       0.999909204262595f},
1540                                                      {0.999987711650796f,
1541                                                       0.999998336943945f,
1542                                                       0.999999774929676f,
1543                                                       0.999999969540041f,
1544                                                       0.999999995877693f}},
1545                                                     {{-0.999329299739067f,
1546                                                       -0.995054753686731f,
1547                                                       -0.964027580075817f,
1548                                                       -0.761594155955765f,
1549                                                       0},
1550                                                      {0.761594155955765f,
1551                                                       0.964027580075817f,
1552                                                       0.995054753686731f,
1553                                                       0.999329299739067f,
1554                                                       0.999909204262595f},
1555                                                      {0.999987711650796f,
1556                                                       0.999998336943945f,
1557                                                       0.999999774929676f,
1558                                                       0.999999969540041f,
1559                                                       0.999999995877693f},
1560                                                      {0.999999999442106f,
1561                                                       0.999999999924497f,
1562                                                       0.999999999989782f,
1563                                                       0.999999999998617f,
1564                                                       0.999999999999813f}},
1565                                                     {{0.761594155955765f,
1566                                                       0.761594155955765f,
1567                                                       0.761594155955765f,
1568                                                       0.761594155955765f,
1569                                                       0.761594155955765f},
1570                                                      {-0.761594155955765f,
1571                                                       -0.761594155955765f,
1572                                                       -0.761594155955765f,
1573                                                       -0.761594155955765f,
1574                                                       -0.761594155955765f},
1575                                                      {0, 0, 0, 0, 0},
1576                                                      {0.964027580075817f,
1577                                                       0.964027580075817f,
1578                                                       0.964027580075817f,
1579                                                       0.964027580075817f,
1580                                                       0.964027580075817f}}})
1581                                .get_vector();
1582
1583     auto test_case = test::TestCase<TestEngine>(function);
1584     test_case.add_multiple_inputs(inputs);
1585     test_case.add_expected_output(expected_output);
1586     test_case.run();
1587 }
1588
1589 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_thresholded_relu)
1590 {
1591     auto function = onnx_import::import_onnx_model(
1592         file_util::path_join(SERIALIZED_ZOO, "onnx/thresholded_relu.prototxt"));
1593
1594     Inputs inputs;
1595     inputs.emplace_back(
1596         test::NDArray<float, 3>(
1597             {{{-9, -8, -7, -6, -5}, {-4, -3, -2, -1, 0}, {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}},
1598              {{-4, -3, -2, -1, 0}, {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}},
1599              {{1, 1, 1, 1, 1}, {-1, -1, -1, -1, -1}, {0, 0, 0, 0, 0}, {2, 2, 2, 2, 2}}})
1600             .get_vector());
1601
1602     auto expected_output =
1603         test::NDArray<float, 3>(
1604             {{{0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 3, 4, 5}, {6, 7, 8, 9, 10}},
1605              {{0, 0, 0, 0, 0}, {0, 0, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}},
1606              {{0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}}})
1607             .get_vector();
1608
1609     auto test_case = test::TestCase<TestEngine>(function);
1610     test_case.add_multiple_inputs(inputs);
1611     test_case.add_expected_output(expected_output);
1612     test_case.run();
1613 }
1614
1615 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_matmul_vec_ten3d)
1616 {
1617     auto function = onnx_import::import_onnx_model(
1618         file_util::path_join(SERIALIZED_ZOO, "onnx/matmul_vec_ten3d.prototxt"));
1619
1620     Inputs inputs;
1621     inputs.emplace_back(std::vector<float>{0.f, 1.f});
1622     inputs.emplace_back(
1623         test::NDArray<float, 3>{{{0.f}, {1.f}}, {{2.f}, {3.f}}, {{4.f}, {5.f}}}.get_vector());
1624
1625     auto expected_output = test::NDArray<float, 2>{{1.f}, {3.f}, {5.f}}.get_vector();
1626
1627     auto test_case = test::TestCase<TestEngine>(function);
1628     test_case.add_multiple_inputs(inputs);
1629     test_case.add_expected_output(expected_output);
1630     test_case.run();
1631 }
1632
1633 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_softplus)
1634 {
1635     auto function = onnx_import::import_onnx_model(
1636         file_util::path_join(SERIALIZED_ZOO, "onnx/softplus.prototxt"));
1637
1638     // -1.0f, 0, 1.0f, 10.f,                    normal input values for activation
1639     // 100.0f, -100.0f, 1000.0f, -1000.0f,      input values that leads to exp() overflow
1640     // FLT_MIN, FLT_MIN / 16, -FLT_MIN / 16,    min, denorm, -denorm
1641     // FLT_MAX, -FLT_MAX,                       max, -max;
1642     Inputs inputs{std::vector<float>{-1.0f,
1643                                      0,
1644                                      1.0f,
1645                                      10.f,
1646                                      100.0f,
1647                                      -100.0f,
1648                                      1000.0f,
1649                                      -1000.0f,
1650                                      FLT_MIN,
1651                                      FLT_MIN / 16,
1652                                      -FLT_MIN / 16,
1653                                      FLT_MAX,
1654                                      -FLT_MAX}};
1655
1656     std::vector<float>& input = inputs.back();
1657     std::vector<float> output;
1658     auto softplus_impl = [](float x) -> float {
1659         if (x > 0)
1660         {
1661             return x + std::log(std::exp(-x) + 1);
1662         }
1663         else
1664         {
1665             return std::log(std::exp(x) + 1);
1666         }
1667     };
1668
1669     std::transform(std::begin(input), std::end(input), std::back_inserter(output), softplus_impl);
1670
1671     auto test_case = test::TestCase<TestEngine>(function);
1672     test_case.add_multiple_inputs(inputs);
1673     test_case.add_expected_output(output);
1674     test_case.run();
1675 }
1676
1677 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_softplus_infinity)
1678 {
1679     auto function = onnx_import::import_onnx_model(
1680         file_util::path_join(SERIALIZED_ZOO, "onnx/softplus.prototxt"));
1681
1682     std::vector<float> input(13, std::numeric_limits<float>::infinity());
1683     std::vector<float> expected_output(13, std::numeric_limits<float>::infinity());
1684
1685     auto test_case = test::TestCase<TestEngine>(function);
1686     test_case.add_input(input);
1687     test_case.add_expected_output(expected_output);
1688     test_case.run();
1689 }
1690
1691 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_sum_opset8)
1692 {
1693     auto function = onnx_import::import_onnx_model(
1694         file_util::path_join(SERIALIZED_ZOO, "onnx/sum_opset8.prototxt"));
1695
1696     Inputs inputs;
1697     inputs.emplace_back(std::vector<float>{1.0f, 2.0f, 3.0f});
1698     inputs.emplace_back(test::NDArray<float, 2>{{10.0f}, {20.0f}, {30.0f}}.get_vector());
1699     inputs.emplace_back(test::NDArray<float, 3>{{{100.0f}}, {{200.0f}}, {{300.0f}}}.get_vector());
1700
1701     auto expected_output =
1702         test::NDArray<float, 3>{
1703             {{111.0f, 112.0f, 113.0f}, {121.0f, 122.0f, 123.0f}, {131.0f, 132.0f, 133.0f}},
1704
1705             {{211.0f, 212.0f, 213.0f}, {221.0f, 222.0f, 223.0f}, {231.0f, 232.0f, 233.0f}},
1706
1707             {{311.0f, 312.0f, 313.0f}, {321.0f, 322.0f, 323.0f}, {331.0f, 332.0f, 333.0f}}}
1708             .get_vector();
1709
1710     auto test_case = test::TestCase<TestEngine>(function);
1711     test_case.add_multiple_inputs(inputs);
1712     test_case.add_expected_output(expected_output);
1713     test_case.run();
1714 }
1715
1716 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_argmax_int32)
1717 {
1718     auto function = onnx_import::import_onnx_model(
1719         file_util::path_join(SERIALIZED_ZOO, "onnx/argmax_int32.prototxt"));
1720
1721     auto test_case = test::TestCase<TestEngine>(function);
1722     test_case.add_input<std::int32_t>({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12});
1723     test_case.add_expected_output<std::int32_t>({1, 1, 1, 1, 1, 1});
1724     test_case.run();
1725 }
1726
1727 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_argmin_int32)
1728 {
1729     auto function = onnx_import::import_onnx_model(
1730         file_util::path_join(SERIALIZED_ZOO, "onnx/argmin_int32.prototxt"));
1731
1732     auto test_case = test::TestCase<TestEngine>(function);
1733     test_case.add_input<std::int32_t>({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12});
1734     test_case.add_expected_output<std::int32_t>({0, 0, 0, 0});
1735     test_case.run();
1736 }
1737
1738 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_argmax_float)
1739 {
1740     auto function = onnx_import::import_onnx_model(
1741         file_util::path_join(SERIALIZED_ZOO, "onnx/argmax_float.prototxt"));
1742
1743     auto test_case = test::TestCase<TestEngine>(function);
1744     test_case.add_input<float>({4, 0.1, 2, 3, -3, 1, -0.9, 0, 1, 2, 3, 0});
1745     test_case.add_expected_output<std::int64_t>({0, 3, 0});
1746     test_case.run();
1747 }
1748
1749 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_argmin_float)
1750 {
1751     auto function = onnx_import::import_onnx_model(
1752         file_util::path_join(SERIALIZED_ZOO, "onnx/argmin_float.prototxt"));
1753
1754     auto test_case = test::TestCase<TestEngine>(function);
1755     test_case.add_input<float>({4, 0.1, 2, 3, -3, 1, -0.9, 0, 1, 2, 3, 0});
1756     test_case.add_expected_output<std::int64_t>({1, 1, 0, 2});
1757     test_case.run();
1758 }
1759
1760 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_top_k)
1761 {
1762     auto function =
1763         onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/top_k.prototxt"));
1764
1765     auto test_case = test::TestCase<TestEngine>(function);
1766     test_case.add_input<float>({0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11});
1767     test_case.add_expected_output<float>(Shape{3, 3}, {3, 2, 1, 7, 6, 5, 11, 10, 9}); // values
1768     test_case.add_expected_output<std::int64_t>(Shape{3, 3},
1769                                                 {3, 2, 1, 3, 2, 1, 3, 2, 1}); // indices
1770     test_case.run();
1771 }
1772
1773 NGRAPH_TEST(${BACKEND_NAME}, onnx_top_k_opset_10)
1774 {
1775     auto function = onnx_import::import_onnx_model(
1776         file_util::path_join(SERIALIZED_ZOO, "onnx/top_k_opset_10.prototxt"));
1777
1778     auto test_case = test::TestCase<TestEngine>(function);
1779     test_case.add_input<float>({0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11});
1780     test_case.add_input<int64_t>({3});
1781
1782     test_case.add_expected_output<float>(Shape{3, 3}, {3, 2, 1, 7, 6, 5, 11, 10, 9}); // values
1783     test_case.add_expected_output<std::int64_t>(Shape{3, 3},
1784                                                 {3, 2, 1, 3, 2, 1, 3, 2, 1}); // indices
1785     test_case.run();
1786 }
1787
1788 NGRAPH_TEST(${BACKEND_NAME}, onnx_top_k_opset_10_const_k)
1789 {
1790     auto function = onnx_import::import_onnx_model(
1791         file_util::path_join(SERIALIZED_ZOO, "onnx/top_k_opset_10_const_k.prototxt"));
1792
1793     auto test_case = test::TestCase<TestEngine>(function);
1794     test_case.add_input<float>({0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11});
1795
1796     test_case.add_expected_output<float>(Shape{3, 3}, {3, 2, 1, 7, 6, 5, 11, 10, 9}); // values
1797     test_case.add_expected_output<std::int64_t>(Shape{3, 3},
1798                                                 {3, 2, 1, 3, 2, 1, 3, 2, 1}); // indices
1799     test_case.run();
1800 }
1801
1802 NGRAPH_TEST(${BACKEND_NAME}, onnx_top_k_opset_11_const_k_smallest)
1803 {
1804     auto function = onnx_import::import_onnx_model(
1805         file_util::path_join(SERIALIZED_ZOO, "onnx/top_k_opset_11_const_k_smallest.prototxt"));
1806
1807     auto test_case = test::TestCase<TestEngine>(function);
1808     test_case.add_input<float>({0, 1, 2, 3, 4, 5, 6, 7, 11, 10, 9, 8});
1809
1810     test_case.add_expected_output<float>(Shape{3, 3}, {0, 1, 2, 4, 5, 6, 8, 9, 10}); // values
1811     test_case.add_expected_output<std::int64_t>(Shape{3, 3},
1812                                                 {0, 1, 2, 0, 1, 2, 3, 2, 1}); // indices
1813     test_case.run();
1814 }
1815
1816 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_acosh)
1817 {
1818     auto function =
1819         onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/acosh.prototxt"));
1820
1821     auto test_case = test::TestCase<TestEngine>(function);
1822     test_case.add_input<float>(Shape{1, 3}, {1.0f, 2.5f, 4.3f});
1823     test_case.add_expected_output<float>(Shape{1, 3}, {0.0f, 1.5667993f, 2.13795861f});
1824
1825     test_case.run();
1826 }
1827
1828 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_asinh)
1829 {
1830     auto function =
1831         onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/asinh.prototxt"));
1832
1833     auto test_case = test::TestCase<TestEngine>(function);
1834     test_case.add_input<float>(Shape{1, 3}, {-1.0f, 0.0f, 1.0f});
1835     test_case.add_expected_output<float>(Shape{1, 3}, {-0.88137358f, 0.0f, 0.88137358f});
1836
1837     test_case.run();
1838 }
1839
1840 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_atanh)
1841 {
1842     auto function =
1843         onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/atanh.prototxt"));
1844
1845     auto test_case = test::TestCase<TestEngine>(function);
1846     test_case.add_input<float>(Shape{1, 3}, {-0.9f, 0.0f, 0.9f});
1847     test_case.add_expected_output<float>(Shape{1, 3}, {-1.4722194f, 0.0f, 1.4722194f});
1848
1849     test_case.run();
1850 }
1851
1852 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_sinh)
1853 {
1854     auto function =
1855         onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/sinh.prototxt"));
1856
1857     auto test_case = test::TestCase<TestEngine>(function);
1858     test_case.add_input<float>({-1.0f, 0.0f, 1.0f});
1859     test_case.add_expected_output<float>({-1.1752012f, 0.f, 1.1752012f});
1860     test_case.run();
1861 }
1862
1863 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_cosh)
1864 {
1865     auto function =
1866         onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/cosh.prototxt"));
1867
1868     auto test_case = test::TestCase<TestEngine>(function);
1869     test_case.add_input<float>({-1.0f, 0.0f, 1.0f});
1870     test_case.add_expected_output<float>({1.54308069f, 1.f, 1.54308069f});
1871     test_case.run();
1872 }
1873
1874 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_sign)
1875 {
1876     auto function =
1877         onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/sign.prototxt"));
1878
1879     Inputs inputs{std::vector<float>{-std::numeric_limits<float>::infinity(),
1880                                      -3.141592f,
1881                                      0.0f,
1882                                      2.71828f,
1883                                      std::numeric_limits<float>::infinity()}};
1884
1885     auto test_case = test::TestCase<TestEngine>(function);
1886     test_case.add_multiple_inputs(inputs);
1887     test_case.add_expected_output<float>({-1.0f, -1.0f, 0.0f, 1.0f, 1.0f});
1888     test_case.run();
1889 }
1890
1891 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_one_hot_with_axis)
1892 {
1893     auto function = onnx_import::import_onnx_model(
1894         file_util::path_join(SERIALIZED_ZOO, "onnx/one_hot_axis.prototxt"));
1895
1896     Inputs inputs{{1.0, 9.0, 2.0, 4.0}, {1.0, 3.0}};
1897     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,
1898                                         1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 3.0,
1899                                         1.0, 1.0, 1.0, 1.0, 3.0, 1.0, 1.0, 1.0, 1.0, 3.0,
1900                                         1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}};
1901
1902     auto test_case = test::TestCase<TestEngine>(function);
1903     test_case.add_multiple_inputs(inputs);
1904     test_case.add_expected_output(expected_output);
1905     test_case.run();
1906 }
1907
1908 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_one_hot_without_axis)
1909 {
1910     auto function = onnx_import::import_onnx_model(
1911         file_util::path_join(SERIALIZED_ZOO, "onnx/one_hot_no_axis.prototxt"));
1912
1913     std::vector<std::vector<std::int64_t>> inputs{{0, 7, 8}, {2, 5}};
1914     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,
1915                                               2, 5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 5, 2, 2, 2};
1916
1917     auto test_case = test::TestCase<TestEngine>(function);
1918     test_case.add_multiple_inputs(inputs);
1919     test_case.add_expected_output(expected_output);
1920     test_case.run();
1921 }
1922
1923 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_where)
1924 {
1925     auto function =
1926         onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/where.prototxt"));
1927
1928     // conditions tensor - 3x3x3
1929     auto condition = std::vector<int>{
1930         {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}};
1931
1932     // 1x3 tensor of "1"
1933     auto x1 = std::vector<int>{1, 1, 1};
1934     // 3x1 tensor of "2"
1935     auto x2 = std::vector<int>{2, 2, 2};
1936
1937     std::vector<std::vector<int>> inputs;
1938     inputs.push_back(std::move(condition));
1939     inputs.push_back(std::move(x1));
1940     inputs.push_back(std::move(x2));
1941
1942     // y = 3x3x3
1943     std::vector<int> expected_output{2, 1, 2, 1, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2,
1944                                      1, 2, 1, 2, 2, 1, 2, 1, 2, 1, 2, 1, 2};
1945
1946     auto test_case = test::TestCase<TestEngine>(function);
1947     test_case.add_multiple_inputs(inputs);
1948     test_case.add_expected_output(expected_output);
1949     test_case.run();
1950 }
1951
1952 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_erf)
1953 {
1954     const auto function =
1955         onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/erf.prototxt"));
1956
1957     Inputs inputs;
1958     inputs.emplace_back(test::NDArray<float, 2>{
1959         {-std::numeric_limits<float>::infinity(), std::numeric_limits<float>::infinity()},
1960         {-3.141592f, 0.0f},
1961         {0.5f, 1.0f}}.get_vector());
1962
1963     const std::vector<float> expected_output = test::NDArray<float, 2>{
1964         {-1.0f, 1.0f},
1965         {-0.99999112f, 0.0f},
1966         {0.52049988f, 0.84270079f}}.get_vector();
1967
1968     auto test_case = test::TestCase<TestEngine>(function);
1969     test_case.add_multiple_inputs(inputs);
1970     test_case.add_expected_output(expected_output);
1971     test_case.run();
1972 }
1973
1974 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_erf_int32)
1975 {
1976     const auto function = onnx_import::import_onnx_model(
1977         file_util::path_join(SERIALIZED_ZOO, "onnx/erf_int32.prototxt"));
1978
1979     const std::vector<std::vector<int32_t>> inputs{
1980         {-std::numeric_limits<int32_t>::max(), -1, 0, 1, std::numeric_limits<int32_t>::max()}};
1981
1982     const std::vector<int32_t> expected_output{-1, 0, 0, 0, 1};
1983
1984     auto test_case = test::TestCase<TestEngine>(function);
1985     test_case.add_multiple_inputs(inputs);
1986     test_case.add_expected_output(expected_output);
1987     test_case.run();
1988 }
1989
1990 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_shrink_float)
1991 {
1992     const auto function = onnx_import::import_onnx_model(
1993         file_util::path_join(SERIALIZED_ZOO, "onnx/shrink_float.prototxt"));
1994
1995     auto test_case = test::TestCase<TestEngine>(function);
1996     test_case.add_input<float>(
1997         {-2.0f, -1.6f, -1.5f, -1.4f, -1.0f, 0.0f, 1.0f, 1.4f, 1.5f, 1.6f, 2.0f});
1998     test_case.add_expected_output<float>(
1999         Shape{11}, {-1.5f, -1.1f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.1f, 1.5f});
2000
2001     test_case.run();
2002 }
2003
2004 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_shrink_int)
2005 {
2006     const auto function = onnx_import::import_onnx_model(
2007         file_util::path_join(SERIALIZED_ZOO, "onnx/shrink_int.prototxt"));
2008
2009     auto test_case = test::TestCase<TestEngine>(function);
2010     test_case.add_input<int>({-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5});
2011     test_case.add_expected_output<int>(Shape{11}, {-4, -3, -2, -1, 0, 0, 0, 1, 2, 3, 4});
2012
2013     test_case.run();
2014 }
2015
2016 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_lp_norm_p1)
2017 {
2018     const auto function = onnx_import::import_onnx_model(
2019         file_util::path_join(SERIALIZED_ZOO, "onnx/lp_norm_p1.prototxt"));
2020
2021     Shape data_shape{2, 3, 4};
2022     std::vector<float> data(shape_size(data_shape));
2023     std::iota(std::begin(data), std::end(data), 1);
2024
2025     auto test_case = test::TestCase<TestEngine>(function);
2026     test_case.add_input<float>(data);
2027     test_case.add_expected_output<float>(
2028         data_shape, {0.07142857f, 0.125f,      0.16666667f, 0.2f,    0.22727273f, 0.25f,
2029                      0.26923078f, 0.2857143f,  0.3f,        0.3125f, 0.32352942f, 0.33333334f,
2030                      0.9285714f,  0.875f,      0.8333333f,  0.8f,    0.77272725f, 0.75f,
2031                      0.7307692f,  0.71428573f, 0.7f,        0.6875f, 0.6764706f,  0.6666667f});
2032
2033     test_case.run();
2034 }
2035
2036 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_lp_norm_p2)
2037 {
2038     const auto function = onnx_import::import_onnx_model(
2039         file_util::path_join(SERIALIZED_ZOO, "onnx/lp_norm_p2.prototxt"));
2040
2041     Shape data_shape{2, 3, 4};
2042     std::vector<float> data(shape_size(data_shape));
2043     std::iota(std::begin(data), std::end(data), 1);
2044
2045     auto test_case = test::TestCase<TestEngine>(function);
2046     test_case.add_input<float>(data);
2047     test_case.add_expected_output<float>(
2048         data_shape, {0.0766965f,  0.14142136f, 0.19611613f, 0.24253564f, 0.28216633f, 0.31622776f,
2049                      0.34570536f, 0.37139067f, 0.39391932f, 0.41380295f, 0.4314555f,  0.4472136f,
2050                      0.9970545f,  0.98994946f, 0.9805807f,  0.97014254f, 0.9593655f,  0.9486833f,
2051                      0.9383431f,  0.9284767f,  0.91914505f, 0.9103665f,  0.9021342f,  0.8944272f});
2052
2053     test_case.run();
2054 }
2055
2056 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_lp_norm_default)
2057 {
2058     const auto function = onnx_import::import_onnx_model(
2059         file_util::path_join(SERIALIZED_ZOO, "onnx/lp_norm_default.prototxt"));
2060
2061     Shape data_shape{2, 3, 4};
2062     std::vector<float> data(shape_size(data_shape));
2063     std::iota(std::begin(data), std::end(data), 1);
2064
2065     auto test_case = test::TestCase<TestEngine>(function);
2066     test_case.add_input<float>(data);
2067     test_case.add_expected_output<float>(
2068         data_shape, {0.18257418f, 0.36514837f, 0.5477225f,  0.73029673f, 0.37904903f, 0.45485884f,
2069                      0.5306686f,  0.60647845f, 0.42616236f, 0.47351375f, 0.5208651f,  0.5682165f,
2070                      0.4469492f,  0.48132992f, 0.51571065f, 0.5500913f,  0.45862272f, 0.48560053f,
2071                      0.5125783f,  0.53955615f, 0.46609157f, 0.4882864f,  0.51048124f, 0.5326761f});
2072
2073     test_case.run();
2074 }
2075
2076 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_instance_normalization)
2077 {
2078     const auto function = onnx_import::import_onnx_model(
2079         file_util::path_join(SERIALIZED_ZOO, "onnx/instance_norm.prototxt"));
2080
2081     Shape data_shape{1, 2, 3, 4};
2082     std::vector<float> data(shape_size(data_shape));
2083     std::iota(std::begin(data), std::end(data), 1);
2084
2085     auto test_case = test::TestCase<TestEngine>(function);
2086
2087     test_case.add_input<float>(data);
2088     test_case.add_input<float>(std::vector<float>{2.134f, 3.256f});
2089     test_case.add_input<float>(std::vector<float>{0.765f, 1.055f});
2090     test_case.add_expected_output<float>(
2091         data_shape, {-2.6335807f, -2.015657f,  -1.3977331f, -0.77980936f, -0.16188562f, 0.45603812f,
2092                      1.0739619f,  1.6918856f,  2.3098092f,  2.927733f,    3.5456567f,   4.1635804f,
2093                      -4.130463f,  -3.1876516f, -2.2448401f, -1.3020288f,  -0.35921717f, 0.5835942f,
2094                      1.5264057f,  2.469217f,   3.4120288f,  4.35484f,     5.2976513f,   6.240463f});
2095     test_case.run();
2096 }
2097
2098 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_eye_like)
2099 {
2100     const auto function = onnx_import::import_onnx_model(
2101         file_util::path_join(SERIALIZED_ZOO, "onnx/eye_like.prototxt"));
2102
2103     auto test_case = test::TestCase<TestEngine>(function);
2104     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});
2105     test_case.add_expected_output<float>(
2106         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});
2107
2108     test_case.run();
2109 }
2110
2111 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_reverse_sequence_0_batch_1)
2112 {
2113     const auto function = onnx_import::import_onnx_model(
2114         file_util::path_join(SERIALIZED_ZOO, "onnx/reverse_sequence_time_0_batch_1.prototxt"));
2115     auto test_case = test::TestCase<TestEngine>(function);
2116
2117     test_case.add_input<float>(
2118         {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});
2119     test_case.add_input<int>({4, 3, 2, 1});
2120     test_case.add_expected_output<float>(
2121         Shape{4, 4},
2122         {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});
2123
2124     test_case.run();
2125 }
2126
2127 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_reverse_sequence_1_batch_0)
2128 {
2129     const auto function = onnx_import::import_onnx_model(
2130         file_util::path_join(SERIALIZED_ZOO, "onnx/reverse_sequence_time_1_batch_0.prototxt"));
2131     auto test_case = test::TestCase<TestEngine>(function);
2132
2133     test_case.add_input<float>(
2134         {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});
2135     test_case.add_input<int>({1, 2, 3, 4});
2136     test_case.add_expected_output<float>(
2137         Shape{4, 4},
2138         {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});
2139
2140     test_case.run();
2141 }
2142
2143 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_reverse_sequence_incorrect_batch_axis)
2144 {
2145     EXPECT_THROW(onnx_import::import_onnx_model(file_util::path_join(
2146                      SERIALIZED_ZOO, "onnx/reverse_sequence_incorrect_batch_axis.prototxt")),
2147                  ngraph_error)
2148         << "ReverseSequence batch_axis attribute can only equal 0 or 1. Value of '2' is not "
2149            "accepted.";
2150 }
2151
2152 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_reverse_sequence_incorrect_time_axis)
2153 {
2154     EXPECT_THROW(onnx_import::import_onnx_model(file_util::path_join(
2155                      SERIALIZED_ZOO, "onnx/reverse_sequence_incorrect_time_axis.prototxt")),
2156                  ngraph_error)
2157         << "ReverseSequence time_axis attribute can only equal 0 or 1. Value of '2' is not "
2158            "accepted.";
2159 }
2160
2161 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_reverse_sequence_time_and_batch_axis_equal)
2162 {
2163     EXPECT_THROW(onnx_import::import_onnx_model(file_util::path_join(
2164                      SERIALIZED_ZOO, "onnx/reverse_sequence_time_and_batch_axis_equal.prototxt")),
2165                  ngraph_error)
2166         << "ReverseSequence 'time_axis' and 'batch_axis' can't be equal.";
2167 }
2168
2169 NGRAPH_TEST(${BACKEND_NAME}, onnx_matmul_float_type)
2170 {
2171     auto function = onnx_import::import_onnx_model(
2172         file_util::path_join(SERIALIZED_ZOO, "onnx/matmul_float.prototxt"));
2173
2174     auto test_case = test::TestCase<TestEngine>(function);
2175     test_case.add_input<float>(std::vector<float>{0, 1, 2, 3, 4, 5});
2176     test_case.add_input<float>(std::vector<float>{0, 1});
2177     test_case.add_expected_output<float>(Shape{3, 1}, std::vector<float>{1, 3, 5});
2178
2179     test_case.run();
2180 }
2181
2182 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_mod)
2183 {
2184     const auto function = onnx_import::import_onnx_model(
2185         file_util::path_join(SERIALIZED_ZOO, "onnx/mod_sign.prototxt"));
2186     auto test_case = test::TestCase<TestEngine>(function);
2187
2188     test_case.add_input<int64_t>({-8, 3, 4, 9, -17, 1});
2189     test_case.add_input<int64_t>({22, -13, 8, -3, 7, 2});
2190     test_case.add_expected_output<int64_t>(Shape{6}, {-8, 3, 4, 0, -3, 1});
2191
2192     test_case.run();
2193 }
2194
2195 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_scatterND)
2196 {
2197     const auto function = onnx_import::import_onnx_model(
2198         file_util::path_join(SERIALIZED_ZOO, "onnx/scatter_nd.prototxt"));
2199     auto test_case = test::TestCase<TestEngine>(function);
2200
2201     test_case.add_input<float>({1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f});
2202     test_case.add_input<int64_t>({4, 3, 1, 7});
2203     test_case.add_input<float>({9.f, 10.f, 11.f, 12.f});
2204     test_case.add_expected_output<float>(Shape{8}, {1.f, 11.f, 3.f, 10.f, 9.f, 6.f, 7.f, 12.f});
2205
2206     test_case.run();
2207 }
2208
2209 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_gatherND_int32)
2210 {
2211     const auto function = onnx_import::import_onnx_model(
2212         file_util::path_join(SERIALIZED_ZOO, "onnx/gatherND_int32.prototxt"));
2213     auto test_case = test::TestCase<TestEngine>(function);
2214
2215     test_case.add_input<int32_t>({0, 1, 2, 3});
2216     test_case.add_input<int64_t>({1, 0});
2217     test_case.add_expected_output<int32_t>(Shape{2, 2}, {2, 3, 0, 1});
2218
2219     test_case.run();
2220 }
2221
2222 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_gatherND_float)
2223 {
2224     const auto function = onnx_import::import_onnx_model(
2225         file_util::path_join(SERIALIZED_ZOO, "onnx/gatherND_float.prototxt"));
2226     auto test_case = test::TestCase<TestEngine>(function);
2227
2228     test_case.add_input<float>({0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f});
2229     test_case.add_input<int64_t>({0, 1, 1, 0});
2230     test_case.add_expected_output<float>(Shape{2, 2}, {2.f, 3.f, 4.f, 5.f});
2231
2232     test_case.run();
2233 }
2234
2235 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_pad_constant)
2236 {
2237     const auto function = onnx_import::import_onnx_model(
2238         file_util::path_join(SERIALIZED_ZOO, "onnx/pad_constant.prototxt"));
2239     auto test_case = test::TestCase<TestEngine>(function);
2240
2241     test_case.add_input<float>({1.f, 1.2f, 2.3f, 3.4f, 4.5f, 5.7f});
2242     test_case.add_expected_output<float>(
2243         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});
2244
2245     test_case.run();
2246 }
2247
2248 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_reciprocal)
2249 {
2250     const auto function = onnx_import::import_onnx_model(
2251         file_util::path_join(SERIALIZED_ZOO, "onnx/reciprocal.prototxt"));
2252     auto test_case = test::TestCase<TestEngine>(function);
2253
2254     test_case.add_input<float>({1.f, 2.f, 3.f, 4.f, 5.f, 6.f});
2255     test_case.add_expected_output<float>(Shape{3, 2},
2256                                          {1.f, 1 / 2.f, 1 / 3.f, 1 / 4.f, 1 / 5.f, 1 / 6.f});
2257
2258     test_case.run();
2259 }
2260
2261 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_round)
2262 {
2263     const auto function =
2264         onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/round.prototxt"));
2265     auto test_case = test::TestCase<TestEngine>(function);
2266
2267     test_case.add_input<float>(
2268         {0.1f, 0.9f, 1.2f, 1.5f, 1.8f, 2.3f, 2.7f, -1.1f, -1.9f, -2.2f, -2.8f});
2269     test_case.add_expected_output<float>(
2270         {0.f, 1.f, 1.f, 2.f, 2.f, 2.f, 3.f, -1.f, -2.f, -2.f, -3.f});
2271
2272     test_case.run();
2273 }
2274
2275 // CASES NOT CORRECTLY HANDLED BY CURRENT IMPLEMENTATION OF ROUND
2276 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_round_half_nearest_even)
2277 {
2278     const auto function = onnx_import::import_onnx_model(
2279         file_util::path_join(SERIALIZED_ZOO, "onnx/round_half_nearest_even.prototxt"));
2280     auto test_case = test::TestCase<TestEngine>(function);
2281
2282     test_case.add_input<float>({0.5f, 2.5f, -1.5f, -2.5f});
2283     test_case.add_expected_output<float>({0.f, 2.f, -2.f, -2.f});
2284
2285     test_case.run();
2286 }
2287
2288 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_scatter10_import_only)
2289 {
2290     const auto scatter_fn = onnx_import::import_onnx_model(
2291         file_util::path_join(SERIALIZED_ZOO, "onnx/scatter_opset10.prototxt"));
2292
2293     const Shape data_shape{2, 2};
2294
2295     EXPECT_EQ(scatter_fn->get_output_size(), 1);
2296     EXPECT_EQ(scatter_fn->get_output_shape(0), data_shape);
2297     EXPECT_EQ(count_ops_of_type<op::v3::ScatterElementsUpdate>(scatter_fn), 1);
2298     EXPECT_EQ(count_ops_of_type<op::v0::Constant>(scatter_fn), 4);
2299 }
2300
2301 NGRAPH_TEST(${BACKEND_NAME}, onnx_model_scatter_elements_import_only)
2302 {
2303     const auto scatter_fn = onnx_import::import_onnx_model(
2304         file_util::path_join(SERIALIZED_ZOO, "onnx/scatter_elements_opset11.prototxt"));
2305
2306     const Shape data_shape{1, 5};
2307
2308     EXPECT_EQ(scatter_fn->get_output_size(), 1);
2309     EXPECT_EQ(scatter_fn->get_output_shape(0), data_shape);
2310     EXPECT_EQ(count_ops_of_type<op::v3::ScatterElementsUpdate>(scatter_fn), 1);
2311     EXPECT_EQ(count_ops_of_type<op::v0::Constant>(scatter_fn), 4);
2312 }
2313
2314 NGRAPH_TEST(${BACKEND_NAME}, onnx_upsample8_import_only)
2315 {
2316     const auto function = onnx_import::import_onnx_model(
2317         file_util::path_join(SERIALIZED_ZOO, "onnx/upsample8_nearest.prototxt"));
2318
2319     // Input data shape (1, 1, 2, 2)
2320     // Scales attribute values {1.0, 1.0, 2.0, 3.0}
2321
2322     const Shape expected_output_shape{1, 1, 4, 6};
2323     EXPECT_EQ(function->get_output_size(), 1);
2324     EXPECT_EQ(function->get_output_shape(0), expected_output_shape);
2325     EXPECT_EQ(count_ops_of_type<onnx_import::default_opset::Interpolate>(function), 1);
2326     EXPECT_EQ(count_ops_of_type<onnx_import::default_opset::Constant>(function), 1);
2327 }
2328
2329 NGRAPH_TEST(${BACKEND_NAME}, onnx_upsample8_nearest_infer)
2330 {
2331     const auto function = onnx_import::import_onnx_model(
2332         file_util::path_join(SERIALIZED_ZOO, "onnx/upsample8_nearest.prototxt"));
2333
2334     // Input data shape (1, 1, 2, 2)
2335     // Scales attribute values {1.0, 1.0, 2.0, 3.0}
2336     // mode: nearest
2337
2338     const Shape expected_output_shape{1, 1, 4, 6};
2339     auto test_case = test::TestCase<TestEngine>(function);
2340     test_case.add_input<float>({1.0, 2.0, 3.0, 4.0});
2341     test_case.add_expected_output<float>(
2342         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,
2343                                 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, 3.0, 3.0, 3.0, 4.0, 4.0, 4.0});
2344     test_case.run();
2345 }
2346
2347 NGRAPH_TEST(${BACKEND_NAME}, onnx_upsample8_linear_infer)
2348 {
2349     const auto function = onnx_import::import_onnx_model(
2350         file_util::path_join(SERIALIZED_ZOO, "onnx/upsample8_linear.prototxt"));
2351
2352     // Input data shape (1, 1, 2, 2)
2353     // Scales attribute values {1.0, 1.0, 2.0, 2.0}
2354     // mode: linear
2355
2356     const Shape expected_output_shape{1, 1, 4, 4};
2357     auto test_case = test::TestCase<TestEngine>(function);
2358     test_case.add_input<float>({1.0, 2.0, 3.0, 4.0});
2359     test_case.add_expected_output<float>(
2360         expected_output_shape,
2361         {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});
2362     test_case.run();
2363 }
2364
2365 NGRAPH_TEST(${BACKEND_NAME}, onnx_upsample9_scales_const_import_only)
2366 {
2367     const auto function = onnx_import::import_onnx_model(
2368         file_util::path_join(SERIALIZED_ZOO, "onnx/upsample9_scales_const_nearest.prototxt"));
2369
2370     // Input data shape (1, 1, 2, 2)
2371     // Input const scales values {1.0, 1.0, 2.0, 3.0}
2372
2373     const Shape expected_output_shape{1, 1, 4, 6};
2374     EXPECT_EQ(function->get_output_size(), 1);
2375     EXPECT_EQ(function->get_output_shape(0), expected_output_shape);
2376     EXPECT_EQ(count_ops_of_type<onnx_import::default_opset::Interpolate>(function), 1);
2377     EXPECT_EQ(count_ops_of_type<onnx_import::default_opset::Constant>(function), 1);
2378 }
2379
2380 NGRAPH_TEST(${BACKEND_NAME}, onnx_upsample9_scales_const_nearest_infer)
2381 {
2382     const auto function = onnx_import::import_onnx_model(
2383         file_util::path_join(SERIALIZED_ZOO, "onnx/upsample9_scales_const_nearest.prototxt"));
2384
2385     // Input data shape (1, 1, 2, 2)
2386     // Input const scales values {1.0, 1.0, 2.0, 3.0}
2387     // mode: nearest
2388
2389     const Shape expected_output_shape{1, 1, 4, 6};
2390     auto test_case = test::TestCase<TestEngine>(function);
2391     test_case.add_input<float>({1.0, 2.0, 3.0, 4.0});
2392     test_case.add_expected_output<float>(
2393         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,
2394                                 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, 3.0, 3.0, 3.0, 4.0, 4.0, 4.0});
2395     test_case.run();
2396 }
2397
2398 NGRAPH_TEST(${BACKEND_NAME}, onnx_upsample9_scales_const_linear_infer)
2399 {
2400     const auto function = onnx_import::import_onnx_model(
2401         file_util::path_join(SERIALIZED_ZOO, "onnx/upsample9_scales_const_linear.prototxt"));
2402
2403     // Input data shape (1, 1, 2, 2)
2404     // Input const scales values {1.0, 1.0, 2.0, 2.0}
2405     // mode: linear
2406
2407     const Shape expected_output_shape{1, 1, 4, 4};
2408     auto test_case = test::TestCase<TestEngine>(function);
2409     test_case.add_input<float>({1.0, 2.0, 3.0, 4.0});
2410     test_case.add_expected_output<float>(
2411         expected_output_shape,
2412         {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});
2413     test_case.run();
2414 }
2415
2416 NGRAPH_TEST(${BACKEND_NAME}, onnx_image_scaler)
2417 {
2418     const auto function = onnx_import::import_onnx_model(
2419         file_util::path_join(SERIALIZED_ZOO, "onnx/image_scaler.prototxt"));
2420
2421     auto test_case = test::TestCase<TestEngine>(function);
2422     test_case.add_input<float>({1.0, 2.0, 3.0, 4.0, 10.0, 20.0, 30.0, 40.0});
2423     test_case.add_expected_output<float>(Shape{1, 2, 2, 2},
2424                                          {12.0, 14.0, 16.0, 18.0, 21.0, 41.0, 61.0, 81.0});
2425     test_case.run();
2426 }