ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Transpose.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#include "execute/OMUtils.h"
26
27using namespace onert_micro;
28using namespace onert_micro::core;
29
30namespace
31{
32constexpr int kInputTensorIdx = 0;
33constexpr int kPermTensorIdx = 1;
34constexpr int kOutputTensorIdx = 0;
35
36} // namespace
37
38namespace onert_micro
39{
40namespace import
41{
42
44{
45 OMRuntimeContext &runtime_context = config_args.runtime_context;
46 uint16_t op_index = config_args.kernel_index;
47
48 execute::OMRuntimeKernel runtime_kernel;
49 runtime_kernel.readKernel(op_index, runtime_context);
50
51 const circle::Tensor *input = runtime_kernel.inputs[kInputTensorIdx];
52 const circle::Tensor *perm = runtime_kernel.inputs[kPermTensorIdx];
53 const circle::Tensor *output = runtime_kernel.outputs[kOutputTensorIdx];
54
55 assert(input != nullptr);
56 assert(perm != nullptr);
57 assert(output != nullptr);
58
59 OMStatus status = Ok;
60
61 status = utils::checkCondition(perm->type() == circle::TensorType_INT32);
62 if (status != Ok)
63 return status;
64
65 core::OMRuntimeShape input_shape(input);
66 core::OMRuntimeShape perm_shape(perm);
67
68 status = utils::checkCondition(perm_shape.dimensionsCount() == 1);
69 if (status != Ok)
70 return status;
71
72 status = utils::checkCondition(perm_shape.dims(0) == input_shape.dimensionsCount());
73 if (status != Ok)
74 return status;
75
76 return status;
77}
78
79} // namespace import
80} // namespace onert_micro
size_t dimensionsCount() const noexcept
OMStatus readKernel(uint16_t op_index, core::OMRuntimeContext &runtime_context)
const circle::Tensor * outputs[maxOutputSize]
const circle::Tensor * inputs[maxInputSize]
OMStatus configure_kernel_CircleTranspose(const OMConfigureArgs &config_args)
Definition Transpose.cpp:43
core::OMRuntimeContext & runtime_context