2 * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
3 * Copyright 2017 The TensorFlow Authors. All Rights Reserved.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #include "kernels/LogicalNot.h"
19 #include "kernels/TestUtils.h"
20 #include "luci_interpreter/TestMemoryManager.h"
22 namespace luci_interpreter
29 using namespace testing;
31 class LogicalNotTest : public ::testing::Test
34 void SetUp() override { _memory_manager = std::make_unique<TestMemoryManager>(); }
36 std::unique_ptr<IMemoryManager> _memory_manager;
39 TEST_F(LogicalNotTest, Basic)
41 Shape input_shape{1, 1, 1, 4};
43 makeInputTensor<DataType::BOOL>(input_shape, {true, false, false, true}, _memory_manager.get());
44 Tensor output_tensor = makeOutputTensor(DataType::BOOL);
46 LogicalNot kernel(&input_tensor, &output_tensor);
48 _memory_manager->allocate_memory(output_tensor);
51 EXPECT_THAT(extractTensorData<bool>(output_tensor),
52 ::testing::ElementsAre(false, true, true, false));
53 EXPECT_THAT(extractTensorShape(output_tensor), ::testing::ElementsAre(1, 1, 1, 4));
56 TEST_F(LogicalNotTest, OutputTypeInvalid_NEG)
58 Tensor input_tensor = makeInputTensor<DataType::BOOL>({1, 1, 1, 4}, {true, false, false, true},
59 _memory_manager.get());
60 Tensor output_tensor = makeOutputTensor(DataType::S32);
62 LogicalNot kernel(&input_tensor, &output_tensor);
63 EXPECT_ANY_THROW(kernel.configure());
66 TEST_F(LogicalNotTest, InputTypeInvalid_NEG)
69 makeInputTensor<DataType::S32>({1, 1, 1, 4}, {1, 0, 0, 1}, _memory_manager.get());
70 Tensor output_tensor = makeOutputTensor(DataType::BOOL);
72 LogicalNot kernel(&input_tensor, &output_tensor);
73 EXPECT_ANY_THROW(kernel.configure());
77 } // namespace kernels
78 } // namespace luci_interpreter