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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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_RUNTIME_BASE_H__
  17. #define __CCE_RUNTIME_BASE_H__
  18. #include <stdint.h>
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. // If you need export the function of this library in Win32 dll, use __declspec(dllexport)
  23. #ifndef RTS_API
  24. #ifdef RTS_DLL_EXPORT
  25. #define RTS_API __declspec(dllexport)
  26. #else
  27. #define RTS_API
  28. #endif
  29. #endif
  30. /**
  31. * @ingroup dvrt_base
  32. * @brief runtime error numbers.
  33. */
  34. typedef enum tagRtError {
  35. RT_ERROR_NONE = 0x0, // succes
  36. RT_ERROR_INVALID_VALUE = 0x1, // invalid value
  37. RT_ERROR_MEMORY_ALLOCATION = 0x2, // memory allocation fail
  38. RT_ERROR_INVALID_RESOURCE_HANDLE = 0x3, // invalid handle
  39. RT_ERROR_INVALID_DEVICE_POINTER = 0x4, // invalid device point
  40. RT_ERROR_INVALID_MEMCPY_DIRECTION = 0x5, // invalid memory copy dirction
  41. RT_ERROR_INVALID_DEVICE = 0x6, // invalid device
  42. RT_ERROR_NO_DEVICE = 0x7, // no valid device
  43. RT_ERROR_CMD_OCCUPY_FAILURE = 0x8, // command occpuy failure
  44. RT_ERROR_SET_SIGNAL_FAILURE = 0x9, // set signal failure
  45. RT_ERROR_UNSET_SIGNAL_FAILURE = 0xA, // unset signal failure
  46. RT_ERROR_OPEN_FILE_FAILURE = 0xB, // unset signal failure
  47. RT_ERROR_WRITE_FILE_FAILURE = 0xC,
  48. RT_ERROR_MEMORY_ADDRESS_UNALIGNED = 0xD,
  49. RT_ERROR_DRV_ERR = 0xE,
  50. RT_ERROR_LOST_HEARTBEAT = 0xF,
  51. RT_ERROR_REPORT_TIMEOUT = 0x10,
  52. RT_ERROR_NOT_READY = 0x11,
  53. RT_ERROR_DATA_OPERATION_FAIL = 0x12,
  54. RT_ERROR_INVALID_L2_INSTR_SIZE = 0x13,
  55. RT_ERROR_DEVICE_PROC_HANG_OUT = 0x14,
  56. RT_ERROR_DEVICE_POWER_UP_FAIL = 0x15,
  57. RT_ERROR_DEVICE_POWER_DOWN_FAIL = 0x16,
  58. RT_ERROR_FEATURE_NOT_SUPPROT = 0x17,
  59. RT_ERROR_KERNEL_DUPLICATE = 0x18, // register same kernel repeatly
  60. RT_ERROR_MODEL_STREAM_EXE_FAILED = 0x91, // the model stream failed
  61. RT_ERROR_MODEL_LOAD_FAILED = 0x94, // the model stream failed
  62. RT_ERROR_END_OF_SEQUENCE = 0x95, // end of sequence
  63. RT_ERROR_RESERVED
  64. } rtError_t;
  65. /**
  66. * @ingroup dvrt_base
  67. * @brief runtime exception numbers.
  68. */
  69. typedef enum tagRtExceptionType {
  70. RT_EXCEPTION_NONE = 0,
  71. RT_EXCEPTION_TS_DOWN = 1,
  72. RT_EXCEPTION_TASK_TIMEOUT = 2,
  73. RT_EXCEPTION_TASK_FAILURE = 3,
  74. RT_EXCEPTION_DEV_RUNNING_DOWN = 4
  75. } rtExceptionType;
  76. /**
  77. * @ingroup dvrt_base
  78. * @brief Switch type.
  79. */
  80. typedef enum tagRtCondition {
  81. RT_EQUAL = 0,
  82. RT_NOT_EQUAL,
  83. RT_GREATER,
  84. RT_GREATER_OR_EQUAL,
  85. RT_LESS,
  86. RT_LESS_OR_EQUAL
  87. } rtCondition_t;
  88. /**
  89. * @ingroup dvrt_base
  90. * @brief Data Type of Extensible Switch Task.
  91. */
  92. typedef enum tagRtSwitchDataType {
  93. RT_SWITCH_INT32 = 0,
  94. RT_SWITCH_INT64 = 1,
  95. } rtSwitchDataType_t;
  96. typedef enum tagRtStreamFlagType {
  97. RT_HEAD_STREAM = 0, // first stream
  98. RT_INVALID_FLAG = 0xFFFFFFFF,
  99. } rtStreamFlagType_t;
  100. typedef enum tagRtLimitType {
  101. RT_LIMIT_TYPE_LOW_POWER_TIMEOUT = 0, // timeout for power down , ms
  102. } rtLimitType_t;
  103. typedef void (*rtErrorCallback)(rtExceptionType);
  104. /**
  105. * @ingroup dvrt_base
  106. * @brief stream handle.
  107. */
  108. typedef void *rtStream_t;
  109. /**
  110. * @ingroup dvrt_base
  111. * @brief runtime event handle.
  112. */
  113. typedef void *rtEvent_t;
  114. /**
  115. * @ingroup dvrt_base
  116. * @brief label handle.
  117. */
  118. typedef void *rtLabel_t;
  119. /**
  120. * @ingroup profiling_base
  121. * @brief runtime handle.
  122. */
  123. RTS_API rtError_t rtSetProfDirEx(const char *profDir, const char *address, const char *jobCtx);
  124. /**
  125. * @ingroup profiling_base
  126. * @brief init profiler object.
  127. */
  128. RTS_API rtError_t rtProfilerInit(const char *profdir, const char *address, const char *job_ctx);
  129. /**
  130. * @ingroup profiling_base
  131. * @brief start rts profiler.
  132. */
  133. RTS_API rtError_t rtProfilerStart(void);
  134. /**
  135. * @ingroup profiling_base
  136. * @brief stop rts profiler.
  137. */
  138. RTS_API rtError_t rtProfilerStop(void);
  139. /**
  140. * @ingroup profiling_base
  141. * @brief ts send keypoint profiler log.
  142. */
  143. RTS_API rtError_t rtProfilerTrace(uint64_t id, bool notify, uint32_t flags, rtStream_t stream);
  144. /**
  145. * @ingroup dvrt_base
  146. * @brief Returns the last error from a runtime call.
  147. */
  148. RTS_API rtError_t rtGetLastError();
  149. /**
  150. * @ingroup dvrt_base
  151. * @brief Returns the last error from a runtime call.
  152. */
  153. RTS_API rtError_t rtPeekAtLastError();
  154. /**
  155. * @ingroup dvrt_base
  156. * @brief set polling receive mode for task report
  157. * @param [out] NA
  158. * @return RT_ERROR_NONE for ok
  159. */
  160. RTS_API rtError_t rtSetPollingMode();
  161. /**
  162. * @ingroup dvrt_base
  163. * @brief register callback for error code
  164. * @param [out] NA
  165. * @return RT_ERROR_NONE for ok
  166. */
  167. RTS_API rtError_t rtSetExceptCallback(rtErrorCallback callback);
  168. /**
  169. * @ingroup dvrt_base
  170. * @brief notify handle.
  171. */
  172. typedef void *rtNotify_t;
  173. /**
  174. * @ingroup dvrt_base
  175. * @brief create label instance
  176. * @param [out] label created label
  177. * @return RT_ERROR_NONE for ok
  178. * @return RT_ERROR_INVALID_RESOURCE_HANDLE for error input handle
  179. */
  180. RTS_API rtError_t rtLabelCreate(rtLabel_t *label);
  181. /**
  182. * @ingroup dvrt_base
  183. * @brief set label and stream instance
  184. * @param [in] label set label
  185. * @param [in] stream set stream
  186. * @return RT_ERROR_NONE for ok
  187. * @return RT_ERROR_INVALID_RESOURCE_HANDLE for error input handle
  188. */
  189. RTS_API rtError_t rtLabelSet(rtLabel_t label, rtStream_t stream);
  190. /**
  191. * @ingroup dvrt_base
  192. * @brief destroy label instance
  193. * @param [in] label label to destroy
  194. * @return RT_ERROR_NONE for ok
  195. * @return RT_ERROR_INVALID_RESOURCE_HANDLE for error input handle
  196. */
  197. RTS_API rtError_t rtLabelDestroy(rtLabel_t label);
  198. /**
  199. * @ingroup dvrt_base
  200. * @brief label switch instance
  201. * @param [in] ptr address to get value compared
  202. * @param [in] condition
  203. * @param [in] value to compare
  204. * @param [in] true_label goto label
  205. * @param [in] stream to submit label_switch task
  206. * @return RT_ERROR_NONE for ok
  207. * @return RT_ERROR_INVALID_RESOURCE_HANDLE for error input handle
  208. */
  209. RTS_API rtError_t rtLabelSwitch(void *ptr, rtCondition_t condition, uint32_t value, rtLabel_t trueLabel,
  210. rtStream_t stream);
  211. /**
  212. * @ingroup dvrt_base
  213. * @brief goto label instance
  214. * @param [in] label goto label
  215. * @param [in] stream to submit label_goto task
  216. * @return RT_ERROR_NONE for ok
  217. * @return RT_ERROR_INVALID_RESOURCE_HANDLE for error input handle
  218. */
  219. RTS_API rtError_t rtLabelGoto(rtLabel_t label, rtStream_t stream);
  220. /**
  221. * @ingroup dvrt_base
  222. * @brief name label instance
  223. * @param [in] label instance
  224. * @param [in] name label name
  225. * @return RT_ERROR_NONE for ok
  226. * @return RT_ERROR_INVALID_RESOURCE_HANDLE for error input handle
  227. */
  228. RTS_API rtError_t rtNameLabel(rtLabel_t label, const char *name);
  229. #ifdef __cplusplus
  230. }
  231. #endif
  232. #endif // __CCE_RUNTIME_BASE_H__

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

Contributors (1)