• 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 "base/core_ops.h"
23 #include "utils/trace_base.h"
24 
25 namespace mindspore {
26 namespace opt {
27 class CacheManager;
28 using CacheManagerPtr = std::shared_ptr<CacheManager>;
29 
30 // @brief ANF Graph level optimization base pass
31 class Pass {
32  public:
name_(name)33   explicit Pass(const std::string &name = "pass") : name_(name) {}
34   virtual ~Pass() = default;
35   virtual bool Run(const FuncGraphPtr &func_graph) = 0;
name()36   virtual std::string name() const { return name_; }
SetCacheManager(const CacheManagerPtr & cm)37   void SetCacheManager(const CacheManagerPtr &cm) { cache_manager_ = cm; }
GetCacheManager()38   const CacheManagerPtr &GetCacheManager() const { return cache_manager_; }
39 
40  private:
41   const std::string name_;
42   CacheManagerPtr cache_manager_;
43 };
44 using PassPtr = std::shared_ptr<Pass>;
45 }  // namespace opt
46 }  // namespace mindspore
47 
48 #endif  // MINDSPORE_CCSRC_BACKEND_OPTIMIZER_COMMON_PASS_H_
49