• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2021 Huawei Technologies Co., Ltd
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 MINDSPORE_LITE_INCLUDE_REGISTRY_PASS_BASE_H_
18 #define MINDSPORE_LITE_INCLUDE_REGISTRY_PASS_BASE_H_
19 
20 #include <memory>
21 #include <string>
22 #include "include/lite_utils.h"
23 #include "api/ir/func_graph.h"
24 
25 namespace mindspore {
26 namespace registry {
27 /// \brief PassBase defined a base class, which provides an interface for user to operate FuncGraph.
28 class MS_API PassBase {
29  public:
30   /// \brief Constructor
31   ///
32   /// \param[in] name Define pass name, which should be unique with each other.
name_(name)33   explicit PassBase(const std::string &name = "PassBase") : name_(name) {}
34 
35   /// \brief Destructor
36   virtual ~PassBase() = default;
37 
38   /// \brief An interface for user to operate FuncGraph.
39   ///
40   /// \param[in] func_graph Define the struct of the model.
41   ///
42   /// \return Boolean value to represent whether the operation is successful or not.
43   virtual bool Execute(const api::FuncGraphPtr &func_graph) = 0;
44 
45  private:
46   const std::string name_;
47 };
48 
49 /// \brief PassBasePtr defined a shared_ptr type.
50 using PassBasePtr = std::shared_ptr<PassBase>;
51 }  // namespace registry
52 }  // namespace mindspore
53 #endif  // MINDSPORE_LITE_INCLUDE_REGISTRY_PASS_BASE_H_
54