1 /** 2 * Copyright 2024 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_CCSRC_FRONTEND_PARALLEL_PASS_UTILS_H_ 18 #define MINDSPORE_CCSRC_FRONTEND_PARALLEL_PASS_UTILS_H_ 19 20 #include <vector> 21 #include <string> 22 #include <utility> 23 #include <set> 24 #include <map> 25 #include <memory> 26 #include <unordered_map> 27 #include "base/base.h" 28 #include "frontend/parallel/device_manager.h" 29 #include "frontend/parallel/tensor_layout/tensor_redistribution.h" 30 #include "frontend/parallel/graph_util/node_info.h" 31 #include "frontend/parallel/strategy_checkpoint/parallel_strategy_checkpoint.h" 32 33 namespace mindspore { 34 namespace parallel { 35 constexpr char INTERLEAVED_OVERLAP_MATMUL[] = "interleaved_overlap_matmul"; 36 constexpr char GRAD_OVERLAP_MATMUL[] = "grad_overlap_matmul"; 37 constexpr char FORWARD_UNIQUE_ID_LIST[] = "forward_unique_id_list"; 38 bool IsForwardNode(const CNodePtr &cnode); 39 bool IsDxMatMul(const CNodePtr &matmul_node); 40 bool IsDwMatMul(const CNodePtr &matmul_node); 41 void ExtractBackwardMatMul(const std::vector<CNodePtr> &origin_nodes_topological, 42 std::unordered_map<CNodePtr, CNodePtr> *backward_matmul_dx_dw_map); 43 std::string AnfNodeInfo(const AnfNodePtr &anf_node); 44 void ExtendDxDwMap(const std::vector<CNodePtr> &origin_nodes_topological, 45 std::unordered_map<CNodePtr, CNodePtr> *backward_matmul_dx_dw_map); 46 } // namespace parallel 47 } // namespace mindspore 48 49 #endif // MINDSPORE_CCSRC_FRONTEND_PARALLEL_PASS_UTILS_H_ 50