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.

runtime_model.cc 18 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
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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  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. #include "ge_runtime/runtime_model.h"
  17. #include <set>
  18. #include "./model_context.h"
  19. #include "./task/task.h"
  20. #include "common/ge_inner_error_codes.h"
  21. #include "common/types.h"
  22. #include "common/util.h"
  23. #include "framework/common/debug/ge_log.h"
  24. #include "framework/common/op/op_parser_util.h"
  25. #include "graph/types.h"
  26. #include "task/task_factory.h"
  27. namespace ge {
  28. namespace model_runner {
  29. namespace {
  30. const int kOffsetUnit = 8;
  31. const uint32_t kStringHeadElems = 2;
  32. } // namespace
  33. RuntimeModel::~RuntimeModel() {
  34. GELOGI("RuntimeModel destructor start");
  35. // Unbind rtModel from all task related streams
  36. RtModelUnbindStream();
  37. // Release task first, hccl task hold stream
  38. task_list_.clear();
  39. // Release all task related streams
  40. RtStreamDestory();
  41. // Release rtlabel resource
  42. RtLabelDestory();
  43. // Release rtEvent resourece
  44. RtEventDestory();
  45. GELOGI("Do RtModelDestory");
  46. // Release all rt_model
  47. RtModelDestory();
  48. }
  49. bool RuntimeModel::InitStream(std::shared_ptr<DavinciModel> &davinci_model) {
  50. if (davinci_model == nullptr) {
  51. GELOGE(PARAM_INVALID, "Davinci model is null.");
  52. return false;
  53. }
  54. std::set<int64_t> wait_active_streams;
  55. std::set<int64_t> force_copy_streams;
  56. for (const auto &stream_id : davinci_model->GetWaitActiveStreams()) {
  57. GELOGI("stream id %u is wait active stream.", stream_id);
  58. (void)wait_active_streams.insert(stream_id);
  59. }
  60. for (const auto &stream_id : davinci_model->GetForceCopyStreams()) {
  61. GELOGI("stream id %u is force copy stream.", stream_id);
  62. (void)force_copy_streams.insert(stream_id);
  63. }
  64. GELOGI("stream number:%u", davinci_model->GetStreamNum());
  65. for (uint32_t i = 0; i < davinci_model->GetStreamNum(); ++i) {
  66. rtStream_t stream = nullptr;
  67. uint32_t flag = (force_copy_streams.find(i) != force_copy_streams.end())
  68. ? (RT_STREAM_PERSISTENT | RT_STREAM_FORCE_COPY)
  69. : (RT_STREAM_PERSISTENT);
  70. rtError_t rt_ret = rtStreamCreateWithFlags(&stream, davinci_model->GetPriority(), flag);
  71. if (rt_ret != RT_ERROR_NONE) {
  72. GELOGE(RT_FAILED, "Call rt api rtStreamCreate failed, ret: 0x%X", rt_ret);
  73. return false;
  74. }
  75. GELOGI("rtStreamCreateWithFlags end.");
  76. stream_list_.emplace_back(stream);
  77. // Bind rt_model_handle_ to all task related streams
  78. flag = (wait_active_streams.find(i) != wait_active_streams.end()) ? (static_cast<uint32_t>(RT_INVALID_FLAG))
  79. : (static_cast<uint32_t>(RT_HEAD_STREAM));
  80. rt_ret = rtModelBindStream(rt_model_handle_, stream, flag);
  81. if (rt_ret != RT_ERROR_NONE) {
  82. GELOGE(RT_FAILED, "Call rt api rtModelBindStream failed, ret: 0x%X", rt_ret);
  83. return false;
  84. }
  85. GELOGI("stream index:%u, stream:%p.", i, stream);
  86. }
  87. return true;
  88. }
  89. bool RuntimeModel::InitEvent(uint32_t event_num) {
  90. GELOGI("event number:%u.", event_num);
  91. for (uint32_t i = 0; i < event_num; ++i) {
  92. rtEvent_t rt_event;
  93. rtError_t rt_ret = rtEventCreate(&rt_event);
  94. if (rt_ret != RT_ERROR_NONE) {
  95. GELOGE(RT_FAILED, "Call rt api rtEventCreate failed, i; %u; ret: 0x%X", i, rt_ret);
  96. return false;
  97. }
  98. event_list_.push_back(rt_event);
  99. }
  100. return true;
  101. }
  102. bool RuntimeModel::InitLabel(std::shared_ptr<DavinciModel> &davinci_model) {
  103. GELOGI("batch number:%u.", davinci_model->GetBatchNum());
  104. label_list_.resize(davinci_model->GetBatchNum());
  105. for (auto &task_info : davinci_model->GetTaskInfoList()) {
  106. if (task_info == nullptr) {
  107. GELOGE(PARAM_INVALID, "task_info is null.");
  108. continue;
  109. }
  110. if (task_info->type() != TaskInfoType::LABEL_SET) {
  111. continue;
  112. }
  113. auto label_set_task_info = std::static_pointer_cast<LabelSetTaskInfo>(task_info);
  114. if (label_set_task_info->stream_id() >= stream_list_.size()) {
  115. GELOGE(PARAM_INVALID, "Invalid stream id.");
  116. return false;
  117. }
  118. rtLabel_t rt_label = nullptr;
  119. rtError_t rt_ret = rtLabelCreateEx(&rt_label, stream_list_[label_set_task_info->stream_id()]);
  120. if (rt_ret != RT_ERROR_NONE) {
  121. GELOGE(RT_FAILED, "Call rt api rtLabelCreate failed, ret: 0x%X", rt_ret);
  122. return false;
  123. }
  124. label_list_[label_set_task_info->label_id()] = rt_label;
  125. }
  126. return true;
  127. }
  128. bool RuntimeModel::InitResource(std::shared_ptr<DavinciModel> &davinci_model) {
  129. GELOGI("InitResource start");
  130. if (davinci_model == nullptr) {
  131. GELOGE(PARAM_INVALID, "davinci model is null");
  132. return false;
  133. }
  134. rtError_t rt_ret = rtModelCreate(&rt_model_handle_, 0);
  135. if (rt_ret != RT_ERROR_NONE) {
  136. GELOGE(RT_FAILED, "Call rt api rtModelCreate failed, ret: 0x%X", rt_ret);
  137. return false;
  138. }
  139. // Create rtStream for rt_model_handle_
  140. rt_ret = rtStreamCreate(&rt_model_stream_, davinci_model->GetPriority());
  141. if (rt_ret != RT_ERROR_NONE) {
  142. GELOGE(RT_FAILED, "Call rt api rtStreamCreate failed, ret: 0x%X", rt_ret);
  143. return false;
  144. }
  145. GELOGI("rtStreamCreate end");
  146. if (!InitStream(davinci_model)) {
  147. return false;
  148. }
  149. if (!InitEvent(davinci_model->GetEventNum())) {
  150. return false;
  151. }
  152. if (!InitLabel(davinci_model)) {
  153. return false;
  154. }
  155. GELOGI("InitResource succ");
  156. return true;
  157. }
  158. void RuntimeModel::GenerateTask(uint32_t device_id, uint64_t session_id, std::shared_ptr<DavinciModel> &davinci_model) {
  159. GELOGI("GenerateTask start.");
  160. if (davinci_model == nullptr) {
  161. GELOGE(PARAM_INVALID, "davinci model is null");
  162. return;
  163. }
  164. auto task_infos = davinci_model->GetTaskInfoList();
  165. ModelContext model_context(device_id, session_id, davinci_model->GetPriority(), rt_model_handle_, rt_model_stream_,
  166. stream_list_, label_list_, event_list_);
  167. for (auto &task_info : task_infos) {
  168. auto task = TaskFactory::GetInstance().Create(model_context, task_info);
  169. task_list_.push_back(task);
  170. }
  171. GELOGI("GenerateTask succ.");
  172. }
  173. bool RuntimeModel::LoadTask() {
  174. GELOGI("LoadTask start.");
  175. for (auto &task : task_list_) {
  176. if (task == nullptr) {
  177. GELOGE(PARAM_INVALID, "task is null.");
  178. continue;
  179. }
  180. bool ret = task->Distribute();
  181. if (!ret) {
  182. GELOGE(FAILED, "task distribute fail.");
  183. return false;
  184. }
  185. uint32_t task_id = 0;
  186. uint32_t stream_id = 0;
  187. rtError_t rt_ret = rtModelGetTaskId(rt_model_handle_, &task_id, &stream_id);
  188. if (rt_ret != RT_ERROR_NONE) {
  189. GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X.", rt_ret);
  190. return false;
  191. }
  192. task_id_list_.push_back(task_id);
  193. stream_id_list_.push_back(stream_id);
  194. if (task->Args() != nullptr) {
  195. std::shared_ptr<RuntimeInfo> runtime_tuple = nullptr;
  196. GE_MAKE_SHARED(runtime_tuple = std::make_shared<RuntimeInfo>(task_id, stream_id, task->Args()), return false);
  197. auto emplace_ret = runtime_info_map_.emplace(task->task_name(), runtime_tuple);
  198. if (!emplace_ret.second) {
  199. GELOGW("Task name exist:%s", task->task_name().c_str());
  200. }
  201. }
  202. }
  203. if (task_list_.empty()) {
  204. GELOGE(FAILED, "Task list is empty");
  205. return false;
  206. }
  207. GELOGI("LoadTask succ.");
  208. return true;
  209. }
  210. bool RuntimeModel::LoadComplete() {
  211. uint32_t task_id = 0;
  212. uint32_t stream_id = 0;
  213. auto rt_ret = rtModelGetTaskId(rt_model_handle_, &task_id, &stream_id);
  214. if (rt_ret != RT_ERROR_NONE) {
  215. GELOGE(RT_FAILED, "Call rtModelGetTaskId failed, ret:0x%X", rt_ret);
  216. return RT_FAILED;
  217. }
  218. task_id_list_.push_back(task_id);
  219. stream_id_list_.push_back(stream_id);
  220. rt_ret = rtModelLoadComplete(rt_model_handle_);
  221. if (rt_ret != RT_ERROR_NONE) {
  222. GELOGE(RT_FAILED, "Call rt api rtModelLoadComplete failed, ret: 0x%X.", rt_ret);
  223. return false;
  224. }
  225. return true;
  226. }
  227. bool RuntimeModel::Load(uint32_t device_id, uint64_t session_id, std::shared_ptr<DavinciModel> &davinci_model) {
  228. bool status = InitResource(davinci_model);
  229. if (!status) {
  230. GELOGE(FAILED, "InitResource failed.");
  231. return status;
  232. }
  233. status = InitDataInfo(davinci_model);
  234. if (!status) {
  235. GELOGE(FAILED, "InitDataInfo failed.");
  236. return status;
  237. }
  238. status = InitOutputInfo(davinci_model);
  239. if (!status) {
  240. GELOGE(FAILED, "InitOutputInfo failed.");
  241. return status;
  242. }
  243. status = InitConstantInfo(davinci_model);
  244. if (!status) {
  245. GELOGE(FAILED, "InitConstantInfo failed.");
  246. return status;
  247. }
  248. GenerateTask(device_id, session_id, davinci_model);
  249. return status;
  250. }
  251. bool RuntimeModel::DistributeTask() {
  252. bool status = LoadTask();
  253. if (!status) {
  254. GELOGE(FAILED, "DistributeTask failed");
  255. return false;
  256. }
  257. return true;
  258. }
  259. bool RuntimeModel::Run() {
  260. GELOGI("Davinci task run start");
  261. rtError_t ret = rtModelExecute(rt_model_handle_, rt_model_stream_, 0);
  262. if (ret != RT_ERROR_NONE) {
  263. GELOGE(RT_FAILED, "Model execute failed, ret = 0x%X", ret);
  264. return false;
  265. }
  266. GELOGI("Run rtModelExecute success, ret = 0x%X", ret);
  267. ret = rtStreamSynchronize(rt_model_stream_);
  268. if (ret != RT_ERROR_NONE) {
  269. if (ret == ACL_ERROR_RT_END_OF_SEQUENCE) {
  270. GELOGI("Model stream ACL_ERROR_RT_END_OF_SEQUENCE signal received, ret = 0x%X", ret);
  271. return true;
  272. }
  273. GELOGE(RT_FAILED, "Model stream sync failed, ret = 0x%X", ret);
  274. return false;
  275. }
  276. GELOGI("Davinci task run succ.");
  277. return true;
  278. }
  279. void RuntimeModel::RtModelUnbindStream() noexcept {
  280. for (size_t i = 0; i < stream_list_.size(); i++) {
  281. if (rtModelUnbindStream(rt_model_handle_, stream_list_[i]) != RT_ERROR_NONE) {
  282. GELOGE(RT_FAILED, "Unbind stream from model failed! Index: %zu", i);
  283. return;
  284. }
  285. }
  286. }
  287. void RuntimeModel::RtStreamDestory() noexcept {
  288. if (rtStreamDestroy(rt_model_stream_) != RT_ERROR_NONE) {
  289. GELOGE(RT_FAILED, "Destroy stream for rt_model failed!");
  290. return;
  291. }
  292. for (size_t i = 0; i < stream_list_.size(); i++) {
  293. if (rtStreamDestroy(stream_list_[i]) != RT_ERROR_NONE) {
  294. GELOGE(RT_FAILED, "Destroy stream failed! Index: %zu", i);
  295. return;
  296. }
  297. }
  298. }
  299. void RuntimeModel::RtLabelDestory() noexcept {
  300. for (size_t i = 0; i < label_list_.size(); i++) {
  301. if (label_list_[i] == nullptr) {
  302. continue;
  303. }
  304. if (rtLabelDestroy(label_list_[i]) != RT_ERROR_NONE) {
  305. GELOGE(RT_FAILED, "Destroy label failed! Index: %zu.", i);
  306. return;
  307. }
  308. }
  309. }
  310. void RuntimeModel::RtModelDestory() noexcept {
  311. rtError_t ret = rtModelDestroy(rt_model_handle_);
  312. if (ret != RT_ERROR_NONE) {
  313. GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", ret);
  314. return;
  315. }
  316. }
  317. void RuntimeModel::RtEventDestory() noexcept {
  318. for (size_t i = 0; i < event_list_.size(); i++) {
  319. if (rtEventDestroy(event_list_[i]) != RT_ERROR_NONE) {
  320. GELOGE(RT_FAILED, "Destroy event failed! Index: %zu", i);
  321. return;
  322. }
  323. }
  324. }
  325. bool RuntimeModel::InitDataInfo(std::shared_ptr<DavinciModel> &davinci_model) { return true; }
  326. bool RuntimeModel::InitOutputInfo(std::shared_ptr<DavinciModel> &davinci_model) {
  327. if (davinci_model == nullptr) {
  328. GELOGE(PARAM_INVALID, "davinci model is null");
  329. return false;
  330. }
  331. output_info_list_ = davinci_model->GetOutputInfoList();
  332. return true;
  333. }
  334. bool RuntimeModel::CopyInputData(const InputData &input_data) {
  335. if (input_data.blobs.size() != data_info_list_.size()) {
  336. GELOGE(PARAM_INVALID, "The input data list size (%zu) does not match the model input list size (%zu)",
  337. input_data.blobs.size(), data_info_list_.size());
  338. return false;
  339. }
  340. for (const auto &data_info : data_info_list_) {
  341. if (data_info == nullptr) {
  342. GELOGE(PARAM_INVALID, "data info is null.");
  343. return false;
  344. }
  345. bool ret = CopyInputDataToModel(input_data.blobs, data_info);
  346. if (!ret) {
  347. GELOGE(FAILED, "Copy input data to model ret fail, data_info: %s, model id: %u", data_info->name.c_str(),
  348. input_data.model_id);
  349. return false;
  350. }
  351. }
  352. return true;
  353. }
  354. bool RuntimeModel::CopyInputDataToModel(const std::vector<DataBuffer> &data, const std::shared_ptr<OpInfo> &data_info) {
  355. return true;
  356. }
  357. bool RuntimeModel::CopyHostData(const std::vector<DataBuffer> &data, const std::shared_ptr<OpInfo> &data_info) const {
  358. GELOGI("Start CopyHostData.");
  359. if (data.empty()) {
  360. GELOGE(PARAM_INVALID, "data buffer is empty.");
  361. return false;
  362. }
  363. if (data_info == nullptr) {
  364. GELOGE(PARAM_INVALID, "data info is null.");
  365. return false;
  366. }
  367. void *host_data_addr = data[data_info->index].data;
  368. uint32_t copy_size = data[data_info->index].length;
  369. GELOGD("data output tensor is aipp tensor,copy data only.");
  370. const std::vector<uintptr_t> &outputs = data_info->output_addrs;
  371. if (outputs.empty()) {
  372. GELOGE(PARAM_INVALID, "Output addrs is empty.");
  373. return false;
  374. }
  375. // Copy input data to data nodes
  376. void *data_out_addr = reinterpret_cast<void *>(outputs[0]);
  377. rtError_t rt_ret = rtMemcpy(data_out_addr, copy_size, host_data_addr, copy_size, RT_MEMCPY_HOST_TO_DEVICE);
  378. if (rt_ret != RT_ERROR_NONE) {
  379. GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret);
  380. return false;
  381. }
  382. return true;
  383. }
  384. bool RuntimeModel::CopyTransData(const std::vector<DataBuffer> &data, const std::shared_ptr<OpInfo> &data_info) {
  385. return true;
  386. }
  387. bool RuntimeModel::InitConstantInfo(std::shared_ptr<DavinciModel> &davinci_model) {
  388. // Const no input, only 1 output, and this output has no data
  389. // weight data copy to output mem
  390. if (davinci_model == nullptr) {
  391. GELOGE(PARAM_INVALID, "Davinci model is null.");
  392. return false;
  393. }
  394. constant_info_list_ = davinci_model->GetConstantInfoList();
  395. for (const auto &constant : constant_info_list_) {
  396. if (constant == nullptr) {
  397. GELOGE(PARAM_INVALID, "constant is null");
  398. continue;
  399. }
  400. if (constant->output_tensors.empty()) {
  401. GELOGE(PARAM_INVALID, "Output tensors is empty");
  402. return false;
  403. }
  404. if (constant->weight_tensors.empty()) {
  405. GELOGE(PARAM_INVALID, "Weight tensors is empty");
  406. return false;
  407. }
  408. if (constant->output_tensors[0].size < constant->weight_data.size()) {
  409. GELOGE(PARAM_INVALID, "Output size:%u is less than weight data size:%zu", constant->output_tensors[0].size,
  410. constant->weight_data.size());
  411. return false;
  412. }
  413. if (constant->weight_data.empty()) {
  414. GELOGW("Const op:%s has no weight data.", constant->name.c_str());
  415. continue;
  416. }
  417. if (constant->weight_tensors[0].datatype == DT_STRING) {
  418. /// If tensor is a scaler, it's shape size if zero, according ge_tensor.cc.
  419. /// The logic of GetShapeSize is wrong, the scaler tensor's GetShapeSize is zero
  420. /// and that of unknown shape is zero too.
  421. /// Unknown shape will not appear here, so we can use zero judge a tensor is scaler or not.
  422. int64_t elem_num =
  423. (constant->weight_tensors[0].GetShapeSize() == 0) ? 1 : constant->weight_tensors[0].GetShapeSize();
  424. if (constant->weight_data.size() < sizeof(uint64_t)) {
  425. GELOGE(FAILED, "weight_data size is smaller than sizeof(uint64_t)");
  426. return false;
  427. }
  428. uint64_t *buff = reinterpret_cast<uint64_t *>(const_cast<char *>(constant->weight_data.data()));
  429. uint32_t head_len = kOffsetUnit * kStringHeadElems;
  430. if (ge::CheckInt64Uint32MulOverflow(elem_num, head_len) != SUCCESS) {
  431. GELOGE(FAILED, "Shape size is invalid");
  432. return false;
  433. }
  434. int64_t offset = elem_num * head_len;
  435. uintptr_t hbm_raw_data_base_addr = reinterpret_cast<uintptr_t>(constant->output_addrs[0]) + offset;
  436. for (int64_t i = elem_num - 1; i >= 0; --i) {
  437. buff[i * kStringHeadElems] = hbm_raw_data_base_addr + (buff[i * kStringHeadElems] - buff[0]);
  438. }
  439. }
  440. rtError_t rt_ret = rtMemcpy(reinterpret_cast<void *>(constant->output_addrs[0]), constant->output_tensors[0].size,
  441. constant->weight_data.data(), constant->weight_data.size(), RT_MEMCPY_HOST_TO_DEVICE);
  442. if (rt_ret != RT_ERROR_NONE) {
  443. GELOGE(RT_FAILED, "rtGetFunctionByName failed, ret: 0x%X", rt_ret);
  444. return false;
  445. }
  446. }
  447. return true;
  448. }
  449. bool RuntimeModel::GetInputOutputDescInfo(bool zero_copy, std::vector<InputOutputDescInfo> *input_desc,
  450. std::vector<InputOutputDescInfo> *output_desc,
  451. std::vector<uint32_t> *input_format, std::vector<uint32_t> *output_format) {
  452. return true;
  453. }
  454. bool RuntimeModel::GetInputDescInfo(std::vector<InputOutputDescInfo> *input_desc, std::vector<uint32_t> *formats) {
  455. return true;
  456. }
  457. bool RuntimeModel::GetOutputDescInfo(std::vector<InputOutputDescInfo> *output_desc, std::vector<uint32_t> *formats) {
  458. return true;
  459. }
  460. void RuntimeModel::CreateOutput(uint32_t index, const OpInfo &op_info, InputOutputDescInfo *output,
  461. uint32_t *format_result) {}
  462. const std::vector<uint32_t> &RuntimeModel::GetTaskIdList() const { return task_id_list_; }
  463. const std::vector<uint32_t> &RuntimeModel::GetStreamIdList() const { return stream_id_list_; }
  464. } // namespace model_runner
  465. } // namespace ge

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