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.

context.h 4.3 kB

5 years ago
5 years ago
3 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
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
3 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /*
  2. * Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved.
  3. * Description: context.h
  4. * Create: 2020-01-01
  5. */
  6. #ifndef CCE_RUNTIME_CONTEXT_H
  7. #define CCE_RUNTIME_CONTEXT_H
  8. #include "base.h"
  9. #if defined(__cplusplus)
  10. extern "C" {
  11. #endif
  12. /**
  13. * @ingroup rt_context
  14. * @brief runtime context handle.
  15. */
  16. typedef void *rtContext_t;
  17. typedef enum tagDryRunFlag {
  18. RT_DRYRUN_FLAG_FALSE = 0,
  19. RT_DRYRUN_FLAG_TRUE = 1,
  20. } rtDryRunFlag_t;
  21. typedef enum tagCtxMode {
  22. RT_CTX_NORMAL_MODE = 0,
  23. RT_CTX_GEN_MODE = 1,
  24. } rtCtxMode_t;
  25. typedef struct tagRtGroupInfo {
  26. int32_t groupId;
  27. uint32_t flag;
  28. uint32_t aicoreNum;
  29. uint32_t aicpuNum;
  30. uint32_t aivectorNum;
  31. uint32_t sdmaNum;
  32. uint32_t activeStreamNum;
  33. void *extrPtr;
  34. } rtGroupInfo_t;
  35. /**
  36. * @ingroup rt_context
  37. * @brief create context and associates it with the calling thread
  38. * @param [out] createCtx created context
  39. * @param [in] flags context creation flag. set to 0.
  40. * @param [in] devId device to create context on
  41. * @return RT_ERROR_NONE for ok
  42. */
  43. RTS_API rtError_t rtCtxCreate(rtContext_t *createCtx, uint32_t flags, int32_t devId);
  44. /**
  45. * @ingroup rt_context
  46. * @brief create context and associates it with the calling thread
  47. * @param [out] createCtx created context
  48. * @param [in] flags context creation flag. set to 0.
  49. * @param [in] devId device to create context on
  50. * @param [in] deviceMode the device mode
  51. * @return RT_ERROR_NONE for ok
  52. */
  53. RTS_API rtError_t rtCtxCreateV2(rtContext_t *createCtx, uint32_t flags, int32_t devId, rtDeviceMode deviceMode);
  54. /**
  55. * @ingroup rt_context
  56. * @brief create context and associates it with the calling thread
  57. * @param [out] createCtx created context
  58. * @param [in] flags context creation flag. set to 0.
  59. * @param [in] devId device to create context on
  60. * @return RT_ERROR_NONE for ok
  61. */
  62. RTS_API rtError_t rtCtxCreateEx(rtContext_t *createCtx, uint32_t flags, int32_t devId);
  63. /**
  64. * @ingroup rt_context
  65. * @brief destroy context instance
  66. * @param [in] destroyCtx context to destroy
  67. * @return RT_ERROR_NONE for ok
  68. */
  69. RTS_API rtError_t rtCtxDestroy(rtContext_t destroyCtx);
  70. /**
  71. * @ingroup rt_context
  72. * @brief destroy context instance
  73. * @param [in] destroyCtx context to destroy
  74. * @return RT_ERROR_NONE for ok
  75. */
  76. RTS_API rtError_t rtCtxDestroyEx(rtContext_t destroyCtx);
  77. /**
  78. * @ingroup rt_context
  79. * @brief binds context to the calling CPU thread.
  80. * @param [in] currentCtx context to bind. if NULL, unbind current context.
  81. * @return RT_ERROR_NONE for ok
  82. */
  83. RTS_API rtError_t rtCtxSetCurrent(rtContext_t currentCtx);
  84. /**
  85. * @ingroup rt_context
  86. * @brief block for a context's tasks to complete
  87. * @return RT_ERROR_NONE for ok
  88. */
  89. RTS_API rtError_t rtCtxSynchronize(void);
  90. /**
  91. * @ingroup rt_context
  92. * @brief returns the context bound to the calling CPU thread.
  93. * @param [out] currentCtx returned context
  94. * @return RT_ERROR_NONE for ok
  95. */
  96. RTS_API rtError_t rtCtxGetCurrent(rtContext_t *currentCtx);
  97. /**
  98. * @ingroup rt_context
  99. * @brief returns the primary context of device.
  100. * @param [out] primaryCtx returned context
  101. * @return RT_ERROR_NONE for ok
  102. */
  103. RTS_API rtError_t rtGetPriCtxByDeviceId(int32_t devId, rtContext_t *primaryCtx);
  104. /**
  105. * @ingroup rt_context
  106. * @brief returns the device ID for the current context
  107. * @param [out] devId returned device id
  108. * @return RT_ERROR_NONE for ok
  109. */
  110. RTS_API rtError_t rtCtxGetDevice(int32_t *devId);
  111. /**
  112. * @ingroup
  113. * @brief set group id
  114. * @param [in] groupid
  115. * @return RT_ERROR_NONE for ok, errno for failed
  116. */
  117. RTS_API rtError_t rtSetGroup(int32_t groupId);
  118. /**
  119. * @ingroup
  120. * @brief get group info
  121. * @param [in] groupid count
  122. * @return RT_ERROR_NONE for ok, errno for failed
  123. */
  124. RTS_API rtError_t rtGetGroupInfo(int32_t groupId, rtGroupInfo_t *groupInfo, uint32_t cnt);
  125. /**
  126. * @ingroup
  127. * @brief get group count
  128. * @param [in] groupid count
  129. * @return RT_ERROR_NONE for ok, errno for failed
  130. */
  131. RTS_API rtError_t rtGetGroupCount(uint32_t *cnt);
  132. /**
  133. * @ingroup rt_context
  134. * @brief set context INF mode
  135. * @param [in] infMode
  136. * @return RT_ERROR_NONE for ok
  137. */
  138. RTS_API rtError_t rtSetCtxINFMode(bool infMode);
  139. #if defined(__cplusplus)
  140. }
  141. #endif
  142. #endif // CCE_RUNTIME_CONTEXT_H

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