Deprecate nGraph v0 ops and builders (#1856)
[platform/upstream/dldt.git] / ngraph / test / backend / aliased_output.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 "util/engine/test_engines.hpp"
20 #include "util/test_case.hpp"
21 #include "util/test_control.hpp"
22
23 NGRAPH_SUPPRESS_DEPRECATED_START
24
25 using namespace std;
26 using namespace ngraph;
27
28 static string s_manifest = "${MANIFEST}";
29 using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME});
30
31 NGRAPH_TEST(${BACKEND_NAME}, aliased_output)
32 {
33     Shape shape{2, 2};
34     auto A = make_shared<op::Parameter>(element::f32, shape);
35     auto B = make_shared<op::Parameter>(element::f32, shape);
36     auto C = A + B;
37     auto D = A * B;
38     auto E = op::Constant::create(element::f32, shape, {1, 2, 3, 4});
39     auto f = make_shared<Function>(NodeVector{C, C, D, D, C, E, E}, ParameterVector{A, B});
40
41     vector<float> a{0, 1, 2, 3};
42     vector<float> b{1, 2, 3, 4};
43     vector<float> expectedC{1, 3, 5, 7};
44     vector<float> expectedD{0, 2, 6, 12};
45     vector<float> expectedE{1, 2, 3, 4};
46
47     auto test_case = test::TestCase<TestEngine>(f);
48     test_case.add_multiple_inputs<float>({a, b});
49     test_case.add_expected_output<float>(shape, expectedC);
50     test_case.add_expected_output<float>(shape, expectedC);
51     test_case.add_expected_output<float>(shape, expectedD);
52     test_case.add_expected_output<float>(shape, expectedD);
53     test_case.add_expected_output<float>(shape, expectedC);
54     test_case.add_expected_output<float>(shape, expectedE);
55     test_case.add_expected_output<float>(shape, expectedE);
56     test_case.run(MIN_FLOAT_TOLERANCE_BITS);
57 }