22d00ec306a99e5c495996445e1cd31925debb69
[platform/core/ml/nnfw.git] / runtime / onert / core / src / exec / LinearExecutor.h
1 /*
2  * Copyright (c) 2019 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 /**
18  * @file  LinearExecutor.h
19  * @brief This file contains LinearExecutor class to define and run execution phase
20  */
21
22 #ifndef __ONERT_EXEC_EXECUTOR_H_
23 #define __ONERT_EXEC_EXECUTOR_H_
24
25 #include "ir/Index.h"
26 #include "ExecutorBase.h"
27 #include "compiler/Linear.h"
28 #include "exec/FunctionSequence.h"
29 #include "compiler/CodeMap.h"
30
31 namespace onert
32 {
33 namespace exec
34 {
35
36 /**
37  * @brief Class to handle execution phase. Simple run the sequence of operations that is sorted in
38  *        topological order
39  */
40 class LinearExecutor final : public ExecutorBase
41 {
42 public:
43   /**
44    * @brief Construct a new LinearExecutor object
45    * @param lowered_graph LoweredGraph object
46    * @param tensor_builders Tensor builders that are currently used
47    * @param code_map OpSequence and its code map
48    */
49   LinearExecutor(std::unique_ptr<compiler::LoweredGraph> lowered_graph,
50                  const std::vector<backend::ITensor *> &input_tensors,
51                  const std::vector<backend::ITensor *> &output_tensors,
52                  const compiler::TensorRegistries &tensor_regs, compiler::CodeMap &&code_map,
53                  const std::vector<ir::OpSequenceIndex> &order)
54       : ExecutorBase{std::move(lowered_graph), input_tensors, output_tensors, tensor_regs}
55   {
56     for (auto index : order)
57     {
58       _code.emplace_back(std::move(code_map.at(index)));
59     }
60   }
61
62 public:
63   void executeImpl(void) override;
64
65 private:
66   std::vector<compiler::CodeAndInfo> _code;
67 };
68
69 } // namespace exec
70 } // namespace onert
71
72 #endif // __ONERT_EXEC_EXECUTOR_H_