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

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

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