Imported Upstream version 1.9.0
[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<std::shared_ptr<backend::ITensor>> &input_tensors,
51                  const std::vector<std::shared_ptr<backend::ITensor>> &output_tensors,
52                  const compiler::TensorRegistries &tensor_regs,
53                  backend::TensorManagerSet &&tensor_mgrs, compiler::CodeMap &&code_map,
54                  const std::vector<ir::OpSequenceIndex> &order)
55       : ExecutorBase{std::move(lowered_graph), input_tensors, output_tensors, tensor_regs,
56                      std::move(tensor_mgrs)}
57   {
58     for (auto index : order)
59     {
60       _code.emplace_back(std::move(code_map.at(index)));
61     }
62   }
63
64 public:
65   void executeImpl(void) override;
66
67 private:
68   std::vector<compiler::CodeAndInfo> _code;
69 };
70
71 } // namespace exec
72 } // namespace onert
73
74 #endif // __ONERT_EXEC_EXECUTOR_H_