792ee3892c2634018f9677745a9698754dcb1cf1
[platform/upstream/dldt.git] / ngraph / test / eval.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 <cmath>
18 #include <cstddef>
19 #include <string>
20 #include <vector>
21
22 #include "gmock/gmock.h"
23 #include "gtest/gtest.h"
24
25 #include "ngraph/node.hpp"
26 #include "ngraph/node_output.hpp"
27 #include "ngraph/op/abs.hpp"
28 #include "ngraph/op/acos.hpp"
29 #include "ngraph/op/add.hpp"
30 #include "ngraph/op/asin.hpp"
31 #include "ngraph/op/atan.hpp"
32 #include "ngraph/op/broadcast.hpp"
33 #include "ngraph/op/ceiling.hpp"
34 #include "ngraph/op/concat.hpp"
35 #include "ngraph/op/constant.hpp"
36 #include "ngraph/op/convert.hpp"
37 #include "ngraph/op/cos.hpp"
38 #include "ngraph/op/cosh.hpp"
39 #include "ngraph/op/erf.hpp"
40 #include "ngraph/op/exp.hpp"
41 #include "ngraph/op/floor.hpp"
42 #include "ngraph/op/gather.hpp"
43 #include "ngraph/op/log.hpp"
44 #include "ngraph/op/max_pool.hpp"
45 #include "ngraph/op/min.hpp"
46 #include "ngraph/op/minimum.hpp"
47 #include "ngraph/op/negative.hpp"
48 #include "ngraph/op/non_zero.hpp"
49 #include "ngraph/op/not.hpp"
50 #include "ngraph/op/parameter.hpp"
51 #include "ngraph/op/range.hpp"
52 #include "ngraph/op/reduce_logical_and.hpp"
53 #include "ngraph/op/relu.hpp"
54 #include "ngraph/op/reshape.hpp"
55 #include "ngraph/op/round.hpp"
56 #include "ngraph/op/scatter_elements_update.hpp"
57 #include "ngraph/op/scatter_update.hpp"
58 #include "ngraph/op/shape_of.hpp"
59 #include "ngraph/op/sigmoid.hpp"
60 #include "ngraph/op/sign.hpp"
61 #include "ngraph/op/sin.hpp"
62 #include "ngraph/op/sinh.hpp"
63 #include "ngraph/op/sqrt.hpp"
64 #include "ngraph/op/squeeze.hpp"
65 #include "ngraph/op/stop_gradient.hpp"
66 #include "ngraph/op/tan.hpp"
67 #include "ngraph/op/tanh.hpp"
68 #include "ngraph/op/topk.hpp"
69 #include "ngraph/op/transpose.hpp"
70 #include "ngraph/op/unsqueeze.hpp"
71 #include "ngraph/runtime/host_tensor.hpp"
72 #include "ngraph/validation_util.hpp"
73 #include "util/all_close_f.hpp"
74 #include "util/ndarray.hpp"
75 #include "util/test_tools.hpp"
76 #include "util/type_prop.hpp"
77
78 NGRAPH_SUPPRESS_DEPRECATED_START
79
80 using namespace std;
81 using namespace ngraph;
82
83 #define ASSERT_FLOAT_VECTORS_EQ(expected, result)                                                  \
84     ASSERT_EQ(expected.size(), result.size()) << "Array sizes differ.";                            \
85     for (size_t i = 0; i < expected.size(); ++i)                                                   \
86     {                                                                                              \
87         ASSERT_FLOAT_EQ(expected[i], result[i]) << "at index: " << i;                              \
88     }
89
90 TEST(eval, bad_get_data_ptr)
91 {
92     HostTensor c(element::f32, Shape{});
93     *c.get_data_ptr<float>() = 1.0;
94     EXPECT_EQ(*c.get_data_ptr<element::Type_t::f32>(), 1.0);
95     try
96     {
97         c.get_data_ptr<element::Type_t::f64>();
98         FAIL() << "Bad type not detected.";
99     }
100     catch (const CheckFailure& error)
101     {
102         EXPECT_HAS_SUBSTRING(error.what(), std::string("get_data_ptr"));
103     }
104     try
105     {
106         c.get_data_ptr<element::Type_t::i32>();
107         FAIL() << "Bad type not detected.";
108     }
109     catch (const CheckFailure& error)
110     {
111         EXPECT_HAS_SUBSTRING(error.what(), std::string("get_data_ptr"));
112     }
113 }
114
115 TEST(eval, max_eval_parameter)
116 {
117     auto p = make_shared<op::Parameter>(element::i64, Shape{});
118
119     auto result = maximum_value(p);
120     EXPECT_FALSE(result.first);
121     EXPECT_EQ(result.second, numeric_limits<uint64_t>::max());
122 }
123
124 TEST(eval, max_eval_constant)
125 {
126     auto c = op::Constant::create<int64_t>(element::i64, Shape{}, {27});
127     auto result = maximum_value(c);
128     ASSERT_TRUE(result.first);
129     EXPECT_EQ(result.second, 27);
130 }
131
132 TEST(eval, max_eval_minimum_constant)
133 {
134     auto c = op::Constant::create<int64_t>(element::i64, Shape{}, {27});
135     auto p = make_shared<op::Parameter>(element::i64, Shape{});
136     auto m = make_shared<op::Minimum>(c, p);
137     auto result = maximum_value(m);
138     ASSERT_TRUE(result.first);
139     EXPECT_EQ(result.second, 27);
140 }
141
142 TEST(eval, max_eval_reduce_min)
143 {
144     auto concat = make_shared<op::v0::Convert>(
145         make_shared<op::v0::Concat>(
146             OutputVector{make_shared<op::v0::Parameter>(element::i64, Shape{4}),
147                          make_shared<op::v0::Constant>(element::i64, Shape{4}, 37)},
148             0),
149         element::i32);
150     auto reduce = make_shared<op::v0::Convert>(
151         make_shared<op::v1::ReduceMin>(concat,
152                                        make_shared<op::v0::Constant>(element::i32, Shape{1}, 0)),
153         element::i64);
154     auto squeezes = make_shared<op::v0::Squeeze>(
155         make_shared<op::v0::Unsqueeze>(reduce,
156                                        make_shared<op::v0::Constant>(element::i32, Shape{1}, 0)),
157         make_shared<op::v0::Constant>(element::i64, Shape{1}, 0));
158     EXPECT_EQ(maximum_value(squeezes).second, 37);
159 }
160
161 TEST(eval, evaluate_shape_of)
162 {
163     auto p = make_shared<op::Parameter>(element::f32, PartialShape{-1, -1});
164     auto so = make_shared<op::v0::ShapeOf>(p);
165     auto fun = make_shared<Function>(OutputVector{so}, ParameterVector{p});
166     auto result = make_shared<HostTensor>();
167     ASSERT_TRUE(fun->evaluate({result},
168                               {make_host_tensor<element::Type_t::f32>(
169                                   Shape{2, 3}, {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f})}));
170     EXPECT_EQ(result->get_element_type(), element::i64);
171     EXPECT_EQ(result->get_partial_shape(), (PartialShape{2}));
172     auto result_shape = read_vector<int64_t>(result);
173     vector<int64_t> arg_shape{2, 3};
174     ASSERT_EQ(result_shape, arg_shape);
175 }
176
177 TEST(eval, evaluate_dynamic_range_sum)
178 {
179     auto p_start = make_shared<op::Parameter>(element::f32, PartialShape{});
180     auto p_stop = make_shared<op::Parameter>(element::f32, PartialShape{});
181     auto p_step = make_shared<op::Parameter>(element::f32, PartialShape{});
182     auto p1 = make_shared<op::Parameter>(element::f32, PartialShape{});
183     auto range = make_shared<op::v0::Range>(p_start, p_stop, p_step);
184     auto add = make_shared<op::v1::Add>(range, p1);
185     auto fun =
186         make_shared<Function>(OutputVector{add}, ParameterVector{p_start, p_stop, p_step, p1});
187     auto result_tensor = make_shared<HostTensor>();
188     ASSERT_TRUE(fun->evaluate({result_tensor},
189                               {make_host_tensor<element::Type_t::f32>({}, {1.0f}),
190                                make_host_tensor<element::Type_t::f32>({}, {10.0f}),
191                                make_host_tensor<element::Type_t::f32>({}, {3.0f}),
192                                make_host_tensor<element::Type_t::f32>({}, {7.0f})}));
193     EXPECT_EQ(result_tensor->get_element_type(), element::f32);
194     EXPECT_EQ(result_tensor->get_partial_shape(), (PartialShape{3}));
195     auto cval = read_vector<float>(result_tensor);
196     vector<float> seq{8.0f, 11.0f, 14.0f};
197     ASSERT_EQ(cval, seq);
198 }
199
200 #ifdef NGRAPH_INTERPRETER_ENABLE
201 TEST(eval, interpret_dynamic_range_sum)
202 {
203     auto p_start = make_shared<op::Parameter>(element::f32, PartialShape{});
204     auto p_stop = make_shared<op::Parameter>(element::f32, PartialShape{});
205     auto p_step = make_shared<op::Parameter>(element::f32, PartialShape{});
206     auto p1 = make_shared<op::Parameter>(element::f32, PartialShape{});
207     auto range = make_shared<op::v0::Range>(p_start, p_stop, p_step);
208     auto add = make_shared<op::v1::Add>(range, p1);
209     auto fun =
210         make_shared<Function>(OutputVector{add}, ParameterVector{p_start, p_stop, p_step, p1});
211     auto backend = runtime::Backend::create("INTERPRETER");
212     auto p_start_val = backend->create_tensor(element::f32, Shape{});
213     copy_data(p_start_val, vector<float>{1.0f});
214     auto p_stop_val = backend->create_tensor(element::f32, Shape{});
215     copy_data(p_stop_val, vector<float>{10.0f});
216     auto p_step_val = backend->create_tensor(element::f32, Shape{});
217     copy_data(p_step_val, vector<float>{3.0f});
218     auto p1_val = backend->create_tensor(element::f32, Shape{});
219     copy_data(p1_val, vector<float>{7.0f});
220     auto result = backend->create_tensor();
221     auto cfun = backend->compile(fun);
222     cfun->call({result}, {p_start_val, p_stop_val, p_step_val, p1_val});
223     EXPECT_EQ(result->get_element_type(), element::f32);
224     EXPECT_EQ(result->get_partial_shape(), (PartialShape{3}));
225     auto result_val = read_vector<float>(result);
226     vector<float> seq{8.0f, 11.0f, 14.0f};
227     ASSERT_EQ(result_val, seq);
228 }
229 #endif
230
231 TEST(eval, evaluate_broadcast_v3_bidirectional)
232 {
233     Shape shape_a{4, 1};
234     auto A = make_shared<op::Parameter>(element::f32, shape_a);
235     auto target_shape = op::Constant::create<int32_t>(element::i32, Shape{3}, {2, 1, 4});
236     auto bcast_v3 =
237         make_shared<op::v3::Broadcast>(A, target_shape, op::BroadcastType::BIDIRECTIONAL);
238     auto fun = make_shared<Function>(OutputVector{bcast_v3}, ParameterVector{A});
239
240     auto result = make_shared<HostTensor>();
241     ASSERT_TRUE(fun->evaluate(
242         {result}, {make_host_tensor<element::Type_t::f32>(Shape{4, 1}, {1.0f, 2.0f, 3.0f, 4.0f})}));
243     EXPECT_EQ(result->get_element_type(), element::f32);
244     EXPECT_EQ(result->get_partial_shape(), (PartialShape{2, 4, 4}));
245     auto result_val = read_vector<float>(result);
246     vector<float> expec{1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4,
247                         1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4};
248     ASSERT_EQ(result_val, expec);
249 }
250
251 TEST(eval, evaluate_broadcast_v3_bidirectional_dyn)
252 {
253     Shape shape_a{4, 1};
254     auto A = make_shared<op::Parameter>(element::i32, shape_a);
255     auto target_shape = make_shared<op::Parameter>(element::i32, Shape{3});
256     auto bcast_v3 =
257         make_shared<op::v3::Broadcast>(A, target_shape, op::BroadcastType::BIDIRECTIONAL);
258     auto fun = make_shared<Function>(OutputVector{bcast_v3}, ParameterVector{A, target_shape});
259
260     auto result = make_shared<HostTensor>();
261     ASSERT_TRUE(fun->evaluate({result},
262                               {make_host_tensor<element::Type_t::i32>(Shape{4, 1}, {1, 2, 3, 4}),
263                                make_host_tensor<element::Type_t::i32>(Shape{3}, {2, 1, 4})}));
264     EXPECT_EQ(result->get_element_type(), element::i32);
265     EXPECT_EQ(result->get_partial_shape(), (PartialShape{2, 4, 4}));
266     auto result_val = read_vector<int32_t>(result);
267     vector<int32_t> expec{1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4,
268                           1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4};
269     ASSERT_EQ(result_val, expec);
270 }
271
272 TEST(eval, evaluate_broadcast_v3_numpy)
273 {
274     Shape shape_a{3, 1};
275     auto A = make_shared<op::Parameter>(element::f32, shape_a);
276     auto target_shape = op::Constant::create<int64_t>(element::i64, Shape{3}, {2, 3, 6});
277     auto bcast_v3 = make_shared<op::v3::Broadcast>(A, target_shape);
278     auto fun = make_shared<Function>(OutputVector{bcast_v3}, ParameterVector{A});
279
280     auto result = make_shared<HostTensor>();
281     ASSERT_TRUE(fun->evaluate(
282         {result}, {make_host_tensor<element::Type_t::f32>(Shape{3, 1}, {1.0f, 2.0f, 3.0f})}));
283     EXPECT_EQ(result->get_element_type(), element::f32);
284     EXPECT_EQ(result->get_partial_shape(), (PartialShape{2, 3, 6}));
285     auto result_val = read_vector<float>(result);
286     vector<float> expec{
287         1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3,
288         1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3,
289     };
290     ASSERT_EQ(result_val, expec);
291 }
292
293 TEST(eval, evaluate_broadcast_v3_numpy_dyn)
294 {
295     Shape shape_a{3, 1};
296     auto A = make_shared<op::Parameter>(element::f32, shape_a);
297     auto target_shape = make_shared<op::Parameter>(element::i32, Shape{3});
298     auto bcast_v3 = make_shared<op::v3::Broadcast>(A, target_shape);
299     auto fun = make_shared<Function>(OutputVector{bcast_v3}, ParameterVector{A, target_shape});
300
301     auto result = make_shared<HostTensor>();
302     ASSERT_TRUE(
303         fun->evaluate({result},
304                       {make_host_tensor<element::Type_t::f32>(Shape{3, 1}, {1.0f, 2.0f, 3.0f}),
305                        make_host_tensor<element::Type_t::i32>(Shape{3}, {2, 3, 6})}));
306     EXPECT_EQ(result->get_element_type(), element::f32);
307     EXPECT_EQ(result->get_partial_shape(), (PartialShape{2, 3, 6}));
308     auto result_val = read_vector<float>(result);
309     vector<float> expec{
310         1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3,
311         1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3,
312     };
313     ASSERT_EQ(result_val, expec);
314 }
315
316 TEST(eval, evaluate_broadcast_v3_numpy_vs_bidi)
317 {
318     Shape in_shape{1, 4, 1};
319
320     auto A = make_shared<op::Parameter>(element::f32, in_shape);
321     auto target_shape = op::Constant::create<int64_t>(element::i64, Shape{3}, {1, 4, 4});
322     auto bcast_v3_num = make_shared<op::v3::Broadcast>(A, target_shape, op::BroadcastType::NUMPY);
323     auto fun_num = make_shared<Function>(OutputVector{bcast_v3_num}, ParameterVector{A});
324
325     auto result = make_shared<HostTensor>();
326     ASSERT_TRUE(fun_num->evaluate(
327         {result}, {make_host_tensor<element::Type_t::f32>(in_shape, {1.0f, 2.0f, 3.0f, 4.0f})}));
328     EXPECT_EQ(result->get_element_type(), element::f32);
329     EXPECT_EQ(result->get_partial_shape(), (PartialShape{1, 4, 4}));
330     auto result_val = read_vector<float>(result);
331     vector<float> expec{1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4};
332     ASSERT_EQ(expec, result_val);
333
334     auto target_shape2 = op::Constant::create<int64_t>(element::i64, Shape{2}, {1, 4});
335     auto bcast_v3 =
336         make_shared<op::v3::Broadcast>(A, target_shape2, op::BroadcastType::BIDIRECTIONAL);
337     auto fun_bidi = make_shared<Function>(OutputVector{bcast_v3_num}, ParameterVector{A});
338
339     auto result2 = make_shared<HostTensor>();
340     ASSERT_TRUE(fun_bidi->evaluate(
341         {result2}, {make_host_tensor<element::Type_t::f32>(in_shape, {1.0f, 2.0f, 3.0f, 4.0f})}));
342     EXPECT_EQ(result2->get_element_type(), element::f32);
343     EXPECT_EQ(result2->get_partial_shape(), (PartialShape{1, 4, 4}));
344     auto result_val2 = read_vector<float>(result2);
345     vector<float> expec2{1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4};
346     ASSERT_EQ(expec2, result_val2);
347 }
348
349 TEST(eval, evaluate_broadcast_v3_bidi_3d)
350 {
351     Shape in_shape{1, 4, 1};
352
353     auto A = make_shared<op::Parameter>(element::f32, in_shape);
354     auto target_shape = op::Constant::create<int64_t>(element::i64, Shape{3}, {1, 1, 3});
355     auto bcast_v3_num =
356         make_shared<op::v3::Broadcast>(A, target_shape, op::BroadcastType::BIDIRECTIONAL);
357     auto fun_num = make_shared<Function>(OutputVector{bcast_v3_num}, ParameterVector{A});
358
359     auto result = make_shared<HostTensor>();
360     ASSERT_TRUE(fun_num->evaluate(
361         {result}, {make_host_tensor<element::Type_t::f32>(in_shape, {1.0f, 2.0f, 3.0f, 4.0f})}));
362     EXPECT_EQ(result->get_element_type(), element::f32);
363     EXPECT_EQ(result->get_partial_shape(), (PartialShape{1, 4, 3}));
364     auto result_val = read_vector<float>(result);
365     vector<float> expec{1.0f, 1.0f, 1.0f, 2.0f, 2.0f, 2.0f, 3.0f, 3.0f, 3.0f, 4.0f, 4.0f, 4.0f};
366     ASSERT_EQ(expec, result_val);
367 }
368
369 TEST(eval, evaluate_broadcast_v3_bidi_4d)
370 {
371     Shape in_shape{4, 1, 1};
372     Shape expec_shape{1, 4, 2, 2};
373
374     auto A = make_shared<op::Parameter>(element::f32, in_shape);
375     auto target_shape = op::Constant::create<int64_t>(element::i64, Shape{4}, {1, 1, 2, 2});
376     auto bcast_v3 =
377         make_shared<op::v3::Broadcast>(A, target_shape, op::BroadcastType::BIDIRECTIONAL);
378     auto fun = make_shared<Function>(OutputVector{bcast_v3}, ParameterVector{A});
379
380     auto result = make_shared<HostTensor>();
381     ASSERT_TRUE(fun->evaluate(
382         {result}, {make_host_tensor<element::Type_t::f32>(in_shape, {1.0f, 2.0f, 3.0f, 4.0f})}));
383     EXPECT_EQ(result->get_element_type(), element::f32);
384     EXPECT_EQ(result->get_partial_shape(), (PartialShape{1, 4, 2, 2}));
385     auto result_val = read_vector<float>(result);
386     vector<float> expec{1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4};
387     ASSERT_EQ(result_val, expec);
388 }
389
390 TEST(eval, evaluate_broadcast_v3_pdpd)
391 {
392     Shape shape_a{3, 1};
393     auto A = make_shared<op::Parameter>(element::f32, shape_a);
394     auto target_shape = op::Constant::create<int64_t>(element::i64, Shape{3}, {2, 3, 6});
395     auto bcast_v3 = make_shared<op::v3::Broadcast>(
396         A, target_shape, op::BroadcastModeSpec(op::BroadcastType::PDPD, 1));
397     auto fun = make_shared<Function>(OutputVector{bcast_v3}, ParameterVector{A});
398
399     auto result = make_shared<HostTensor>();
400     ASSERT_TRUE(fun->evaluate(
401         {result}, {make_host_tensor<element::Type_t::f32>(Shape{3, 1}, {1.0f, 2.0f, 3.0f})}));
402     EXPECT_EQ(result->get_element_type(), element::f32);
403     EXPECT_EQ(result->get_partial_shape(), (PartialShape{2, 3, 6}));
404     auto result_val = read_vector<float>(result);
405     vector<float> expec{
406         1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3,
407         1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3,
408     };
409     ASSERT_EQ(result_val, expec);
410 }
411
412 TEST(eval, evaluate_broadcast_v3_pdpd_dyn)
413 {
414     Shape shape_a{3, 1};
415     auto A = make_shared<op::Parameter>(element::f32, shape_a);
416     auto target_shape = make_shared<op::Parameter>(element::i32, Shape{3});
417     auto bcast_v3 = make_shared<op::v3::Broadcast>(
418         A, target_shape, op::BroadcastModeSpec(op::BroadcastType::PDPD, 1));
419     auto fun = make_shared<Function>(OutputVector{bcast_v3}, ParameterVector{A, target_shape});
420
421     auto result = make_shared<HostTensor>();
422     ASSERT_TRUE(
423         fun->evaluate({result},
424                       {make_host_tensor<element::Type_t::f32>(Shape{3, 1}, {1.0f, 2.0f, 3.0f}),
425                        make_host_tensor<element::Type_t::i32>(Shape{3}, {2, 3, 6})}));
426     EXPECT_EQ(result->get_element_type(), element::f32);
427     EXPECT_EQ(result->get_partial_shape(), (PartialShape{2, 3, 6}));
428     auto result_val = read_vector<float>(result);
429     vector<float> expec{
430         1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3,
431         1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3,
432     };
433     ASSERT_EQ(result_val, expec);
434 }
435
436 TEST(eval, evaluate_broadcast_v1_numpy)
437 {
438     Shape shape_a{3, 1};
439     auto A = make_shared<op::Parameter>(element::f32, shape_a);
440     auto target_shape = op::Constant::create<int64_t>(element::i64, Shape{3}, {2, 3, 6});
441     auto bcast_v3 = make_shared<op::v1::Broadcast>(A, target_shape);
442     auto fun = make_shared<Function>(OutputVector{bcast_v3}, ParameterVector{A});
443
444     auto result = make_shared<HostTensor>();
445     ASSERT_TRUE(fun->evaluate(
446         {result}, {make_host_tensor<element::Type_t::f32>(Shape{3, 1}, {1.0f, 2.0f, 3.0f})}));
447     EXPECT_EQ(result->get_element_type(), element::f32);
448     EXPECT_EQ(result->get_partial_shape(), (PartialShape{2, 3, 6}));
449     auto result_val = read_vector<float>(result);
450     vector<float> expec{
451         1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3,
452         1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3,
453     };
454     ASSERT_EQ(result_val, expec);
455 }
456
457 TEST(eval, evaluate_broadcast_v1_numpy_dyn)
458 {
459     Shape shape_a{3, 1};
460     auto A = make_shared<op::Parameter>(element::f32, shape_a);
461     auto target_shape = make_shared<op::Parameter>(element::i64, Shape{3});
462     auto bcast_v3 = make_shared<op::v1::Broadcast>(A, target_shape);
463     auto fun = make_shared<Function>(OutputVector{bcast_v3}, ParameterVector{A, target_shape});
464
465     auto result = make_shared<HostTensor>();
466     ASSERT_TRUE(
467         fun->evaluate({result},
468                       {make_host_tensor<element::Type_t::f32>(Shape{3, 1}, {1.0f, 2.0f, 3.0f}),
469                        make_host_tensor<element::Type_t::i64>(Shape{3}, {2, 3, 6})}));
470     EXPECT_EQ(result->get_element_type(), element::f32);
471     EXPECT_EQ(result->get_partial_shape(), (PartialShape{2, 3, 6}));
472     auto result_val = read_vector<float>(result);
473     vector<float> expec{
474         1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3,
475         1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3,
476     };
477     ASSERT_EQ(result_val, expec);
478 }
479
480 TEST(eval, evaluate_broadcast_v1_pdpd)
481 {
482     Shape shape_a{3, 1};
483     auto A = make_shared<op::Parameter>(element::f32, shape_a);
484     auto target_shape = op::Constant::create<int64_t>(element::i64, Shape{3}, {2, 3, 6});
485     auto bcast_v3 = make_shared<op::v1::Broadcast>(
486         A, target_shape, op::AutoBroadcastSpec(op::AutoBroadcastType::PDPD, 1));
487     auto fun = make_shared<Function>(OutputVector{bcast_v3}, ParameterVector{A});
488
489     auto result = make_shared<HostTensor>();
490     ASSERT_TRUE(fun->evaluate(
491         {result}, {make_host_tensor<element::Type_t::f32>(Shape{3, 1}, {1.0f, 2.0f, 3.0f})}));
492     EXPECT_EQ(result->get_element_type(), element::f32);
493     EXPECT_EQ(result->get_partial_shape(), (PartialShape{2, 3, 6}));
494     auto result_val = read_vector<float>(result);
495     vector<float> expec{
496         1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3,
497         1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3,
498     };
499     ASSERT_EQ(result_val, expec);
500 }
501
502 TEST(eval, evaluate_broadcast_v1_pdpd_dyn)
503 {
504     Shape shape_a{3, 1};
505     auto A = make_shared<op::Parameter>(element::f32, shape_a);
506     auto target_shape = make_shared<op::Parameter>(element::i64, Shape{3});
507     auto bcast_v3 = make_shared<op::v1::Broadcast>(
508         A, target_shape, op::AutoBroadcastSpec(op::AutoBroadcastType::PDPD, 1));
509     auto fun = make_shared<Function>(OutputVector{bcast_v3}, ParameterVector{A, target_shape});
510
511     auto result = make_shared<HostTensor>();
512     ASSERT_TRUE(
513         fun->evaluate({result},
514                       {make_host_tensor<element::Type_t::f32>(Shape{3, 1}, {1.0f, 2.0f, 3.0f}),
515                        make_host_tensor<element::Type_t::i64>(Shape{3}, {2, 3, 6})}));
516     EXPECT_EQ(result->get_element_type(), element::f32);
517     EXPECT_EQ(result->get_partial_shape(), (PartialShape{2, 3, 6}));
518     auto result_val = read_vector<float>(result);
519     vector<float> expec{
520         1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3,
521         1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3,
522     };
523     ASSERT_EQ(result_val, expec);
524 }
525
526 TEST(eval, evaluate_broadcast_v1_explicit)
527 {
528     Shape shape_a{3, 1};
529     auto A = make_shared<op::Parameter>(element::f32, shape_a);
530     auto target_shape = op::Constant::create<int64_t>(element::i64, Shape{3}, {2, 3, 1});
531     auto axes_mapping = op::Constant::create<int32_t>(element::i32, Shape{2}, {1, 2});
532     auto bcast_v3 = make_shared<op::v1::Broadcast>(
533         A, target_shape, axes_mapping, op::AutoBroadcastSpec(op::AutoBroadcastType::EXPLICIT));
534     auto fun = make_shared<Function>(OutputVector{bcast_v3}, ParameterVector{A});
535
536     auto result = make_shared<HostTensor>();
537     ASSERT_TRUE(fun->evaluate(
538         {result}, {make_host_tensor<element::Type_t::f32>(Shape{3, 1}, {1.0f, 2.0f, 3.0f})}));
539     EXPECT_EQ(result->get_element_type(), element::f32);
540     EXPECT_EQ(result->get_partial_shape(), (PartialShape{2, 3, 1}));
541     auto result_val = read_vector<float>(result);
542     vector<float> expec{1, 2, 3, 1, 2, 3};
543     ASSERT_EQ(result_val, expec);
544 }
545
546 TEST(eval, evaluate_broadcast_v1_explicit_dyn)
547 {
548     Shape shape_a{3, 1};
549     auto A = make_shared<op::Parameter>(element::f32, shape_a);
550     auto target_shape = make_shared<op::Parameter>(element::i64, Shape{3});
551     auto axes_mapping = make_shared<op::Parameter>(element::i32, Shape{2});
552
553     auto bcast_v1 = make_shared<op::v1::Broadcast>(
554         A, target_shape, axes_mapping, op::AutoBroadcastSpec(op::AutoBroadcastType::EXPLICIT));
555     auto fun = make_shared<Function>(OutputVector{bcast_v1},
556                                      ParameterVector{A, target_shape, axes_mapping});
557
558     auto result = make_shared<HostTensor>();
559     ASSERT_TRUE(
560         fun->evaluate({result},
561                       {make_host_tensor<element::Type_t::f32>(Shape{3, 1}, {1.0f, 2.0f, 3.0f}),
562                        make_host_tensor<element::Type_t::i64>(Shape{3}, {2, 3, 1}),
563                        make_host_tensor<element::Type_t::i32>(Shape{2}, {1, 2})}));
564     EXPECT_EQ(result->get_element_type(), element::f32);
565     EXPECT_EQ(result->get_partial_shape(), (PartialShape{2, 3, 1}));
566     auto result_val = read_vector<float>(result);
567     vector<float> expec{1, 2, 3, 1, 2, 3};
568     ASSERT_EQ(result_val, expec);
569 }
570
571 TEST(eval, evaluate_broadcast_v3_explicit_dyn)
572 {
573     Shape shape_a{3, 1};
574     auto A = make_shared<op::Parameter>(element::f32, shape_a);
575     auto target_shape = make_shared<op::Parameter>(element::i64, Shape{3});
576     auto axes_mapping = make_shared<op::Parameter>(element::i32, Shape{2});
577
578     auto bcast_v3 = make_shared<op::v3::Broadcast>(
579         A, target_shape, axes_mapping, op::BroadcastModeSpec(op::BroadcastType::EXPLICIT));
580     auto fun = make_shared<Function>(OutputVector{bcast_v3},
581                                      ParameterVector{A, target_shape, axes_mapping});
582
583     auto result = make_shared<HostTensor>();
584     ASSERT_TRUE(
585         fun->evaluate({result},
586                       {make_host_tensor<element::Type_t::f32>(Shape{3, 1}, {1.0f, 2.0f, 3.0f}),
587                        make_host_tensor<element::Type_t::i64>(Shape{3}, {2, 3, 1}),
588                        make_host_tensor<element::Type_t::i32>(Shape{2}, {1, 2})}));
589     EXPECT_EQ(result->get_element_type(), element::f32);
590     EXPECT_EQ(result->get_partial_shape(), (PartialShape{2, 3, 1}));
591     auto result_val = read_vector<float>(result);
592     vector<float> expec{1, 2, 3, 1, 2, 3};
593     ASSERT_EQ(result_val, expec);
594 }
595
596 TEST(eval, evaluate_broadcast_v0)
597 {
598     Shape shape_a{2, 4};
599     auto A = make_shared<op::Parameter>(element::f32, shape_a);
600     Shape target_shape = Shape{2, 3, 4};
601     auto bcast_v0 = make_shared<op::v0::Broadcast>(A, target_shape, AxisSet{1});
602     auto fun = make_shared<Function>(OutputVector{bcast_v0}, ParameterVector{A});
603
604     auto result = make_shared<HostTensor>();
605     ASSERT_TRUE(fun->evaluate(
606         {result}, {make_host_tensor<element::Type_t::f32>(Shape{2, 4}, {1, 2, 3, 4, 1, 2, 3, 4})}));
607     EXPECT_EQ(result->get_element_type(), element::f32);
608     EXPECT_EQ(result->get_partial_shape(), (PartialShape{2, 3, 4}));
609     auto result_val = read_vector<float>(result);
610     vector<float> expec{1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4};
611     ASSERT_EQ(result_val, expec);
612 }
613
614 TEST(eval, test_op_multi_out)
615 {
616     auto p = make_shared<op::Parameter>(element::f32, PartialShape{2, 3});
617     auto p2 = make_shared<op::Parameter>(element::f64, PartialShape{2, 2});
618     auto so = make_shared<TestOpMultiOut>(p, p2);
619     auto fun =
620         make_shared<Function>(OutputVector{so->output(0), so->output(1)}, ParameterVector{p, p2});
621     auto result = make_shared<HostTensor>(element::Type_t::f32, Shape{2, 3});
622     auto result2 = make_shared<HostTensor>(element::Type_t::f64, Shape{2, 2});
623     HostTensorVector ins{make_host_tensor<element::Type_t::f32>(Shape{2, 3}),
624                          make_host_tensor<element::Type_t::f64>(Shape{2, 2})};
625     ASSERT_TRUE(fun->evaluate({result, result2}, ins));
626     EXPECT_EQ(result->get_element_type(), element::f32);
627     EXPECT_EQ(result->get_partial_shape(), (PartialShape{2, 3}));
628     auto result_val = read_vector<float>(result);
629     auto arg_val = read_vector<float>(ins[0]);
630     ASSERT_EQ(result_val, arg_val);
631     EXPECT_EQ(result2->get_element_type(), element::f64);
632     EXPECT_EQ(result2->get_partial_shape(), (PartialShape{2, 2}));
633     auto result_val2 = read_vector<double>(result2);
634     auto arg_val2 = read_vector<double>(ins[1]);
635     ASSERT_EQ(result_val2, arg_val2);
636 }
637
638 TEST(eval, evaluate_reshape_v1)
639 {
640     auto data = make_shared<op::Parameter>(element::f32, Shape{2, 5});
641     auto pattern = make_shared<op::Parameter>(element::i64, Shape{2});
642     auto dyn_reshape = make_shared<op::v1::Reshape>(data, pattern, false);
643     auto func = make_shared<Function>(OutputVector{dyn_reshape}, ParameterVector{data, pattern});
644     auto result_tensor = make_shared<HostTensor>();
645     ASSERT_TRUE(func->evaluate(
646         {result_tensor},
647         {make_host_tensor<element::Type_t::f32>({2, 5}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}),
648          make_host_tensor<element::Type_t::i64>({2}, {5, 2})}));
649     EXPECT_EQ(result_tensor->get_element_type(), element::f32);
650     EXPECT_EQ(result_tensor->get_partial_shape(), (PartialShape{5, 2}));
651     auto computed_val = read_vector<float>(result_tensor);
652     vector<float> expected_val{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
653     ASSERT_EQ(computed_val, expected_val);
654 }
655
656 TEST(eval, evaluate_reshape_v1_negative_index)
657 {
658     auto data = make_shared<op::Parameter>(element::f32, Shape{2, 5});
659     auto pattern = make_shared<op::Parameter>(element::i64, Shape{2});
660     auto dyn_reshape = make_shared<op::v1::Reshape>(data, pattern, false);
661     auto func = make_shared<Function>(OutputVector{dyn_reshape}, ParameterVector{data, pattern});
662     auto result_tensor = make_shared<HostTensor>();
663     ASSERT_TRUE(func->evaluate(
664         {result_tensor},
665         {make_host_tensor<element::Type_t::f32>({2, 5}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}),
666          make_host_tensor<element::Type_t::i64>({2}, {2, -1})}));
667     EXPECT_EQ(result_tensor->get_element_type(), element::f32);
668     EXPECT_EQ(result_tensor->get_partial_shape(), (PartialShape{2, 5}));
669     auto computed_val = read_vector<float>(result_tensor);
670     vector<float> expected_val{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
671     ASSERT_EQ(computed_val, expected_val);
672 }
673
674 TEST(eval, evaluate_reshape_v1_negative_index_zero_dim_zero_flag)
675 {
676     auto data = make_shared<op::Parameter>(element::f32, Shape{2, 2, 2, 2});
677     auto pattern = make_shared<op::Parameter>(element::i64, Shape{6});
678     auto dyn_reshape = make_shared<op::v1::Reshape>(data, pattern, true);
679     auto func = make_shared<Function>(OutputVector{dyn_reshape}, ParameterVector{data, pattern});
680     auto result_tensor = make_shared<HostTensor>();
681     ASSERT_TRUE(
682         func->evaluate({result_tensor},
683                        {make_host_tensor<element::Type_t::f32>(
684                             {2, 2, 2, 2}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}),
685                         make_host_tensor<element::Type_t::i64>({6}, {2, 0, 1, -1, 1, 2})}));
686     EXPECT_EQ(result_tensor->get_element_type(), element::f32);
687     EXPECT_EQ(result_tensor->get_partial_shape(), (PartialShape{2, 2, 1, 2, 1, 2}));
688     auto computed_val = read_vector<float>(result_tensor);
689     vector<float> expected_val{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
690     ASSERT_EQ(computed_val, expected_val);
691 }
692
693 TEST(eval, evaluate_reshape_v1_pattern_int16)
694 {
695     auto data = make_shared<op::Parameter>(element::f32, Shape{2, 2, 2, 2});
696     auto pattern = make_shared<op::Parameter>(element::i16, Shape{6});
697     auto dyn_reshape = make_shared<op::v1::Reshape>(data, pattern, true);
698     auto func = make_shared<Function>(OutputVector{dyn_reshape}, ParameterVector{data, pattern});
699     auto result_tensor = make_shared<HostTensor>();
700     ASSERT_TRUE(
701         func->evaluate({result_tensor},
702                        {make_host_tensor<element::Type_t::f32>(
703                             {2, 2, 2, 2}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}),
704                         make_host_tensor<element::Type_t::i16>({6}, {2, 0, 1, -1, 1, 2})}));
705     EXPECT_EQ(result_tensor->get_element_type(), element::f32);
706     EXPECT_EQ(result_tensor->get_partial_shape(), (PartialShape{2, 2, 1, 2, 1, 2}));
707     auto computed_val = read_vector<float>(result_tensor);
708     vector<float> expected_val{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
709     ASSERT_EQ(computed_val, expected_val);
710 }
711
712 TEST(eval, evaluate_convert)
713 {
714     auto p = make_shared<op::Parameter>(element::f32, PartialShape{-1, -1});
715     auto convert = make_shared<op::v0::Convert>(p, element::i64);
716     auto fun = make_shared<Function>(OutputVector{convert}, ParameterVector{p});
717
718     std::vector<std::vector<float>> inputs{{-1, 1}};
719     std::vector<std::vector<int64_t>> expected_result{{-1, 1}};
720     for (size_t i = 0; i < inputs.size(); i++)
721     {
722         auto result = make_shared<HostTensor>();
723         ASSERT_TRUE(fun->evaluate(
724             {result}, {make_host_tensor<element::Type_t::f32>(Shape{1, 2}, inputs[i])}));
725         EXPECT_EQ(result->get_element_type(), element::i64);
726         EXPECT_EQ(result->get_shape(), (Shape{1, 2}));
727         auto result_data = read_vector<int64_t>(result);
728         ASSERT_EQ(result_data, expected_result[i]);
729     }
730 }
731
732 TEST(eval, evaluate_abs)
733 {
734     auto p = make_shared<op::Parameter>(element::f32, Shape{2, 3});
735     auto abs = make_shared<op::Abs>(p);
736     auto fun = make_shared<Function>(OutputVector{abs}, ParameterVector{p});
737     auto result = make_shared<HostTensor>();
738     ASSERT_TRUE(fun->evaluate({result},
739                               {make_host_tensor<element::Type_t::f32>(
740                                   Shape{2, 3}, {0.0f, -1.0f, -2.0f, -3.0f, 4.0f, 5.0f})}));
741     EXPECT_EQ(result->get_element_type(), element::f32);
742     auto result_val = read_vector<float>(result);
743     vector<float> expec{0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f};
744     ASSERT_EQ(result_val, expec);
745 }
746
747 TEST(eval, evaluate_erf)
748 {
749     auto p = make_shared<op::Parameter>(element::f32, Shape{2, 3});
750     auto erf = make_shared<op::Erf>(p);
751     auto fun = make_shared<Function>(OutputVector{erf}, ParameterVector{p});
752     auto result = make_shared<HostTensor>();
753     ASSERT_TRUE(fun->evaluate({result},
754                               {make_host_tensor<element::Type_t::f32>(
755                                   Shape{2, 3}, {0.0f, -1.0f, -2.0f, -3.0f, 4.0f, 5.0f})}));
756     EXPECT_EQ(result->get_element_type(), element::f32);
757     auto result_val = read_vector<float>(result);
758     vector<float> expec{std::erf(0.0f),
759                         std::erf(-1.0f),
760                         std::erf(-2.0f),
761                         std::erf(-3.0f),
762                         std::erf(4.0f),
763                         std::erf(5.0f)};
764     ASSERT_EQ(result_val, expec);
765 }
766
767 TEST(eval, evaluate_exp)
768 {
769     auto p = make_shared<op::Parameter>(element::f32, Shape{2, 3});
770     auto exp = make_shared<op::Exp>(p);
771     auto fun = make_shared<Function>(OutputVector{exp}, ParameterVector{p});
772     auto result = make_shared<HostTensor>();
773     ASSERT_TRUE(fun->evaluate({result},
774                               {make_host_tensor<element::Type_t::f32>(
775                                   Shape{2, 3}, {0.0f, -1.0f, -2.0f, -3.0f, 4.0f, 5.0f})}));
776     EXPECT_EQ(result->get_element_type(), element::f32);
777     auto result_val = read_vector<float>(result);
778     vector<float> expec{std::exp(0.0f),
779                         std::exp(-1.0f),
780                         std::exp(-2.0f),
781                         std::exp(-3.0f),
782                         std::exp(4.0f),
783                         std::exp(5.0f)};
784     ASSERT_FLOAT_VECTORS_EQ(expec, result_val);
785 }
786
787 TEST(eval, evaluate_floor)
788 {
789     auto p = make_shared<op::Parameter>(element::f32, Shape{2, 2});
790     auto floor = make_shared<op::Floor>(p);
791     auto fun = make_shared<Function>(OutputVector{floor}, ParameterVector{p});
792     auto result = make_shared<HostTensor>();
793     ASSERT_TRUE(fun->evaluate(
794         {result},
795         {make_host_tensor<element::Type_t::f32>(Shape{2, 2}, {-2.5f, -2.0f, 0.3f, 4.8f})}));
796     EXPECT_EQ(result->get_element_type(), element::f32);
797     auto result_val = read_vector<float>(result);
798     vector<float> expec{-3.0f, -2.0f, 0.0f, 4.0f};
799     ASSERT_EQ(result_val, expec);
800 }
801
802 TEST(eval, evaluate_floor_int32)
803 {
804     auto p = make_shared<op::Parameter>(element::i32, Shape{2, 2});
805     auto floor = make_shared<op::Floor>(p);
806     auto fun = make_shared<Function>(OutputVector{floor}, ParameterVector{p});
807     auto result = make_shared<HostTensor>();
808     ASSERT_TRUE(fun->evaluate({result},
809                               {make_host_tensor<element::Type_t::i32>(
810                                   Shape{2, 2}, {-2, -136314888, 0x40000010, 0x40000001})}));
811     EXPECT_EQ(result->get_element_type(), element::i32);
812     auto result_val = read_vector<int32_t>(result);
813     vector<int32_t> expec{-2, -136314888, 0x40000010, 0x40000001};
814     ASSERT_EQ(result_val, expec);
815 }
816
817 TEST(eval, evaluate_log)
818 {
819     auto p = make_shared<op::Parameter>(element::f32, Shape{2, 2, 2});
820     auto log = make_shared<op::Log>(p);
821     auto fun = make_shared<Function>(OutputVector{log}, ParameterVector{p});
822     auto result = make_shared<HostTensor>();
823     ASSERT_TRUE(
824         fun->evaluate({result},
825                       {make_host_tensor<element::Type_t::f32>(
826                           Shape{2, 2, 2}, {0.125f, 0.25f, 0.5f, 1.f, 2.f, 4.f, 8.f, 16.f})}));
827     EXPECT_EQ(result->get_element_type(), element::f32);
828     auto result_val = read_vector<float>(result);
829     vector<float> expec{std::log(0.125f),
830                         std::log(0.25f),
831                         std::log(0.5f),
832                         std::log(1.f),
833                         std::log(2.f),
834                         std::log(4.f),
835                         std::log(8.f),
836                         std::log(16.f)};
837     ASSERT_EQ(result_val, expec);
838 }
839
840 TEST(eval, evaluate_negative_f32)
841 {
842     auto p = make_shared<op::Parameter>(element::f32, Shape{2, 5});
843     auto negate = make_shared<op::Negative>(p);
844     auto fun = make_shared<Function>(OutputVector{negate}, ParameterVector{p});
845     auto result = make_shared<HostTensor>();
846     ASSERT_TRUE(fun->evaluate(
847         {result},
848         {make_host_tensor<element::Type_t::f32>(
849             Shape{2, 5},
850             {1.35f, 8.76f, -8.0f, 17.234f, -2.121f, 1.0f, 8.7f, -8.92f, 17.0f, -1.0f})}));
851     EXPECT_EQ(result->get_element_type(), element::f32);
852     auto result_val = read_vector<float>(result);
853     vector<float> expec{-1.35f, -8.76f, 8.0f, -17.234f, 2.121f, -1.0f, -8.7f, 8.92f, -17.0f, 1.0f};
854     ASSERT_EQ(result_val, expec);
855 }
856
857 TEST(eval, evaluate_negative_i32)
858 {
859     auto p = make_shared<op::Parameter>(element::i32, Shape{2, 5});
860     auto negate = make_shared<op::Negative>(p);
861     auto fun = make_shared<Function>(OutputVector{negate}, ParameterVector{p});
862     auto result = make_shared<HostTensor>();
863     ASSERT_TRUE(fun->evaluate({result},
864                               {make_host_tensor<element::Type_t::i32>(
865                                   Shape{2, 5}, {1, 8, -8, 17, -2, 1, 8, -8, 17, 0})}));
866     EXPECT_EQ(result->get_element_type(), element::i32);
867     auto result_val = read_vector<int32_t>(result);
868     vector<int32_t> expec{-1, -8, 8, -17, 2, -1, -8, 8, -17, 0};
869     ASSERT_EQ(result_val, expec);
870 }
871
872 TEST(eval, evaluate_relu_2Ffprop_f32)
873 {
874     auto p = make_shared<op::Parameter>(element::f32, Shape{2, 5});
875     auto relu = make_shared<op::Relu>(p);
876     auto fun = make_shared<Function>(OutputVector{relu}, ParameterVector{p});
877     auto result = make_shared<HostTensor>();
878     ASSERT_TRUE(fun->evaluate({result},
879                               {make_host_tensor<element::Type_t::f32>(
880                                   Shape{2, 5}, {1, 8, -8, 17, -0.5, 0.1, 8.5, -8, 17, -0.5})}));
881     EXPECT_EQ(result->get_element_type(), element::f32);
882     auto result_val = read_vector<float>(result);
883     vector<float> expec{1, 8, 0, 17, 0, 0.1, 8.5, 0, 17, 0};
884     ASSERT_EQ(result_val, expec);
885 }
886
887 TEST(eval, evaluate_relu_2Ffprop_i32)
888 {
889     auto p = make_shared<op::Parameter>(element::i32, Shape{2, 5});
890     auto relu = make_shared<op::Relu>(p);
891     auto fun = make_shared<Function>(OutputVector{relu}, ParameterVector{p});
892     auto result = make_shared<HostTensor>();
893     ASSERT_TRUE(fun->evaluate({result},
894                               {make_host_tensor<element::Type_t::i32>(
895                                   Shape{2, 5}, {1, 8, -8, 17, -2, 1, 8, -8, 17, -1})}));
896     EXPECT_EQ(result->get_element_type(), element::i32);
897     auto result_val = read_vector<int32_t>(result);
898     vector<int32_t> expec{1, 8, 0, 17, 0, 1, 8, 0, 17, 0};
899     ASSERT_EQ(result_val, expec);
900 }
901
902 TEST(eval, evaluate_round)
903 {
904     auto p = make_shared<op::Parameter>(element::f32, Shape{5});
905     auto round = make_shared<op::Round>(p);
906     auto fun = make_shared<Function>(OutputVector{round}, ParameterVector{p});
907     auto result = make_shared<HostTensor>();
908     ASSERT_TRUE(fun->evaluate(
909         {result},
910         {make_host_tensor<element::Type_t::f32>(Shape{5}, {0.9f, 2.5f, 2.3f, 1.5f, -4.5f})}));
911     EXPECT_EQ(result->get_element_type(), element::f32);
912     auto result_val = read_vector<float>(result);
913     vector<float> expec{1.0f, 2.0f, 2.0f, 2.0f, -4.0f};
914     ASSERT_EQ(result_val, expec);
915 }
916
917 TEST(eval, evaluate_round_2D)
918 {
919     auto p = make_shared<op::Parameter>(element::f32, Shape{3, 5});
920     auto round = make_shared<op::Round>(p);
921     auto fun = make_shared<Function>(OutputVector{round}, ParameterVector{p});
922     auto result = make_shared<HostTensor>();
923     ASSERT_TRUE(fun->evaluate({result},
924                               {make_host_tensor<element::Type_t::f32>(Shape{3, 5},
925                                                                       {0.1f,
926                                                                        0.5f,
927                                                                        0.9f,
928                                                                        1.2f,
929                                                                        1.5f,
930                                                                        1.8f,
931                                                                        2.3f,
932                                                                        2.5f,
933                                                                        2.7f,
934                                                                        -1.1f,
935                                                                        -1.5f,
936                                                                        -1.9f,
937                                                                        -2.2f,
938                                                                        -2.5f,
939                                                                        -2.8f})}));
940     EXPECT_EQ(result->get_element_type(), element::f32);
941     auto result_val = read_vector<float>(result);
942     vector<float> expec{
943         0.f, 0.f, 1.f, 1.f, 2.f, 2.f, 2.f, 2.f, 3.f, -1.f, -2.f, -2.f, -2.f, -2.f, -3.f};
944     ASSERT_EQ(result_val, expec);
945 }
946
947 TEST(eval, evaluate_sigmoid)
948 {
949     auto p = make_shared<op::Parameter>(element::f32, Shape{1, 1, 2, 2});
950     auto sigmoid = make_shared<op::Sigmoid>(p);
951     auto fun = make_shared<Function>(OutputVector{sigmoid}, ParameterVector{p});
952     auto result = make_shared<HostTensor>();
953
954     float x1 = 1.0f;
955     float x2 = 4.0f;
956     float sigma1 = 1.0f / (1.0f + std::exp(-x1));
957     float sigma2 = 1.0f / (1.0f + std::exp(-x2));
958     ASSERT_TRUE(fun->evaluate(
959         {result}, {make_host_tensor<element::Type_t::f32>(Shape{1, 1, 2, 2}, {x1, x2, x1, x2})}));
960     EXPECT_EQ(result->get_element_type(), element::f32);
961     auto result_val = read_vector<float>(result);
962     vector<float> expec{sigma1, sigma2, sigma1, sigma2};
963     EXPECT_EQ(result_val.size(), expec.size());
964 }
965
966 TEST(eval, evaluate_sign)
967 {
968     auto p = make_shared<op::Parameter>(element::f32, Shape{2, 3});
969     auto sign = make_shared<op::Sign>(p);
970     auto fun = make_shared<Function>(OutputVector{sign}, ParameterVector{p});
971     auto result = make_shared<HostTensor>();
972
973     ASSERT_TRUE(fun->evaluate(
974         {result},
975         {make_host_tensor<element::Type_t::f32>(Shape{2, 3}, {1, -2, 0, -4.8f, 4.8f, -0.0f})}));
976     EXPECT_EQ(result->get_element_type(), element::f32);
977     auto result_val = read_vector<float>(result);
978     vector<float> expec{1, -1, 0, -1, 1, 0};
979     ASSERT_EQ(result_val, expec);
980 }
981
982 TEST(eval, evaluate_sin)
983 {
984     auto p = make_shared<op::Parameter>(element::f32, Shape{11});
985     auto sin = make_shared<op::Sin>(p);
986     auto fun = make_shared<Function>(OutputVector{sin}, ParameterVector{p});
987     auto result = make_shared<HostTensor>();
988
989     ASSERT_TRUE(fun->evaluate(
990         {result},
991         {make_host_tensor<element::Type_t::f32>(
992             Shape{11}, {0.f, 0.25f, -0.25f, 0.5f, -0.5f, 1.f, -1.f, 2.f, -2.f, 4.f, -4.f})}));
993     EXPECT_EQ(result->get_element_type(), element::f32);
994     auto result_val = read_vector<float>(result);
995     vector<float> expec{0.00000000f,
996                         0.24740396f,
997                         -0.24740396f,
998                         0.47942554f,
999                         -0.47942554f,
1000                         0.84147098f,
1001                         -0.84147098f,
1002                         0.90929743f,
1003                         -0.90929743f,
1004                         -0.75680250f,
1005                         0.75680250f};
1006     ASSERT_FLOAT_VECTORS_EQ(expec, result_val);
1007 }
1008
1009 TEST(eval, evaluate_sinh)
1010 {
1011     auto p = make_shared<op::Parameter>(element::f32, Shape{6});
1012     auto sinh = make_shared<op::Sinh>(p);
1013     auto fun = make_shared<Function>(OutputVector{sinh}, ParameterVector{p});
1014     auto result = make_shared<HostTensor>();
1015
1016     vector<float> input{1.0f, 0.0f, -0.0f, -1.0f, 5.0f, -5.0f};
1017     ASSERT_TRUE(fun->evaluate({result}, {make_host_tensor<element::Type_t::f32>(Shape{6}, input)}));
1018     EXPECT_EQ(result->get_element_type(), element::f32);
1019     auto result_val = read_vector<float>(result);
1020     std::transform(
1021         input.begin(), input.end(), input.begin(), [](float x) -> float { return sinhf(x); });
1022     ASSERT_FLOAT_VECTORS_EQ(input, result_val);
1023 }
1024
1025 TEST(eval, evaluate_sqrt)
1026 {
1027     auto p = make_shared<op::Parameter>(element::f32, Shape{6});
1028     auto sqrt = make_shared<op::Sqrt>(p);
1029     auto fun = make_shared<Function>(OutputVector{sqrt}, ParameterVector{p});
1030     auto result = make_shared<HostTensor>();
1031
1032     vector<float> input{16, 4, 81, 100, 10000, 0};
1033     ASSERT_TRUE(fun->evaluate({result}, {make_host_tensor<element::Type_t::f32>(Shape{6}, input)}));
1034     EXPECT_EQ(result->get_element_type(), element::f32);
1035     auto result_val = read_vector<float>(result);
1036     vector<float> expec{4, 2, 9, 10, 100, 0};
1037     ASSERT_FLOAT_VECTORS_EQ(expec, result_val);
1038 }
1039
1040 TEST(eval, evaluate_acos)
1041 {
1042     auto p = make_shared<op::Parameter>(element::f32, Shape{11});
1043     auto acos = make_shared<op::Acos>(p);
1044     auto fun = make_shared<Function>(OutputVector{acos}, ParameterVector{p});
1045     auto result = make_shared<HostTensor>();
1046
1047     vector<float> input{-1.f, -0.75f, -0.5f, -0.25f, -0.125f, 0.f, 0.125f, 0.25f, 0.5f, 0.75f, 1.f};
1048     ASSERT_TRUE(
1049         fun->evaluate({result}, {make_host_tensor<element::Type_t::f32>(Shape{11}, input)}));
1050     EXPECT_EQ(result->get_element_type(), element::f32);
1051     auto result_val = read_vector<float>(result);
1052     std::transform(
1053         input.begin(), input.end(), input.begin(), [](float x) -> float { return std::acos(x); });
1054     ASSERT_FLOAT_VECTORS_EQ(input, result_val);
1055 }
1056
1057 TEST(eval, evaluate_asin)
1058 {
1059     auto p = make_shared<op::Parameter>(element::f32, Shape{11});
1060     auto asin = make_shared<op::Asin>(p);
1061     auto fun = make_shared<Function>(OutputVector{asin}, ParameterVector{p});
1062     auto result = make_shared<HostTensor>();
1063
1064     vector<float> input{-1.f, -0.75f, -0.5f, -0.25f, -0.125f, 0.f, 0.125f, 0.25f, 0.5f, 0.75f, 1.f};
1065     ASSERT_TRUE(
1066         fun->evaluate({result}, {make_host_tensor<element::Type_t::f32>(Shape{11}, input)}));
1067     EXPECT_EQ(result->get_element_type(), element::f32);
1068     auto result_val = read_vector<float>(result);
1069     std::transform(
1070         input.begin(), input.end(), input.begin(), [](float x) -> float { return std::asin(x); });
1071
1072     ASSERT_FLOAT_VECTORS_EQ(input, result_val);
1073 }
1074
1075 TEST(eval, evaluate_atan)
1076 {
1077     auto p = make_shared<op::Parameter>(element::f32, Shape{11});
1078     auto atan = make_shared<op::Atan>(p);
1079     auto fun = make_shared<Function>(OutputVector{atan}, ParameterVector{p});
1080     auto result = make_shared<HostTensor>();
1081
1082     vector<float> input{-4.f, -2.f, -1.f, -0.5f, -0.25f, 0.f, 0.25f, 0.5f, 1.f, 2.f, 4.f};
1083     ASSERT_TRUE(
1084         fun->evaluate({result}, {make_host_tensor<element::Type_t::f32>(Shape{11}, input)}));
1085     EXPECT_EQ(result->get_element_type(), element::f32);
1086     auto result_val = read_vector<float>(result);
1087     std::transform(
1088         input.begin(), input.end(), input.begin(), [](float x) -> float { return std::atan(x); });
1089
1090     ASSERT_FLOAT_VECTORS_EQ(input, result_val);
1091 }
1092
1093 TEST(eval, evaluate_ceiling)
1094 {
1095     auto p = make_shared<op::Parameter>(element::f32, Shape{2, 2});
1096     auto ceil = make_shared<op::Ceiling>(p);
1097     auto fun = make_shared<Function>(OutputVector{ceil}, ParameterVector{p});
1098     auto result = make_shared<HostTensor>();
1099
1100     vector<float> input{-2.5f, -2.0f, 0.3f, 4.8f};
1101     ASSERT_TRUE(
1102         fun->evaluate({result}, {make_host_tensor<element::Type_t::f32>(Shape{2, 2}, input)}));
1103     EXPECT_EQ(result->get_element_type(), element::f32);
1104     auto result_val = read_vector<float>(result);
1105     vector<float> expec{-2.0f, -2.0f, 1.0f, 5.0f};
1106     ASSERT_EQ(result_val, expec);
1107 }
1108
1109 TEST(eval, evaluate_cos)
1110 {
1111     auto p = make_shared<op::Parameter>(element::f32, Shape{11});
1112     auto cos = make_shared<op::Cos>(p);
1113     auto fun = make_shared<Function>(OutputVector{cos}, ParameterVector{p});
1114     auto result = make_shared<HostTensor>();
1115
1116     vector<float> input{0.f, 0.25f, -0.25f, 0.5f, -0.5f, 1.f, -1.f, 2.f, -2.f, 4.f, -4.f};
1117     ASSERT_TRUE(
1118         fun->evaluate({result}, {make_host_tensor<element::Type_t::f32>(Shape{11}, input)}));
1119     EXPECT_EQ(result->get_element_type(), element::f32);
1120     auto result_val = read_vector<float>(result);
1121     std::transform(
1122         input.begin(), input.end(), input.begin(), [](float x) -> float { return std::cos(x); });
1123
1124     ASSERT_FLOAT_VECTORS_EQ(input, result_val);
1125 }
1126
1127 TEST(eval, evaluate_cosh)
1128 {
1129     auto p = make_shared<op::Parameter>(element::f32, Shape{6});
1130     auto cosh = make_shared<op::Cosh>(p);
1131     auto fun = make_shared<Function>(OutputVector{cosh}, ParameterVector{p});
1132     auto result = make_shared<HostTensor>();
1133
1134     vector<float> input{1.0f, 0.0f, -0.0f, -1.0f, 5.0f, -5.0f};
1135     ASSERT_TRUE(fun->evaluate({result}, {make_host_tensor<element::Type_t::f32>(Shape{6}, input)}));
1136     EXPECT_EQ(result->get_element_type(), element::f32);
1137     auto result_val = read_vector<float>(result);
1138     std::transform(
1139         input.begin(), input.end(), input.begin(), [](float x) -> float { return std::cosh(x); });
1140
1141     ASSERT_FLOAT_VECTORS_EQ(input, result_val);
1142 }
1143
1144 TEST(eval, evaluate_tan)
1145 {
1146     auto p = make_shared<op::Parameter>(element::f32, Shape{11});
1147     auto tan = make_shared<op::Tan>(p);
1148     auto fun = make_shared<Function>(OutputVector{tan}, ParameterVector{p});
1149     auto result = make_shared<HostTensor>();
1150
1151     vector<float> input{0.f, 0.25f, -0.25f, 0.5f, -0.5f, 1.f, -1.f, 2.f, -2.f, 4.f, -4.f};
1152     ASSERT_TRUE(
1153         fun->evaluate({result}, {make_host_tensor<element::Type_t::f32>(Shape{11}, input)}));
1154     EXPECT_EQ(result->get_element_type(), element::f32);
1155     auto result_val = read_vector<float>(result);
1156     std::transform(
1157         input.begin(), input.end(), input.begin(), [](float x) -> float { return std::tan(x); });
1158
1159     ASSERT_FLOAT_VECTORS_EQ(input, result_val);
1160 }
1161
1162 TEST(eval, evaluate_tanh)
1163 {
1164     auto p = make_shared<op::Parameter>(element::f32, Shape{6});
1165     auto tanh = make_shared<op::Tanh>(p);
1166     auto fun = make_shared<Function>(OutputVector{tanh}, ParameterVector{p});
1167     auto result = make_shared<HostTensor>();
1168
1169     vector<float> input{1.0f, 0.0f, -0.0f, -1.0f, 0.5f, -0.5f};
1170     ASSERT_TRUE(fun->evaluate({result}, {make_host_tensor<element::Type_t::f32>(Shape{6}, input)}));
1171     EXPECT_EQ(result->get_element_type(), element::f32);
1172     auto result_val = read_vector<float>(result);
1173     std::transform(
1174         input.begin(), input.end(), input.begin(), [](float x) -> float { return std::tanh(x); });
1175
1176     ASSERT_FLOAT_VECTORS_EQ(input, result_val);
1177 }
1178
1179 TEST(eval, evaluate_not)
1180 {
1181     auto p = make_shared<op::Parameter>(element::boolean, Shape{2, 2});
1182     auto op_not = make_shared<op::Not>(p);
1183     auto fun = make_shared<Function>(OutputVector{op_not}, ParameterVector{p});
1184     auto result = make_shared<HostTensor>();
1185
1186     ASSERT_TRUE(fun->evaluate(
1187         {result}, {make_host_tensor<element::Type_t::boolean>(Shape{2, 2}, {1, 0, 1, 0})}));
1188     EXPECT_EQ(result->get_element_type(), element::boolean);
1189     auto result_val = read_vector<char>(result);
1190     vector<char> expec{0, 1, 0, 1};
1191     ASSERT_EQ(result_val, expec);
1192 }
1193
1194 TEST(eval, evaluate_not_i32)
1195 {
1196     auto p = make_shared<op::Parameter>(element::i32, Shape{2, 2});
1197     auto op_not = make_shared<op::Not>(p);
1198     auto fun = make_shared<Function>(OutputVector{op_not}, ParameterVector{p});
1199     auto result = make_shared<HostTensor>();
1200
1201     ASSERT_TRUE(fun->evaluate(
1202         {result}, {make_host_tensor<element::Type_t::i32>(Shape{2, 2}, {100, 0, -2, 0})}));
1203     EXPECT_EQ(result->get_element_type(), element::i32);
1204     auto result_val = read_vector<int32_t>(result);
1205     vector<int32_t> expec{0, 1, 0, 1};
1206     ASSERT_EQ(result_val, expec);
1207 }
1208
1209 TEST(eval, evaluate_logical_not)
1210 {
1211     auto p = make_shared<op::Parameter>(element::boolean, Shape{2, 2});
1212     auto logical_not = make_shared<op::v1::LogicalNot>(p);
1213     auto fun = make_shared<Function>(OutputVector{logical_not}, ParameterVector{p});
1214     auto result = make_shared<HostTensor>();
1215
1216     ASSERT_TRUE(fun->evaluate(
1217         {result}, {make_host_tensor<element::Type_t::boolean>(Shape{2, 2}, {1, 0, 1, 0})}));
1218     EXPECT_EQ(result->get_element_type(), element::boolean);
1219     auto result_val = read_vector<char>(result);
1220     vector<char> expec{0, 1, 0, 1};
1221     ASSERT_EQ(result_val, expec);
1222 }
1223
1224 TEST(eval, evaluate_dynamic_gather)
1225 {
1226     auto arg1 = make_shared<op::Parameter>(element::f32, PartialShape::dynamic());
1227     auto arg2 = make_shared<op::Parameter>(element::i32, PartialShape::dynamic());
1228     auto gather = make_shared<op::v0::Gather>(arg1, arg2);
1229     auto fun = make_shared<Function>(OutputVector{gather}, ParameterVector{arg1, arg2});
1230     auto result_tensor = make_shared<HostTensor>();
1231     ASSERT_TRUE(fun->evaluate({result_tensor},
1232                               {make_host_tensor<element::Type_t::f32>({3}, {1.0f, 2.0f, 3.0f}),
1233                                make_host_tensor<element::Type_t::i32>({2}, {1, 0})}));
1234     EXPECT_EQ(result_tensor->get_element_type(), element::f32);
1235     EXPECT_EQ(result_tensor->get_partial_shape(), (PartialShape{2}));
1236     auto cval = read_vector<float>(result_tensor);
1237     vector<float> out{2.0f, 1.0f};
1238     ASSERT_EQ(cval, out);
1239 }
1240
1241 TEST(eval, evaluate_dynamic_axis_gather)
1242 {
1243     auto arg1 = make_shared<op::Parameter>(element::f32, PartialShape::dynamic());
1244     auto arg2 = make_shared<op::Parameter>(element::i32, PartialShape::dynamic());
1245     auto arg3 = make_shared<op::Parameter>(element::i64, PartialShape::dynamic());
1246     auto gather = make_shared<op::v1::Gather>(arg1, arg2, arg3);
1247     auto fun = make_shared<Function>(OutputVector{gather}, ParameterVector{arg1, arg2, arg3});
1248     auto result_tensor = make_shared<HostTensor>();
1249     ASSERT_TRUE(fun->evaluate({result_tensor},
1250                               {make_host_tensor<element::Type_t::f32>(
1251                                    {3, 3}, {1.0f, 1.1f, 1.2f, 2.0f, 2.1f, 2.2f, 3.0f, 3.1f, 3.2f}),
1252                                make_host_tensor<element::Type_t::i32>({1, 2}, {0, 2}),
1253                                make_host_tensor<element::Type_t::u64>({}, {1})}));
1254     EXPECT_EQ(result_tensor->get_element_type(), element::f32);
1255     EXPECT_EQ(result_tensor->get_partial_shape(), (PartialShape{3, 1, 2}));
1256     auto cval = read_vector<float>(result_tensor);
1257     vector<float> out{1.0f, 1.2f, 2.0f, 2.2f, 3.0f, 3.2f};
1258     ASSERT_EQ(cval, out);
1259 }
1260
1261 TEST(eval, evaluate_dynamic_concat)
1262 {
1263     auto arg1 = make_shared<op::Parameter>(element::f32, PartialShape::dynamic());
1264     auto arg2 = make_shared<op::Parameter>(element::f32, PartialShape::dynamic());
1265     auto concat = make_shared<op::v0::Concat>(NodeVector{arg1, arg2}, 1);
1266     auto fun = make_shared<Function>(OutputVector{concat}, ParameterVector{arg1, arg2});
1267     auto result_tensor = make_shared<HostTensor>();
1268     ASSERT_TRUE(fun->evaluate({result_tensor},
1269                               {make_host_tensor<element::Type_t::f32>({1, 1}, {1.0f}),
1270                                make_host_tensor<element::Type_t::f32>({1, 2}, {8.0f, 10.0f})}));
1271     EXPECT_EQ(result_tensor->get_element_type(), element::f32);
1272     EXPECT_EQ(result_tensor->get_partial_shape(), (PartialShape{1, 3}));
1273     auto cval = read_vector<float>(result_tensor);
1274     vector<float> out{1.0f, 8.0f, 10.0f};
1275     ASSERT_EQ(cval, out);
1276 }
1277
1278 template <element::Type_t T>
1279 void test_eval(shared_ptr<Function> fun,
1280                vector<vector<float>>& inputs,
1281                vector<Shape>& x_shapes,
1282                vector<Shape>& result_shapes,
1283                vector<vector<float>>& results)
1284 {
1285     using IN_T = typename element_type_traits<T>::value_type;
1286     std::vector<std::vector<IN_T>> perms{{0, 1}, {1, 0}, {2, 1, 0}};
1287     for (size_t i = 0; i < x_shapes.size(); i++)
1288     {
1289         auto result_tensor = make_shared<HostTensor>();
1290         ASSERT_TRUE(fun->evaluate({result_tensor},
1291                                   {make_host_tensor<element::Type_t::f32>(x_shapes[i], inputs[i]),
1292                                    make_host_tensor<T>(Shape{perms[i].size()}, perms[i])}));
1293
1294         ASSERT_EQ(result_tensor->get_shape(), result_shapes[i]);
1295         auto actual_results = read_vector<float>(result_tensor);
1296         ASSERT_EQ(actual_results, results[i]);
1297     }
1298 }
1299
1300 TEST(eval, eval_transpose)
1301 {
1302     auto x = make_shared<op::Parameter>(element::f32, PartialShape::dynamic());
1303     vector<shared_ptr<op::Parameter>> axes;
1304     axes.push_back(make_shared<op::Parameter>(element::i8, PartialShape{Dimension::dynamic()}));
1305     axes.push_back(make_shared<op::Parameter>(element::i16, PartialShape{Dimension::dynamic()}));
1306     axes.push_back(make_shared<op::Parameter>(element::i32, PartialShape{Dimension::dynamic()}));
1307     axes.push_back(make_shared<op::Parameter>(element::i64, PartialShape{Dimension::dynamic()}));
1308
1309     axes.push_back(make_shared<op::Parameter>(element::u8, PartialShape{Dimension::dynamic()}));
1310     axes.push_back(make_shared<op::Parameter>(element::u16, PartialShape{Dimension::dynamic()}));
1311     axes.push_back(make_shared<op::Parameter>(element::u32, PartialShape{Dimension::dynamic()}));
1312     axes.push_back(make_shared<op::Parameter>(element::u64, PartialShape{Dimension::dynamic()}));
1313
1314     std::vector<Shape> x_shapes{Shape{2, 3}, Shape{2, 3}, Shape{2, 2, 3}};
1315
1316     std::vector<std::vector<float>> inputs{
1317         {1, 2, 3, 4, 5, 6}, {1, 2, 3, 4, 5, 6}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}};
1318     std::vector<Shape> result_shapes{Shape{2, 3}, Shape{3, 2}, {3, 2, 2}};
1319     std::vector<std::vector<float>> results{
1320         {1, 2, 3, 4, 5, 6}, {1, 4, 2, 5, 3, 6}, {1, 7, 4, 10, 2, 8, 5, 11, 3, 9, 6, 12}};
1321
1322     for (auto& axis : axes)
1323     {
1324         auto x_transpose = make_shared<op::v1::Transpose>(x, axis);
1325         auto fun = make_shared<Function>(NodeVector{x_transpose}, ParameterVector{x, axis});
1326
1327         switch (axis->get_element_type())
1328         {
1329         case element::Type_t::i8:
1330             test_eval<element::Type_t::i8>(fun, inputs, x_shapes, result_shapes, results);
1331             break;
1332         case element::Type_t::i16:
1333             test_eval<element::Type_t::i16>(fun, inputs, x_shapes, result_shapes, results);
1334             break;
1335         case element::Type_t::i32:
1336             test_eval<element::Type_t::i32>(fun, inputs, x_shapes, result_shapes, results);
1337             break;
1338         case element::Type_t::i64:
1339             test_eval<element::Type_t::i64>(fun, inputs, x_shapes, result_shapes, results);
1340             break;
1341         case element::Type_t::u8:
1342             test_eval<element::Type_t::u8>(fun, inputs, x_shapes, result_shapes, results);
1343             break;
1344         case element::Type_t::u16:
1345             test_eval<element::Type_t::u16>(fun, inputs, x_shapes, result_shapes, results);
1346             break;
1347         case element::Type_t::u32:
1348             test_eval<element::Type_t::u32>(fun, inputs, x_shapes, result_shapes, results);
1349             break;
1350         case element::Type_t::u64:
1351             test_eval<element::Type_t::u64>(fun, inputs, x_shapes, result_shapes, results);
1352             break;
1353         default: NGRAPH_CHECK(false, "Invalid type"); break;
1354         }
1355     }
1356 }
1357
1358 TEST(eval, max_pool_v1_dynamic)
1359 {
1360     Shape window_shape{3};
1361     auto A = make_shared<op::Parameter>(element::f32, PartialShape::dynamic());
1362     auto f = make_shared<Function>(
1363         make_shared<op::v1::MaxPool>(
1364             A, Strides(), Shape(), Shape(), window_shape, op::RoundingType::FLOOR),
1365         ParameterVector{A});
1366     auto result_tensor = make_shared<HostTensor>();
1367
1368     ASSERT_TRUE(f->evaluate({result_tensor},
1369                             {make_host_tensor<element::Type_t::f32>(
1370                                 {1, 1, 14}, {0, 1, 0, 2, 1, 0, 3, 2, 0, 0, 2, 0, 0, 0})}));
1371
1372     EXPECT_EQ(result_tensor->get_element_type(), element::f32);
1373     EXPECT_EQ(result_tensor->get_partial_shape(), (PartialShape{1, 1, 12}));
1374     auto cval = read_vector<float>(result_tensor);
1375     vector<float> out{1, 2, 2, 2, 3, 3, 3, 2, 2, 2, 2, 0};
1376 }
1377
1378 TEST(eval, evaluate_static_scatter_elements_update_basic)
1379 {
1380     const Shape data_shape{3, 3};
1381     const Shape indices_shape{2, 3};
1382     auto arg1 = make_shared<op::Parameter>(element::f32, data_shape);
1383     auto arg2 = make_shared<op::Parameter>(element::i32, indices_shape);
1384     auto arg3 = make_shared<op::Parameter>(element::f32, indices_shape);
1385     auto arg4 = make_shared<op::Parameter>(element::i64, Shape{});
1386     auto scatter_elements_update =
1387         make_shared<op::v3::ScatterElementsUpdate>(arg1, arg2, arg3, arg4);
1388     auto fun = make_shared<Function>(OutputVector{scatter_elements_update},
1389                                      ParameterVector{arg1, arg2, arg3, arg4});
1390     auto result_tensor = make_shared<HostTensor>();
1391     ASSERT_TRUE(
1392         fun->evaluate({result_tensor},
1393                       {make_host_tensor<element::Type_t::f32>(
1394                            data_shape, {0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f}),
1395                        make_host_tensor<element::Type_t::i32>(indices_shape, {1, 0, 2, 0, 2, 1}),
1396                        make_host_tensor<element::Type_t::f32>(indices_shape,
1397                                                               {1.0f, 1.1f, 1.2f, 2.0f, 2.1f, 2.2f}),
1398                        make_host_tensor<element::Type_t::i64>({}, {0})}));
1399     EXPECT_EQ(result_tensor->get_element_type(), element::f32);
1400     EXPECT_EQ(result_tensor->get_shape(), (Shape{3, 3}));
1401     auto cval = read_vector<float>(result_tensor);
1402     vector<float> out{2.f, 1.1f, 0.0f, 1.f, 0.0f, 2.2f, 0.f, 2.1f, 1.2f};
1403     ASSERT_EQ(cval, out);
1404 }
1405
1406 TEST(eval, evaluate_dynamic_scatter_elements_update_basic)
1407 {
1408     const Shape data_shape{3, 3};
1409     const Shape indices_shape{2, 3};
1410
1411     auto arg1 = make_shared<op::Parameter>(element::f32, PartialShape::dynamic());
1412     auto arg2 = make_shared<op::Parameter>(element::i32, PartialShape::dynamic());
1413     auto arg3 = make_shared<op::Parameter>(element::f32, PartialShape::dynamic());
1414     auto arg4 = make_shared<op::Parameter>(element::i64, PartialShape::dynamic());
1415
1416     auto scatter_elements_update =
1417         make_shared<op::v3::ScatterElementsUpdate>(arg1, arg2, arg3, arg4);
1418     auto fun = make_shared<Function>(OutputVector{scatter_elements_update},
1419                                      ParameterVector{arg1, arg2, arg3, arg4});
1420     auto result_tensor = make_shared<HostTensor>();
1421     ASSERT_TRUE(
1422         fun->evaluate({result_tensor},
1423                       {make_host_tensor<element::Type_t::f32>(
1424                            data_shape, {0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f}),
1425                        make_host_tensor<element::Type_t::i32>(indices_shape, {1, 0, 2, 0, 2, 1}),
1426                        make_host_tensor<element::Type_t::f32>(indices_shape,
1427                                                               {1.0f, 1.1f, 1.2f, 2.0f, 2.1f, 2.2f}),
1428                        make_host_tensor<element::Type_t::i64>({}, {0})}));
1429
1430     EXPECT_EQ(result_tensor->get_element_type(), element::f32);
1431     EXPECT_EQ(result_tensor->get_partial_shape(), (PartialShape{3, 3}));
1432     auto cval = read_vector<float>(result_tensor);
1433     vector<float> out{2.f, 1.1f, 0.0f, 1.f, 0.0f, 2.2f, 0.f, 2.1f, 1.2f};
1434     ASSERT_EQ(cval, out);
1435 }
1436
1437 TEST(eval, evaluate_dynamic_scatter_elements_update_negative_axis)
1438 {
1439     const Shape data_shape{3, 3};
1440     const Shape indices_shape{2, 3};
1441     const Shape axis_shape{};
1442
1443     auto arg1 = make_shared<op::Parameter>(element::f32, PartialShape::dynamic());
1444     auto arg2 = make_shared<op::Parameter>(element::i32, PartialShape::dynamic());
1445     auto arg3 = make_shared<op::Parameter>(element::f32, PartialShape::dynamic());
1446     auto arg4 = make_shared<op::Parameter>(element::i64, PartialShape::dynamic());
1447
1448     auto scatter_elements_update =
1449         make_shared<op::v3::ScatterElementsUpdate>(arg1, arg2, arg3, arg4);
1450     auto fun = make_shared<Function>(OutputVector{scatter_elements_update},
1451                                      ParameterVector{arg1, arg2, arg3, arg4});
1452     auto result_tensor = make_shared<HostTensor>();
1453     ASSERT_TRUE(
1454         fun->evaluate({result_tensor},
1455                       {make_host_tensor<element::Type_t::f32>(
1456                            data_shape, {0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f}),
1457                        make_host_tensor<element::Type_t::i32>(indices_shape, {1, 0, 2, 0, 2, 1}),
1458                        make_host_tensor<element::Type_t::f32>(indices_shape,
1459                                                               {1.0f, 1.1f, 1.2f, 2.0f, 2.1f, 2.2f}),
1460                        make_host_tensor<element::Type_t::i64>(axis_shape, {-1})}));
1461
1462     EXPECT_EQ(result_tensor->get_element_type(), element::f32);
1463     EXPECT_EQ(result_tensor->get_partial_shape(), (PartialShape{3, 3}));
1464     auto cval = read_vector<float>(result_tensor);
1465     vector<float> out{1.1f, 1.0f, 1.2f, 2.0f, 2.2f, 2.1f, 0.0f, 0.0f, 0.0f};
1466     ASSERT_EQ(cval, out);
1467 }
1468
1469 TEST(eval, evaluate_dynamic_scatter_elements_update_1d_axis)
1470 {
1471     const Shape data_shape{3, 3};
1472     const Shape indices_shape{2, 3};
1473
1474     auto arg1 = make_shared<op::Parameter>(element::f32, PartialShape::dynamic());
1475     auto arg2 = make_shared<op::Parameter>(element::i32, PartialShape::dynamic());
1476     auto arg3 = make_shared<op::Parameter>(element::f32, PartialShape::dynamic());
1477     auto arg4 = make_shared<op::Parameter>(element::i64, PartialShape::dynamic());
1478
1479     auto scatter_elements_update =
1480         make_shared<op::v3::ScatterElementsUpdate>(arg1, arg2, arg3, arg4);
1481     auto fun = make_shared<Function>(OutputVector{scatter_elements_update},
1482                                      ParameterVector{arg1, arg2, arg3, arg4});
1483     auto result_tensor = make_shared<HostTensor>();
1484     ASSERT_TRUE(
1485         fun->evaluate({result_tensor},
1486                       {make_host_tensor<element::Type_t::f32>(
1487                            data_shape, {0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f}),
1488                        make_host_tensor<element::Type_t::i32>(indices_shape, {1, 0, 2, 0, 2, 1}),
1489                        make_host_tensor<element::Type_t::f32>(indices_shape,
1490                                                               {1.0f, 1.1f, 1.2f, 2.0f, 2.1f, 2.2f}),
1491                        make_host_tensor<element::Type_t::i64>({1}, {0})}));
1492
1493     EXPECT_EQ(result_tensor->get_element_type(), element::f32);
1494     EXPECT_EQ(result_tensor->get_partial_shape(), (PartialShape{3, 3}));
1495     auto cval = read_vector<float>(result_tensor);
1496     vector<float> out{2.f, 1.1f, 0.0f, 1.f, 0.0f, 2.2f, 0.f, 2.1f, 1.2f};
1497     ASSERT_EQ(cval, out);
1498 }
1499
1500 // Disabled test for disabled reference implementation
1501 TEST(eval, DISABLED_evaluate_dynamic_scatter_elements_update_3d_i16)
1502 {
1503     const Shape data_shape{3, 3, 3};
1504     const Shape indices_shape{2, 2, 3};
1505
1506     auto arg1 = make_shared<op::Parameter>(element::i16, PartialShape::dynamic());
1507     auto arg2 = make_shared<op::Parameter>(element::i16, PartialShape::dynamic());
1508     auto arg3 = make_shared<op::Parameter>(element::i16, PartialShape::dynamic());
1509     auto arg4 = make_shared<op::Parameter>(element::i64, PartialShape::dynamic());
1510
1511     auto scatter_elements_update =
1512         make_shared<op::v3::ScatterElementsUpdate>(arg1, arg2, arg3, arg4);
1513     auto fun = make_shared<Function>(OutputVector{scatter_elements_update},
1514                                      ParameterVector{arg1, arg2, arg3, arg4});
1515     auto result_tensor = make_shared<HostTensor>();
1516     ASSERT_TRUE(fun->evaluate({result_tensor},
1517                               {make_host_tensor<element::Type_t::i16>(
1518                                    data_shape, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1519                                                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}),
1520                                make_host_tensor<element::Type_t::i16>(
1521                                    indices_shape, {1, 0, 2, 0, 2, 1, 2, 2, 2, 0, 1, 0}),
1522                                make_host_tensor<element::Type_t::i16>(
1523                                    indices_shape, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}),
1524                                make_host_tensor<element::Type_t::i64>({}, {1})}));
1525
1526     EXPECT_EQ(result_tensor->get_element_type(), element::i16);
1527     EXPECT_EQ(result_tensor->get_partial_shape(), (PartialShape{3, 3, 3}));
1528     auto cval = read_vector<int16_t>(result_tensor);
1529     vector<int16_t> out{4, 2, 0, 1, 0, 6, 0, 5, 3, 10, 0, 12, 0, 11,
1530                         0, 7, 8, 9, 0, 0, 0, 0, 0, 0,  0, 0,  0};
1531     ASSERT_EQ(cval, out);
1532 }
1533
1534 TEST(eval, evaluate_dynamic_scatter_elements_update_one_elem_i32)
1535 {
1536     const Shape data_shape{3, 3, 3};
1537     const Shape indices_shape{1, 1, 1};
1538
1539     auto arg1 = make_shared<op::Parameter>(element::i32, PartialShape::dynamic());
1540     auto arg2 = make_shared<op::Parameter>(element::i32, PartialShape::dynamic());
1541     auto arg3 = make_shared<op::Parameter>(element::i32, PartialShape::dynamic());
1542     auto arg4 = make_shared<op::Parameter>(element::i64, PartialShape::dynamic());
1543
1544     auto scatter_elements_update =
1545         make_shared<op::v3::ScatterElementsUpdate>(arg1, arg2, arg3, arg4);
1546     auto fun = make_shared<Function>(OutputVector{scatter_elements_update},
1547                                      ParameterVector{arg1, arg2, arg3, arg4});
1548     auto result_tensor = make_shared<HostTensor>();
1549     ASSERT_TRUE(fun->evaluate({result_tensor},
1550                               {make_host_tensor<element::Type_t::i32>(
1551                                    data_shape, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1552                                                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}),
1553                                make_host_tensor<element::Type_t::i32>(indices_shape, {1}),
1554                                make_host_tensor<element::Type_t::i32>(indices_shape, {2}),
1555                                make_host_tensor<element::Type_t::i64>({}, {0})}));
1556
1557     EXPECT_EQ(result_tensor->get_element_type(), element::i32);
1558     EXPECT_EQ(result_tensor->get_partial_shape(), (PartialShape{3, 3, 3}));
1559     auto cval = read_vector<int32_t>(result_tensor);
1560     vector<int32_t> out{0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0,
1561                         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
1562     ASSERT_EQ(cval, out);
1563 }
1564
1565 TEST(eval, topk_v1)
1566 {
1567     Shape shape{2, 3, 2};
1568     Shape rshape{2, 2, 2};
1569
1570     auto A = make_shared<op::Parameter>(element::f32, shape);
1571     const auto k = op::Constant::create(element::i32, Shape{}, {2});
1572     auto B = make_shared<op::v1::TopK>(A, k, 1, "max", "index", element::i32);
1573
1574     auto fun = make_shared<Function>(OutputVector{B->output(0), B->output(1)}, ParameterVector{A});
1575
1576     auto result0 = make_shared<HostTensor>();
1577     auto result1 = make_shared<HostTensor>();
1578     ASSERT_TRUE(fun->evaluate({result0, result1},
1579                               {make_host_tensor<element::Type_t::f32>(
1580                                   Shape{2, 3, 2}, {12, 2, 10, 9, 8, 4, 6, 1, 5, 3, 11, 7})}));
1581     EXPECT_EQ(result0->get_element_type(), element::f32);
1582     EXPECT_EQ(result0->get_partial_shape(), (PartialShape{2, 2, 2}));
1583     EXPECT_EQ(result1->get_element_type(), element::i32);
1584     EXPECT_EQ(result1->get_partial_shape(), (PartialShape{2, 2, 2}));
1585     auto result0_val = read_vector<float>(result0);
1586
1587     auto result1_val = read_vector<int32_t>(result1);
1588
1589     vector<float> expec0{12, 9, 10, 4, 6, 3, 11, 7};
1590     ASSERT_EQ(result0_val, expec0);
1591
1592     vector<int32_t> expec1{0, 1, 1, 2, 0, 1, 2, 2};
1593     ASSERT_EQ(result1_val, expec1);
1594 }
1595
1596 TEST(eval, topk_v1_dyn)
1597 {
1598     Shape shape{2, 3, 2};
1599
1600     auto A = make_shared<op::Parameter>(element::f32, shape);
1601     auto k = make_shared<op::Parameter>(element::u32, Shape{});
1602     auto B = make_shared<op::v1::TopK>(A, k, 1, "max", "index", element::i32);
1603
1604     auto fun =
1605         make_shared<Function>(OutputVector{B->output(0), B->output(1)}, ParameterVector{A, k});
1606
1607     auto result0 = make_shared<HostTensor>();
1608     auto result1 = make_shared<HostTensor>();
1609     ASSERT_TRUE(fun->evaluate({result0, result1},
1610                               {make_host_tensor<element::Type_t::f32>(
1611                                    Shape{2, 3, 2}, {12, 2, 10, 9, 8, 4, 6, 1, 5, 3, 11, 7}),
1612                                make_host_tensor<element::Type_t::i32>(Shape{}, {2})}));
1613     EXPECT_EQ(result0->get_element_type(), element::f32);
1614     EXPECT_EQ(result0->get_partial_shape(), (PartialShape{2, 2, 2}));
1615     EXPECT_EQ(result1->get_element_type(), element::i32);
1616     EXPECT_EQ(result1->get_partial_shape(), (PartialShape{2, 2, 2}));
1617     auto result0_val = read_vector<float>(result0);
1618     auto result1_val = read_vector<int32_t>(result1);
1619     vector<float> expec0{12, 9, 10, 4, 6, 3, 11, 7};
1620     ASSERT_EQ(result0_val, expec0);
1621
1622     vector<int32_t> expec1{0, 1, 1, 2, 0, 1, 2, 2};
1623     ASSERT_EQ(result1_val, expec1);
1624 }
1625
1626 TEST(eval, topk_v3_dyn)
1627 {
1628     Shape shape{2, 3, 2};
1629
1630     auto A = make_shared<op::Parameter>(element::f32, shape);
1631     auto k = make_shared<op::Parameter>(element::u32, Shape{});
1632     auto B = make_shared<op::v3::TopK>(A, k, 1, "max", "index", element::i32);
1633
1634     auto fun =
1635         make_shared<Function>(OutputVector{B->output(0), B->output(1)}, ParameterVector{A, k});
1636
1637     auto result0 = make_shared<HostTensor>();
1638     auto result1 = make_shared<HostTensor>();
1639     ASSERT_TRUE(fun->evaluate({result0, result1},
1640                               {make_host_tensor<element::Type_t::f32>(
1641                                    Shape{2, 3, 2}, {12, 2, 10, 9, 8, 4, 6, 1, 5, 3, 11, 7}),
1642                                make_host_tensor<element::Type_t::i32>(Shape{}, {2})}));
1643     EXPECT_EQ(result0->get_element_type(), element::f32);
1644     EXPECT_EQ(result0->get_partial_shape(), (PartialShape{2, 2, 2}));
1645     EXPECT_EQ(result1->get_element_type(), element::i32);
1646     EXPECT_EQ(result1->get_partial_shape(), (PartialShape{2, 2, 2}));
1647     auto result0_val = read_vector<float>(result0);
1648     auto result1_val = read_vector<int32_t>(result1);
1649     vector<float> expec0{12, 9, 10, 4, 6, 3, 11, 7};
1650     ASSERT_EQ(result0_val, expec0);
1651
1652     vector<int32_t> expec1{0, 1, 1, 2, 0, 1, 2, 2};
1653     ASSERT_EQ(result1_val, expec1);
1654 }
1655
1656 TEST(eval, topk_v3_dyn_values)
1657 {
1658     Shape shape{2, 3, 2};
1659
1660     auto A = make_shared<op::Parameter>(element::f32, shape);
1661     auto k = make_shared<op::Parameter>(element::u32, Shape{});
1662     auto B = make_shared<op::v3::TopK>(A, k, 1, "max", "value", element::i32);
1663
1664     auto fun =
1665         make_shared<Function>(OutputVector{B->output(0), B->output(1)}, ParameterVector{A, k});
1666
1667     auto result0 = make_shared<HostTensor>();
1668     auto result1 = make_shared<HostTensor>();
1669     ASSERT_TRUE(fun->evaluate({result0, result1},
1670                               {make_host_tensor<element::Type_t::f32>(
1671                                    Shape{2, 3, 2}, {12, 2, 10, 9, 8, 4, 6, 1, 5, 3, 11, 7}),
1672                                make_host_tensor<element::Type_t::i32>(Shape{}, {2})}));
1673     EXPECT_EQ(result0->get_element_type(), element::f32);
1674     EXPECT_EQ(result0->get_partial_shape(), (PartialShape{2, 2, 2}));
1675     EXPECT_EQ(result1->get_element_type(), element::i32);
1676     EXPECT_EQ(result1->get_partial_shape(), (PartialShape{2, 2, 2}));
1677     auto result0_val = read_vector<float>(result0);
1678     auto result1_val = read_vector<int32_t>(result1);
1679     vector<float> expec0{12, 9, 10, 4, 11, 7, 6, 3};
1680     ASSERT_EQ(result0_val, expec0);
1681
1682     vector<int32_t> expec1{0, 1, 1, 2, 2, 2, 0, 1};
1683     ASSERT_EQ(result1_val, expec1);
1684 }
1685
1686 TEST(eval, topk_v3_dyn_values_k0)
1687 {
1688     Shape shape{2, 3, 2};
1689
1690     auto A = make_shared<op::Parameter>(element::f32, shape);
1691     auto k = make_shared<op::Parameter>(element::u32, Shape{});
1692     auto B = make_shared<op::v3::TopK>(A, k, 1, "max", "value", element::i32);
1693
1694     auto fun =
1695         make_shared<Function>(OutputVector{B->output(0), B->output(1)}, ParameterVector{A, k});
1696
1697     auto result0 = make_shared<HostTensor>();
1698     auto result1 = make_shared<HostTensor>();
1699     ASSERT_TRUE(fun->evaluate({result0, result1},
1700                               {make_host_tensor<element::Type_t::f32>(
1701                                    Shape{2, 3, 2}, {12, 2, 10, 9, 8, 4, 6, 1, 5, 3, 11, 7}),
1702                                make_host_tensor<element::Type_t::i32>(Shape{}, {0})}));
1703     EXPECT_EQ(result0->get_element_type(), element::f32);
1704     EXPECT_EQ(result0->get_partial_shape(), (PartialShape{2, 3, 2}));
1705     EXPECT_EQ(result1->get_element_type(), element::i32);
1706     EXPECT_EQ(result1->get_partial_shape(), (PartialShape{2, 3, 2}));
1707     auto result0_val = read_vector<float>(result0);
1708     auto result1_val = read_vector<int32_t>(result1);
1709     vector<float> expec0{12, 9, 10, 4, 8, 2, 11, 7, 6, 3, 5, 1};
1710     ASSERT_EQ(result0_val, expec0);
1711
1712     vector<int32_t> expec1{0, 1, 1, 2, 2, 0, 2, 2, 0, 1, 1, 0};
1713     ASSERT_EQ(result1_val, expec1);
1714 }
1715
1716 TEST(eval, topk_v0_dyn)
1717 {
1718     Shape shape{2, 3, 2};
1719
1720     auto A = make_shared<op::Parameter>(element::f32, shape);
1721     auto k = make_shared<op::Parameter>(element::i64, Shape{});
1722     auto axis = make_shared<op::Parameter>(element::i64, Shape{});
1723
1724     element::Type result_et{element::i32};
1725     bool compute_max = true;
1726
1727     auto B = make_shared<op::v0::TopK>(
1728         A, k, axis, result_et, compute_max, op::v0::TopK::SortType::SORT_VALUES);
1729
1730     auto fun = make_shared<Function>(OutputVector{B->output(0), B->output(1)},
1731                                      ParameterVector{A, k, axis});
1732
1733     auto result0 = make_shared<HostTensor>();
1734     auto result1 = make_shared<HostTensor>();
1735     ASSERT_TRUE(fun->evaluate({result0, result1},
1736                               {make_host_tensor<element::Type_t::f32>(
1737                                    Shape{2, 3, 2}, {12, 2, 10, 9, 8, 4, 6, 1, 5, 3, 11, 7}),
1738                                make_host_tensor<element::Type_t::i64>(Shape{}, {2}),
1739                                make_host_tensor<element::Type_t::i64>(Shape{}, {1})}));
1740     EXPECT_EQ(result0->get_element_type(), element::i32);
1741     EXPECT_EQ(result0->get_partial_shape(), (PartialShape{2, 2, 2}));
1742     EXPECT_EQ(result1->get_element_type(), element::f32);
1743     EXPECT_EQ(result1->get_partial_shape(), (PartialShape{2, 2, 2}));
1744     auto result1_val = read_vector<float>(result1);
1745     auto result0_val = read_vector<int32_t>(result0);
1746
1747     vector<float> expec1{12, 9, 10, 4, 11, 7, 6, 3};
1748     ASSERT_EQ(result1_val, expec1);
1749
1750     vector<int32_t> expec0{0, 1, 1, 2, 2, 2, 0, 1};
1751     ASSERT_EQ(result0_val, expec0);
1752 }
1753
1754 TEST(eval, topk_v0_dyn_k0)
1755 {
1756     Shape shape{2, 3, 2};
1757
1758     auto A = make_shared<op::Parameter>(element::f32, shape);
1759     auto k = make_shared<op::Parameter>(element::i64, Shape{});
1760     auto axis = make_shared<op::Parameter>(element::i64, Shape{});
1761
1762     element::Type result_et{element::i32};
1763     bool compute_max = true;
1764
1765     auto B = make_shared<op::v0::TopK>(
1766         A, k, axis, result_et, compute_max, op::v0::TopK::SortType::SORT_VALUES);
1767
1768     auto fun = make_shared<Function>(OutputVector{B->output(0), B->output(1)},
1769                                      ParameterVector{A, k, axis});
1770
1771     auto result0 = make_shared<HostTensor>();
1772     auto result1 = make_shared<HostTensor>();
1773     ASSERT_TRUE(fun->evaluate({result0, result1},
1774                               {make_host_tensor<element::Type_t::f32>(
1775                                    Shape{2, 3, 2}, {12, 2, 10, 9, 8, 4, 6, 1, 5, 3, 11, 7}),
1776                                make_host_tensor<element::Type_t::i64>(Shape{}, {0}),
1777                                make_host_tensor<element::Type_t::i64>(Shape{}, {1})}));
1778     EXPECT_EQ(result0->get_element_type(), element::i32);
1779     EXPECT_EQ(result0->get_partial_shape(), (PartialShape{2, 3, 2}));
1780     EXPECT_EQ(result1->get_element_type(), element::f32);
1781     EXPECT_EQ(result1->get_partial_shape(), (PartialShape{2, 3, 2}));
1782     auto result1_val = read_vector<float>(result1);
1783     auto result0_val = read_vector<int32_t>(result0);
1784
1785     vector<float> expec1{12, 9, 10, 4, 8, 2, 11, 7, 6, 3, 5, 1};
1786     ASSERT_EQ(result1_val, expec1);
1787
1788     vector<int32_t> expec0{0, 1, 1, 2, 2, 0, 2, 2, 0, 1, 1, 0};
1789     ASSERT_EQ(result0_val, expec0);
1790 }
1791
1792 TEST(eval, topk_v3_param_dyn_values_k0)
1793 {
1794     auto A = make_shared<op::Parameter>(element::f32, PartialShape::dynamic());
1795     auto k = make_shared<op::Parameter>(element::u32, Shape{});
1796     auto B = make_shared<op::v3::TopK>(A, k, 1, "max", "value", element::i32);
1797
1798     auto fun =
1799         make_shared<Function>(OutputVector{B->output(0), B->output(1)}, ParameterVector{A, k});
1800
1801     auto result0 = make_shared<HostTensor>();
1802     auto result1 = make_shared<HostTensor>();
1803     ASSERT_TRUE(fun->evaluate({result0, result1},
1804                               {make_host_tensor<element::Type_t::f32>(
1805                                    Shape{2, 3, 2}, {12, 2, 10, 9, 8, 4, 6, 1, 5, 3, 11, 7}),
1806                                make_host_tensor<element::Type_t::i32>(Shape{}, {0})}));
1807     EXPECT_EQ(result0->get_element_type(), element::f32);
1808     EXPECT_EQ(result0->get_partial_shape(), (PartialShape{2, 3, 2}));
1809     EXPECT_EQ(result1->get_element_type(), element::i32);
1810     EXPECT_EQ(result1->get_partial_shape(), (PartialShape{2, 3, 2}));
1811     auto result0_val = read_vector<float>(result0);
1812     auto result1_val = read_vector<int32_t>(result1);
1813     vector<float> expec0{12, 9, 10, 4, 8, 2, 11, 7, 6, 3, 5, 1};
1814     ASSERT_EQ(result0_val, expec0);
1815
1816     vector<int32_t> expec1{0, 1, 1, 2, 2, 0, 2, 2, 0, 1, 1, 0};
1817     ASSERT_EQ(result1_val, expec1);
1818 }
1819
1820 TEST(eval, topk_v3_param_dyn_values_k2)
1821 {
1822     auto A = make_shared<op::Parameter>(element::f32, PartialShape::dynamic());
1823     auto k = make_shared<op::Parameter>(element::u32, Shape{});
1824     auto B = make_shared<op::v3::TopK>(A, k, 1, "max", "value", element::i32);
1825
1826     auto fun =
1827         make_shared<Function>(OutputVector{B->output(0), B->output(1)}, ParameterVector{A, k});
1828
1829     auto result0 = make_shared<HostTensor>();
1830     auto result1 = make_shared<HostTensor>();
1831     ASSERT_TRUE(fun->evaluate({result0, result1},
1832                               {make_host_tensor<element::Type_t::f32>(
1833                                    Shape{2, 3, 2}, {12, 2, 10, 9, 8, 4, 6, 1, 5, 3, 11, 7}),
1834                                make_host_tensor<element::Type_t::i32>(Shape{}, {2})}));
1835     EXPECT_EQ(result0->get_element_type(), element::f32);
1836     EXPECT_EQ(result0->get_partial_shape(), (PartialShape{2, 2, 2}));
1837     EXPECT_EQ(result1->get_element_type(), element::i32);
1838     EXPECT_EQ(result1->get_partial_shape(), (PartialShape{2, 2, 2}));
1839     auto result0_val = read_vector<float>(result0);
1840     auto result1_val = read_vector<int32_t>(result1);
1841     vector<float> expec0{12, 9, 10, 4, 11, 7, 6, 3};
1842     ASSERT_EQ(result0_val, expec0);
1843
1844     vector<int32_t> expec1{0, 1, 1, 2, 2, 2, 0, 1};
1845     ASSERT_EQ(result1_val, expec1);
1846 }
1847
1848 TEST(eval, topk_v0_param_dyn_k2)
1849 {
1850     auto A = make_shared<op::Parameter>(element::f32, PartialShape::dynamic());
1851     auto k = make_shared<op::Parameter>(element::i64, Shape{});
1852     auto axis = make_shared<op::Parameter>(element::i64, Shape{});
1853
1854     element::Type result_et{element::i32};
1855     bool compute_max = true;
1856
1857     auto B = make_shared<op::v0::TopK>(
1858         A, k, axis, result_et, compute_max, op::v0::TopK::SortType::SORT_VALUES);
1859
1860     auto fun = make_shared<Function>(OutputVector{B->output(0), B->output(1)},
1861                                      ParameterVector{A, k, axis});
1862
1863     auto result0 = make_shared<HostTensor>();
1864     auto result1 = make_shared<HostTensor>();
1865     ASSERT_TRUE(fun->evaluate({result0, result1},
1866                               {make_host_tensor<element::Type_t::f32>(
1867                                    Shape{2, 3, 2}, {12, 2, 10, 9, 8, 4, 6, 1, 5, 3, 11, 7}),
1868                                make_host_tensor<element::Type_t::i64>(Shape{}, {2}),
1869                                make_host_tensor<element::Type_t::i64>(Shape{}, {1})}));
1870     EXPECT_EQ(result0->get_element_type(), element::i32);
1871     EXPECT_EQ(result0->get_partial_shape(), (PartialShape{2, 2, 2}));
1872     EXPECT_EQ(result1->get_element_type(), element::f32);
1873     EXPECT_EQ(result1->get_partial_shape(), (PartialShape{2, 2, 2}));
1874     auto result1_val = read_vector<float>(result1);
1875     auto result0_val = read_vector<int32_t>(result0);
1876
1877     vector<float> expec1{12, 9, 10, 4, 11, 7, 6, 3};
1878     ASSERT_EQ(result1_val, expec1);
1879
1880     vector<int32_t> expec0{0, 1, 1, 2, 2, 2, 0, 1};
1881     ASSERT_EQ(result0_val, expec0);
1882 }
1883
1884 TEST(eval, topk_v0_param_dyn_k0)
1885 {
1886     auto A = make_shared<op::Parameter>(element::f32, PartialShape::dynamic());
1887     auto k = make_shared<op::Parameter>(element::i64, Shape{});
1888     auto axis = make_shared<op::Parameter>(element::i64, Shape{});
1889
1890     element::Type result_et{element::i32};
1891     bool compute_max = true;
1892
1893     auto B = make_shared<op::v0::TopK>(
1894         A, k, axis, result_et, compute_max, op::v0::TopK::SortType::SORT_VALUES);
1895
1896     auto fun = make_shared<Function>(OutputVector{B->output(0), B->output(1)},
1897                                      ParameterVector{A, k, axis});
1898
1899     auto result0 = make_shared<HostTensor>();
1900     auto result1 = make_shared<HostTensor>();
1901     ASSERT_TRUE(fun->evaluate({result0, result1},
1902                               {make_host_tensor<element::Type_t::f32>(
1903                                    Shape{2, 3, 2}, {12, 2, 10, 9, 8, 4, 6, 1, 5, 3, 11, 7}),
1904                                make_host_tensor<element::Type_t::i64>(Shape{}, {0}),
1905                                make_host_tensor<element::Type_t::i64>(Shape{}, {1})}));
1906     EXPECT_EQ(result0->get_element_type(), element::i32);
1907     EXPECT_EQ(result0->get_partial_shape(), (PartialShape{2, 3, 2}));
1908     EXPECT_EQ(result1->get_element_type(), element::f32);
1909     EXPECT_EQ(result1->get_partial_shape(), (PartialShape{2, 3, 2}));
1910     auto result1_val = read_vector<float>(result1);
1911     auto result0_val = read_vector<int32_t>(result0);
1912
1913     vector<float> expec1{12, 9, 10, 4, 8, 2, 11, 7, 6, 3, 5, 1};
1914     ASSERT_EQ(result1_val, expec1);
1915
1916     vector<int32_t> expec0{0, 1, 1, 2, 2, 0, 2, 2, 0, 1, 1, 0};
1917     ASSERT_EQ(result0_val, expec0);
1918 }
1919
1920 TEST(eval, reduce_logical_and__neg_axis)
1921 {
1922     const auto data = make_shared<op::Parameter>(element::boolean, Shape{2, 2, 2});
1923     const auto axes = make_shared<op::Parameter>(element::i64, Shape{});
1924
1925     const auto op = make_shared<op::v1::ReduceLogicalAnd>(data, axes);
1926
1927     auto fun = make_shared<Function>(op, ParameterVector{data, axes});
1928
1929     auto result = make_shared<HostTensor>();
1930
1931     // when ReduceLogicalAnd node evaluator returns false -> the Function object throws
1932     EXPECT_THROW(
1933         fun->evaluate({result},
1934                       {
1935                           make_host_tensor<element::Type_t::boolean>(
1936                               Shape{2, 2, 2}, {true, false, true, false, true, false, true, false}),
1937                           make_host_tensor<element::Type_t::i64>(Shape{}, {-1}),
1938                       }),
1939         ngraph::ngraph_error);
1940 }
1941
1942 TEST(eval, evaluate_static_scatter_update_basic_axes_indices_i32)
1943 {
1944     const Shape data_shape{3, 3};
1945     const Shape indices_shape{1, 2};
1946     const Shape updates_shape{1, 2, 3};
1947
1948     auto arg1 = make_shared<op::Parameter>(element::f32, data_shape);
1949     auto arg2 = make_shared<op::Parameter>(element::i32, indices_shape);
1950     auto arg3 = make_shared<op::Parameter>(element::f32, updates_shape);
1951     auto arg4 = make_shared<op::Parameter>(element::i32, Shape{});
1952     auto scatter_update = make_shared<op::v3::ScatterUpdate>(arg1, arg2, arg3, arg4);
1953     auto fun = make_shared<Function>(OutputVector{scatter_update},
1954                                      ParameterVector{arg1, arg2, arg3, arg4});
1955     auto result_tensor = make_shared<HostTensor>();
1956     ASSERT_TRUE(fun->evaluate({result_tensor},
1957                               {make_host_tensor<element::Type_t::f32>(
1958                                    data_shape, std::vector<float>(shape_size(data_shape))),
1959                                make_host_tensor<element::Type_t::i32>(indices_shape, {1, 2}),
1960                                make_host_tensor<element::Type_t::f32>(
1961                                    updates_shape, {1.0f, 1.1f, 1.2f, 2.0f, 2.1f, 2.2f}),
1962                                make_host_tensor<element::Type_t::i32>({}, {0})}));
1963     EXPECT_EQ(result_tensor->get_element_type(), element::f32);
1964     EXPECT_EQ(result_tensor->get_shape(), (Shape{3, 3}));
1965     auto cval = read_vector<float>(result_tensor);
1966     vector<float> out{0.f, 0.f, 0.f, 1.0f, 1.1f, 1.2f, 2.0f, 2.1f, 2.2f};
1967     ASSERT_EQ(cval, out);
1968 }
1969
1970 TEST(eval, evaluate_static_scatter_update_basic_axes_indices_i64)
1971 {
1972     const Shape data_shape{3, 3};
1973     const Shape indices_shape{1, 2};
1974     const Shape updates_shape{1, 2, 3};
1975
1976     auto arg1 = make_shared<op::Parameter>(element::f32, data_shape);
1977     auto arg2 = make_shared<op::Parameter>(element::i64, indices_shape);
1978     auto arg3 = make_shared<op::Parameter>(element::f32, updates_shape);
1979     auto arg4 = make_shared<op::Parameter>(element::i64, Shape{});
1980     auto scatter_update = make_shared<op::v3::ScatterUpdate>(arg1, arg2, arg3, arg4);
1981     auto fun = make_shared<Function>(OutputVector{scatter_update},
1982                                      ParameterVector{arg1, arg2, arg3, arg4});
1983     auto result_tensor = make_shared<HostTensor>();
1984     ASSERT_TRUE(fun->evaluate({result_tensor},
1985                               {make_host_tensor<element::Type_t::f32>(
1986                                    data_shape, std::vector<float>(shape_size(data_shape))),
1987                                make_host_tensor<element::Type_t::i64>(indices_shape, {1, 2}),
1988                                make_host_tensor<element::Type_t::f32>(
1989                                    updates_shape, {1.0f, 1.1f, 1.2f, 2.0f, 2.1f, 2.2f}),
1990                                make_host_tensor<element::Type_t::i64>({}, {0})}));
1991     EXPECT_EQ(result_tensor->get_element_type(), element::f32);
1992     EXPECT_EQ(result_tensor->get_shape(), (Shape{3, 3}));
1993     auto cval = read_vector<float>(result_tensor);
1994     vector<float> out{0.f, 0.f, 0.f, 1.0f, 1.1f, 1.2f, 2.0f, 2.1f, 2.2f};
1995     ASSERT_EQ(cval, out);
1996 }
1997
1998 TEST(eval, evaluate_dynamic_scatter_update_basic)
1999 {
2000     const Shape data_shape{3, 3};
2001     const Shape indices_shape{1, 2};
2002     const Shape updates_shape{1, 2, 3};
2003
2004     auto arg1 = make_shared<op::Parameter>(element::f32, PartialShape::dynamic());
2005     auto arg2 = make_shared<op::Parameter>(element::i32, PartialShape::dynamic());
2006     auto arg3 = make_shared<op::Parameter>(element::f32, PartialShape::dynamic());
2007     auto arg4 = make_shared<op::Parameter>(element::i64, PartialShape::dynamic());
2008
2009     auto scatter_update = make_shared<op::v3::ScatterUpdate>(arg1, arg2, arg3, arg4);
2010     auto fun = make_shared<Function>(OutputVector{scatter_update},
2011                                      ParameterVector{arg1, arg2, arg3, arg4});
2012     auto result_tensor = make_shared<HostTensor>();
2013     ASSERT_TRUE(fun->evaluate({result_tensor},
2014                               {make_host_tensor<element::Type_t::f32>(
2015                                    data_shape, std::vector<float>(shape_size(data_shape))),
2016                                make_host_tensor<element::Type_t::i32>(indices_shape, {1, 2}),
2017                                make_host_tensor<element::Type_t::f32>(
2018                                    updates_shape, {1.0f, 1.1f, 1.2f, 2.0f, 2.1f, 2.2f}),
2019                                make_host_tensor<element::Type_t::i64>({}, {0})}));
2020
2021     EXPECT_EQ(result_tensor->get_element_type(), element::f32);
2022     EXPECT_EQ(result_tensor->get_partial_shape(), (PartialShape{3, 3}));
2023     auto cval = read_vector<float>(result_tensor);
2024     vector<float> out{0.f, 0.f, 0.f, 1.0f, 1.1f, 1.2f, 2.0f, 2.1f, 2.2f};
2025     ASSERT_EQ(cval, out);
2026 }
2027
2028 TEST(eval, evaluate_dynamic_scatter_update_negative_axis)
2029 {
2030     const Shape data_shape{3, 3};
2031     const Shape indices_shape{1, 2};
2032     const Shape updates_shape{3, 1, 2};
2033     const Shape axis_shape{};
2034
2035     auto arg1 = make_shared<op::Parameter>(element::f32, PartialShape::dynamic());
2036     auto arg2 = make_shared<op::Parameter>(element::i32, PartialShape::dynamic());
2037     auto arg3 = make_shared<op::Parameter>(element::f32, PartialShape::dynamic());
2038     auto arg4 = make_shared<op::Parameter>(element::i64, PartialShape::dynamic());
2039
2040     auto scatter_update = make_shared<op::v3::ScatterUpdate>(arg1, arg2, arg3, arg4);
2041     auto fun = make_shared<Function>(OutputVector{scatter_update},
2042                                      ParameterVector{arg1, arg2, arg3, arg4});
2043     auto result_tensor = make_shared<HostTensor>();
2044     ASSERT_TRUE(fun->evaluate({result_tensor},
2045                               {make_host_tensor<element::Type_t::f32>(
2046                                    data_shape, std::vector<float>(shape_size(data_shape))),
2047                                make_host_tensor<element::Type_t::i32>(indices_shape, {1, 2}),
2048                                make_host_tensor<element::Type_t::f32>(
2049                                    updates_shape, {1.0f, 1.1f, 1.2f, 2.0f, 2.1f, 2.2f}),
2050                                make_host_tensor<element::Type_t::i64>(axis_shape, {-1})}));
2051
2052     EXPECT_EQ(result_tensor->get_element_type(), element::f32);
2053     EXPECT_EQ(result_tensor->get_partial_shape(), (PartialShape{3, 3}));
2054     auto cval = read_vector<float>(result_tensor);
2055     vector<float> out{0.f, 1.0f, 1.1f, 0.0f, 1.2f, 2.0f, 0.0f, 2.1f, 2.2f};
2056     ASSERT_EQ(cval, out);
2057 }
2058
2059 TEST(eval, evaluate_dynamic_scatter_update_1d_axis)
2060 {
2061     const Shape data_shape{3, 3};
2062     const Shape indices_shape{1, 2};
2063     const Shape updates_shape{3, 1, 2};
2064
2065     auto arg1 = make_shared<op::Parameter>(element::f32, PartialShape::dynamic());
2066     auto arg2 = make_shared<op::Parameter>(element::i32, PartialShape::dynamic());
2067     auto arg3 = make_shared<op::Parameter>(element::f32, PartialShape::dynamic());
2068     auto arg4 = make_shared<op::Parameter>(element::i64, PartialShape::dynamic());
2069
2070     auto scatter_update = make_shared<op::v3::ScatterUpdate>(arg1, arg2, arg3, arg4);
2071     auto fun = make_shared<Function>(OutputVector{scatter_update},
2072                                      ParameterVector{arg1, arg2, arg3, arg4});
2073     auto result_tensor = make_shared<HostTensor>();
2074     ASSERT_TRUE(fun->evaluate({result_tensor},
2075                               {make_host_tensor<element::Type_t::f32>(
2076                                    data_shape, std::vector<float>(shape_size(data_shape))),
2077                                make_host_tensor<element::Type_t::i32>(indices_shape, {1, 2}),
2078                                make_host_tensor<element::Type_t::f32>(
2079                                    updates_shape, {1.0f, 1.1f, 1.2f, 2.0f, 2.1f, 2.2f}),
2080                                make_host_tensor<element::Type_t::i64>({1}, {1})}));
2081
2082     EXPECT_EQ(result_tensor->get_element_type(), element::f32);
2083     EXPECT_EQ(result_tensor->get_partial_shape(), (PartialShape{3, 3}));
2084     auto cval = read_vector<float>(result_tensor);
2085     vector<float> out{0.f, 1.0f, 1.1f, 0.0f, 1.2f, 2.0f, 0.0f, 2.1f, 2.2f};
2086     ASSERT_EQ(cval, out);
2087 }
2088
2089 TEST(eval, evaluate_dynamic_scatter_update_one_elem_i32)
2090 {
2091     const Shape data_shape{3, 3, 2};
2092     const Shape indices_shape{1, 1};
2093     const Shape updates_shape{1, 1, 3, 2};
2094
2095     auto arg1 = make_shared<op::Parameter>(element::i32, PartialShape::dynamic());
2096     auto arg2 = make_shared<op::Parameter>(element::i32, PartialShape::dynamic());
2097     auto arg3 = make_shared<op::Parameter>(element::i32, PartialShape::dynamic());
2098     auto arg4 = make_shared<op::Parameter>(element::i64, PartialShape::dynamic());
2099
2100     auto scatter_update = make_shared<op::v3::ScatterUpdate>(arg1, arg2, arg3, arg4);
2101     auto fun = make_shared<Function>(OutputVector{scatter_update},
2102                                      ParameterVector{arg1, arg2, arg3, arg4});
2103     auto result_tensor = make_shared<HostTensor>();
2104     ASSERT_TRUE(
2105         fun->evaluate({result_tensor},
2106                       {make_host_tensor<element::Type_t::i32>(
2107                            data_shape, std::vector<int32_t>(shape_size(data_shape))),
2108                        make_host_tensor<element::Type_t::i32>(indices_shape, {1}),
2109                        make_host_tensor<element::Type_t::i32>(updates_shape, {1, 2, 3, 4, 5, 6}),
2110                        make_host_tensor<element::Type_t::i64>({}, {0})}));
2111
2112     EXPECT_EQ(result_tensor->get_element_type(), element::i32);
2113     EXPECT_EQ(result_tensor->get_partial_shape(), (PartialShape{3, 3, 2}));
2114     auto cval = read_vector<int32_t>(result_tensor);
2115     vector<int32_t> out{0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 0, 0, 0, 0, 0, 0};
2116     ASSERT_EQ(cval, out);
2117 }