ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
StridedSlice.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
25
26using namespace onert_micro;
27using namespace onert_micro::core;
28
29namespace
30{
31
32constexpr uint32_t inputTensorIdx = 0;
33constexpr uint32_t beginTensorIdx = 1;
34constexpr uint32_t endTensorIdx = 2;
35constexpr uint32_t stridesTensorIdx = 3;
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 *input = runtime_kernel.inputs[inputTensorIdx];
57 const circle::Tensor *begin = runtime_kernel.inputs[beginTensorIdx];
58 const circle::Tensor *end = runtime_kernel.inputs[endTensorIdx];
59 const circle::Tensor *strides = runtime_kernel.inputs[stridesTensorIdx];
60
61 const circle::Tensor *output = runtime_kernel.outputs[outputTensorIdx];
62
63 assert(input != nullptr);
64 assert(begin != nullptr);
65 assert(end != nullptr);
66 assert(strides != nullptr);
67 assert(output != nullptr);
68
69 status = utils::checkCondition(input->type() == output->type());
70 if (status != Ok)
71 return status;
72
73 status = utils::checkCondition(begin->type() == circle::TensorType_INT32 and
74 end->type() == circle::TensorType_INT32 and
75 strides->type() == circle::TensorType_INT32);
76 if (status != Ok)
77 return status;
78
79 return status;
80}
81
82} // namespace import
83} // 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 outputTensorIdx
OMStatus configure_kernel_CircleStridedSlice(const OMConfigureArgs &config_args)
int32_t begin[5]
Definition Slice.cpp:33
core::OMRuntimeContext & runtime_context