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.

hcom.h 4.1 kB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
5 years ago
4 years ago
4 years ago
4 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /**
  2. * Copyright 2019-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. /**
  17. * @file hcom.h
  18. * @brief HCOM API
  19. */
  20. #ifndef HCOM_H_
  21. #define HCOM_H_
  22. #include <hccl/base.h>
  23. #include <hccl/hccl_types.h>
  24. #include <functional>
  25. #include <vector>
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif // __cplusplus
  29. /**
  30. * @brief Get the rank number in the group.
  31. *
  32. * @param group A string identifying the group name.
  33. * @param rankSize A pointer identifying the rank number.
  34. * @return HcclResult
  35. */
  36. HcclResult HcomGetRankSize(const char *group, u32 *rankSize);
  37. /**
  38. * @brief Get the rank number of this rank's server within the group.
  39. *
  40. * @param group A string identifying the group name.
  41. * @param localRankSize A pointer identifying the rank number.
  42. * @return HcclResult
  43. */
  44. HcclResult HcomGetLocalRankSize(const char *group, u32 *localRankSize);
  45. /**
  46. * @brief Get the rank id of this rank.
  47. *
  48. * @param group A string identifying the group name.
  49. * @param rankId A pointer identifying the rank id.
  50. * @return HcclResult
  51. */
  52. HcclResult HcomGetRankId(const char *group, u32 *rankId);
  53. /**
  54. * @brief Get the local rank id of this rank's server within the group.
  55. *
  56. * @param group A string identifying the group name.
  57. * @param localRankId A pointer identifying the local rank id.
  58. * @return HcclResult
  59. */
  60. HcclResult HcomGetLocalRankId(const char *group, u32 *localRankId);
  61. /**
  62. * @brief Get the world rank id according to the group rank id.
  63. *
  64. * @param group A string identifying the group name.
  65. * @param groupRank An integer(u32) identifying the group rank id.
  66. * @param worldRank A pointer identifying the world rank id.
  67. * @return HcclResult
  68. */
  69. HcclResult HcomGetWorldRankFromGroupRank(const char *group, u32 groupRank, u32 *worldRank);
  70. /**
  71. * @brief Get the group rank id according to the world rank id.
  72. *
  73. * @param worldRank An integer(u32) identifying the world rank id.
  74. * @param group A string identifying the group name.
  75. * @param groupRank A pointer identifying the group rank id.
  76. * @return HcclResult
  77. */
  78. HcclResult HcomGetGroupRankFromWorldRank(u32 worldRank, const char *group, u32 *groupRank);
  79. /**
  80. * @brief Create group.
  81. *
  82. * @param group A string identifying the group name.
  83. * @param rankNum An integer(u32) identifying the number of ranks in the group.
  84. * @param rankIds A list identifying the ranks in the group.
  85. * @return HcclResult
  86. */
  87. HcclResult HcomCreateGroup(const char *group, u32 rankNum, u32 *rankIds);
  88. /**
  89. * @brief Destroy group
  90. *
  91. * @param group A string identifying the group name.
  92. * @return HcclResult
  93. */
  94. HcclResult HcomDestroyGroup(const char *group);
  95. /**
  96. * @brief Set the gradient split strategy with in the group, according to gradient index.
  97. *
  98. * @param group A string identifying the group name.
  99. * @param segmentNum An integer(u32) identifying the segments number of gradients.
  100. * @param IdxList A list identifying the index of end gradient in each segment.
  101. * @return HcclResult
  102. */
  103. extern HcclResult HcomSetGradFusionByIndex(const char *group, u32 segmentNum, const u32 *IdxList);
  104. /**
  105. * @brief Set the gradient split strategy with in the group, according to gradient data size.
  106. *
  107. * @param group A string identifying the group name.
  108. * @param segmentNum An integer(u32) identifying the segments number of gradients.
  109. * @param sizeList A list identifying the percent of each segment.
  110. * @return HcclResult
  111. */
  112. extern HcclResult HcomSetGradFusionBySize(const char *group, u32 segmentNum, const float *sizeList);
  113. #ifdef __cplusplus
  114. }
  115. #endif // __cplusplus
  116. #endif // HCOM_H_

图引擎模块(GE)是MindSpore的一个子模块,其代码由C++实现,位于前端模块ME和底层硬件之间,起到承接作用。图引擎模块以ME下发的图作为输入,然后进行一系列的深度图优化操作,最后输出一张可以在底层硬件上高效运行的图。GE针对昇腾AI处理器的硬件结构特点,做了特定的优化工作,以此来充分发挥出昇腾AI处理器的强大算力。在进行模型训练/推理时,GE会被自动调用而用户并不感知。GE主要由GE API和GE Core两部分组成,详细的架构图如下所示