Deprecate nGraph v0 ops and builders (#1856)
[platform/upstream/dldt.git] / ngraph / test / input_output_assign.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 "gtest/gtest.h"
18
19 #include "ngraph/ngraph.hpp"
20
21 #include <memory>
22
23 NGRAPH_SUPPRESS_DEPRECATED_START
24
25 using namespace std;
26 using namespace ngraph;
27
28 TEST(input_output, param_tensor)
29 {
30     // Params have no arguments, so we can check that the value becomes a tensor output
31     auto& et = element::f32;
32     Shape shape{2, 4};
33     auto param = make_shared<op::Parameter>(et, shape);
34
35     ASSERT_EQ(param->get_output_size(), 1);
36     ASSERT_EQ(et, param->get_element_type());
37     ASSERT_EQ(shape, param->get_shape());
38 }
39
40 TEST(input_output, simple_output)
41 {
42     auto param_0 = make_shared<op::Parameter>(element::f32, Shape{2, 4});
43     auto param_1 = make_shared<op::Parameter>(element::f32, Shape{2, 4});
44     auto add = make_shared<op::Add>(param_0, param_1);
45
46     // Sort the ops
47     vector<shared_ptr<Node>> nodes;
48     nodes.push_back(param_0);
49     nodes.push_back(param_1);
50     nodes.push_back(add);
51
52     // At this point, the add should have each input associated with the output of the appropriate
53     // parameter
54     ASSERT_EQ(1, add->get_output_size());
55     ASSERT_EQ(2, add->get_input_size());
56     for (size_t i = 0; i < add->get_input_size(); i++)
57     {
58         ASSERT_EQ(add->input_value(i).get_node_shared_ptr(), nodes.at(i));
59     }
60 }