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.
21 namespace luci_interpreter
24 void configure_kernel_CircleSplit(const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
26 const auto input_index = cur_op->inputs()->operator[](0);
27 const auto axis_index = cur_op->inputs()->operator[](1);
29 LUCI_INTERPRETER_CHECK(input_index != -1);
30 LUCI_INTERPRETER_CHECK(axis_index != -1);
32 const auto input = runtime_graph->getCircleTensorByIndex(input_index);
33 const auto axis = runtime_graph->getCircleTensorByIndex(axis_index);
35 LUCI_INTERPRETER_CHECK(input != nullptr);
36 LUCI_INTERPRETER_CHECK(axis != nullptr);
39 void execute_kernel_CircleSplit(const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
41 const auto input_index = cur_op->inputs()->operator[](1);
42 const auto axis_index = cur_op->inputs()->operator[](0);
44 assert(input_index != -1);
45 assert(axis_index != -1);
47 const auto input = runtime_graph->getCircleTensorByIndex(input_index);
48 const auto axis = runtime_graph->getCircleTensorByIndex(axis_index);
50 assert(input != nullptr);
51 assert(axis != nullptr);
53 const auto *axis_data = runtime_graph->getDataByTensor(axis);
54 if (axis_data == nullptr)
55 axis_data = runtime_graph->getConstDataByTensor(axis);
59 int32_t axis_value = (kernels::getTensorData<int32_t>(axis_data))[0];
61 axis_value += Tensor::num_dims(input);
63 assert(axis_value >= 0);
64 assert(axis_value < Tensor::num_dims(input));
66 switch (Tensor::element_type(input))
69 case DataType::FLOAT32:
71 return splitImpl<float>(cur_op, input, axis_value, runtime_graph);
77 return splitImpl<int8_t>(cur_op, input, axis_value, runtime_graph);
81 return splitImpl<int16_t>(cur_op, input, axis_value, runtime_graph);
86 return splitImpl<int32_t>(cur_op, input, axis_value, runtime_graph);
89 assert(false && "Unsupported type");
93 } // namespace luci_interpreter