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
38OMStatus onert_micro::import::configure_kernel_CircleTranspose(const OMConfigureArgs &config_args)
39{
40 OMRuntimeContext &runtime_context = config_args.runtime_context;
41 uint16_t op_index = config_args.kernel_index;
42
43 execute::OMRuntimeKernel runtime_kernel;
44 runtime_kernel.readKernel(op_index, runtime_context);
45
46 const circle::Tensor *input = runtime_kernel.inputs[kInputTensorIdx];
47 const circle::Tensor *perm = runtime_kernel.inputs[kPermTensorIdx];
48 const circle::Tensor *output = runtime_kernel.outputs[kOutputTensorIdx];
49
50 assert(input != nullptr);
51 assert(perm != nullptr);
52 assert(output != nullptr);
53
54 OMStatus status = Ok;
55
56 status = utils::checkCondition(perm->type() == circle::TensorType_INT32);
57 if (status != Ok)
58 return status;
59
60 core::OMRuntimeShape input_shape(input);
61 core::OMRuntimeShape perm_shape(perm);
62
63 status = utils::checkCondition(perm_shape.dimensionsCount() == 1);
64 if (status != Ok)
65 return status;
66
67 status = utils::checkCondition(perm_shape.dims(0) == input_shape.dimensionsCount());
68 if (status != Ok)
69 return status;
70
71 return status;
72}
OMStatus readKernel(uint16_t op_index, core::OMRuntimeContext &runtime_context)
const circle::Tensor * outputs[maxOutputSize]
const circle::Tensor * inputs[maxInputSize]