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.

stream.h 6.5 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
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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /**
  2. * Copyright 2020 Huawei Technologies Co., Ltd
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. * http://www.apache.org/licenses/LICENSE-2.0
  7. * Unless required by applicable law or agreed to in writing, software
  8. * distributed under the License is distributed on an "AS IS" BASIS,
  9. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. * See the License for the specific language governing permissions and
  11. * limitations under the License.
  12. */
  13. #ifndef __CCE_RUNTIME_STREAM_H__
  14. #define __CCE_RUNTIME_STREAM_H__
  15. #include "base.h"
  16. #include "event.h"
  17. #if defined(__cplusplus) && !defined(COMPILE_OMG_PACKAGE)
  18. extern "C" {
  19. #endif
  20. /**
  21. * @ingroup stream_flags
  22. * @brief stream op bit flags
  23. */
  24. #define RT_STREAM_DEFAULT (0x00)
  25. #define RT_STREAM_PERSISTENT (0x01)
  26. #define RT_STREAM_FORCE_COPY (0x02)
  27. #define RT_STREAM_HUGE (0x04)
  28. #define RT_STREAM_AICPU (0x08)
  29. #define RT_STREAM_FORBIDDEN_DEFAULT (0x10)
  30. #define RT_STREAM_HEAD (0x20)
  31. #define RT_STREAM_PRIMARY_DEFAULT (0x40)
  32. /**
  33. * @ingroup stream_type
  34. * @brief stream type
  35. */
  36. #define RT_NORMAL_STREAM (0x00)
  37. #define RT_HUGE_STREAM (0x01)
  38. /**
  39. * priority level default value when create a stream
  40. */
  41. #define RT_STREAM_PRIORITY_DEFAULT (0)
  42. /**
  43. * @ingroup dvrt_stream
  44. * @brief create stream instance
  45. * @param [in|out] stream created stream
  46. * @param [in] priority stream priority
  47. * @return RT_ERROR_NONE for ok
  48. * @return RT_ERROR_INVALID_VALUE for error input
  49. */
  50. RTS_API rtError_t rtStreamCreate(rtStream_t *stream, int32_t priority);
  51. /**
  52. * @ingroup dvrt_stream
  53. * @brief create stream instance
  54. * @param [in|out] stream created stream
  55. * @param [in] priority stream priority
  56. * @param [in] flags stream op flags
  57. * @return RT_ERROR_NONE for ok
  58. * @return RT_ERROR_INVALID_VALUE for error input
  59. */
  60. RTS_API rtError_t rtStreamCreateWithFlags(rtStream_t *stream, int32_t priority, uint32_t flags);
  61. /**
  62. * @ingroup dvrt_stream
  63. * @brief destroy stream instance.
  64. * @param [in] stream the stream to destroy
  65. * @return RT_ERROR_NONE for ok
  66. * @return RT_ERROR_INVALID_VALUE for error input
  67. */
  68. RTS_API rtError_t rtStreamDestroy(rtStream_t stream);
  69. /**
  70. * @ingroup dvrt_stream
  71. * @brief wait an recorded event for stream
  72. * @param [in] stream the wait stream
  73. * @param [in] event the event to wait
  74. * @return RT_ERROR_NONE for ok
  75. * @return RT_ERROR_INVALID_VALUE for error input
  76. */
  77. RTS_API rtError_t rtStreamWaitEvent(rtStream_t stream, rtEvent_t event);
  78. /**
  79. * @ingroup dvrt_stream
  80. * @brief wait stream to be complete
  81. * @param [in] stream stream to wait
  82. * @return RT_ERROR_NONE for ok
  83. * @return RT_ERROR_INVALID_VALUE for error input
  84. */
  85. RTS_API rtError_t rtStreamSynchronize(rtStream_t stream);
  86. /**
  87. * @ingroup dvrt_stream
  88. * @brief queries an asynchronous stream for completion status
  89. * @param [in] stream stream to query
  90. * @return RT_ERROR_NONE for complete
  91. * @return RT_ERROR_STREAM_NOT_COMPLETE for not complete
  92. */
  93. RTS_API rtError_t rtStreamQuery(rtStream_t stream);
  94. /**
  95. * @ingroup dvrt_stream
  96. * @brief get stream id from a stream handle
  97. * @param [in] stream stream hadle
  98. * @param [in] streamId stream id
  99. * @return RT_ERROR_NONE for complete
  100. * @return RT_ERROR_INVALID_VALUE for error input
  101. */
  102. RTS_API rtError_t rtGetStreamId(rtStream_t stream, int32_t *streamId);
  103. /**
  104. * @ingroup dvrt_stream
  105. * @brief inquire max stream count and max task count per stream
  106. * @param [in] streamType Stream Type
  107. * @param [in] MaxStrCount Max stream count
  108. * @param [in] MaxTaskCount max task count per stream
  109. * @return RT_ERROR_NONE for complete
  110. * @return RT_ERROR_INVALID_VALUE for error input
  111. */
  112. RTS_API rtError_t rtGetMaxStreamAndTask(uint32_t streamType, uint32_t *maxStrCount, uint32_t *maxTaskCount);
  113. /**
  114. * @ingroup dvrt_stream
  115. * @brief Name a stream
  116. * @param [in] stream stream to be named
  117. * @param [in] name identification name
  118. * @return RT_ERROR_NONE for complete
  119. * @return RT_ERROR_INVALID_VALUE for error input
  120. */
  121. RTS_API rtError_t rtNameStream(rtStream_t stream, const char *name);
  122. /**
  123. * @ingroup dvrt_stream
  124. * @brief switch to the corresponding stream according to the contents of the ptr
  125. * @param [in] ptr Determine the address where the value of the true and false branches is located
  126. * @param [in] condition switch condition
  127. * @param [in] value switch value
  128. * @param [in] trueStream Stream that needs to be activated when the value is non-zero
  129. * @param [in] stream input stream to init task
  130. * @return RT_ERROR_NONE for complete
  131. * @return RT_ERROR_INVALID_VALUE for error input
  132. */
  133. RTS_API rtError_t rtStreamSwitch(void *ptr, rtCondition_t condition, int64_t value, rtStream_t trueStream,
  134. rtStream_t stream);
  135. /**
  136. * @brief execute extensible stream switch task
  137. * @param [in] ptr pointer of value
  138. * @param [in] condition judge condition
  139. * @param [in] value_ptr pointer of target value
  140. * @param [in] true_stream stream to be activated when value is not zero
  141. * @param [in] stream stream id
  142. * @param [in] dataType data type of target value
  143. * @return RT_ERROR_NONE for complete
  144. */
  145. RTS_API rtError_t rtStreamSwitchEx(void *ptr, rtCondition_t condition, void *valuePtr, rtStream_t trueStream,
  146. rtStream_t stream, rtSwitchDataType_t dataType);
  147. /**
  148. * @ingroup dvrt_stream
  149. * @brief Active a stream
  150. * @param [in] activeStream stream to be activated
  151. * @param [in] stream input stream to init task
  152. * @return RT_ERROR_NONE for complete
  153. * @return RT_ERROR_INVALID_VALUE for error input
  154. */
  155. RTS_API rtError_t rtStreamActive(rtStream_t activeStream, rtStream_t stream);
  156. /**
  157. * @brief execute extensible stream case switch task
  158. * @param [in] ptr pointer of value
  159. * @param [in] size pointer num of value
  160. * @param [in] valuePtr pointer of target value, length = size * elementSize
  161. * @param [in] trueStreamPtr streams to be activated
  162. * @param [in] elementSize size of to be activated true streams
  163. * @param [in] stream input stream to init task
  164. * @param [in] dataType data type of target value
  165. * @return RT_ERROR_NONE for complete
  166. */
  167. RTS_API rtError_t rtStreamSwitchN(void *ptr, uint32_t size, void *valuePtr, rtStream_t *trueStreamPtr,
  168. uint32_t elementSize, rtStream_t stream, rtSwitchDataType_t dataType);
  169. #if defined(__cplusplus) && !defined(COMPILE_OMG_PACKAGE)
  170. }
  171. #endif
  172. #endif // __CCE_RUNTIME_STREAM_H__

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