Imported Upstream version 1.12.0
[platform/core/ml/nnfw.git] / compiler / luci / pass / src / ModulePhase.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 __MODULE_PHASE_H__
18 #define __MODULE_PHASE_H__
19
20 #include <luci/ModulePass.h>
21
22 #include <logo/Phase.h>
23
24 #include <vector>
25
26 namespace luci
27 {
28
29 using Phase = std::vector<std::unique_ptr<Pass>>;
30
31 template <logo::PhaseStrategy S> class PhaseRunner;
32
33 template <>
34 class PhaseRunner<logo::PhaseStrategy::Saturate> final : public logo::PhaseRunnerMixinObservable
35 {
36 public:
37   PhaseRunner(luci::Module *module) : _module{module}
38   {
39     // DO NOTHING
40   }
41
42 public:
43   void run(const Phase &) const;
44
45 private:
46   luci::Module *_module;
47 };
48
49 template <>
50 class PhaseRunner<logo::PhaseStrategy::Restart> final : public logo::PhaseRunnerMixinObservable
51 {
52 public:
53   PhaseRunner(luci::Module *module) : _module{module}
54   {
55     // DO NOTHING
56   }
57
58 public:
59   void run(const Phase &) const;
60
61 private:
62   luci::Module *_module;
63 };
64
65 } // namespace luci
66
67 #endif // __MODULE_PHASE_H__