ONE - On-device Neural Engine
Loading...
Searching...
No Matches
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
42onert_micro::import::configure_kernel_CircleStridedSlice(const OMConfigureArgs &config_args)
43{
44 OMRuntimeContext &runtime_context = config_args.runtime_context;
45 uint16_t op_index = config_args.kernel_index;
46
47 execute::OMRuntimeKernel runtime_kernel;
48 OMStatus status = runtime_kernel.readKernel(op_index, runtime_context);
49 if (status != Ok)
50 return status;
51
52 const circle::Tensor *input = runtime_kernel.inputs[inputTensorIdx];
53 const circle::Tensor *begin = runtime_kernel.inputs[beginTensorIdx];
54 const circle::Tensor *end = runtime_kernel.inputs[endTensorIdx];
55 const circle::Tensor *strides = runtime_kernel.inputs[stridesTensorIdx];
56
57 const circle::Tensor *output = runtime_kernel.outputs[outputTensorIdx];
58
59 assert(input != nullptr);
60 assert(begin != nullptr);
61 assert(end != nullptr);
62 assert(strides != nullptr);
63 assert(output != nullptr);
64
65 status = utils::checkCondition(input->type() == output->type());
66 if (status != Ok)
67 return status;
68
69 status = utils::checkCondition(begin->type() == circle::TensorType_INT32 and
70 end->type() == circle::TensorType_INT32 and
71 strides->type() == circle::TensorType_INT32);
72 if (status != Ok)
73 return status;
74
75 return status;
76}
OMStatus readKernel(uint16_t op_index, core::OMRuntimeContext &runtime_context)
const circle::Tensor * outputs[maxOutputSize]
const circle::Tensor * inputs[maxInputSize]
constexpr uint32_t outputTensorIdx
ShapeIterator end(const Shape &s)
int32_t begin[5]
Definition Slice.cpp:33