ONE - On-device Neural Engine
Loading...
Searching...
No Matches
LogicalNot.cpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
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 "kernels/LogicalNot.h"
18
19#include "kernels/Utils.h"
20
21#include "kernels/BinaryOpCommon.h"
22
23namespace luci_interpreter
24{
25namespace kernels
26{
27
28LogicalNot::LogicalNot(const Tensor *input, Tensor *output) : Kernel({input}, {output}) {}
29
31{
32 LUCI_INTERPRETER_CHECK(input()->element_type() == output()->element_type());
33 output()->resize(input()->shape());
34}
35
37{
38 switch (input()->element_type())
39 {
40 case DataType::BOOL:
41 evalLogicalNot();
42 break;
43 default:
44 throw std::runtime_error("luci-intp LogicalNot Unsupported type.");
45 }
46}
47
48inline void LogicalNot::evalLogicalNot() const
49{
50 const int size = tflite::MatchingFlatSize(getTensorShape(input()), getTensorShape(output()));
51 bool *output_data = getTensorData<bool>(output());
52 const bool *input_data = getTensorData<bool>(input());
53 for (int i = 0; i < size; ++i)
54 {
55 output_data[i] = !input_data[i];
56 }
57}
58
59} // namespace kernels
60} // namespace luci_interpreter
void resize(const Shape &new_shape)
Definition Tensor.cpp:56
LogicalNot(const Tensor *input, Tensor *output)
#define LUCI_INTERPRETER_CHECK(cond)
Definition Utils.h:36
tflite::RuntimeShape getTensorShape(const Tensor *tensor)
Definition Utils.h:194
int32_t size[5]
Definition Slice.cpp:35