ONE - On-device Neural Engine
Loading...
Searching...
No Matches
LogicalNot.cpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 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#include "Builders.h"
17#include "kernels/Utils.h"
18#include "SISOKernel.h"
19
20#include "PALLogicalNot.h"
21
22namespace luci_interpreter
23{
24void configure_kernel_CircleLogicalNot(const circle::Operator *cur_op,
25 BaseRuntimeGraph *runtime_graph)
26{
27 kernels::SISOKernel kernel(cur_op, runtime_graph);
28
29 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input()) == DataType::BOOL);
30 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.output()) == DataType::BOOL);
31
32 // check that input and output dimensions are equal
33 int N = Tensor::num_dims(kernel.input());
34 LUCI_INTERPRETER_CHECK(N == Tensor::num_dims(kernel.output()));
35
36 // check that sizes of all dimensions are equal
37 for (int i = 0; i < N; ++i)
38 {
40 kernels::getTensorShape(kernel.output()).dims(i));
41 }
42}
43
44void execute_kernel_CircleLogicalNot(const circle::Operator *cur_op,
45 BaseRuntimeGraph *runtime_graph)
46{
47 kernels::SISOKernel kernel(cur_op, runtime_graph);
48
49 auto data = kernels::getTensorData<bool>(runtime_graph->getDataByTensor(kernel.input()));
50 if (data == nullptr)
51 data = kernels::getTensorData<bool>(runtime_graph->getConstDataByTensor(kernel.input()));
52
53 assert(data != nullptr);
54
55 auto output_data = kernels::getTensorData<bool>(runtime_graph->getDataByTensor(kernel.output()));
56
57 const int64_t flat_size = kernels::getTensorShape(kernel.input()).flatSize();
58 luci_interpreter_pal::LogicalNot(flat_size, data, output_data);
59}
60
61} // namespace luci_interpreter
uint8_t * getConstDataByTensor(const circle::Tensor *raw_tensor)
uint8_t * getDataByTensor(const circle::Tensor *raw_tensor)
const circle::Tensor * output() const
Definition SISOKernel.h:47
const circle::Tensor * input() const
Definition SISOKernel.h:46
#define LUCI_INTERPRETER_CHECK(cond)
Definition Utils.h:36
const T * data(const std::vector< T, Alloc > &v)
tflite::RuntimeShape getTensorShape(const Tensor *tensor)
Definition Utils.h:194
void LogicalNot(const int flat_size, const bool *input_data, bool *output_data)
void configure_kernel_CircleLogicalNot(const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
void execute_kernel_CircleLogicalNot(const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)