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
46onert_micro::import::configure_kernel_CircleTransposeConv(const OMConfigureArgs &config_args)
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 runtime_kernel.readKernel(op_index, runtime_context);
53
54 const circle::Tensor *input = runtime_kernel.inputs[kInputTensorIdx];
55 const circle::Tensor *weight = runtime_kernel.inputs[kWeightTensorIdx];
56 const circle::Tensor *output = runtime_kernel.outputs[kOutputTensorIdx];
57
58 assert(input != nullptr);
59 assert(weight != nullptr);
60 // Bias can be nullptr
61 assert(output != nullptr);
62
63 OMStatus status = Ok;
64
65 status = utils::checkCondition(input->type() == output->type());
66 if (status != Ok)
67 return status;
68
69 status = utils::checkCondition(input->type() == weight->type());
70 if (status != Ok)
71 return status;
72
73 core::OMRuntimeShape input_shape(input);
74 core::OMRuntimeShape weight_shape(weight);
75
76 status = utils::checkCondition(input_shape.dimensionsCount() == 4);
77 if (status != Ok)
78 return status;
79
80 status = utils::checkCondition(input_shape.dimensionsCount() == weight_shape.dimensionsCount());
81 if (status != Ok)
82 return status;
83
84 return status;
85}
OMStatus readKernel(uint16_t op_index, core::OMRuntimeContext &runtime_context)
const circle::Tensor * outputs[maxOutputSize]
const circle::Tensor * inputs[maxInputSize]