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 9.7 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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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, // success
  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_STREAM_DUPLICATE = 0x19, // streamId Map is repeatly
  61. RT_ERROR_STREAM_NOT_EXIST = 0x1a, // streamId is not exist
  62. RT_ERROR_SQ_NO_EXIST_SQ_TO_REUSE = 0x1b, // no exist sq to reuse
  63. RT_ERROR_SQID_FULL = 0x3C,
  64. RT_ERROR_MODEL_STREAM_EXE_FAILED = 0x91, // the model stream failed
  65. RT_ERROR_MODEL_LOAD_FAILED = 0x94, // the model stream failed
  66. RT_ERROR_END_OF_SEQUENCE = 0x95, // end of sequence
  67. RT_ERROR_NO_STREAM_CB_REG = 0x96, // no callback register info for stream
  68. RT_ERROR_DATA_DUMP_LOAD_FAILED = 0x97, // data dump load info fail
  69. RT_ERROR_CALLBACK_THREAD_UNSUBSTRIBE = 0x98, // callback thread unsubstribe
  70. RT_ERROR_DEBUG_REGISTER_FAILED = 0x99, // debug register fail
  71. RT_ERROR_DEBUG_UNREGISTER_FAILED = 0x9A, // debug unregister fail
  72. RT_ERROR_GROUP_NOT_SET = 0x9B,
  73. RT_ERROR_GROUP_NOT_CREATE = 0x9C,
  74. RT_ERROR_RESERVED
  75. } rtError_t;
  76. /**
  77. * @ingroup dvrt_base
  78. * @brief runtime exception numbers.
  79. */
  80. typedef enum tagRtExceptionType {
  81. RT_EXCEPTION_NONE = 0,
  82. RT_EXCEPTION_TS_DOWN = 1,
  83. RT_EXCEPTION_TASK_TIMEOUT = 2,
  84. RT_EXCEPTION_TASK_FAILURE = 3,
  85. RT_EXCEPTION_DEV_RUNNING_DOWN = 4
  86. } rtExceptionType;
  87. /**
  88. * @ingroup dvrt_base
  89. * @brief Switch type.
  90. */
  91. typedef enum tagRtCondition {
  92. RT_EQUAL = 0,
  93. RT_NOT_EQUAL,
  94. RT_GREATER,
  95. RT_GREATER_OR_EQUAL,
  96. RT_LESS,
  97. RT_LESS_OR_EQUAL
  98. } rtCondition_t;
  99. /**
  100. * @ingroup dvrt_base
  101. * @brief Data Type of Extensible Switch Task.
  102. */
  103. typedef enum tagRtSwitchDataType {
  104. RT_SWITCH_INT32 = 0,
  105. RT_SWITCH_INT64 = 1,
  106. } rtSwitchDataType_t;
  107. typedef enum tagRtStreamFlagType {
  108. RT_HEAD_STREAM = 0, // first stream
  109. RT_INVALID_FLAG = 0xFFFFFFFF,
  110. } rtStreamFlagType_t;
  111. typedef enum tagRtLimitType {
  112. RT_LIMIT_TYPE_LOW_POWER_TIMEOUT = 0, // timeout for power down , ms
  113. } rtLimitType_t;
  114. typedef struct rtExceptionInfo {
  115. uint32_t taskid;
  116. uint32_t streamid;
  117. uint32_t tid;
  118. } rtExceptionInfo;
  119. typedef void (*rtErrorCallback)(rtExceptionType);
  120. typedef void (*rtTaskFailCallback)(rtExceptionInfo *exceptionInfo);
  121. /**
  122. * @ingroup dvrt_base
  123. * @brief stream handle.
  124. */
  125. typedef void *rtStream_t;
  126. /**
  127. * @ingroup dvrt_base
  128. * @brief runtime event handle.
  129. */
  130. typedef void *rtEvent_t;
  131. /**
  132. * @ingroup dvrt_base
  133. * @brief label handle.
  134. */
  135. typedef void *rtLabel_t;
  136. /**
  137. * @ingroup profiling_base
  138. * @brief runtime handle.
  139. */
  140. RTS_API rtError_t rtSetProfDirEx(const char *profDir, const char *address, const char *jobCtx);
  141. /**
  142. * @ingroup profiling_base
  143. * @brief init profiler object.
  144. */
  145. RTS_API rtError_t rtProfilerInit(const char *profdir, const char *address, const char *job_ctx);
  146. /**
  147. * @ingroup profiling_base
  148. * @brief config rts profiler.
  149. */
  150. RTS_API rtError_t rtProfilerConfig(uint16_t type);
  151. /**
  152. * @ingroup profiling_base
  153. * @brief start rts profiler.
  154. */
  155. RTS_API rtError_t rtProfilerStart(void);
  156. /**
  157. * @ingroup profiling_base
  158. * @brief stop rts profiler.
  159. */
  160. RTS_API rtError_t rtProfilerStop(void);
  161. /**
  162. * @ingroup profiling_base
  163. * @brief ts send keypoint profiler log.
  164. */
  165. RTS_API rtError_t rtProfilerTrace(uint64_t id, bool notify, uint32_t flags, rtStream_t stream);
  166. /**
  167. * @ingroup dvrt_base
  168. * @brief Returns the last error from a runtime call.
  169. */
  170. RTS_API rtError_t rtGetLastError();
  171. /**
  172. * @ingroup dvrt_base
  173. * @brief Returns the last error from a runtime call.
  174. */
  175. RTS_API rtError_t rtPeekAtLastError();
  176. /**
  177. * @ingroup dvrt_base
  178. * @brief register callback for error code
  179. * @param [out] NA
  180. * @return RT_ERROR_NONE for ok
  181. */
  182. RTS_API rtError_t rtSetExceptCallback(rtErrorCallback callback);
  183. /**
  184. * @ingroup dvrt_base
  185. * @brief register callback for task fail
  186. * @param [out] NA
  187. * @return RT_ERROR_NONE for ok
  188. */
  189. RTS_API rtError_t rtSetTaskFailCallback(rtTaskFailCallback callback);
  190. /**
  191. * @ingroup dvrt_base
  192. * @brief notify handle.
  193. */
  194. typedef void *rtNotify_t;
  195. /**
  196. * @ingroup dvrt_base
  197. * @brief create label instance
  198. * @param [out] label created label
  199. * @return RT_ERROR_NONE for ok
  200. * @return RT_ERROR_INVALID_RESOURCE_HANDLE for error input handle
  201. */
  202. RTS_API rtError_t rtLabelCreate(rtLabel_t *label);
  203. /**
  204. * @ingroup dvrt_base
  205. * @brief set label and stream instance
  206. * @param [in] label set label
  207. * @param [in] stream set stream
  208. * @return RT_ERROR_NONE for ok
  209. * @return RT_ERROR_INVALID_RESOURCE_HANDLE for error input handle
  210. */
  211. RTS_API rtError_t rtLabelSet(rtLabel_t label, rtStream_t stream);
  212. /**
  213. * @ingroup dvrt_base
  214. * @brief destroy label instance
  215. * @param [in] label label to destroy
  216. * @return RT_ERROR_NONE for ok
  217. * @return RT_ERROR_INVALID_RESOURCE_HANDLE for error input handle
  218. */
  219. RTS_API rtError_t rtLabelDestroy(rtLabel_t label);
  220. /**
  221. * @ingroup dvrt_base
  222. * @brief label switch instance
  223. * @param [in] ptr address to get value compared
  224. * @param [in] condition
  225. * @param [in] value to compare
  226. * @param [in] true_label goto label
  227. * @param [in] stream to submit label_switch task
  228. * @return RT_ERROR_NONE for ok
  229. * @return RT_ERROR_INVALID_RESOURCE_HANDLE for error input handle
  230. */
  231. RTS_API rtError_t rtLabelSwitch(void *ptr, rtCondition_t condition, uint32_t value, rtLabel_t trueLabel,
  232. rtStream_t stream);
  233. /**
  234. * @ingroup dvrt_base
  235. * @brief goto label instance
  236. * @param [in] label goto label
  237. * @param [in] stream to submit label_goto task
  238. * @return RT_ERROR_NONE for ok
  239. * @return RT_ERROR_INVALID_RESOURCE_HANDLE for error input handle
  240. */
  241. RTS_API rtError_t rtLabelGoto(rtLabel_t label, rtStream_t stream);
  242. /**
  243. * @ingroup dvrt_base
  244. * @brief name label instance
  245. * @param [in] label instance
  246. * @param [in] name label name
  247. * @return RT_ERROR_NONE for ok
  248. * @return RT_ERROR_INVALID_RESOURCE_HANDLE for error input handle
  249. */
  250. RTS_API rtError_t rtNameLabel(rtLabel_t label, const char *name);
  251. /**
  252. * @ingroup dvrt_base
  253. * @brief label switch by index
  254. * @param [in] ptr index value ptr
  255. * @param [in] max index max value
  256. * @param [in] labelInfoPtr label content info ptr
  257. * @param [in] stream set stream
  258. * @return RT_ERROR_NONE for ok
  259. * @return RT_ERROR_INVALID_RESOURCE_HANDLE for error input handle
  260. */
  261. RTS_API rtError_t rtLabelSwitchByIndex(void *ptr, uint32_t max, void *labelInfoPtr, rtStream_t stream);
  262. /**
  263. * @ingroup dvrt_base
  264. * @brief stream goto label
  265. * @param [in] label goto label
  266. * @param [in] stream stream to submit label_goto task
  267. * @return RT_ERROR_NONE for ok
  268. * @return RT_ERROR_INVALID_RESOURCE_HANDLE for error input handle
  269. */
  270. RTS_API rtError_t rtLabelGotoEx(rtLabel_t label, rtStream_t stream);
  271. /**
  272. * @ingroup dvrt_base
  273. * @brief labels to dev info
  274. * @param [in] label model label list
  275. * @param [in] labelNumber label number
  276. * @param [in] dst device ptr
  277. * @param [in] dstMax dst size
  278. * @return RT_ERROR_NONE for ok
  279. * @return RT_ERROR_INVALID_RESOURCE_HANDLE for error input handle
  280. */
  281. RTS_API rtError_t rtLabelListCpy(rtLabel_t *label, uint32_t labelNumber, void *dst, uint32_t dstMax);
  282. /**
  283. * @ingroup dvrt_base
  284. * @brief labels to dev info
  285. * @param [out] label created label handle
  286. * @param [in] stream label bind stream
  287. * @return RT_ERROR_NONE for ok
  288. * @return RT_ERROR_INVALID_RESOURCE_HANDLE for error input handle
  289. */
  290. RTS_API rtError_t rtLabelCreateEx(rtLabel_t *label, rtStream_t stream);
  291. #ifdef __cplusplus
  292. }
  293. #endif
  294. #endif // __CCE_RUNTIME_BASE_H__

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