1 //*****************************************************************************
2 // Copyright 2017-2020 Intel Corporation
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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 //*****************************************************************************
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"
26 NGRAPH_SUPPRESS_DEPRECATED_START
29 using namespace ngraph;
31 static string s_manifest = "${MANIFEST}";
33 // Multiple retrive values
34 NGRAPH_TEST(${BACKEND_NAME}, multiple_result)
37 auto A = make_shared<op::Parameter>(element::f32, shape);
38 auto B = make_shared<op::Parameter>(element::f32, shape);
39 auto C = make_shared<op::Parameter>(element::f32, shape);
40 auto A_add_B = make_shared<op::Add>(A, B);
41 auto A_add_B_mul_C = make_shared<op::Multiply>(A_add_B, C);
43 auto f = make_shared<Function>(NodeVector{A_add_B, A_add_B_mul_C}, ParameterVector{A, B, C});
45 auto backend = runtime::Backend::create("${BACKEND_NAME}");
47 auto a = backend->create_tensor(element::f32, shape);
48 copy_data(a, vector<float>{1, 2, 3, 4});
49 auto b = backend->create_tensor(element::f32, shape);
50 copy_data(b, vector<float>{5, 6, 7, 8});
51 auto c = backend->create_tensor(element::f32, shape);
52 copy_data(c, vector<float>{9, 10, 11, 12});
54 auto r0 = backend->create_tensor(element::f32, shape);
55 auto r1 = backend->create_tensor(element::f32, shape);
57 auto handle = backend->compile(f);
58 handle->call_with_validate({r0, r1}, {a, b, c});
60 EXPECT_TRUE(test::all_close_f((vector<float>{6, 8, 10, 12}), read_vector<float>(r0)));
61 EXPECT_TRUE(test::all_close_f((vector<float>{54, 80, 110, 144}), read_vector<float>(r1)));