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.

split_strategy.h 1.7 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. #include <vector>
  17. #include <string>
  18. #include <unordered_map>
  19. #ifndef MINDSPORE_LITE_SRC_PASS_PARALLEL_SPLIT_STRATEGY_H_
  20. #define MINDSPORE_LITE_SRC_PASS_PARALLEL_SPLIT_STRATEGY_H_
  21. namespace mindspore {
  22. namespace opt {
  23. constexpr auto OP = "op";
  24. constexpr auto STRATEGY = "strategy";
  25. constexpr auto DEV_TYPE = "dev_type";
  26. constexpr auto PARALLEL_NAME_SUFFIX = "_parallel";
  27. constexpr auto kSplitOp = "Conv2D";
  28. const std::vector<int64_t> kSplitRatio = {1, 1};
  29. const std::vector<int64_t> kSplitDefaultRatio = {0, 0};
  30. const std::vector<std::string> kSplitDevTypes = {"CPU", "GPU"};
  31. using Strategys = std::vector<std::vector<std::vector<int64_t>>>;
  32. enum SplitMode {
  33. NoSplit = 0,
  34. SplitN = 1,
  35. SplitH = 2,
  36. SplitCIN = 3,
  37. SplitCOUT = 4,
  38. };
  39. struct SplitStrategy {
  40. Strategys strategys;
  41. std::vector<std::string> dev_types;
  42. size_t dev_num;
  43. };
  44. std::unordered_map<std::string, opt::SplitStrategy> ParserSplitStrategy(SplitMode parallel_mode);
  45. } // namespace opt
  46. } // namespace mindspore
  47. #endif // MINDSPORE_LITE_SRC_PASS_PARALLEL_SPLIT_STRATEGY_H_