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.

step_auto_parallel.h 3.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /**
  2. * Copyright 2019 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_STEP_AUTO_PARALLEL_H_
  17. #define MINDSPORE_CCSRC_FRONTEND_PARALLEL_STEP_AUTO_PARALLEL_H_
  18. #include <map>
  19. #include <memory>
  20. #include <string>
  21. #include <vector>
  22. #include <utility>
  23. #include "frontend/optimizer/opt.h"
  24. #include "frontend/parallel/status.h"
  25. #include "ir/anf.h"
  26. #include "pipeline/jit/pipeline.h"
  27. #include "frontend/parallel/auto_parallel/rec_core/rec_parse_graph.h"
  28. namespace mindspore {
  29. namespace parallel {
  30. // main step of Auto-parallel
  31. bool StepAutoParallel(const FuncGraphPtr &func_graph, const opt::OptimizerPtr &optimizer);
  32. bool IsSplittableOperator(const std::string &);
  33. bool IsAutoParallelCareNode(const CNodePtr &);
  34. void InitCostGraph();
  35. Status ConstructCostGraphNodesByUniqueId(const std::vector<AnfNodePtr> &all_nodes, const FuncGraphPtr &root);
  36. Status ConstructCostGraphNodesByUniqueIdTC(const std::vector<AnfNodePtr> &all_nodes, const FuncGraphPtr &root);
  37. void ConstructCostGraphEdges(const std::vector<AnfNodePtr> &all_nodes);
  38. void AugmentCostGraph(const std::vector<AnfNodePtr> &all_nodes);
  39. Status IgnoreOperatorsInCostGraph();
  40. Status ParallelStrategySearch(const std::vector<AnfNodePtr> &all_nodes, const FuncGraphPtr &root);
  41. Status ParallelStrategyRecSearch(const std::vector<AnfNodePtr> &all_nodes, const FuncGraphPtr &root);
  42. std::vector<std::vector<std::string>> RecInputTensorNames(const std::map<std::string, std::string>::iterator &it,
  43. std::vector<std::vector<std::string>> input_tensor_names);
  44. CNodePtr GetInternalOperatorInfo(const CNodePtr &cnode, const ValueNodePtr &prim_anf_node);
  45. void ModifyInputsTensorNameListIfOperatorInfoCreated(const std::string &name, const std::string &uniqueid);
  46. size_t FindOperatorIndexById(const std::string &unique_id,
  47. const std::vector<std::vector<std::string>> &input_tensor_names);
  48. void AddSharedTensorWhenMultiUsers(
  49. const std::pair<std::string, std::pair<AnfNodePtr, AnfNodeIndexSet>> &parameter_users_info);
  50. std::vector<std::vector<size_t>> GetSharedTensorsOps(
  51. const std::shared_ptr<Graph> &graph, const std::vector<std::shared_ptr<OperatorInfo>> &ops,
  52. const std::vector<std::vector<std::string>> &shared_tensors_ops_names,
  53. const std::vector<std::vector<std::string>> &input_tensor_names);
  54. } // namespace parallel
  55. } // namespace mindspore
  56. #endif // MINDSPORE_CCSRC_FRONTEND_PARALLEL_STEP_AUTO_PARALLEL_H_