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.

cce_def.hpp 4.9 kB

5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. #ifndef CCE_DEF_H__
  17. #define CCE_DEF_H__
  18. #include "runtime/rt.h"
  19. namespace cce {
  20. /**
  21. * @ingroup cce
  22. * @brief memory configure for fusion
  23. */
  24. typedef struct TagCceFusionMemCfg {
  25. uint64_t memAddr; /**< memAddr */
  26. uint32_t memSize; /**< memSize */
  27. uint32_t addrChangeFlag; /**< op data addr change flag. value:0,valid;1,not valid */
  28. uint32_t poolFlag; /**< mempool flag : value:0,is valid; value: 1, not valid */
  29. TagCceFusionMemCfg() {
  30. memAddr = 0;
  31. memSize = 0;
  32. addrChangeFlag = 0;
  33. poolFlag = 0;
  34. }
  35. } CceFusionMemCfg_t;
  36. /**
  37. * @ingroup cce
  38. * @brief return value
  39. */
  40. typedef enum tagCcStatus {
  41. CC_STATUS_SUCCESS = 0, /**< succ */
  42. CC_STATUS_NOT_INITIALIZED = 1, /**< not init */
  43. CC_STATUS_ALLOC_FAILED = 2, /**< alloc mem failed */
  44. CC_STATUS_BAD_PARAM = 3, /**< para check failed */
  45. CC_STATUS_INTERNAL_ERROR = 4, /**< internal error */
  46. CC_STATUS_KERNEL_ERROR = 5, /**< kernel error */
  47. CC_STATUS_RUNTIME_ERROR = 6, /**< runtime error */
  48. CC_STATUS_NOT_SUPPORTED = 7, /**< unsupport error */
  49. CC_STATUS_INVALID_VALUE = 7, /**< invalid value error for blas*/
  50. CC_STATUS_RESERVED /**< just for check */
  51. } ccStatus_t;
  52. /**
  53. * @ingroup cce
  54. * @brief original data type
  55. */
  56. typedef enum tagCcDataType {
  57. CC_DATA_FLOAT = 0, /**< float type */
  58. CC_DATA_HALF, /**< fp16 type */
  59. CC_DATA_INT8, /**< int8 type */
  60. CC_DATA_INT32, /**< int32 type */
  61. CC_DATA_UINT8, /**< uint8 type */
  62. CC_DATA_HALF_UINT16_PROPOSAL, /**<mixed type for proposal*/
  63. CC_DATA_INT16, /**< int16 type */
  64. CC_DATA_UINT16, /**< uint16 type */
  65. CC_DATA_UINT32, /**< uint32 type */
  66. CC_DATA_INT64, /**< int64 type */
  67. CC_DATA_UINT64, /**< uint64 type */
  68. CC_DATA_DOUBLE, /**< double type */
  69. CC_DATA_BOOL, /**< bool type */
  70. CC_DATA_DUAL, /**< dual output type */
  71. CC_DATA_DUAL_SUB_INT8, /**< dual output int8 type */
  72. CC_DATA_DUAL_SUB_UINT8, /**< dual output uint8 type */
  73. CC_DATA_COMPLEX64,
  74. CC_DATA_COMPLEX128,
  75. CC_DATA_QINT8,
  76. CC_DATA_QINT16,
  77. CC_DATA_QINT32,
  78. CC_DATA_QUINT8,
  79. CC_DATA_QUINT16,
  80. CC_DATA_RESERVED
  81. } ccDataType_t;
  82. /**
  83. * @ingroup cce
  84. * @brief save context of cce library
  85. */
  86. typedef struct tagCcContext {
  87. rtStream_t streamId;
  88. uint32_t opIndex;
  89. } ccContext_t;
  90. typedef struct tagCcContext *ccHandle_t;
  91. /**
  92. * @ingroup cce
  93. * @brief mode of data type transform
  94. */
  95. typedef enum tagCcDataTypeTransMode {
  96. CC_DATATYPE_TRANS_FLOAT_NO_TRANS = 0, /**< origin data is float, no trans */
  97. CC_DATATYPE_TRANS_FP16_NO_TRANS, /**< origin data is fp16, no trans */
  98. CC_DATATYPE_TRANS_INT8_NO_TRANS, /**< origin data is int8, no trans */
  99. CC_DATATYPE_TRANS_FLOAT_TO_FP16, /**< data type float trans to fp16 */
  100. CC_DATATYPE_TRANS_FP16_TO_FLOAT, /**< data type fp16 trans to float */
  101. CC_DATATYPE_TRANS_FLOAT_TO_INT8, /**< data type float trans to int8 */
  102. CC_DATATYPE_TRANS_INT8_TO_FLOAT, /**< data type int8 trans to float */
  103. CC_DATATYPE_TRANS_UINT8_TO_FLOAT, /**< data type uint8 trans to float */
  104. CC_DATATYPE_TRANS_UINT8_NO_TRANS, /**< origin data is uint8, no trans */
  105. CC_DATATYPE_TRANS_INT32_NO_TRANS, /**< data type uint8 trans to float */
  106. CC_DATATYPE_TRANS_UINT16_NO_TRANS, /** < origin data is uint16, no trans*/
  107. CC_DATATYPE_TRANS_UINT16_TO_FLOAT, /** < data type uint16 trans to float*/
  108. CC_DATATYPE_TRANS_MODE_RESERVED
  109. } ccDataTypeTransMode_t;
  110. typedef struct tagContextInfo {
  111. ccHandle_t handle;
  112. rtStream_t stream;
  113. uint8_t *memBase;
  114. uint64_t totalMemSize;
  115. uint8_t *weightsMemBase;
  116. uint64_t weightsMemSize;
  117. uint8_t *weightsMemBaseHost;
  118. } ContextInfo;
  119. /**
  120. * @ingroup cce
  121. * @brief cce function parameter type
  122. */
  123. typedef enum tagCcFuncType {
  124. CC_FUSION_L2,
  125. GLOBAL_MEMORY_CLEAR,
  126. MAX_NUM,
  127. } ccFuncParamType_t;
  128. /**
  129. * @ingroup cce
  130. * @brief cce set function point state
  131. */
  132. ccStatus_t ccSetFuncState(ccFuncParamType_t type, bool isOpen);
  133. /**
  134. * @ingroup cce
  135. * @brief cce get function point state
  136. */
  137. bool ccGetFuncState(ccFuncParamType_t type);
  138. } // namespace cce
  139. #endif // CCE_DEF_H__

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