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"
20 #include "kernels/BinaryOpCommon.h"
24 namespace luci_interpreter
27 // TODO: reduce code duplication with Mul
28 void configure_kernel_CircleDiv(const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
30 kernels::TISOKernel kernel(cur_op, runtime_graph);
32 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
33 Tensor::element_type(kernel.input2()));
34 LUCI_INTERPRETER_CHECK(Tensor::element_type(kernel.input1()) ==
35 Tensor::element_type(kernel.input2()));
38 void execute_kernel_CircleDiv(const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
40 kernels::TISOKernel kernel(cur_op, runtime_graph);
42 const auto *options = cur_op->builtin_options_as_DivOptions();
44 luci_interpreter::RuntimeShape input_shape1 =
45 kernels::getTensorRuntimeShape(kernel.input1(), runtime_graph);
46 luci_interpreter::RuntimeShape input_shape2 =
47 kernels::getTensorRuntimeShape(kernel.input2(), runtime_graph);
49 bool is_inplace = runtime_graph->is_inplace_op(cur_op);
51 switch (Tensor::element_type(kernel.input1()))
54 case DataType::FLOAT32:
56 auto tiso_func = luci_interpreter_pal::Div<float>;
57 auto broadcast_tiso_func = luci_interpreter_pal::BroadcastDiv4DSlow<float>;
60 kernels::evalTISOInplaceKernel<float>(tiso_func, broadcast_tiso_func, &kernel, options,
61 std::move(input_shape1), std::move(input_shape2));
65 kernels::TISOData kernel_data = kernel.readData();
66 kernels::evalTISOKernel<float>(tiso_func, broadcast_tiso_func, &kernel, &kernel_data,
67 options, std::move(input_shape1), std::move(input_shape2));
73 assert(false && "Unsupported type.");
77 } // namespace luci_interpreter