• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2019 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 #ifndef MINDSPORE_CCSRC_BACKEND_OPTIMIZER_COMMON_PASS_H_
17 #define MINDSPORE_CCSRC_BACKEND_OPTIMIZER_COMMON_PASS_H_
18 #include <memory>
19 #include <string>
20 
21 #include "ir/anf.h"
22 #include "utils/trace_base.h"
23 
24 namespace mindspore {
25 namespace opt {
26 class CacheManager;
27 using CacheManagerPtr = std::shared_ptr<CacheManager>;
28 
29 // @brief ANF Graph level optimization base pass
30 class Pass {
31  public:
name_(name)32   explicit Pass(const std::string &name = "pass") : name_(name) {}
33   virtual ~Pass() = default;
34   virtual bool Run(const FuncGraphPtr &func_graph) = 0;
name()35   const std::string &name() const { return name_; }
SetCacheManager(const CacheManagerPtr & cm)36   void SetCacheManager(const CacheManagerPtr &cm) { cache_manager_ = cm; }
GetCacheManager()37   const CacheManagerPtr &GetCacheManager() const { return cache_manager_; }
38 
39  private:
40   const std::string name_;
41   CacheManagerPtr cache_manager_;
42 };
43 using PassPtr = std::shared_ptr<Pass>;
44 }  // namespace opt
45 }  // namespace mindspore
46 #endif  // MINDSPORE_CCSRC_BACKEND_OPTIMIZER_COMMON_PASS_H_
47