Imported Upstream version 1.25.0
[platform/core/ml/nnfw.git] / onert-micro / luci-interpreter / src / kernels / SISOKernel.h
1 /*
2  * Copyright (c) 2023 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 #ifndef LUCI_INTERPRETER_KERNELS_SISO_KERNEL_H
18 #define LUCI_INTERPRETER_KERNELS_SISO_KERNEL_H
19
20 #include "Builders.h"
21
22 namespace luci_interpreter
23 {
24 namespace kernels
25 {
26
27 // Single input single output kernel
28 class SISOKernel
29 {
30 public:
31   SISOKernel(const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
32   {
33     const auto input_index = cur_op->inputs()->operator[](0);
34     const auto output_index = cur_op->outputs()->operator[](0);
35
36     assert(input_index != -1);
37     assert(output_index != -1);
38
39     _input_tensor = runtime_graph->getCircleTensorByIndex(input_index);
40     _output_tensor = runtime_graph->getCircleTensorByIndex(output_index);
41
42     assert(_input_tensor != nullptr);
43     assert(_output_tensor != nullptr);
44   }
45
46   const circle::Tensor *input() const { return _input_tensor; }
47   const circle::Tensor *output() const { return _output_tensor; }
48
49 private:
50   const circle::Tensor *_input_tensor;
51   const circle::Tensor *_output_tensor;
52 };
53
54 } // namespace kernels
55 } // namespace luci_interpreter
56
57 #endif // LUCI_INTERPRETER_KERNELS_SISO_KERNEL_H