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.hpp"
22 #include "util/all_close_f.hpp"
23 #include "util/ndarray.hpp"
24 #include "util/test_control.hpp"
25 #include "util/test_tools.hpp"
27 NGRAPH_SUPPRESS_DEPRECATED_START
30 using namespace ngraph;
32 static string s_manifest = "${MANIFEST}";
34 NGRAPH_TEST(${BACKEND_NAME}, numeric_float_nan)
37 auto A = op::Constant::create(element::f32, shape, {-2.5f, 25.5f, 2.25f, NAN, 6.0f});
38 auto B = op::Constant::create(element::f32, shape, {10.0f, 5.0f, 2.25f, 10.0f, NAN});
39 auto f = make_shared<Function>(make_shared<op::Equal>(A, B), ParameterVector{});
41 auto backend = runtime::Backend::create("${BACKEND_NAME}");
43 // Create some tensors for input/output
44 auto result = backend->create_tensor(element::boolean, shape);
45 auto handle = backend->compile(f);
46 handle->call_with_validate({result}, {});
47 EXPECT_EQ((vector<char>{false, false, true, false, false}), read_vector<char>(result));
50 NGRAPH_TEST(${BACKEND_NAME}, numeric_double_nan)
53 auto A = op::Constant::create(element::f64, shape, {-2.5f, 25.5f, 2.25f, NAN, 6.0f});
54 auto B = op::Constant::create(element::f64, shape, {10.0f, 5.0f, 2.25f, 10.0f, NAN});
55 auto f = make_shared<Function>(make_shared<op::Equal>(A, B), ParameterVector{});
57 auto backend = runtime::Backend::create("${BACKEND_NAME}");
59 // Create some tensors for input/output
60 auto result = backend->create_tensor(element::boolean, shape);
61 auto handle = backend->compile(f);
62 handle->call_with_validate({result}, {});
63 EXPECT_EQ((vector<char>{false, false, true, false, false}), read_vector<char>(result));
66 NGRAPH_TEST(${BACKEND_NAME}, numeric_float_inf)
69 auto A = op::Constant::create(element::f32, shape, {-2.5f, 25.5f, 2.25f, INFINITY, 6.0f});
70 auto B = op::Constant::create(element::f32, shape, {10.0f, 5.0f, 2.25f, 10.0f, -INFINITY});
71 auto f = make_shared<Function>(make_shared<op::Equal>(A, B), ParameterVector{});
73 auto backend = runtime::Backend::create("${BACKEND_NAME}");
75 // Create some tensors for input/output
76 auto result = backend->create_tensor(element::boolean, shape);
77 auto handle = backend->compile(f);
78 handle->call_with_validate({result}, {});
79 EXPECT_EQ((vector<char>{false, false, true, false, false}), read_vector<char>(result));
82 NGRAPH_TEST(${BACKEND_NAME}, numeric_double_inf)
85 auto A = op::Constant::create(element::f64, shape, {-2.5f, 25.5f, 2.25f, INFINITY, 6.0f});
86 auto B = op::Constant::create(element::f64, shape, {10.0f, 5.0f, 2.25f, 10.0f, -INFINITY});
87 auto f = make_shared<Function>(make_shared<op::Equal>(A, B), ParameterVector{});
89 auto backend = runtime::Backend::create("${BACKEND_NAME}");
91 // Create some tensors for input/output
92 auto result = backend->create_tensor(element::boolean, shape);
93 auto handle = backend->compile(f);
94 handle->call_with_validate({result}, {});
95 EXPECT_EQ((vector<char>{false, false, true, false, false}), read_vector<char>(result));