Imported Upstream version 1.25.0
[platform/core/ml/nnfw.git] / runtime / onert / core / src / compiler / train / TrainingCompiler.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  TrainingCompiler.h
19  * @brief This file contains TrainingCompiler class to define and run compilation phase
20  */
21
22 #ifndef __ONERT_COMPILER_TRAIN_TRAINING_COMPILER_H_
23 #define __ONERT_COMPILER_TRAIN_TRAINING_COMPILER_H_
24
25 #include "compiler/CompilerOptions.h"
26 #include "compiler/ICompiler.h"
27 #include "compiler/train/TrainingInfo.h"
28 #include "ir/NNPkg.h"
29
30 namespace onert
31 {
32 namespace compiler
33 {
34 namespace train
35 {
36
37 /**
38  * @brief Class to compile NN package
39  */
40 class TrainingCompiler : public ICompiler
41 {
42 public:
43   /**
44    * @brief     Construct a new TrainingCompiler object for single model
45    * @param[in] model     model to compile
46    * @param[in] inference_compiler Compiler for inference
47    * @param[in] coptions           Compiler Options
48    * @param[in] training_info      Training information
49    */
50   explicit TrainingCompiler(const std::shared_ptr<ir::NNPkg> &nnpkg,
51                             std::vector<std::unique_ptr<CompilerOptions>> &copts,
52                             const TrainingInfo &training_info);
53
54   /**
55    * @brief Default Construct
56    *
57    */
58   TrainingCompiler(void) = delete;
59
60   /**
61    * @brief Destroy the TrainingCompiler object
62    */
63   ~TrainingCompiler() = default;
64
65 public:
66   /**
67    * @brief Do compilation with the options
68    *
69    * @return std::shared_ptr<CompilerArtifact> Executors as a result of compilation
70    */
71   std::shared_ptr<CompilerArtifact> compile(void);
72
73 private:
74   std::shared_ptr<ir::Model> _model;
75   CompilerOptions *_options;
76   const TrainingInfo _training_info;
77 };
78
79 } // namespace train
80 } // namespace compiler
81 } // namespace onert
82
83 #endif // __ONERT_COMPILER_TRAIN_TRAINING_COMPILER_H_