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.

davinci_model.h 36 kB

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
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
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
4 years ago
4 years ago
5 years ago
4 years ago
5 years ago
5 years ago
4 years ago
4 years ago
4 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
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
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
4 years ago
4 years ago
5 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120
  1. /**
  2. * Copyright 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 GE_GRAPH_LOAD_NEW_MODEL_MANAGER_DAVINCI_MODEL_H_
  17. #define GE_GRAPH_LOAD_NEW_MODEL_MANAGER_DAVINCI_MODEL_H_
  18. #include <map>
  19. #include <memory>
  20. #include <set>
  21. #include <string>
  22. #include <thread>
  23. #include <vector>
  24. #include "framework/common/ge_types.h"
  25. #include "framework/common/helper/model_helper.h"
  26. #include "framework/common/helper/om_file_helper.h"
  27. #include "common/opskernel/ge_task_info.h"
  28. #include "common/properties_manager.h"
  29. #include "common/dump/exception_dumper.h"
  30. #include "common/dump/opdebug_register.h"
  31. #include "framework/common/types.h"
  32. #include "framework/common/util.h"
  33. #include "graph/debug/ge_attr_define.h"
  34. #include "graph/load/model_manager/aipp_utils.h"
  35. #include "common/dump/data_dumper.h"
  36. #include "graph/load/model_manager/data_inputer.h"
  37. #include "graph/load/model_manager/model_utils.h"
  38. #include "graph/load/model_manager/zero_copy_offset.h"
  39. #include "graph/load/model_manager/zero_copy_task.h"
  40. #include "graph/model.h"
  41. #include "graph/node.h"
  42. #include "graph/op_desc.h"
  43. #include "external/graph/operator.h"
  44. #include "graph/utils/attr_utils.h"
  45. #include "graph/utils/tensor_utils.h"
  46. #include "mmpa/mmpa_api.h"
  47. #include "proto/task.pb.h"
  48. #include "graph/load/model_manager/task_info/task_info.h"
  49. #include "common/local_context.h"
  50. using std::mutex;
  51. using std::thread;
  52. using std::multimap;
  53. namespace ge {
  54. // op debug need 2048 bits buffer
  55. const size_t kOpDebugMemorySize = 2048UL;
  56. const size_t kDebugP2pSize = 8UL;
  57. typedef enum tagModelProcStage {
  58. MODEL_LOAD_START = 1,
  59. MODEL_LOAD_END,
  60. MODEL_PRE_PROC_START,
  61. MODEL_PRE_PROC_END,
  62. MODEL_INFER_START,
  63. MODEL_INFER_END,
  64. MODEL_AFTER_PROC_START,
  65. MODEL_AFTER_PROC_END,
  66. MODEL_PROC_INVALID,
  67. } ModelProcStage;
  68. struct timeInfo {
  69. uint32_t modelId;
  70. int64_t processBeginTime;
  71. int64_t processEndTime;
  72. int64_t inferenceBeginTime;
  73. int64_t inferenceEndTime;
  74. int64_t dumpBeginTime;
  75. int64_t dumpEndTime;
  76. };
  77. // For super kernel
  78. struct SuperKernelTaskInfo {
  79. uint32_t last_block_dim;
  80. uint32_t last_args_size;
  81. uint32_t last_task_id;
  82. uint32_t last_stream_id;
  83. void *last_stream;
  84. void *last_sm_desc;
  85. vector<void *> kernel_list;
  86. vector<void *> arg_list;
  87. vector<uint32_t> dump_flag_list;
  88. vector<OpDescPtr> op_desc_list;
  89. vector<uintptr_t> dump_args_list;
  90. uint32_t last_dump_flag;
  91. int64_t last_group_key;
  92. uintptr_t last_dump_args;
  93. OpDescPtr last_op;
  94. };
  95. struct TaskMemInfo {
  96. int64_t input_size{0};
  97. int64_t output_size{0};
  98. int64_t weight_size{0};
  99. int64_t workspace_size{0};
  100. int64_t total_size{0};
  101. };
  102. struct ProfileInfo {
  103. FusionOpInfo fusion_info;
  104. TaskMemInfo memory_info;
  105. uint32_t task_count{0};
  106. };
  107. enum ExecuteMode {
  108. INITIALIZATION,
  109. SYNCHRONIZATION,
  110. ASYNCHRONIZATION,
  111. };
  112. // comments
  113. class DavinciModel {
  114. public:
  115. ///
  116. /// @ingroup ge
  117. /// @brief DavinciModel constructor
  118. /// @author
  119. ///
  120. DavinciModel(int32_t priority, const shared_ptr<ModelListener> &listener);
  121. ///
  122. /// @ingroup ge
  123. /// @brief DavinciModel desctructor, free Parse and Init resources
  124. /// @author
  125. ///
  126. ~DavinciModel();
  127. ///
  128. /// @ingroup ge
  129. /// @brief apply model to model_def_
  130. ///
  131. Status Assign(const GeModelPtr &ge_model);
  132. ///
  133. /// @ingroup ge
  134. /// @brief DavinciModel initialization, including Stream, ccHandle, Event, DataInputer, etc
  135. /// @return execute result
  136. /// @author
  137. ///
  138. Status Init(void *dev_ptr = nullptr, size_t memsize = 0, void *weight_ptr = nullptr, size_t weightsize = 0);
  139. ///
  140. /// @ingroup ge
  141. /// @brief ACL case, Load task list with queue.
  142. /// @param [in] input_que_ids: input queue ids from user, nums equal Data Op.
  143. /// @param [in] output_que_ids: input queue ids from user, nums equal NetOutput Op.
  144. /// @return: 0 for success / others for fail
  145. ///
  146. Status SetQueIds(const vector<uint32_t> &input_queue_ids, const vector<uint32_t> &output_queue_ids);
  147. ///
  148. /// @ingroup ge
  149. /// @brief Get DataInputer
  150. /// @return model ID
  151. ///
  152. uint32_t Id() const { return model_id_; }
  153. ///
  154. /// @ingroup ge
  155. /// @brief Get DataInputer
  156. /// @return model ID
  157. ///
  158. void SetId(uint32_t model_id) { model_id_ = model_id; }
  159. ///
  160. /// @ingroup ge
  161. /// @brief Get SubModelId
  162. /// @return sub model ID
  163. ///
  164. uint32_t SubModelId() const { return sub_model_id_; }
  165. ///
  166. /// @ingroup ge
  167. /// @brief Get SubModelId
  168. /// @return sub model ID
  169. ///
  170. void SetSubModelId(uint32_t sub_model_id) { sub_model_id_ = sub_model_id; }
  171. static void *Run(DavinciModel *model_pointer);
  172. ///
  173. /// @ingroup ge
  174. /// @brief NnExecute
  175. /// @param [in] stream execute stream
  176. /// @param [in] async_mode is asynchronize mode.
  177. /// @param [in] input_data model input data
  178. /// @param [out] output_data model output data
  179. ///
  180. Status NnExecute(rtStream_t stream, bool async_mode, const InputData &input_data, OutputData &output_data);
  181. ///
  182. /// @ingroup ge
  183. /// @brief lock mutex run flag
  184. /// @author
  185. ///
  186. void LockRunFlg() { mux_run_flg_.lock(); }
  187. ///
  188. /// @ingroup ge
  189. /// @brief unlock mutex run flag
  190. /// @author
  191. ///
  192. void UnlockRunFlg() { mux_run_flg_.unlock(); }
  193. ///
  194. /// @ingroup ge
  195. /// @brief get DataInputer
  196. /// @return DataInputer pointer
  197. ///
  198. DataInputer *const GetDataInputer() const { return data_inputer_; }
  199. uint32_t GetDataInputerSize() {
  200. GE_CHECK_NOTNULL(data_inputer_);
  201. return data_inputer_->Size();
  202. }
  203. // get Stream number
  204. uint32_t StreamNum() const { return runtime_param_.stream_num; }
  205. // get Event number
  206. uint32_t EventNum() const { return runtime_param_.event_num; }
  207. // get Lable number
  208. uint32_t LabelNum() const { return runtime_param_.label_num; }
  209. // get batch number
  210. uint32_t BatchNum() const { return runtime_param_.batch_num; }
  211. // get session id
  212. uint64_t SessionId() const { return runtime_param_.session_id; }
  213. // get model priority
  214. int32_t Priority() const { return priority_; }
  215. // get total mem size
  216. size_t TotalMemSize() const { return runtime_param_.mem_size; }
  217. ///
  218. /// @ingroup ge
  219. /// @brief Get total useful size, in known subgraph, no need to allocate zero copy memory during initialization.
  220. /// @param [in] total_useful_size: total mem size - zero copy size.
  221. /// @return Status
  222. ///
  223. Status GetTotalMemSizeExcludeZeroCopy(int64_t &total_useful_size);
  224. // model name
  225. string Name() const { return name_; }
  226. // om_name
  227. const string &OmName() const { return om_name_; }
  228. // dump_model_name
  229. const string &DumpModelName() const { return dump_model_name_; }
  230. // version
  231. uint32_t Version() const { return version_; }
  232. // get total weights mem size
  233. size_t TotalWeightsMemSize() const { return runtime_param_.weight_size; }
  234. size_t TotalVarMemSize() const { return runtime_param_.var_size; }
  235. // get base memory address
  236. uint8_t *MemBase() { return mem_base_; }
  237. // get weight base memory address
  238. uint8_t *WeightsMemBase() { return weights_mem_base_; }
  239. uint8_t *VarMemBase() { return var_mem_base_; }
  240. // get Event list
  241. const vector<rtEvent_t> &GetEventList() const { return event_list_; }
  242. const vector<rtStream_t> &GetStreamList() const { return stream_list_; }
  243. const vector<rtLabel_t> &GetLabelList() const { return label_list_; }
  244. uint64_t GetAllStreamNum() const { return stream_list_.size() + all_hccl_stream_list_.size(); }
  245. Status GetLabelGotoAddr(uint32_t label_index, rtMemType_t memory_type, void *&addr, uint32_t &size);
  246. Status DestroyThread();
  247. // get Op
  248. OpDescPtr GetOpByIndex(uint32_t index) const {
  249. if (op_list_.find(index) == op_list_.end()) {
  250. return nullptr;
  251. }
  252. return op_list_.at(index);
  253. }
  254. void SetGlobalStep(void *global_step, uint64_t global_step_size);
  255. void *GetGlobalStep() const { return global_step_addr_; }
  256. // get task info for profiling
  257. const vector<TaskDescInfo> &GetTaskDescInfo() const { return task_desc_info_; }
  258. // get updated task info list
  259. vector<TaskInfoPtr> GetTaskList() { return task_list_; }
  260. // Modified from KernelTaskInfo.
  261. SuperKernelTaskInfo &GetSuperKernelTaskInfo() { return skt_info_; }
  262. rtModel_t GetRtModelHandle() const { return rt_model_handle_; }
  263. rtStream_t GetRtModelStream() const { return rt_model_stream_; }
  264. uint64_t GetRtBaseAddr() const { return runtime_param_.logic_mem_base; }
  265. uint64_t GetRtWeightAddr() const { return runtime_param_.logic_weight_base; }
  266. uint64_t GetRtVarAddr() const { return runtime_param_.logic_var_base; }
  267. uint32_t GetFlowctrlIndex(uint32_t op_index);
  268. void PushHcclStream(rtStream_t value);
  269. bool IsBroadCastOpData(const NodePtr &var_node);
  270. ///
  271. /// @ingroup ge
  272. /// @brief For TVM Op, avoid Addr Reuse.
  273. /// @return void*
  274. ///
  275. const char *GetRegisterStub(const string &tvm_binfile_key, const string &session_graph_model_id = "");
  276. ///
  277. /// @ingroup ge
  278. /// @brief get model input and output desc info
  279. /// @param [out] input_shape model input size
  280. /// @param [out] output_shape model output size
  281. /// @return execute result
  282. ///
  283. Status GetInputOutputDescInfo(vector<InputOutputDescInfo> &input_desc, vector<InputOutputDescInfo> &output_desc);
  284. Status GetInputOutputDescInfo(vector<InputOutputDescInfo> &input_desc, vector<InputOutputDescInfo> &output_desc,
  285. vector<uint32_t> &input_formats, vector<uint32_t> &output_formats, bool by_dims);
  286. ///
  287. /// @ingroup ge
  288. /// @brief Get dynamic batch_info
  289. /// @param [out] batch_info
  290. /// @param [out] dynamic_type
  291. /// @return execute result
  292. ///
  293. Status GetDynamicBatchInfo(vector<vector<int64_t>> &batch_info, int32_t &dynamic_type) const;
  294. ///
  295. /// @ingroup ge
  296. /// @brief Get combined dynamic dims info
  297. /// @param [out] batch_info
  298. /// @return None
  299. ///
  300. void GetCombinedDynamicDims(vector<vector<int64_t>> &batch_info) const;
  301. void GetUserDesignateShapeOrder(vector<string> &user_input_shape_order) const;
  302. void GetCurShape(vector<int64_t> &batch_info, int32_t &dynamic_type) const;
  303. Status GetOpAttr(const std::string &op_name, const std::string &attr_name, std::string &attr_value) const;
  304. void GetModelAttr(vector<string> &dynamic_output_shape_info) const;
  305. ///
  306. /// @ingroup ge
  307. /// @brief Get AIPP input info
  308. /// @param [in] index
  309. /// @param [out] aipp_info
  310. /// @return execute result
  311. ///
  312. Status GetAippInfo(uint32_t index, AippConfigInfo &aipp_info) const;
  313. Status GetAippType(uint32_t index, InputAippType &type, size_t &aipp_index) const;
  314. ///
  315. /// @ingroup ge
  316. /// @brief Get model_id.
  317. /// @return model_id
  318. ///
  319. uint32_t GetModelId() const { return model_id_; }
  320. ///
  321. /// @ingroup ge
  322. /// @brief get unique identification for op when load two or more models
  323. /// @param [in] op_desc : current op.
  324. /// @param [in] string identification: unique identification for current op.
  325. /// @return None
  326. ///
  327. void GetUniqueId(const OpDescPtr &op_desc, string &unique_identification);
  328. Status ReturnResult(uint32_t data_id, const bool rslt_flg, const bool seq_end_flg, OutputData *output_data);
  329. Status ReturnNoOutput(uint32_t data_id);
  330. Status ModelRunStart();
  331. ///
  332. /// @ingroup ge
  333. /// @brief stop run model
  334. /// @return Status
  335. ///
  336. Status ModelRunStop();
  337. ///
  338. /// @ingroup ge
  339. /// @brief model run flag
  340. /// @return Status
  341. ///
  342. bool RunFlag() const { return run_flg_; }
  343. ///
  344. /// @ingroup ge
  345. /// @brief Set Session Id
  346. /// @return void
  347. ///
  348. void SetSessionId(uint64_t session_id) { session_id_ = session_id; }
  349. ///
  350. /// @ingroup ge
  351. /// @brief Get Session Id
  352. /// @return sessionID
  353. ///
  354. uint64_t GetSessionId() const { return session_id_; }
  355. const struct error_message::Context &GetErrorContext() const { return error_context_; }
  356. ///
  357. /// @ingroup ge
  358. /// @brief SetDeviceId
  359. /// @return void
  360. ///
  361. void SetDeviceId(uint32_t device_id) { device_id_ = device_id; }
  362. ///
  363. /// @ingroup ge
  364. /// @brief Get device Id
  365. /// @return device id
  366. ///
  367. uint32_t GetDeviceId() const { return device_id_; }
  368. bool NeedDestroyAicpuKernel() const { return need_destroy_aicpu_kernel_; }
  369. Status UpdateSessionId(uint64_t session_id);
  370. const RuntimeParam &GetRuntimeParam() { return runtime_param_; }
  371. int32_t GetDataInputTid() const { return dataInputTid; }
  372. void SetDataInputTid(int32_t data_input_tid) { dataInputTid = data_input_tid; }
  373. void DisableZeroCopy(const void *addr);
  374. bool GetOpDugReg() const { return is_op_debug_reg_; }
  375. ///
  376. /// @ingroup ge
  377. /// @brief Save outside address of Data or NetOutput used info for ZeroCopy.
  378. /// @param [in] const OpDescPtr &op_desc: current op desc
  379. /// @param [in] const vector<void *> &outside_addrs: address of task
  380. /// @param [in] const void *args_offset: arguments address save the address.
  381. /// @return None.
  382. ///
  383. void SetZeroCopyAddr(const OpDescPtr &op_desc, const vector<void *> &outside_addrs, const void *info, void *args,
  384. size_t size, size_t offset);
  385. void SetDynamicSize(const vector<uint64_t> &batch_num, int32_t dynamic_type);
  386. bool GetL1FusionEnableOption() { return is_l1_fusion_enable_; }
  387. void SetProfileTime(ModelProcStage stage, int64_t endTime = 0);
  388. int64_t GetLoadBeginTime() { return load_begin_time_; }
  389. int64_t GetLoadEndTime() { return load_end_time_; }
  390. void SaveSpecifyAttrValues(const OpDescPtr &op_desc);
  391. Status ReportProfilingData();
  392. void SaveDumpOpInfo(const RuntimeParam &model_param, const OpDescPtr &op, uint32_t task_id, uint32_t stream_id) {
  393. exception_dumper_.SaveDumpOpInfo(model_param, op, task_id, stream_id);
  394. }
  395. void SaveDumpTask(uint32_t task_id, uint32_t stream_id, const shared_ptr<OpDesc> &op_desc, uintptr_t args) {
  396. data_dumper_.SaveDumpTask(task_id, stream_id, op_desc, args);
  397. }
  398. Status DumpExceptionInfo(const std::vector<rtExceptionInfo> &exception_infos) const {
  399. return exception_dumper_.DumpExceptionInfo(exception_infos);
  400. }
  401. void DumperShrink() {
  402. data_dumper_.DumpShrink();
  403. }
  404. bool OpNeedDump(const string &op_name) {
  405. return GetDumpProperties().IsLayerNeedDump(dump_model_name_, om_name_, op_name);
  406. }
  407. bool ModelNeedDump();
  408. void SetEndGraphId(uint32_t task_id, uint32_t stream_id);
  409. DavinciModel &operator=(const DavinciModel &model) = delete;
  410. DavinciModel(const DavinciModel &model) = delete;
  411. const map<int64_t, vector<rtStream_t>> &GetHcclFolowStream() {
  412. return main_follow_stream_mapping_;
  413. }
  414. void SaveHcclFollowStream(int64_t main_stream_id, rtStream_t stream);
  415. void InitRuntimeParams();
  416. Status InitVariableMem();
  417. void UpdateMemBase(uint8_t *mem_base) {
  418. runtime_param_.mem_base = mem_base;
  419. mem_base_ = mem_base;
  420. }
  421. void SetTotalArgsSize(uint32_t args_size) { total_args_size_ += args_size; }
  422. uint32_t GetTotalArgsSize() { return total_args_size_; }
  423. void *GetCurrentArgsAddr(uint32_t offset) {
  424. void *cur_args = static_cast<char *>(args_) + offset;
  425. return cur_args;
  426. }
  427. void SetTotalIOAddrs(const vector<void *> &io_addrs);
  428. void SetHybridArgsSize(uint32_t args_size) { total_hybrid_args_size_ += args_size; }
  429. uint32_t GetHybridArgsSize() {
  430. return total_hybrid_args_size_;
  431. }
  432. void *GetCurrentHybridArgsAddr(uint32_t offset) {
  433. void *cur_args = static_cast<char *>(hybrid_addrs_) + offset;
  434. return cur_args;
  435. }
  436. void SetTotalFixedAddrsSize(string tensor_name, int64_t fix_addr_size);
  437. int64_t GetFixedAddrsSize(string tensor_name);
  438. void *GetCurrentFixedAddr(int64_t offset) const {
  439. void *cur_addr = static_cast<char *>(fixed_addrs_) + offset;
  440. return cur_addr;
  441. }
  442. uint32_t GetFixedAddrOutputIndex(string tensor_name) {
  443. if (tensor_name_to_peer_output_index_.find(tensor_name) != tensor_name_to_peer_output_index_.end()) {
  444. return tensor_name_to_peer_output_index_[tensor_name];
  445. }
  446. return UINT32_MAX;
  447. }
  448. void SetKnownNode(bool known_node) { known_node_ = known_node; }
  449. bool IsKnownNode() { return known_node_; }
  450. Status MallocKnownArgs();
  451. Status CheckCapability(rtFeatureType_t featureType, int32_t featureInfo, bool &is_support) const;
  452. Status UpdateKnownNodeArgs(const vector<void *> &inputs, const vector<void *> &outputs);
  453. Status CreateKnownZeroCopyMap(const vector<void *> &inputs, const vector<void *> &outputs);
  454. Status UpdateKnownZeroCopyAddr(vector<void *> &total_io_addrs, bool update_args = true);
  455. Status GetOrigInputInfo(uint32_t index, OriginInputInfo &orig_input_info) const;
  456. Status GetAllAippInputOutputDims(uint32_t index, vector<InputOutputDims> &input_dims,
  457. vector<InputOutputDims> &output_dims) const;
  458. // om file name
  459. void SetOmName(const string &om_name) { om_name_ = om_name; }
  460. void SetDumpModelName(const string &dump_model_name) { dump_model_name_ = dump_model_name; }
  461. void SetDumpProperties(const DumpProperties &dump_properties) { data_dumper_.SetDumpProperties(dump_properties); }
  462. const DumpProperties &GetDumpProperties() const { return data_dumper_.GetDumpProperties(); }
  463. bool GetOpDescInfo(uint32_t stream_id, uint32_t task_id, OpDescInfo &op_desc_info) const {
  464. return exception_dumper_.GetOpDescInfo(stream_id, task_id, op_desc_info);
  465. }
  466. void UpdateOpIOAddrs(uint32_t task_id, uint32_t stream_id, const std::vector<void *> &io_addrs);
  467. bool GetRunningFlag() const { return running_flg_; }
  468. void SetRunningFlag(bool flag) { running_flg_ = flag; }
  469. Status SetRunAsyncListenerCallback(const RunAsyncCallback &callback);
  470. // for blocking aicpu op
  471. Status GetEventByStream(const rtStream_t &stream, rtEvent_t &rt_event);
  472. Status GetEventIdForBlockingAicpuOp(const OpDescPtr &op_desc, rtStream_t stream, uint32_t &event_id);
  473. private:
  474. // memory address of weights
  475. uint8_t *weights_mem_base_;
  476. uint8_t *var_mem_base_;
  477. // memory address of model
  478. uintptr_t fixed_mem_base_; // Initial of mem_base_, keep forever.
  479. uint8_t *mem_base_;
  480. bool is_inner_mem_base_;
  481. bool is_inner_weight_base_;
  482. // input data manager
  483. DataInputer *data_inputer_;
  484. int64_t load_begin_time_;
  485. int64_t load_end_time_;
  486. struct timeInfo time_info_;
  487. int32_t dataInputTid;
  488. void *GetRunAddress(void *addr) const;
  489. ///
  490. /// @ingroup ge
  491. /// @brief Copy Check input size and model op size.
  492. /// @param [in] const int64_t &input_size: input size.
  493. /// @param [in] const int64_t &op_size: model op size.
  494. /// @param [in] is_dynamic: dynamic batch input flag.
  495. /// @return true if success
  496. ///
  497. bool CheckUserAndModelSize(const int64_t &size, const int64_t &op_size, bool is_input, bool is_dynamic);
  498. ///
  499. /// @ingroup ge
  500. /// @brief Set copy only for No task feed NetOutput address.
  501. /// @return None.
  502. ///
  503. void SetCopyOnlyOutput();
  504. ///
  505. /// @ingroup ge
  506. /// @brief Copy Input/Output to model for direct use.
  507. /// @param [in] const InputData &input_data: user input data info.
  508. /// @param [in/out] OutputData &output_data: user output data info.
  509. /// @param [in] bool is_dynamic: whether is dynamic input, true: is dynamic input; false: not is dynamic input
  510. /// @return SUCCESS handle successfully / others handle failed
  511. ///
  512. Status CopyModelData(const InputData &input_data, OutputData &output_data, bool is_dynamic);
  513. ///
  514. /// @ingroup ge
  515. /// @brief Copy Data addr to model for direct use.
  516. /// @param [in] data_info: model memory addr/size map { data_index, { tensor_size, tensor_addr } }.
  517. /// @param [in] is_input: input data or output data
  518. /// @param [in] blobs: user input/output data list.
  519. /// @param [in] is_dynamic: whether is dynamic input, true: is dynamic input; false: not is dynamic input
  520. /// @param [in] batch_label: batch label for multi-batch scenes
  521. /// @return SUCCESS handle successfully / others handle failed
  522. ///
  523. Status UpdateIoTaskArgs(const map<uint32_t, ZeroCopyOffset> &data_info, bool is_input,
  524. const vector<DataBuffer> &blobs, bool is_dynamic, const string &batch_label);
  525. Status CopyInputData(const InputData &input_data);
  526. Status CopyOutputData(uint32_t data_id, OutputData &output_data, rtMemcpyKind_t kind);
  527. Status SyncVarData();
  528. Status InitWeightMem(void *dev_ptr, void *weight_ptr, size_t weight_size);
  529. Status InitFeatureMapAndP2PMem(void *dev_ptr, size_t mem_size);
  530. void CreateInputDimsInfo(const OpDescPtr &op_desc, Format format, ShapeDescription &shape1, ShapeDescription &shape2);
  531. void SetInputDimsInfo(const vector<int64_t> &input_dims, Format &format, ShapeDescription &shape_info);
  532. Status GetInputDescInfo(vector<InputOutputDescInfo> &input_desc, vector<uint32_t> &input_formats, bool by_dims) const;
  533. Status GetOutputDescInfo(vector<InputOutputDescInfo> &output_desc, vector<uint32_t> &output_formats) const;
  534. Status InitTaskInfo(domi::ModelTaskDef &modelTaskInfo);
  535. void UnbindHcomStream();
  536. Status DistributeTask();
  537. void SaveProfilingTaskDescInfo(const OpDescPtr &op, const TaskInfoPtr &task,
  538. const domi::TaskDef &task_def, size_t task_index);
  539. uint8_t *MallocFeatureMapMem(size_t data_size);
  540. uint8_t *MallocWeightsMem(size_t weights_size);
  541. Status MallocExMem();
  542. void FreeFeatureMapMem();
  543. void FreeWeightsMem();
  544. void FreeExMem();
  545. void ReleaseTask();
  546. void ClearTaskAddrs();
  547. void UnbindTaskSinkStream();
  548. bool IsAicpuKernelConnectSpecifiedLayer();
  549. ///
  550. /// @ingroup ge
  551. /// @brief Reduce memory usage after task sink.
  552. /// @return: void
  553. ///
  554. void Shrink();
  555. ///
  556. /// @ingroup ge
  557. /// @brief Travel all nodes and do some init.
  558. /// @param [in] compute_graph: ComputeGraph to load.
  559. /// @return Status
  560. ///
  561. Status InitNodes(const ComputeGraphPtr &compute_graph);
  562. ///
  563. /// @ingroup ge
  564. /// @brief Data Op Initialize.
  565. /// @param [in] ComputeGraphPtr: root graph of the model.
  566. /// @param [in] NodePtr: Data Op.
  567. /// @param [in/out] data_op_index: index of courrent count.
  568. /// @param [in/out] data_by_index: Data ordered by index.
  569. /// @return Status
  570. ///
  571. Status InitDataOp(const ComputeGraphPtr &graph, const NodePtr &node, uint32_t &data_op_index,
  572. map<uint32_t, OpDescPtr> &data_by_index, set<const void *> &input_outside_addrs);
  573. ///
  574. /// @ingroup ge
  575. /// @brief Sort Data op list by index.
  576. /// @param [in] data_by_index: map of Data Op.
  577. /// @param [in] output_op_list: list of NetOutput op.
  578. /// @return Status
  579. ///
  580. Status GenInputOutputInfo(const map<uint32_t, OpDescPtr> &data_by_index, const vector<OpDescPtr> &output_op_list);
  581. ///
  582. /// @ingroup ge
  583. /// @brief NetOutput Op Initialize.
  584. /// @param [in] ComputeGraphPtr: root graph of the model.
  585. /// @param [in] NodePtr: NetOutput Op.
  586. /// @param [in/out] vector<OpDescPtr>: All NetOutput node in model.
  587. /// @return Status
  588. ///
  589. Status InitNetOutput(const ComputeGraphPtr &graph, const NodePtr &node, vector<OpDescPtr> &output_op_list,
  590. set<const void *> &output_outside_addrs);
  591. ///
  592. /// @ingroup ge
  593. /// @brief Constant Op Init.
  594. /// @return Status
  595. ///
  596. Status InitConstant(const OpDescPtr &op_desc);
  597. Status InitVariable(const OpDescPtr &op_desc, map<string, OpDescPtr> &variable_by_name);
  598. /// @ingroup ge
  599. /// @brief LabelSet Op Initialize.
  600. /// @param [in] op_desc: LabelSet Op descriptor.
  601. /// @return Status
  602. Status InitLabelSet(const OpDescPtr &op_desc);
  603. Status InitStreamSwitch(const OpDescPtr &op_desc);
  604. Status InitStreamActive(const OpDescPtr &op_desc);
  605. Status InitStreamSwitchN(const OpDescPtr &op_desc);
  606. ///
  607. /// @ingroup ge
  608. /// @brief Case Op Init.
  609. /// @return Status
  610. ///
  611. Status InitCase(const OpDescPtr &op_desc);
  612. Status SetDynamicBatchInfo(const OpDescPtr &op_desc, uint32_t batch_num);
  613. ///
  614. /// @ingroup ge
  615. /// @brief TVM Op Init.
  616. /// @return Status
  617. ///
  618. Status InitTbeHandle(const OpDescPtr &op_desc);
  619. Status InitTbeHandleWithFfts(const OpDescPtr &op_desc);
  620. Status FunctionRegister(const OpDescPtr &op_desc, string &bin_file, OpKernelBinPtr &tbe_kernel, bool is_ffts,
  621. size_t thread_index = 0);
  622. Status InitBinaryMagic(const OpDescPtr &op_desc, bool is_ffts, size_t thread_index, rtDevBinary_t &binary);
  623. Status InitMetaData(const OpDescPtr &op_desc, bool is_ffts, size_t thread_index, void *bin_handle);
  624. Status InitKernelName(const OpDescPtr &op_desc, bool is_ffts, size_t thread_index, string &kernel_name);
  625. void StoreTbeHandle(const string &handle_key);
  626. void CleanTbeHandle();
  627. ///
  628. /// @ingroup ge
  629. /// @brief Make active stream list and bind to model.
  630. /// @return: 0 for success / others for fail
  631. ///
  632. Status BindModelStream();
  633. ///
  634. /// @ingroup ge
  635. /// @brief Init model stream for NN model.
  636. /// @return Status
  637. ///
  638. Status InitModelStream(rtStream_t stream);
  639. ///
  640. /// @ingroup ge
  641. /// @brief ACL, Load task list with queue entrance.
  642. /// @return: 0 for success / others for fail
  643. ///
  644. Status LoadWithQueue();
  645. ///
  646. /// @ingroup ge
  647. /// @brief ACL, Bind Data Op addr to input queue.
  648. /// @return: 0 for success / others for fail
  649. ///
  650. Status BindInputQueue();
  651. Status CpuTaskModelZeroCopy(vector<uintptr_t> &mbuf_list, const map<uint32_t, ZeroCopyOffset> &outside_addrs);
  652. ///
  653. /// @ingroup ge
  654. /// @brief ACL, Bind NetOutput Op addr to output queue.
  655. /// @return: 0 for success / others for fail
  656. ///
  657. Status BindOutputQueue();
  658. Status CpuModelPrepareOutput(uintptr_t addr, uint32_t size);
  659. ///
  660. /// @ingroup ge
  661. /// @brief definiteness queue schedule, bind input queue to task.
  662. /// @param [in] queue_id: input queue id from user.
  663. /// @param [in] addr: Data Op output tensor address.
  664. /// @param [in] size: Data Op output tensor size.
  665. /// @return: 0 for success / others for fail
  666. ///
  667. Status CpuModelDequeue(uint32_t queue_id);
  668. ///
  669. /// @ingroup ge
  670. /// @brief definiteness queue schedule, bind output queue to task.
  671. /// @param [in] queue_id: output queue id from user.
  672. /// @param [in] addr: NetOutput Op input tensor address.
  673. /// @param [in] size: NetOutput Op input tensor size.
  674. /// @return: 0 for success / others for fail
  675. ///
  676. Status CpuModelEnqueue(uint32_t queue_id, uintptr_t addr, uint32_t size);
  677. ///
  678. /// @ingroup ge
  679. /// @brief definiteness queue schedule, active original model stream.
  680. /// @return: 0 for success / others for fail
  681. ///
  682. Status CpuActiveStream();
  683. ///
  684. /// @ingroup ge
  685. /// @brief definiteness queue schedule, wait for end graph.
  686. /// @return: 0 for success / others for fail
  687. ///
  688. Status CpuWaitEndGraph();
  689. Status BindEnqueue();
  690. Status CpuModelEnqueue(uint32_t queue_id, uintptr_t out_mbuf);
  691. ///
  692. /// @ingroup ge
  693. /// @brief definiteness queue schedule, repeat run model.
  694. /// @return: 0 for success / others for fail
  695. ///
  696. Status CpuModelRepeat();
  697. Status InitEntryTask();
  698. Status AddHeadStream();
  699. ///
  700. /// @ingroup ge
  701. /// @brief set ts device.
  702. /// @return: 0 for success / others for fail
  703. ///
  704. Status SetTSDevice();
  705. Status OpDebugRegister();
  706. void OpDebugUnRegister();
  707. void CheckHasHcomOp(const ComputeGraphPtr &graph);
  708. Status DoTaskSink();
  709. void CreateOutput(uint32_t index, const OpDescPtr &op_desc, InputOutputDescInfo &output, uint32_t &format_result);
  710. Status TransAllVarData(ComputeGraphPtr &graph, uint32_t graph_id);
  711. void SetDataDumperArgs(const ComputeGraphPtr &graph, const map<string, OpDescPtr> &variable_by_name);
  712. Status InitL1DataDumperArgs();
  713. Status InitModelProfile();
  714. Status SinkModelProfile();
  715. Status SinkTimeProfile(const InputData &current_data);
  716. Status InitOutputTensorInfo(const OpDescPtr &op_desc);
  717. Status GenOutputTensorInfo(OutputData *output_data, vector<ge::Tensor> &outputs);
  718. Status InitInputDescInfo(const OpDescPtr &op_desc);
  719. Status InitOutputDescInfo(const OpDescPtr &op_desc, const vector<string> &out_node_name);
  720. Status InitOrigInputInfo(uint32_t index, const OpDescPtr &op_desc);
  721. Status InitAippInfo(uint32_t index, const OpDescPtr &op_desc);
  722. Status InitAippType(uint32_t index, const OpDescPtr &op_desc, const map<uint32_t, OpDescPtr> &data_list);
  723. Status InitAippInputOutputDims(uint32_t index, const OpDescPtr &op_desc);
  724. void ParseAIPPInfo(string in_out_info, InputOutputDims &dims_info);
  725. void SetLabelForDynamic(const NodePtr &node);
  726. void ParseDynamicOutShape(const vector<string> &str_info, vector<vector<int64_t>> &vec_info);
  727. bool IsGetNextSinkDynamic(const OpDescPtr &op_desc);
  728. Status InitRealSizeAndShapeInfo(const ComputeGraphPtr &compute_graph, const NodePtr &node);
  729. void GetAllGearsInfo(const NodePtr &node);
  730. Status GetGetDynamicDimsNodeInfo(const NodePtr &node);
  731. Status GetGearAndRealOutSizeInfo(const ComputeGraphPtr &graph, const NodePtr &node);
  732. Status GetRealOutputSizeOfCase(const ComputeGraphPtr &graph, size_t input_index, const NodePtr &case_node);
  733. Status GetGearAndRealOutShapeInfo(const ComputeGraphPtr &graph, const NodePtr &node);
  734. bool is_weight_mem_has_inited_;
  735. bool is_feature_map_mem_has_inited_;
  736. uint32_t model_id_;
  737. uint32_t runtime_model_id_;
  738. uint32_t sub_model_id_ = 0;
  739. string name_;
  740. // used for inference data dump
  741. string om_name_;
  742. string dump_model_name_;
  743. uint32_t version_;
  744. GeModelPtr ge_model_; // release after DavinciModel::Init
  745. bool need_destroy_aicpu_kernel_{false};
  746. map<uint32_t, OpDescPtr> op_list_; // release after DavinciModel::Init
  747. map<string, GeTensorDesc> broadcast_variable_;
  748. void *global_step_addr_{nullptr};
  749. uint64_t global_step_size_{0};
  750. map<uint32_t, ZeroCopyOffset> input_data_info_;
  751. map<uint32_t, ZeroCopyOffset> output_data_info_;
  752. set<const void *> real_virtual_addrs_;
  753. // output op: save cce op actual needed memory size
  754. vector<int64_t> output_memory_size_list_;
  755. thread thread_id_;
  756. shared_ptr<ModelListener> listener_;
  757. bool run_flg_;
  758. // check whether model is running with data
  759. bool running_flg_ = false;
  760. mutex mux_run_flg_;
  761. int32_t priority_;
  762. vector<rtStream_t> stream_list_;
  763. mutex all_hccl_stream_list_mutex_;
  764. vector<rtStream_t> all_hccl_stream_list_;
  765. // for reuse hccl_follow_stream
  766. mutex capacity_of_stream_mutex_;
  767. map<int64_t, vector<rtStream_t>> main_follow_stream_mapping_;
  768. vector<rtEvent_t> event_list_;
  769. vector<rtLabel_t> label_list_;
  770. set<uint32_t> label_id_indication_;
  771. mutex label_args_mutex_;
  772. map<uint32_t, pair<void *, uint32_t>> label_goto_args_;
  773. mutex outside_addrs_mutex_;
  774. vector<ZeroCopyTask> zero_copy_tasks_; // Task used Data or NetOutput addr.
  775. set<const void *> copy_only_addrs_; // Address need copy to original place.
  776. vector<TaskInfoPtr> task_list_;
  777. // rt_moodel_handle
  778. rtModel_t rt_model_handle_;
  779. rtStream_t rt_model_stream_;
  780. bool is_inner_model_stream_;
  781. bool is_async_mode_; // For NN execute, Async mode use rtMemcpyAsync on rt_model_stream_.
  782. ExecuteMode last_execute_mode_;
  783. bool is_stream_list_bind_{false};
  784. bool is_pure_head_stream_{false};
  785. rtStream_t rt_head_stream_{nullptr};
  786. rtStream_t rt_entry_stream_{nullptr};
  787. rtAicpuDeployType_t deploy_type_{AICPU_DEPLOY_RESERVED};
  788. // ACL queue schedule, save queue ids for Init.
  789. vector<TaskInfoPtr> cpu_task_list_;
  790. vector<uint32_t> input_queue_ids_; // input queue ids created by caller.
  791. vector<uint32_t> output_queue_ids_; // output queue ids created by caller.
  792. vector<uintptr_t> input_mbuf_list_; // input mbuf created by dequeue task.
  793. vector<uintptr_t> output_mbuf_list_; // output mbuf created by dequeue task.
  794. uint64_t session_id_;
  795. struct error_message::Context error_context_;
  796. uint32_t device_id_;
  797. mutex flowctrl_op_index_internal_map_mutex_;
  798. map<uint32_t, uint32_t> flowctrl_op_index_internal_map_;
  799. vector<rtStream_t> active_stream_list_;
  800. set<uint32_t> active_stream_indication_;
  801. set<uint32_t> hcom_streams_;
  802. RuntimeParam runtime_param_;
  803. static mutex tvm_bin_mutex_;
  804. set<string> tvm_bin_kernel_;
  805. map<string, uint32_t> used_tbe_handle_map_;
  806. // for profiling task and graph info
  807. vector<TaskDescInfo> task_desc_info_;
  808. std::map<std::string, std::pair<uint32_t, uint32_t>> profiler_report_op_info_;
  809. int64_t maxDumpOpNum_;
  810. // for data dump
  811. DataDumper data_dumper_;
  812. ExceptionDumper exception_dumper_;
  813. OpdebugRegister opdebug_register_;
  814. uint64_t iterator_count_;
  815. bool is_l1_fusion_enable_;
  816. map<OpDescPtr, void *> saved_task_addrs_; // release after DavinciModel::Init
  817. void *l1_fusion_addr_ = nullptr;
  818. bool known_node_ = false;
  819. uint32_t total_args_size_ = 0;
  820. void *args_ = nullptr;
  821. void *args_host_ = nullptr;
  822. void *fixed_addrs_ = nullptr;
  823. void *hybrid_addrs_ = nullptr;
  824. uint32_t total_hybrid_args_size_ = 0;
  825. int64_t total_fixed_addr_size_ = 0;
  826. map<const void *, void *> known_input_data_info_;
  827. map<const void *, void *> known_output_data_info_;
  828. vector<void *> total_io_addrs_;
  829. vector<vector<int64_t>> batch_info_;
  830. vector<vector<int64_t>> combined_batch_info_;
  831. vector<string> user_designate_shape_order_;
  832. int32_t dynamic_type_ = 0;
  833. bool is_dynamic_ = false;
  834. vector<uint64_t> batch_size_;
  835. // key: input tensor name, generally rts op;
  836. // value: the fixed addr of input anchor, same as the peer output anchor addr of the peer op
  837. map<string, int64_t> tensor_name_to_fixed_addr_size_;
  838. // key: input tensor name, generally rts op; value: the peer output anchor of the peer op
  839. map<string, int64_t> tensor_name_to_peer_output_index_;
  840. // if model is first execute
  841. bool is_first_execute_;
  842. // for op debug
  843. mutex debug_reg_mutex_;
  844. bool is_op_debug_reg_ = false;
  845. bool is_online_infer_dynamic_ = false;
  846. bool is_getnext_sink_dynamic_ = false;
  847. vector<int32_t> cur_dynamic_dims_;
  848. void *netoutput_last_input_addr_ = nullptr;
  849. int64_t netoutput_last_input_size_ = 0;
  850. size_t shape_of_cur_dynamic_dims_ = 0;
  851. // key: input_index: input is merge node; value: each gear info and each output size
  852. map<size_t, map<vector<int32_t>, int64_t>> merge_nodes_gear_and_real_out_size_info_;
  853. // key: input_index: input is merge node; value: each gear info and each output shape
  854. map<size_t, map<vector<int32_t>, vector<int64_t>>> merge_nodes_gear_and_real_out_shape_info_;
  855. vector<vector<int32_t>> all_gears_info_;
  856. multimap<uint32_t, uint32_t> op_id_map_;
  857. vector<ProfileInfo> profile_list_;
  858. // For super kernel.
  859. SuperKernelTaskInfo skt_info_;
  860. bool has_output_node_ = false;
  861. bool is_dynamic_aipp_ = false;
  862. vector<string> dynamic_output_shape_info_;
  863. vector<vector<void *>> input_addrs_list_;
  864. vector<vector<void *>> output_addrs_list_;
  865. vector<int64_t> output_buffer_size_;
  866. vector<GeShape> output_shape_info_;
  867. map<uint32_t, OriginInputInfo> orig_input_info_;
  868. map<uint32_t, AippConfigInfo> aipp_info_list_;
  869. map<uint32_t, pair<InputAippType, size_t>> aipp_type_list_;
  870. map<uint32_t, pair<vector<InputOutputDims>, vector<InputOutputDims>>> aipp_dims_info_;
  871. vector<InputOutputDescInfo> input_descs_;
  872. vector<InputOutputDescInfo> input_descs_dims_;
  873. vector<uint32_t> input_formats_;
  874. vector<InputOutputDescInfo> output_descs_;
  875. vector<uint32_t> output_formats_;
  876. // op name to attrs mapping
  877. std::map<std::string, std::map<std::string, std::vector<std::string>>> op_name_to_attrs_;
  878. std::map<rtStream_t, rtEvent_t> stream_2_event_;
  879. };
  880. } // namespace ge
  881. #endif // GE_GRAPH_LOAD_NEW_MODEL_MANAGER_DAVINCI_MODEL_H_

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