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.0 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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /**
  2. * @file prof_engine.h
  3. *
  4. * Copyright (c) Huawei Technologies Co., Ltd. 2019-2022. All rights reserved.
  5. *
  6. * This program is distributed in the hope that it will be useful,
  7. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. *
  10. */
  11. #ifndef MSPROF_ENGINE_PROF_ENGINE_H_
  12. #define MSPROF_ENGINE_PROF_ENGINE_H_
  13. #define MSVP_PROF_API __attribute__((visibility("default")))
  14. #include <map>
  15. #include <string>
  16. #include "prof_reporter.h"
  17. /**
  18. * @file prof_engine.h
  19. * @defgroup ModuleJobConfig the ModuleJobConfig group
  20. * This is the ModuleJobConfig group
  21. */
  22. namespace Msprof {
  23. namespace Engine {
  24. /**
  25. * @ingroup ModuleJobConfig
  26. * @brief struct ModuleJobConfig
  27. * record config info
  28. */
  29. struct ModuleJobConfig {
  30. std::map<std::string, std::string> switches; /**< key is the config name, value is the config value(on or off) */
  31. };
  32. /**
  33. * @defgroup PluginIntf the pluginInf group
  34. * This is the pluginInf group
  35. */
  36. /**
  37. * @ingroup PluginIntf
  38. * @brief class PluginIntf
  39. */
  40. class MSVP_PROF_API PluginIntf {
  41. public:
  42. virtual ~PluginIntf() {}
  43. public:
  44. /**
  45. * @ingroup PluginIntf
  46. * @name : Init
  47. * @brief : API of user plugin, libmsporf call this API to send a Reporter to user plugin
  48. * @par description :
  49. * API of user plugin, libmsporf call this API to send a Reporter to user plugin.
  50. * @param reporter [IN] const Reporter* the Reporter from libmsprof
  51. * @retval PROFILING_SUCCESS 0 (success)
  52. * @retval PROFILING_FAILED -1 (failed)
  53. *
  54. * @par depend:
  55. * @li libmsprof
  56. * @li prof_engine.h
  57. * @since c60
  58. * @see UnInit
  59. */
  60. virtual int Init(const Reporter *reporter) = 0;
  61. /**
  62. * @ingroup PluginIntf
  63. * @name : OnNewConfig
  64. * @brief : API of user plugin, libmsprof call this API to send config info to user plugin \n
  65. If the user plugin needn't config, no need to redefine this function
  66. * @param config [IN] const ModuleJobConfig * the config from libmsprof
  67. * @retval PROFILING_SUCCESS 0 (success)
  68. * @retval PROFILING_FAILED -1 (failed)
  69. *
  70. * @par depend:
  71. * @li libmsprof
  72. * @li prof_engine.h
  73. * @since c60
  74. * @see Init | UnInit
  75. */
  76. virtual int OnNewConfig(const ModuleJobConfig *config) = 0;
  77. /**
  78. * @ingroup PluginIntf
  79. * @name : UnInit
  80. * @brief : API of user plugin, libmsprof call this API to notify plugin stop to send data
  81. * @retval PROFILING_SUCCESS 0 (success)
  82. * @retval PROFILING_FAILED -1 (failed)
  83. *
  84. * @par depend:
  85. * @li libmsprof
  86. * @li prof_engine.h
  87. * @since c60
  88. * @see Init
  89. */
  90. virtual int UnInit() = 0;
  91. };
  92. /**
  93. * @defgroup EngineIntf the EngineIntf group
  94. * This is the EngineIntf group
  95. */
  96. /**
  97. * @ingroup EngineIntf
  98. * @brief class EngineIntf
  99. */
  100. class MSVP_PROF_API EngineIntf {
  101. public:
  102. virtual ~EngineIntf() {}
  103. public:
  104. /**
  105. * @ingroup EngineIntf
  106. * @name : CreatePlugin
  107. * @brief : API of user engine, libmsporf call this API to get a plugin
  108. * @retval PluginIntf * The pointer of the new plugin
  109. *
  110. * @par depend:
  111. * @li libmsprof
  112. * @li prof_engine.h
  113. * @since c60
  114. * @see ReleasePlugin
  115. */
  116. virtual PluginIntf *CreatePlugin() = 0;
  117. /**
  118. * @ingroup EngineIntf
  119. * @name : ReleasePlugin
  120. * @brief : API of user engine, libmsprof call this API to release a plugin
  121. * @param plugin [IN] PluginIntf * the plugin to release
  122. * @retval PROFILING_SUCCESS 0 (success)
  123. * @retval PROFILING_FAILED -1 (failed)
  124. *
  125. * @par depend:
  126. * @li libmsprof
  127. * @li prof_engine.h
  128. * @since c60
  129. * @see CreatePlugin
  130. */
  131. virtual int ReleasePlugin(PluginIntf *plugin) = 0;
  132. };
  133. /**
  134. * @defgroup EngineMgr the EngineMgr group
  135. * This is the EngineMgr group
  136. */
  137. /**
  138. * @ingroup EngineMgr
  139. * @name : RegisterEngine
  140. * @brief : API of libmsprof, register an engine with a name
  141. * @param module [IN] const std::string the name of plugin
  142. * @param engine [IN] const EngineIntf* the plugin
  143. * @retval PROFILING_SUCCESS 0 (success)
  144. * @retval PROFILING_FAILED -1 (failed)
  145. *
  146. * @par depend:
  147. * @li libmsprof
  148. * @li prof_engine.h
  149. * @since c60
  150. */
  151. MSVP_PROF_API int RegisterEngine(const std::string &module, const EngineIntf *engine);
  152. /**
  153. * @ingroup EngineMgr
  154. * @name : Init
  155. * @brief : API of libmsprof, init an engine with a name
  156. * @param module [IN] const std::string the name of plugin
  157. * @param module [IN] const EngineIntf* the plugin
  158. * @retval PROFILING_SUCCESS 0 (success)
  159. * @retval PROFILING_FAILED -1 (failed)
  160. *
  161. * @par depend:
  162. * @li libmsprof
  163. * @li prof_engine.h
  164. * @since c60
  165. * @see UnInit
  166. */
  167. MSVP_PROF_API int Init(const std::string &module, const EngineIntf *engine);
  168. /**
  169. * @ingroup EngineMgr
  170. * @name : Init
  171. * @brief : API of libmsprof, uninit an engine with a name
  172. * @param module [IN] const std::string the name of plugin
  173. * @retval PROFILING_SUCCESS 0 (success)
  174. * @retval PROFILING_FAILED -1 (failed)
  175. *
  176. * @par depend:
  177. * @li libmsprof
  178. * @li prof_engine.h
  179. * @since c60
  180. * @see Init
  181. */
  182. MSVP_PROF_API int UnInit(const std::string &module);
  183. } // namespace Engine
  184. } // namespace Msprof
  185. #endif // MSPROF_ENGINE_PROF_ENGINE_H_

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