ONE - On-device Neural Engine
Loading...
Searching...
No Matches
SplitV.cpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 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
17#include "OMStatus.h"
18
19#include "core/OMUtils.h"
20#include "core/OMKernelData.h"
21
23#include "execute/OMUtils.h"
25
26#include "PALSplit.h"
27
28using namespace onert_micro;
29using namespace onert_micro::core;
30using namespace onert_micro::execute;
31
32namespace
33{
34
35constexpr uint32_t inputTensorIdx = 0;
36constexpr uint32_t axisTensorIdx = 2;
37constexpr uint32_t outputTensorIdx = 0;
38
39} // namespace
40
41namespace onert_micro
42{
43namespace execute
44{
45
47{
48 core::OMRuntimeContext &runtime_context = execute_args.runtime_context;
49 core::OMRuntimeStorage &runtime_storage = execute_args.runtime_storage;
50 uint16_t op_index = execute_args.kernel_index;
51
52 const circle::Tensor *input;
53 const circle::Tensor *axis;
54 const circle::Tensor *output;
55
56 uint8_t *input_data;
57 uint8_t *axis_data;
58
59 // Read kernel
60 core::SplitParams params{};
61 {
62 execute::OMRuntimeKernel runtime_kernel;
63 OMStatus status = runtime_kernel.readKernel(op_index, runtime_context);
64 if (status != Ok)
65 return status;
66
67 input = runtime_kernel.inputs[inputTensorIdx];
68 axis = runtime_kernel.inputs[axisTensorIdx];
69 output = runtime_kernel.outputs[outputTensorIdx];
70 assert(input != nullptr);
71 assert(axis != nullptr);
72 assert(output != nullptr);
73
74 status = runtime_kernel.getDataFromStorage(op_index, runtime_storage, runtime_context);
75 if (status != Ok)
76 return status;
77
78 input_data = runtime_kernel.inputs_data[inputTensorIdx];
79 axis_data = runtime_kernel.inputs_data[axisTensorIdx];
80 assert(input_data != nullptr);
81 assert(axis_data != nullptr);
82
83 params.num_outputs = runtime_kernel.outputs_num;
84
85 for (uint32_t i = 0; i < params.num_outputs; ++i)
86 {
87 params.output_data[i] = runtime_kernel.outputs_data[i];
88 }
89 }
90 OMStatus status;
91 OMRuntimeShape axis_shape(axis);
92 OMRuntimeShape input_shape(input);
94
95 int32_t axis_value = axis_data[0];
96 if (axis_value < 0)
97 {
98 axis_value += input_shape.dimensionsCount() + 1;
99 }
100
101 switch (input->type())
102 {
103#ifndef DIS_FLOAT
104 case circle::TensorType_FLOAT32:
105 status = pal::Split<float>(params, input_shape, core::utils::castInputData<float>(input_data),
106 output_shape, axis_value);
107 break;
108#endif // DIS_FLOAT
109 default:
110 {
111 status = UnsupportedActivation;
112 assert(false && "Unsupported type.");
113 }
114 }
115
116 return status;
117}
118
119} // namespace execute
120} // namespace onert_micro
size_t dimensionsCount() const noexcept
uint8_t * outputs_data[maxOutputSize]
OMStatus getDataFromStorage(uint16_t op_index, core::OMRuntimeStorage &storage, core::OMRuntimeContext &context)
OMStatus readKernel(uint16_t op_index, core::OMRuntimeContext &runtime_context)
const circle::Tensor * outputs[maxOutputSize]
const circle::Tensor * inputs[maxInputSize]
const luci_interpreter::RuntimeShape output_shape
constexpr uint32_t outputTensorIdx
OMStatus execute_kernel_CircleSplitV(const OMExecuteArgs &execute_args)
Definition SplitV.cpp:46
@ UnsupportedActivation
Definition OMStatus.h:28
core::OMRuntimeContext & runtime_context
core::OMRuntimeStorage & runtime_storage