9e944bccc0aae1eaaaa91bd71bcae6bcc8e37674
[platform/core/ml/nnfw.git] / runtime / onert / core / src / backend / controlflow / kernel / IfLayer.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_IF_LAYER_H__
18 #define __ONERT_BACKEND_CONTROLFLOW_KERNEL_IF_LAYER_H__
19
20 #include <backend/ITensor.h>
21 #include <exec/IExecutor.h>
22 #include "../ExternalContext.h"
23
24 namespace onert
25 {
26 namespace backend
27 {
28 namespace controlflow
29 {
30 namespace kernel
31 {
32
33 class IfLayer : public ::onert::exec::IFunction
34 {
35 public:
36   IfLayer(backend::ITensor *cond_tensor, const std::vector<backend::ITensor *> input_tensors,
37           const std::vector<backend::ITensor *> output_tensors,
38           const ir::OperandIndexSequence &output_indices, const ir::Graph &graph,
39           const ir::SubgraphIndex &then_subg_index, const ir::SubgraphIndex &else_subg_index,
40           exec::ExecutorMap *executor_map,
41           const std::shared_ptr<ExternalContext> &external_context);
42
43 public:
44   void run() override;
45
46 private:
47   backend::ITensor *_cond_tensor;
48   const std::vector<backend::ITensor *> _input_tensors;
49   const std::vector<backend::ITensor *> _output_tensors;
50   const ir::OperandIndexSequence &_output_indices;
51   const ir::Graph &_graph;
52   const ir::SubgraphIndex _then_subg_index;
53   const ir::SubgraphIndex _else_subg_index;
54   exec::ExecutorMap *_executor_map;
55   const std::shared_ptr<ExternalContext> _external_context;
56 };
57
58 } // namespace kernel
59 } // namespace controlflow
60 } // namespace backend
61 } // namespace onert
62
63 #endif // __ONERT_BACKEND_CONTROLFLOW_KERNEL_IF_LAYER_H__