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.

base.h 3.8 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
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 HCCL data type
  74. */
  75. typedef enum tagHcclDataType {
  76. HCCL_DATA_TYPE_INT8 = 0, /**< int8 */
  77. HCCL_DATA_TYPE_INT = 1, /**< int32 */
  78. HCCL_DATA_TYPE_HALF = 2, /**< fp16 */
  79. HCCL_DATA_TYPE_FLOAT = 3, /**< fp32 */
  80. HCCL_DATA_TYPE_RESERVED /**< reserved */
  81. } hcclDataType_t;
  82. const s32 HCCL_TAG_ANY = -1;
  83. const u32 BASE_UNIQUE_ID_BYTES = 27;
  84. #define HCCL_UNIQUE_ID_BYTES (BASE_UNIQUE_ID_BYTES + 5 + 16 + 128)
  85. typedef struct {
  86. char internal[HCCL_UNIQUE_ID_BYTES];
  87. } hcclUniqueId;
  88. const u32 HCCL_MAX_SEGMENT_NUM = 8; // The max number of gradient segments.
  89. /**
  90. * @brief the feature of the model
  91. */
  92. struct model_feature {
  93. const char *model_name; /**< The model name */
  94. u32 gradient_num; /**< The number of gradients */
  95. float *gradient_size; /**< The size of each gradient */
  96. float *gradient_time; /**< The BP compution time of each gradient */
  97. };
  98. /**
  99. * @brief stream handle.
  100. */
  101. typedef void *rtStream_t;
  102. /**
  103. * @brief model handle.
  104. */
  105. typedef void *rtModel_t;
  106. #ifdef __cplusplus
  107. }
  108. #endif // __cplusplus
  109. #endif // HCCL_BASE_H_

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