1 /** 2 * Copyright 2023 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_INPLACE_NODE_PASS_H 18 #define MINDSPORE_INPLACE_NODE_PASS_H 19 20 #include <memory> 21 #include <string> 22 #include "utils/hash_map.h" 23 #include "ir/anf.h" 24 #include "ir/func_graph.h" 25 #include "ir/primitive.h" 26 #include "include/backend/optimizer/pass_manager.h" 27 #include "include/backend/optimizer/pattern_engine.h" 28 #include "ir/graph_utils.h" 29 #include "utils/ms_utils.h" 30 #include "include/backend/optimizer/helper.h" 31 #include "include/backend/optimizer/graph_optimizer.h" 32 #include "include/backend/visible.h" 33 34 namespace mindspore { 35 namespace opt { 36 class BACKEND_EXPORT InplaceNodePass : public NodePass { 37 public: NodePass(name)38 explicit InplaceNodePass(const std::string &name = "") : NodePass(name) {} 39 ~InplaceNodePass() override = default; 40 virtual bool Process(const AnfNodePtr &) const = 0; 41 AnfNodePtr Run(const FuncGraphPtr &, const AnfNodePtr &node) override; IsFastPass()42 bool IsFastPass() override { return true; } 43 }; 44 } // namespace opt 45 } // namespace mindspore 46 47 #endif // MINDSPORE_INPLACE_NODE_PASS_H 48