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 NGRAPH_TEST(${BACKEND_NAME}, function_name)
36 auto A = make_shared<op::Parameter>(element::f32, shape);
37 auto B = make_shared<op::Parameter>(element::f32, shape);
38 auto f = make_shared<Function>(A + B, ParameterVector{A, B}, "funky func name");
40 auto backend = runtime::Backend::create("${BACKEND_NAME}");
42 // Create some tensors for input/output
43 shared_ptr<runtime::Tensor> a = backend->create_tensor<float>(shape);
44 shared_ptr<runtime::Tensor> b = backend->create_tensor<float>(shape);
45 shared_ptr<runtime::Tensor> result = backend->create_tensor<float>(shape);
47 copy_data(a, test::NDArray<float, 2>({{1, 2}, {3, 4}}).get_vector());
48 copy_data(b, test::NDArray<float, 2>({{5, 6}, {7, 8}}).get_vector());
50 auto handle = backend->compile(f);
51 handle->call_with_validate({result}, {a, b});
52 EXPECT_TRUE(test::all_close_f(read_vector<float>(result),
53 (test::NDArray<float, 2>({{6, 8}, {10, 12}})).get_vector()));