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
41namespace onert_micro
42{
43namespace import
44{
45
47{
48 OMRuntimeContext &runtime_context = config_args.runtime_context;
49 uint16_t op_index = config_args.kernel_index;
50
51 execute::OMRuntimeKernel runtime_kernel;
52 OMStatus status = runtime_kernel.readKernel(op_index, runtime_context);
53 if (status != Ok)
54 return status;
55
56 const circle::Tensor *input1 = runtime_kernel.inputs[input1TensorIdx];
57 const circle::Tensor *input2 = runtime_kernel.inputs[input2TensorIdx];
58 const circle::Tensor *input3 = runtime_kernel.inputs[input3TensorIdx];
59
60 const circle::Tensor *output = runtime_kernel.outputs[outputTensorIdx];
61
62 assert(input1 != nullptr);
63 assert(input2 != nullptr);
64 assert(input3 != nullptr);
65 assert(output != nullptr);
66
67 status = utils::checkCondition(input1->type() == output->type());
68 if (status != Ok)
69 return status;
70
71 status = utils::checkCondition(input2->type() == circle::TensorType_INT32 and
72 input3->type() == circle::TensorType_INT32);
73 if (status != Ok)
74 return status;
75
76 status = utils::checkCondition(OMRuntimeShape(input2).dimensionsCount() == 1 and
77 OMRuntimeShape(input3).dimensionsCount() == 1);
78 if (status != Ok)
79 return status;
80
81 status = utils::checkCondition(OMRuntimeShape(input1).dimensionsCount() <= MAX_DIM);
82 if (status != Ok)
83 return status;
84
85 return status;
86}
87
88} // namespace import
89} // namespace onert_micro
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
OMStatus configure_kernel_CircleSlice(const OMConfigureArgs &config_args)
Definition Slice.cpp:46
core::OMRuntimeContext & runtime_context