ONE - On-device Neural Engine
Loading...
Searching...
No Matches
TransposeConv.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{
32
33// For the TfLite transpose_conv implementation, input tensor 0 corresponds to
34// the OutputShapeTensor. However, since TFLM does not support dynamic tensors,
35// the TFLM implementation ignores input tensor 0 and the only inputs we care
36// about are kFilterTensor, kInputTensor and kBiasTensor.
37
38constexpr int kWeightTensorIdx = 1;
39constexpr int kInputTensorIdx = 2;
40constexpr int kBiasTensorIdx = 3;
41constexpr int kOutputTensorIdx = 0;
42
43} // namespace
44
45namespace onert_micro
46{
47namespace import
48{
49
51{
52 OMRuntimeContext &runtime_context = config_args.runtime_context;
53 uint16_t op_index = config_args.kernel_index;
54
55 execute::OMRuntimeKernel runtime_kernel;
56 runtime_kernel.readKernel(op_index, runtime_context);
57
58 const circle::Tensor *input = runtime_kernel.inputs[kInputTensorIdx];
59 const circle::Tensor *weight = runtime_kernel.inputs[kWeightTensorIdx];
60 const circle::Tensor *output = runtime_kernel.outputs[kOutputTensorIdx];
61
62 assert(input != nullptr);
63 assert(weight != nullptr);
64 // Bias can be nullptr
65 assert(output != nullptr);
66
67 OMStatus status = Ok;
68
69 status = utils::checkCondition(input->type() == output->type());
70 if (status != Ok)
71 return status;
72
73 status = utils::checkCondition(input->type() == weight->type());
74 if (status != Ok)
75 return status;
76
77 core::OMRuntimeShape input_shape(input);
78 core::OMRuntimeShape weight_shape(weight);
79
80 status = utils::checkCondition(input_shape.dimensionsCount() == 4);
81 if (status != Ok)
82 return status;
83
84 status = utils::checkCondition(input_shape.dimensionsCount() == weight_shape.dimensionsCount());
85 if (status != Ok)
86 return status;
87
88 return status;
89}
90
91} // namespace import
92} // namespace onert_micro
OMStatus readKernel(uint16_t op_index, core::OMRuntimeContext &runtime_context)
const circle::Tensor * outputs[maxOutputSize]
const circle::Tensor * inputs[maxInputSize]
OMStatus configure_kernel_CircleTransposeConv(const OMConfigureArgs &config_args)
core::OMRuntimeContext & runtime_context