2 * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
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.
18 #include "kernels/Utils.h"
19 #include "TISOKernel.h"
21 #include "PALComparisons.h"
23 namespace luci_interpreter
28 // TODO: reduce code duplication with less
30 void evalGeneric(const circle::Tensor *x, const circle::Tensor *y, const circle::Tensor *output,
31 BaseRuntimeGraph *runtime_graph)
33 auto x_data = kernels::getTensorData<T>(runtime_graph->getDataByTensor(x));
34 if (x_data == nullptr)
35 x_data = kernels::getTensorData<T>(runtime_graph->getConstDataByTensor(x));
37 assert(x_data != nullptr);
39 auto y_data = kernels::getTensorData<T>(runtime_graph->getDataByTensor(y));
40 if (y_data == nullptr)
41 y_data = kernels::getTensorData<T>(runtime_graph->getConstDataByTensor(y));
43 assert(y_data != nullptr);
45 auto output_data = kernels::getTensorData<bool>(runtime_graph->getDataByTensor(output));
47 luci_interpreter_pal::ComparisonParams op_params;
48 op_params.is_broadcast = Tensor::num_elements(x) != Tensor::num_elements(y);
50 const int64_t flat_size = kernels::getTensorShape(x).flatSize();
51 luci_interpreter_pal::ComparisonNoScaling<T>(flat_size, x_data, y_data, output_data,
52 luci_interpreter_pal::GreaterFn);
57 void configure_kernel_CircleGreater(const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
59 kernels::TISOKernel kernel(cur_op, runtime_graph);
61 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
62 Tensor::element_type(kernel.input2()));
63 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.output()) == DataType::BOOL);
66 void execute_kernel_CircleGreater(const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
68 kernels::TISOKernel kernel(cur_op, runtime_graph);
70 switch (Tensor::element_type(kernel.input1()))
73 evalGeneric<int64_t>(kernel.input1(), kernel.input2(), kernel.output(), runtime_graph);
76 evalGeneric<int32_t>(kernel.input1(), kernel.input2(), kernel.output(), runtime_graph);
79 case DataType::FLOAT32:
80 evalGeneric<float>(kernel.input1(), kernel.input2(), kernel.output(), runtime_graph);
84 assert(false && "Unsupported type.");
88 } // namespace luci_interpreter