Imported Upstream version 1.12.0
[platform/core/ml/nnfw.git] / runtime / onert / core / src / backend / controlflow / kernel / WhileLayer.h
1 /*
2  * Copyright (c) 2020 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 __ONERT_BACKEND_CONTROLFLOW_KERNEL_WHILE_LAYER_H__
18 #define __ONERT_BACKEND_CONTROLFLOW_KERNEL_WHILE_LAYER_H__
19
20 #include <backend/IPortableTensor.h>
21 #include <exec/IExecutor.h>
22 #include <exec/IFunction.h>
23 #include <ir/OperandIndexSequence.h>
24 #include <ir/Graph.h>
25 #include "../ExternalContext.h"
26
27 #include "backend/cpu_common/MemoryManager.h"
28
29 namespace onert
30 {
31 namespace backend
32 {
33 namespace controlflow
34 {
35 namespace kernel
36 {
37
38 class WhileLayer : public ::onert::exec::IFunction
39 {
40 public:
41   WhileLayer(const std::vector<backend::IPortableTensor *> input_tensors,
42              const std::vector<backend::IPortableTensor *> output_tensors,
43              const ir::SubgraphIndex &cond_subg_index, const ir::SubgraphIndex &body_subg_index,
44              exec::ExecutorMap *executor_map, cpu_common::DynamicMemoryManager *dyn_memory_manager,
45              const std::shared_ptr<ExternalContext> &external_context);
46
47 public:
48   void run() override;
49
50 private:
51   const ir::SubgraphIndex _cond_subg_index;
52   const ir::SubgraphIndex _body_subg_index;
53   const std::vector<backend::IPortableTensor *> _input_tensors;
54   const std::vector<backend::IPortableTensor *> _output_tensors;
55   exec::ExecutorMap *_executor_map;
56   cpu_common::DynamicMemoryManager *_dyn_memory_manager; // For generating temp tensors
57   const std::shared_ptr<ExternalContext> _external_context;
58 };
59
60 } // namespace kernel
61 } // namespace controlflow
62 } // namespace backend
63 } // namespace onert
64
65 #endif // __ONERT_BACKEND_CONTROLFLOW_KERNEL_WHILE_LAYER_H__