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.6 kB

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

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