1 /** 2 * Copyright 2019-2022 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_GRAPH_KERNEL_CORE_GRAPH_KERNEL_PASS_MANAGER_H_ 17 #define MINDSPORE_CCSRC_BACKEND_OPTIMIZER_GRAPH_KERNEL_CORE_GRAPH_KERNEL_PASS_MANAGER_H_ 18 19 #include <utility> 20 #include <vector> 21 #include <string> 22 #include <memory> 23 24 #include "backend/common/graph_kernel/graph_kernel_flags.h" 25 #include "include/backend/optimizer/pass_manager.h" 26 27 namespace mindspore::graphkernel { 28 using opt::PassManager; 29 class GraphKernelPassManager : public PassManager { 30 public: GraphKernelPassManager(size_t stage,const std::string & name)31 GraphKernelPassManager(size_t stage, const std::string &name) 32 : PassManager(name, true), stage_(stage), flags_(GraphKernelFlags::GetInstance()) {} 33 ~GraphKernelPassManager() = default; 34 35 // Add graph pass, the pass object will be freed when pass manager freed. 36 void Add(const opt::PassPtr &pass, unsigned int pass_level, bool supported_device = true); 37 38 // Run passes on the func_graph 39 bool Run(const FuncGraphPtr &func_graph) const override; 40 41 protected: 42 std::string GetPassFullname(size_t pass_id, const opt::PassPtr &pass) const override; 43 44 size_t stage_; 45 std::vector<bool> enabled_; 46 const GraphKernelFlags &flags_; 47 }; 48 } // namespace mindspore::graphkernel 49 #endif // MINDSPORE_CCSRC_BACKEND_OPTIMIZER_GRAPH_KERNEL_CORE_GRAPH_KERNEL_PASS_MANAGER_H_ 50