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.

common.h 3.5 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /**
  2. * Copyright 2020 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_PS_COMMON_H_
  17. #define MINDSPORE_CCSRC_FRONTEND_PARALLEL_PS_COMMON_H_
  18. #include <iostream>
  19. #include <vector>
  20. #include <memory>
  21. #include "ps/ps.h"
  22. namespace mindspore {
  23. namespace parallel {
  24. namespace ps {
  25. constexpr char kEnvCommType[] = "MS_COMM_TYPE";
  26. constexpr char kEnvInterface[] = "MS_INTERFACE";
  27. constexpr char kEnvPServerNum[] = "MS_SERVER_NUM";
  28. constexpr char kEnvWorkerNum[] = "MS_WORKER_NUM";
  29. constexpr char kEnvSchedulerHost[] = "MS_SCHED_HOST";
  30. constexpr char kEnvSchedulerPort[] = "MS_SCHED_PORT";
  31. constexpr char kEnvRole[] = "MS_ROLE";
  32. constexpr char kEnvRoleOfPServer[] = "MS_PSERVER";
  33. constexpr char kEnvRoleOfWorker[] = "MS_WORKER";
  34. constexpr char kEnvRoleOfScheduler[] = "MS_SCHED";
  35. constexpr char kDmlcCommType[] = "DMLC_PS_VAN_TYPE";
  36. constexpr char kDmlcInterface[] = "DMLC_INTERFACE";
  37. constexpr char kDmlcPServerNum[] = "DMLC_NUM_SERVER";
  38. constexpr char kDmlcWorkerNum[] = "DMLC_NUM_WORKER";
  39. constexpr char kDmlcRole[] = "DMLC_ROLE";
  40. constexpr char kDmlcSchedulerHost[] = "DMLC_PS_ROOT_URI";
  41. constexpr char kDmlcSchedulerPort[] = "DMLC_PS_ROOT_PORT";
  42. constexpr char kCommTypeOfIBVerbs[] = "ibverbs";
  43. constexpr char kCommTypeOfTCP[] = "zmq";
  44. constexpr char kRoleOfPServer[] = "server";
  45. constexpr char kRoleOfWorker[] = "worker";
  46. constexpr char kRoleOfScheduler[] = "scheduler";
  47. constexpr char kLearningRate[] = "learning_rate";
  48. constexpr char kMomentum[] = "momentum";
  49. constexpr char kApplyMomentum[] = "ApplyMomentum";
  50. constexpr char kSparseAdam[] = "Adam";
  51. constexpr char kSparseLazyAdam[] = "LazyAdam";
  52. constexpr char kSparseFtrl[] = "Ftrl";
  53. constexpr char kApplyMomentumOp[] = "Momentum";
  54. constexpr char kSparseAdamOp[] = "Adam";
  55. constexpr char kSparseLazyAdamOp[] = "LazyAdam";
  56. constexpr char kSparseFtrlOp[] = "FTRL";
  57. constexpr int kInitWeightsCmd = 10;
  58. constexpr int kInitWeightToOptimIdCmd = 11;
  59. constexpr int kInitOptimInputsShapeCmd = 12;
  60. constexpr int kInitKeyToPushNodeIdCmd = 13;
  61. constexpr int kInitEmbeddingsCmd = 20;
  62. constexpr int kCheckReadyForPushCmd = 25;
  63. constexpr int kCheckReadyForPullCmd = 26;
  64. constexpr int kEmbeddingLookupCmd = 30;
  65. constexpr int kFinalizeCmd = 40;
  66. constexpr size_t kInvalidKey = UINT64_MAX;
  67. constexpr int kInvalidID = -1;
  68. using Key = ::ps::Key;
  69. using Keys = ::ps::SArray<Key>;
  70. using Values = ::ps::SArray<float>;
  71. using ValuesPtr = std::shared_ptr<Values>;
  72. using Weight = ::ps::SArray<float>;
  73. using Grad = ::ps::SArray<float>;
  74. using LookupIds = ::ps::SArray<Key>;
  75. using Lengths = ::ps::SArray<int>;
  76. using WeightPtr = std::shared_ptr<Weight>;
  77. using GradPtr = std::shared_ptr<Grad>;
  78. using InputsShape = std::vector<std::shared_ptr<std::vector<size_t>>>;
  79. using InputsShapePtr = std::shared_ptr<std::vector<std::shared_ptr<std::vector<size_t>>>>;
  80. } // namespace ps
  81. } // namespace parallel
  82. } // namespace mindspore
  83. #endif // MINDSPORE_CCSRC_FRONTEND_PARALLEL_PS_COMMON_H_