89af664f8195b66cdb98c688fe41382bfa310d3a
[platform/core/ml/nnfw.git] / runtime / onert / core / src / compiler / MultiModelCompiler.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 /**
18  * @file  MultiModelCompiler.h
19  * @brief This file contains MultiModelCompiler class to define and run compilation phase
20  */
21
22 #ifndef __ONERT_COMPILER_MULTI_MODEL_COMPILER_H__
23 #define __ONERT_COMPILER_MULTI_MODEL_COMPILER_H__
24
25 #include "compiler/CompilerOptions.h"
26 #include "compiler/ICompiler.h"
27 #include "ir/NNPkg.h"
28
29 namespace onert
30 {
31 namespace compiler
32 {
33
34 /**
35  * @brief Class to compile NN package
36  */
37 class MultiModelCompiler final : public ICompiler
38 {
39 public:
40   /**
41    * @brief     Construct a new Compiler object for NN package
42    * @param[in] nnpkg    NN package to compile
43    * @param[in] coptions Compiler option vector for each model in package
44    */
45   MultiModelCompiler(const std::shared_ptr<ir::NNPkg> &nnpkg,
46                      std::vector<std::unique_ptr<CompilerOptions>> &copts);
47
48   /**
49    * @brief Destroy the MultiModelCompiler object
50    */
51   ~MultiModelCompiler() = default;
52
53 public:
54   /**
55    * @brief   Do compilation with the options
56    *
57    * @return std::shared_ptr<CompilerArtifact> Executors as a result of compilation
58    */
59   std::shared_ptr<CompilerArtifact> compile(void);
60
61 private:
62   std::shared_ptr<ir::Graph> &primary_subgraph()
63   {
64     return _nnpkg->primary_model()->at(ir::SubgraphIndex{0});
65   }
66
67 private:
68   std::shared_ptr<ir::NNPkg> _nnpkg;
69   std::vector<CompilerOptions *> _voptions;
70 };
71
72 } // namespace compiler
73 } // namespace onert
74
75 #endif // __ONERT_COMPILER_MULTI_MODEL_COMPILER_H__