• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2021 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_PARAMETER_MANAGER_H_
18 #define MINDSPORE_CCSRC_FRONTEND_PARALLEL_PARAMETER_MANAGER_H_
19 
20 #include <vector>
21 #include <string>
22 #include <utility>
23 #include "base/base.h"
24 #include "frontend/parallel/device_manager.h"
25 #include "frontend/parallel/step_parallel_utils.h"
26 
27 namespace mindspore {
28 namespace parallel {
29 constexpr char EXP_AVG[] = "exp_avg_";
30 constexpr char EXP_AVG_SQ_ROW[] = "exp_avg_sq_row_";
31 constexpr char EXP_AVG_SQ_COL[] = "exp_avg_sq_col_";
32 constexpr char EXP_AVG_SQ[] = "exp_avg_sq_";
33 using RefKeyPair = std::pair<AnfNodePtr, std::vector<AnfNodePtr>>;
34 using ParameterUsersInfo = std::pair<std::string, std::pair<AnfNodePtr, AnfNodeIndexSet>>;
35 struct ParameterSliceInfo {
36   Shape slice_shape;
37   RankList group_ranks;
38 };
39 
40 ParameterUsersInfo FindParameterUsers(const AnfNodePtr &node, bool (*IsCareNode)(const CNodePtr &));
41 void CheckParameterSplit(const std::vector<AnfNodePtr> &all_nodes);
42 void HandleSymbolicKeyInstance(const FuncGraphPtr &root, const std::vector<AnfNodePtr> &all_nodes);
43 void HandleNoUsedParameter(const FuncGraphPtr &root);
44 void HandleFullySplitParameters(const FuncGraphPtr &root);
45 void SetClonedTensorShapeForOptimizer(const FuncGraphPtr &root);
46 void HandleAdaFactorOpt(const FuncGraphPtr &root);
47 bool ParameterIsCloned(const AnfNodePtr &parameter_node);
48 }  // namespace parallel
49 }  // namespace mindspore
50 
51 #endif  // MINDSPORE_CCSRC_FRONTEND_PARALLEL_PARAMETER_MANAGER_H_
52