You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

parameter_manager.h 2.9 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. #ifndef MINDSPORE_CCSRC_FRONTEND_PARALLEL_PARAMETER_MANAGER_H_
  17. #define MINDSPORE_CCSRC_FRONTEND_PARALLEL_PARAMETER_MANAGER_H_
  18. #include <vector>
  19. #include <string>
  20. #include <utility>
  21. #include <memory>
  22. #include <unordered_map>
  23. #include "base/base.h"
  24. #include "frontend/parallel/device_manager.h"
  25. #include "frontend/parallel/step_parallel_utils.h"
  26. namespace mindspore {
  27. namespace parallel {
  28. constexpr char EXP_AVG[] = "exp_avg";
  29. constexpr char EXP_AVG_SQ_ROW[] = "exp_avg_sq_row_";
  30. constexpr char EXP_AVG_SQ_COL[] = "exp_avg_sq_col_";
  31. constexpr char EXP_AVG_SQ[] = "exp_avg_sq_";
  32. using RefKeyPair = std::pair<AnfNodePtr, std::vector<AnfNodePtr>>;
  33. using ParameterUsersInfo = std::pair<std::string, std::pair<AnfNodePtr, AnfNodeIndexSet>>;
  34. ParameterUsersInfo FindParameterUsers(const AnfNodePtr &node, bool (*IsCareNode)(const CNodePtr &));
  35. void CheckParameterSplit(const std::vector<AnfNodePtr> &all_nodes);
  36. void HandleSymbolicKeyInstance(const FuncGraphPtr &root, const std::vector<AnfNodePtr> &all_nodes);
  37. void HandleNoUsedParameter(const FuncGraphPtr &root);
  38. void HandleFullySplitParameters(const FuncGraphPtr &root);
  39. void SetClonedTensorShapeForOptimizer(const FuncGraphPtr &root);
  40. void HandleAdaFactorOpt(const FuncGraphPtr &root);
  41. std::pair<AnfNodePtr, bool> FindParameter(const AnfNodePtr &node, const FuncGraphPtr &func_graph);
  42. std::pair<AnfNodePtr, bool> FindParameterWithAllgather(const AnfNodePtr &node, const FuncGraphPtr &func_graph,
  43. const std::string &name);
  44. std::unordered_map<std::string, std::shared_ptr<TensorLayout>> AdaSumParamTensorLayout(const FuncGraphPtr &root);
  45. bool HandleAdaSum(const FuncGraphPtr &root, const std::vector<AnfNodePtr> &all_nodes,
  46. std::unordered_map<std::string, std::shared_ptr<TensorLayout>> *adasum_param_tensor_layout_map);
  47. void HandleMirrorInAdaSum(
  48. const FuncGraphPtr &root,
  49. std::unordered_map<std::string, std::shared_ptr<TensorLayout>> *adasum_param_tensor_layout_map);
  50. bool ParameterIsCloned(const AnfNodePtr &parameter_node);
  51. bool IsFullySplitParameter(const ParameterPtr &param_ptr, size_t allow_repeat_num = 1);
  52. } // namespace parallel
  53. } // namespace mindspore
  54. #endif // MINDSPORE_CCSRC_FRONTEND_PARALLEL_PARAMETER_MANAGER_H_