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.

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
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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 base.h
  18. * @brief HCOM data type definition
  19. *
  20. */
  21. #ifndef HCCL_BASE_H_
  22. #define HCCL_BASE_H_
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif // __cplusplus
  26. typedef signed char s8;
  27. typedef signed short s16;
  28. typedef signed int s32;
  29. typedef signed long long s64;
  30. typedef unsigned char u8;
  31. typedef unsigned short u16;
  32. typedef unsigned int u32;
  33. typedef unsigned long long u64;
  34. /**
  35. * @brief HCOM functions return value definition
  36. */
  37. typedef enum tagHcclResult {
  38. HCCL_SUCCESS = 0, /**< success */
  39. HCCL_E_PARA = 1, /**< parameter error */
  40. HCCL_E_PTR = 2, /**< empty pointer */
  41. HCCL_E_MEMORY = 3, /**< memory error */
  42. HCCL_E_INTERNAL = 4, /**< internal error */
  43. HCCL_E_NOT_SUPPORT = 5, /**< not support feature */
  44. HCCL_E_NOT_FOUND = 6, /**< not found specific resource */
  45. HCCL_E_UNAVAIL = 7, /**< resource unavailable */
  46. HCCL_E_SYSCALL = 8, /**< call system interface error */
  47. HCCL_E_TIMEOUT = 9, /**< timeout */
  48. HCCL_E_OPEN_FILE_FAILURE = 10, /**< open file fail */
  49. HCCL_E_TCP_CONNECT = 11, /**< tcp connect fail */
  50. HCCL_E_ROCE_CONNECT = 12, /**< roce connect fail */
  51. HCCL_E_TCP_TRANSFER = 13, /**< tcp transfer fail */
  52. HCCL_E_ROCE_TRANSFER = 14, /**< roce transfer fail */
  53. HCCL_E_RUNTIME = 15, /**< call runtime api fail */
  54. HCCL_E_DRV = 16, /**< call driver api fail */
  55. HCCL_E_PROFILING = 17, /**< call profiling api fail */
  56. HCCL_E_CCE = 18, /**< call cce api fail */
  57. HCCL_E_NETWORK = 19, /**< call network api fail */
  58. HCCL_E_RESERVED /**< reserved */
  59. } hcclResult_t;
  60. /* handle to communicator */
  61. typedef void *hcclComm_t;
  62. /**
  63. * @brief HCCL Reduction opperation
  64. */
  65. typedef enum tagHcclRedOp {
  66. HCCL_REP_OP_SUM = 0, /**< sum */
  67. HCCL_REP_OP_PROD = 1, /**< prod */
  68. HCCL_REP_OP_MAX = 2, /**< max */
  69. HCCL_REP_OP_MIN = 3, /**< min */
  70. HCCL_REP_OP_RESERVED /**< reserved */
  71. } hcclRedOp_t;
  72. /**
  73. * @brief Horovod Reduction opperation
  74. */
  75. typedef enum tagHorovodRedOp {
  76. HOROVOD_REP_OP_AVERAGE = 0, /**< average */
  77. HOROVOD_REP_OP_SUM = 1, /**< sum */
  78. HOROVOD_REP_OP_ADASUM = 2, /**< adasum */
  79. HOROVOD_REP_OP_MIN = 3, /**< min */
  80. HOROVOD_REP_OP_MAX = 4, /**< max */
  81. HOROVOD_REP_OP_PROD = 5, /**< proo */
  82. HOROVOD_REP_OP_RESERVED /**< reserved */
  83. } horovodRedOp_t;
  84. /**
  85. * @brief HCCL data type
  86. */
  87. typedef enum tagHcclDataType {
  88. HCCL_DATA_TYPE_INT8 = 0, /**< int8 */
  89. HCCL_DATA_TYPE_INT = 1, /**< int32 */
  90. HCCL_DATA_TYPE_HALF = 2, /**< fp16 */
  91. HCCL_DATA_TYPE_FLOAT = 3, /**< fp32 */
  92. HCCL_DATA_TYPE_INT16 = 4, /**< int16 */
  93. HCCL_DATA_TYPE_RESERVED /**< reserved */
  94. } hcclDataType_t;
  95. constexpr u32 HCCL_UNIQUE_ID_BYTES = 2060; // 2060: unique id length
  96. using hcclUniqueId = struct hcclUniqueIdDef {
  97. char internal[HCCL_UNIQUE_ID_BYTES];
  98. };
  99. const u32 HCCL_MAX_SEGMENT_NUM = 8; // The max number of gradient segments.
  100. /**
  101. * @brief the feature of the model
  102. */
  103. struct model_feature {
  104. const char *model_name; /**< The model name */
  105. u32 gradient_num; /**< The number of gradients */
  106. float *gradient_size; /**< The size of each gradient */
  107. float *gradient_time; /**< The BP compution time of each gradient */
  108. };
  109. enum GradSplitForceMode {
  110. FORCE_NONE, /**< no force */
  111. FORCE_SIZE, /**< force split gradient by size */
  112. FORCE_RESERVED /**< reserved */
  113. };
  114. enum OriginalGraphShapeType {
  115. KNOWN_SHAPE,
  116. UNKNOWN_SHAPE,
  117. SHAPE_RESERVED /**< reserved */
  118. };
  119. /**
  120. * @brief stream handle.
  121. */
  122. typedef void *rtStream_t;
  123. /**
  124. * @brief model handle.
  125. */
  126. typedef void *rtModel_t;
  127. #ifdef __cplusplus
  128. }
  129. #endif // __cplusplus
  130. #endif // HCCL_BASE_H_

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