Deprecate nGraph v0 ops and builders (#1856)
[platform/upstream/dldt.git] / ngraph / test / backend / node_name.in.cpp
1 //*****************************************************************************
2 // Copyright 2017-2020 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //*****************************************************************************
16
17 #include "gtest/gtest.h"
18 #include "ngraph/ngraph.hpp"
19 #include "ngraph/runtime/tensor.hpp"
20 #include "runtime/backend.hpp"
21 #include "util/all_close_f.hpp"
22 #include "util/ndarray.hpp"
23 #include "util/test_control.hpp"
24 #include "util/test_tools.hpp"
25
26 NGRAPH_SUPPRESS_DEPRECATED_START
27
28 using namespace std;
29 using namespace ngraph;
30
31 static string s_manifest = "${MANIFEST}";
32
33 NGRAPH_TEST(${BACKEND_NAME}, node_name)
34 {
35     Shape shape{2, 2};
36     auto A = make_shared<op::Parameter>(element::f32, shape);
37     auto B = make_shared<op::Parameter>(element::f32, shape);
38     auto C = A + B;
39     C->set_friendly_name("a node name");
40     auto f = make_shared<Function>(C, ParameterVector{A, B});
41
42     auto backend = runtime::Backend::create("${BACKEND_NAME}");
43
44     // Create some tensors for input/output
45     shared_ptr<runtime::Tensor> a = backend->create_tensor(element::f32, shape);
46     shared_ptr<runtime::Tensor> b = backend->create_tensor(element::f32, shape);
47     shared_ptr<runtime::Tensor> result = backend->create_tensor(element::f32, shape);
48
49     copy_data(a, test::NDArray<float, 2>({{1, 2}, {3, 4}}).get_vector());
50     copy_data(b, test::NDArray<float, 2>({{5, 6}, {7, 8}}).get_vector());
51
52     auto handle = backend->compile(f);
53     handle->call_with_validate({result}, {a, b});
54     EXPECT_TRUE(test::all_close_f(read_vector<float>(result),
55                                   (test::NDArray<float, 2>({{6, 8}, {10, 12}})).get_vector()));
56 }