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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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 // __cplusplus
  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 // RTS_DLL_EXPORT
  29. #endif // RTS_API
  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_NO_STREAM_CB_REG = 0x96, // no callback register info for stream
  64. RT_ERROR_DATA_DUMP_LOAD_FAILED = 0x97, // data dump load info fail
  65. RT_ERROR_RESERVED
  66. } rtError_t;
  67. /**
  68. * @ingroup dvrt_base
  69. * @brief runtime exception numbers.
  70. */
  71. typedef enum tagRtExceptionType {
  72. RT_EXCEPTION_NONE = 0,
  73. RT_EXCEPTION_TS_DOWN = 1,
  74. RT_EXCEPTION_TASK_TIMEOUT = 2,
  75. RT_EXCEPTION_TASK_FAILURE = 3,
  76. RT_EXCEPTION_DEV_RUNNING_DOWN = 4
  77. } rtExceptionType;
  78. /**
  79. * @ingroup dvrt_base
  80. * @brief Switch type.
  81. */
  82. typedef enum tagRtCondition {
  83. RT_EQUAL = 0,
  84. RT_NOT_EQUAL,
  85. RT_GREATER,
  86. RT_GREATER_OR_EQUAL,
  87. RT_LESS,
  88. RT_LESS_OR_EQUAL
  89. } rtCondition_t;
  90. /**
  91. * @ingroup dvrt_base
  92. * @brief Data Type of Extensible Switch Task.
  93. */
  94. typedef enum tagRtSwitchDataType {
  95. RT_SWITCH_INT32 = 0,
  96. RT_SWITCH_INT64 = 1,
  97. } rtSwitchDataType_t;
  98. typedef enum tagRtStreamFlagType {
  99. RT_HEAD_STREAM = 0, // first stream
  100. RT_INVALID_FLAG = 0xFFFFFFFF,
  101. } rtStreamFlagType_t;
  102. typedef enum tagRtLimitType {
  103. RT_LIMIT_TYPE_LOW_POWER_TIMEOUT = 0, // timeout for power down , ms
  104. } rtLimitType_t;
  105. typedef void (*rtErrorCallback)(rtExceptionType);
  106. /**
  107. * @ingroup dvrt_base
  108. * @brief stream handle.
  109. */
  110. typedef void *rtStream_t;
  111. /**
  112. * @ingroup dvrt_base
  113. * @brief runtime event handle.
  114. */
  115. typedef void *rtEvent_t;
  116. /**
  117. * @ingroup dvrt_base
  118. * @brief label handle.
  119. */
  120. typedef void *rtLabel_t;
  121. /**
  122. * @ingroup profiling_base
  123. * @brief runtime handle.
  124. */
  125. RTS_API rtError_t rtSetProfDirEx(const char *profDir, const char *address, const char *jobCtx);
  126. /**
  127. * @ingroup profiling_base
  128. * @brief init profiler object.
  129. */
  130. RTS_API rtError_t rtProfilerInit(const char *profdir, const char *address, const char *job_ctx);
  131. /**
  132. * @ingroup profiling_base
  133. * @brief start rts profiler.
  134. */
  135. RTS_API rtError_t rtProfilerStart(void);
  136. /**
  137. * @ingroup profiling_base
  138. * @brief stop rts profiler.
  139. */
  140. RTS_API rtError_t rtProfilerStop(void);
  141. /**
  142. * @ingroup profiling_base
  143. * @brief ts send keypoint profiler log.
  144. */
  145. RTS_API rtError_t rtProfilerTrace(uint64_t id, bool notify, uint32_t flags, rtStream_t stream);
  146. /**
  147. * @ingroup dvrt_base
  148. * @brief Returns the last error from a runtime call.
  149. */
  150. RTS_API rtError_t rtGetLastError();
  151. /**
  152. * @ingroup dvrt_base
  153. * @brief Returns the last error from a runtime call.
  154. */
  155. RTS_API rtError_t rtPeekAtLastError();
  156. /**
  157. * @ingroup dvrt_base
  158. * @brief set polling receive mode for task report
  159. * @param [out] NA
  160. * @return RT_ERROR_NONE for ok
  161. */
  162. RTS_API rtError_t rtSetPollingMode();
  163. /**
  164. * @ingroup dvrt_base
  165. * @brief register callback for error code
  166. * @param [out] NA
  167. * @return RT_ERROR_NONE for ok
  168. */
  169. RTS_API rtError_t rtSetExceptCallback(rtErrorCallback callback);
  170. /**
  171. * @ingroup dvrt_base
  172. * @brief notify handle.
  173. */
  174. typedef void *rtNotify_t;
  175. /**
  176. * @ingroup dvrt_base
  177. * @brief create label instance
  178. * @param [out] label created label
  179. * @return RT_ERROR_NONE for ok
  180. * @return RT_ERROR_INVALID_RESOURCE_HANDLE for error input handle
  181. */
  182. RTS_API rtError_t rtLabelCreate(rtLabel_t *label);
  183. /**
  184. * @ingroup dvrt_base
  185. * @brief set label and stream instance
  186. * @param [in] label set label
  187. * @param [in] stream set stream
  188. * @return RT_ERROR_NONE for ok
  189. * @return RT_ERROR_INVALID_RESOURCE_HANDLE for error input handle
  190. */
  191. RTS_API rtError_t rtLabelSet(rtLabel_t label, rtStream_t stream);
  192. /**
  193. * @ingroup dvrt_base
  194. * @brief destroy label instance
  195. * @param [in] label label to destroy
  196. * @return RT_ERROR_NONE for ok
  197. * @return RT_ERROR_INVALID_RESOURCE_HANDLE for error input handle
  198. */
  199. RTS_API rtError_t rtLabelDestroy(rtLabel_t label);
  200. /**
  201. * @ingroup dvrt_base
  202. * @brief label switch instance
  203. * @param [in] ptr address to get value compared
  204. * @param [in] condition
  205. * @param [in] value to compare
  206. * @param [in] true_label goto label
  207. * @param [in] stream to submit label_switch task
  208. * @return RT_ERROR_NONE for ok
  209. * @return RT_ERROR_INVALID_RESOURCE_HANDLE for error input handle
  210. */
  211. RTS_API rtError_t rtLabelSwitch(void *ptr, rtCondition_t condition, uint32_t value, rtLabel_t trueLabel,
  212. rtStream_t stream);
  213. /**
  214. * @ingroup dvrt_base
  215. * @brief goto label instance
  216. * @param [in] label goto label
  217. * @param [in] stream to submit label_goto task
  218. * @return RT_ERROR_NONE for ok
  219. * @return RT_ERROR_INVALID_RESOURCE_HANDLE for error input handle
  220. */
  221. RTS_API rtError_t rtLabelGoto(rtLabel_t label, rtStream_t stream);
  222. /**
  223. * @ingroup dvrt_base
  224. * @brief name label instance
  225. * @param [in] label instance
  226. * @param [in] name label name
  227. * @return RT_ERROR_NONE for ok
  228. * @return RT_ERROR_INVALID_RESOURCE_HANDLE for error input handle
  229. */
  230. RTS_API rtError_t rtNameLabel(rtLabel_t label, const char *name);
  231. #ifdef __cplusplus
  232. }
  233. #endif
  234. #endif // __CCE_RUNTIME_BASE_H__

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