ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Slice.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
24
25using namespace onert_micro;
26using namespace onert_micro::core;
27
28namespace
29{
30
31const int MAX_DIM = 5;
32
33constexpr uint32_t input1TensorIdx = 0;
34constexpr uint32_t input2TensorIdx = 1;
35constexpr uint32_t input3TensorIdx = 2;
36
37constexpr uint32_t outputTensorIdx = 0;
38
39} // namespace
40
41OMStatus onert_micro::import::configure_kernel_CircleSlice(const OMConfigureArgs &config_args)
42{
43 OMRuntimeContext &runtime_context = config_args.runtime_context;
44 uint16_t op_index = config_args.kernel_index;
45
46 execute::OMRuntimeKernel runtime_kernel;
47 OMStatus status = runtime_kernel.readKernel(op_index, runtime_context);
48 if (status != Ok)
49 return status;
50
51 const circle::Tensor *input1 = runtime_kernel.inputs[input1TensorIdx];
52 const circle::Tensor *input2 = runtime_kernel.inputs[input2TensorIdx];
53 const circle::Tensor *input3 = runtime_kernel.inputs[input3TensorIdx];
54
55 const circle::Tensor *output = runtime_kernel.outputs[outputTensorIdx];
56
57 assert(input1 != nullptr);
58 assert(input2 != nullptr);
59 assert(input3 != nullptr);
60 assert(output != nullptr);
61
62 status = utils::checkCondition(input1->type() == output->type());
63 if (status != Ok)
64 return status;
65
66 status = utils::checkCondition(input2->type() == circle::TensorType_INT32 and
67 input3->type() == circle::TensorType_INT32);
68 if (status != Ok)
69 return status;
70
71 status = utils::checkCondition(OMRuntimeShape(input2).dimensionsCount() == 1 and
72 OMRuntimeShape(input3).dimensionsCount() == 1);
73 if (status != Ok)
74 return status;
75
76 status = utils::checkCondition(OMRuntimeShape(input1).dimensionsCount() <= MAX_DIM);
77 if (status != Ok)
78 return status;
79
80 return status;
81}
OMStatus readKernel(uint16_t op_index, core::OMRuntimeContext &runtime_context)
const circle::Tensor * outputs[maxOutputSize]
const circle::Tensor * inputs[maxInputSize]
constexpr uint32_t input1TensorIdx
constexpr uint32_t outputTensorIdx
constexpr uint32_t input2TensorIdx