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.

prof_engine.h 5.5 kB

5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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 _MSPROF_ENGINE_PROF_ENGINE_H_
  17. #define _MSPROF_ENGINE_PROF_ENGINE_H_
  18. #define MSVP_PROF_API __attribute__((visibility("default")))
  19. #include <map>
  20. #include <string>
  21. #include "prof_reporter.h"
  22. namespace Msprof {
  23. namespace Engine {
  24. /**
  25. * @defgroup ModuleJobConfig the ModuleJobConfig group
  26. * This is the ModuleJobConfig group
  27. */
  28. /**
  29. * @ingroup ModuleJobConfig
  30. * @brief struct ModuleJobConfig
  31. * record config info
  32. */
  33. struct ModuleJobConfig {
  34. std::map<std::string, std::string> switches; /**< key is the config name, value is the config value(on or off) */
  35. };
  36. /**
  37. * @defgroup PluginIntf the pluginInf group
  38. * This is the pluginInf group
  39. */
  40. /**
  41. * @ingroup PluginIntf
  42. * @brief class PluginIntf
  43. */
  44. class MSVP_PROF_API PluginIntf {
  45. public:
  46. virtual ~PluginIntf() {}
  47. public:
  48. /**
  49. * @ingroup PluginIntf
  50. * @name : Init
  51. * @brief : API of user plugin, libmsporf call this API to send a Reporter to user plugin
  52. * @par description :
  53. * API of user plugin, libmsporf call this API to send a Reporter to user plugin.
  54. * @param reporter [IN] const Reporter* the Reporter from libmsprof
  55. * @retval PROFILING_SUCCESS 0 (success)
  56. * @retval PROFILING_FAILED -1 (failed)
  57. *
  58. * @par depend:
  59. * @li libmsprof
  60. * @li prof_engine.h
  61. * @since c60
  62. * @see UnInit
  63. */
  64. virtual int Init(const Reporter *reporter) = 0;
  65. /**
  66. * @ingroup PluginIntf
  67. * @name : OnNewConfig
  68. * @brief : API of user plugin, libmsprof call this API to send config info to user plugin \n
  69. If the user plugin needn't config, no need to redefine this function
  70. * @param config [IN] const ModuleJobConfig * the config from libmsprof
  71. * @retval PROFILING_SUCCESS 0 (success)
  72. * @retval PROFILING_FAILED -1 (failed)
  73. *
  74. * @par depend:
  75. * @li libmsprof
  76. * @li prof_engine.h
  77. * @since c60
  78. * @see Init | UnInit
  79. */
  80. virtual int OnNewConfig(const ModuleJobConfig *config) { return 0; }
  81. /**
  82. * @ingroup PluginIntf
  83. * @name : UnInit
  84. * @brief : API of user plugin, libmsprof call this API to notify plugin stop to send data
  85. * @retval PROFILING_SUCCESS 0 (success)
  86. * @retval PROFILING_FAILED -1 (failed)
  87. *
  88. * @par depend:
  89. * @li libmsprof
  90. * @li prof_engine.h
  91. * @since c60
  92. * @see Init
  93. */
  94. virtual int UnInit() = 0;
  95. };
  96. /**
  97. * @defgroup EngineIntf the EngineIntf group
  98. * This is the EngineIntf group
  99. */
  100. /**
  101. * @ingroup EngineIntf
  102. * @brief class EngineIntf
  103. */
  104. class MSVP_PROF_API EngineIntf {
  105. public:
  106. virtual ~EngineIntf() {}
  107. public:
  108. /**
  109. * @ingroup EngineIntf
  110. * @name : CreatePlugin
  111. * @brief : API of user engine, libmsporf call this API to get a plugin
  112. * @retval PluginIntf * The pointer of the new plugin
  113. *
  114. * @par depend:
  115. * @li libmsprof
  116. * @li prof_engine.h
  117. * @since c60
  118. * @see ReleasePlugin
  119. */
  120. virtual PluginIntf *CreatePlugin() = 0;
  121. /**
  122. * @ingroup EngineIntf
  123. * @name : ReleasePlugin
  124. * @brief : API of user engine, libmsprof call this API to release a plugin
  125. * @param plugin [IN] PluginIntf * the plugin to release
  126. * @retval PROFILING_SUCCESS 0 (success)
  127. * @retval PROFILING_FAILED -1 (failed)
  128. *
  129. * @par depend:
  130. * @li libmsprof
  131. * @li prof_engine.h
  132. * @since c60
  133. * @see CreatePlugin
  134. */
  135. virtual int ReleasePlugin(PluginIntf *plugin) = 0;
  136. };
  137. /**
  138. * @defgroup EngineMgr the EngineMgr group
  139. * This is the EngineMgr group
  140. */
  141. /**
  142. * @ingroup EngineMgr
  143. * @name : RegisterEngine
  144. * @brief : API of libmsprof, register an engine with a name
  145. * @param module [IN] const std::string the name of plugin
  146. * @param engine [IN] const EngineIntf* the plugin
  147. * @retval PROFILING_SUCCESS 0 (success)
  148. * @retval PROFILING_FAILED -1 (failed)
  149. *
  150. * @par depend:
  151. * @li libmsprof
  152. * @li prof_engine.h
  153. * @since c60
  154. */
  155. MSVP_PROF_API int RegisterEngine(const std::string &module, const EngineIntf *engine);
  156. /**
  157. * @ingroup EngineMgr
  158. * @name : Init
  159. * @brief : API of libmsprof, init an engine with a name
  160. * @param module [IN] const std::string the name of plugin
  161. * @param module [IN] const EngineIntf* the plugin
  162. * @retval PROFILING_SUCCESS 0 (success)
  163. * @retval PROFILING_FAILED -1 (failed)
  164. *
  165. * @par depend:
  166. * @li libmsprof
  167. * @li prof_engine.h
  168. * @since c60
  169. * @see UnInit
  170. */
  171. MSVP_PROF_API int Init(const std::string &module, const EngineIntf *engine);
  172. /**
  173. * @ingroup EngineMgr
  174. * @name : Init
  175. * @brief : API of libmsprof, uninit an engine with a name
  176. * @param module [IN] const std::string the name of plugin
  177. * @retval PROFILING_SUCCESS 0 (success)
  178. * @retval PROFILING_FAILED -1 (failed)
  179. *
  180. * @par depend:
  181. * @li libmsprof
  182. * @li prof_engine.h
  183. * @since c60
  184. * @see Init
  185. */
  186. MSVP_PROF_API int UnInit(const std::string &module);
  187. } // namespace Engine
  188. } // namespace Msprof
  189. #endif
  190. /*
  191. * History: \n
  192. * 2019-04-10, huawei, Create file. \n
  193. * 2020-02-10, huawei, Add Api Comment. \n
  194. *
  195. * vi: set expandtab ts=4 sw=4 tw=120:
  196. */

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

Contributors (1)