• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_GRAPH_UTIL_GRAPH_UTILS_H_
18 #define MINDSPORE_CCSRC_FRONTEND_PARALLEL_GRAPH_UTIL_GRAPH_UTILS_H_
19 #include <set>
20 #include <vector>
21 #include <string>
22 #include "mindspore/core/base/base.h"
23 #include "mindspore/core/ir/anf.h"
24 #include "frontend/parallel/status.h"
25 #include "frontend/parallel/tensor_layout/tensor_redistribution.h"
26 #include "frontend/parallel/ops_info/operator_info.h"
27 
28 namespace mindspore::parallel {
29 CNodePtr InsertNode(const Operator &op, const CNodePtr &node, size_t index, const AnfNodePtr &pre_node,
30                     const FuncGraphPtr &func_graph, const std::string &instance_name,
31                     const std::string &param_name = "", const FuncGraphPtr &root = nullptr,
32                     const TensorRedistributionPtr &tensor_redistribution = nullptr);
33 std::set<FuncGraphPtr> FindForwardGraphByRootNodes(const std::vector<AnfNodePtr> &root_all_nodes);
34 std::vector<AnfNodePtr> ReplaceOpInput(const Operator &replace_op, const std::string &instance_name,
35                                        const CNodePtr &node);
36 std::vector<AnfNodePtr> CreateInput(const Operator &op, const AnfNodePtr &pre_node, const std::string &instance_name,
37                                     const CNodePtr &cur_cnode = nullptr);
38 std::vector<AnfNodePtr> CreateMirrorInput(const FuncGraphPtr &root, const Operator &op, const AnfNodePtr &node,
39                                           const std::string &instance_name, const std::string &weight_name);
40 CNodePtr CreateShape(const AnfNodePtr &pre_cnode, const FuncGraphPtr &func_graph, const std::string &inst_name = "");
41 AnfNodePtr GetAccuGrad(const std::vector<AnfNodePtr> &parameters, const std::string &weight_name);
42 AnfNodePtr ConvertConstParamToDynamic(const TensorRedistributionPtr &tensor_redistribution, const Param &param,
43                                       const FuncGraphPtr &func_graph, bool is_reshape, enum ReshapeMode reshape_mode);
44 AnfNodePtr CreateDiv(const AnfNodePtr &input_node, int64_t divisor, const FuncGraphPtr &func_graph,
45                      bool to_long = false, const std::string &inst_name = "");
46 CNodePtr CreateSplit(const std::vector<AnfNodePtr> &inputs, const FuncGraphPtr &func_graph,
47                      const std::string &inst_name = "");
48 bool IsToBeInsertedSplitOp(const Operator &op);
49 Status MergeEntireShapeForDynamic(const FuncGraphPtr &func_graph);
50 Status SegmentEntireShapeToPartialForDynamic(const CNodePtr &reshape_node, const FuncGraphPtr &func_graph);
51 int64_t GetPrimeFactor(int64_t value);
52 }  // namespace mindspore::parallel
53 #endif  // MINDSPORE_CCSRC_FRONTEND_PARALLEL_GRAPH_UTIL_GRAPH_UTILS_H_
54