2 * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
3 * Copyright 2019 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/Utils.h"
19 #include "TISOKernel.h"
21 #include "PALLogicalCommon.h"
23 namespace luci_interpreter
28 bool LogicalOr(bool x, bool y) { return x || y; }
31 void configure_kernel_CircleLogicalOr(const circle::Operator *cur_op,
32 BaseRuntimeGraph *runtime_graph)
34 kernels::TISOKernel kernel(cur_op, runtime_graph);
36 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
37 Tensor::element_type(kernel.input2()));
38 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) == DataType::BOOL);
39 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.output()) == DataType::BOOL);
41 // TODO support broadcast
42 LUCI_INTERPRETER_CHECK(Tensor::num_elements(kernel.input1()) ==
43 Tensor::num_elements(kernel.input2()));
44 LUCI_INTERPRETER_CHECK(Tensor::num_dims(kernel.input1()) == Tensor::num_dims(kernel.input2()));
48 // TODO: reduce code duplication with LogicalAnd
49 void execute_kernel_CircleLogicalOr(const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
51 kernels::TISOKernel kernel(cur_op, runtime_graph);
53 auto x_data = kernels::getTensorData<bool>(runtime_graph->getDataByTensor(kernel.input1()));
54 if (x_data == nullptr)
55 x_data = kernels::getTensorData<bool>(runtime_graph->getConstDataByTensor(kernel.input1()));
57 assert(x_data != nullptr);
59 auto y_data = kernels::getTensorData<bool>(runtime_graph->getDataByTensor(kernel.input2()));
60 if (y_data == nullptr)
61 y_data = kernels::getTensorData<bool>(runtime_graph->getConstDataByTensor(kernel.input2()));
63 assert(y_data != nullptr);
65 auto output_data = kernels::getTensorData<bool>(runtime_graph->getDataByTensor(kernel.output()));
67 const int64_t flat_size = kernels::getTensorShape(kernel.input1()).flatSize();
68 luci_interpreter_pal::LogicalCommon(flat_size, x_data, y_data, output_data, LogicalOr);
71 } // namespace luci_interpreter