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.

execution_engine.cc 19 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
4 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
4 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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  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 "hybrid/executor/worker/execution_engine.h"
  17. #include "graph/runtime_inference_context.h"
  18. #include "graph/utils/tensor_utils.h"
  19. #include "graph/utils/tensor_adapter.h"
  20. #include "graph/debug/ge_attr_define.h"
  21. #include "hybrid/node_executor/node_executor.h"
  22. #include "hybrid/executor//worker//shape_inference_engine.h"
  23. #include "common/dump/dump_op.h"
  24. #include "common/profiling/profiling_manager.h"
  25. namespace ge {
  26. namespace hybrid {
  27. namespace {
  28. constexpr int64_t kMaxPadding = 63;
  29. Status LogInputs(const NodeItem &node_item, const TaskContext &task_context) {
  30. for (auto i = 0; i < task_context.NumInputs(); ++i) {
  31. const auto &input_tensor = task_context.GetInput(i);
  32. GE_CHECK_NOTNULL(input_tensor);
  33. const auto &tensor_desc = task_context.GetInputDesc(i);
  34. GE_CHECK_NOTNULL(tensor_desc);
  35. GELOGD("[%s] Print task args. input[%d] = %s, shape = [%s]",
  36. node_item.NodeName().c_str(),
  37. i,
  38. input_tensor->DebugString().c_str(),
  39. tensor_desc->GetShape().ToString().c_str());
  40. }
  41. return SUCCESS;
  42. }
  43. Status LogOutputs(const NodeItem &node_item, const TaskContext &task_context) {
  44. for (auto i = 0; i < task_context.NumOutputs(); ++i) {
  45. const auto &output_tensor = task_context.GetOutput(i);
  46. GE_CHECK_NOTNULL(output_tensor);
  47. const auto &tensor_desc = node_item.MutableOutputDesc(i);
  48. GE_CHECK_NOTNULL(tensor_desc);
  49. GELOGD("[%s] Print task args. output[%d] = %s, shape = [%s]",
  50. node_item.NodeName().c_str(),
  51. i,
  52. output_tensor->DebugString().c_str(),
  53. tensor_desc->MutableShape().ToString().c_str());
  54. }
  55. return SUCCESS;
  56. }
  57. } // namespace
  58. class NodeDoneCallback {
  59. public:
  60. NodeDoneCallback(GraphExecutionContext *graph_context, std::shared_ptr<TaskContext> task_context);
  61. ~NodeDoneCallback() = default;
  62. Status OnNodeDone();
  63. private:
  64. Status PrepareConstInputs(const NodeItem &node_item);
  65. Status DumpDynamicNode();
  66. Status ProfilingReport();
  67. Status GetTaskDescInfo(const NodePtr node, const HybridModel *model,
  68. std::vector<TaskDescInfo> &task_desc_info);
  69. GraphExecutionContext *graph_context_;
  70. std::shared_ptr<TaskContext> context_;
  71. DumpOp dump_op_;
  72. };
  73. NodeDoneCallback::NodeDoneCallback(GraphExecutionContext *graph_context,
  74. std::shared_ptr<TaskContext> task_context)
  75. : graph_context_(graph_context), context_(std::move(task_context)) {
  76. }
  77. Status NodeDoneCallback::PrepareConstInputs(const NodeItem &node_item) {
  78. for (auto output_idx : node_item.to_const_output_id_list) {
  79. RECORD_CALLBACK_EVENT(graph_context_, node_item.NodeName().c_str(),
  80. "[PrepareConstInputs] [index = %d] Start",
  81. output_idx);
  82. auto output_tensor = context_->GetOutput(output_idx);
  83. GE_CHECK_NOTNULL(output_tensor);
  84. Tensor tensor;
  85. auto ge_tensor_desc = node_item.MutableOutputDesc(output_idx);
  86. GE_CHECK_NOTNULL(ge_tensor_desc);
  87. tensor.SetTensorDesc(TensorAdapter::GeTensorDesc2TensorDesc(*ge_tensor_desc));
  88. int64_t tensor_size;
  89. GE_CHK_GRAPH_STATUS_RET(TensorUtils::GetTensorSizeInBytes(*ge_tensor_desc, tensor_size),
  90. "Failed to invoke GetTensorSizeInBytes");
  91. if (output_tensor->GetSize() < static_cast<size_t>(tensor_size)) {
  92. GELOGE(INTERNAL_ERROR,
  93. "[Check][Size][%s] Tensor size is not enough. output index = %d, required size = %ld, tensor = %s.",
  94. node_item.NodeName().c_str(), output_idx, tensor_size,
  95. output_tensor->DebugString().c_str());
  96. REPORT_INNER_ERROR("E19999",
  97. "[%s] Tensor size is not enough. output index = %d, required size = %ld, tensor = %s when %s.",
  98. node_item.NodeName().c_str(), output_idx, tensor_size,
  99. output_tensor->DebugString().c_str(), __FUNCTION__);
  100. return INTERNAL_ERROR;
  101. }
  102. vector<uint8_t> host_buffer(static_cast<unsigned long>(tensor_size));
  103. GELOGD("[%s] To cache output[%d] to host, size = %zu",
  104. node_item.NodeName().c_str(),
  105. output_idx,
  106. output_tensor->GetSize());
  107. if (tensor_size > 0) {
  108. GE_CHK_RT_RET(rtMemcpy(host_buffer.data(),
  109. tensor_size,
  110. output_tensor->GetData(),
  111. tensor_size,
  112. RT_MEMCPY_DEVICE_TO_HOST));
  113. }
  114. tensor.SetData(std::move(host_buffer));
  115. string context_id = std::to_string(graph_context_->context_id);
  116. RuntimeInferenceContext *runtime_infer_ctx = nullptr;
  117. GE_CHK_GRAPH_STATUS_RET(RuntimeInferenceContext::GetContext(context_id, &runtime_infer_ctx),
  118. "Failed to get RuntimeInferenceContext, context_id = %s", context_id.c_str());
  119. GE_CHK_STATUS_RET(runtime_infer_ctx->SetTensor(node_item.node_id, output_idx, std::move(tensor)),
  120. "[Set][Tensor] Failed, node = %s, output_index = %d", node_item.NodeName().c_str(), output_idx);
  121. GELOGD("[%s] Output[%d] cached successfully in context: %s. node_id = %d, shape = [%s]",
  122. node_item.NodeName().c_str(),
  123. output_idx,
  124. context_id.c_str(),
  125. node_item.node_id,
  126. ge_tensor_desc->GetShape().ToString().c_str());
  127. RECORD_CALLBACK_EVENT(graph_context_, node_item.NodeName().c_str(),
  128. "[PrepareConstInputs] [index = %d] End",
  129. output_idx);
  130. }
  131. return SUCCESS;
  132. }
  133. Status NodeDoneCallback::GetTaskDescInfo(const NodePtr node, const HybridModel *model,
  134. std::vector<TaskDescInfo> &task_desc_info) {
  135. GE_CHECK_NOTNULL(node);
  136. GE_CHECK_NOTNULL(model);
  137. // only report aicpu and aicore node
  138. bool is_profiling_report = context_->GetNodeItem().is_profiling_report;
  139. if (!is_profiling_report) {
  140. GELOGD("Node[%s] is not aicore or aicpu, and no need to report data.", node->GetName().c_str());
  141. return SUCCESS;
  142. }
  143. GELOGD("GetTaskDescInfo of node [%s] start.", node->GetName().c_str());
  144. auto &prof_mgr = ProfilingManager::Instance();
  145. task_desc_info = context_->GetProfilingTaskDescInfo();
  146. context_->ClearProfilingTaskDescInfo();
  147. for (auto &tmp_task_desc : task_desc_info) {
  148. // save op input and output info
  149. auto op_desc = node->GetOpDesc();
  150. GE_CHECK_NOTNULL(op_desc);
  151. prof_mgr.GetOpInputOutputInfo(op_desc, tmp_task_desc);
  152. }
  153. return SUCCESS;
  154. }
  155. Status NodeDoneCallback::ProfilingReport() {
  156. auto node = context_->GetNodeItem().node;
  157. if (node == nullptr) {
  158. GELOGE(PARAM_INVALID, "[Get][Node] value is nullptr.");
  159. REPORT_INNER_ERROR("E19999", "Get node failed, when %s.", __FUNCTION__);
  160. return PARAM_INVALID;
  161. }
  162. const auto &op_type = node->GetType();
  163. if (op_type == PARTITIONEDCALL) {
  164. return SUCCESS;
  165. }
  166. GE_CHECK_NOTNULL(graph_context_);
  167. const HybridModel *model = graph_context_->model;
  168. GE_CHECK_NOTNULL(model);
  169. GELOGD("ProfilingReport of node [%s] model [%s] start.", node->GetName().c_str(), model->GetModelName().c_str());
  170. std::vector<TaskDescInfo> task_desc_info;
  171. auto profiling_ret = GetTaskDescInfo(node, model, task_desc_info);
  172. if (profiling_ret != RT_ERROR_NONE) {
  173. GELOGE(profiling_ret, "[Get][TaskDescInfo] of node:%s failed.", node->GetName().c_str());
  174. REPORT_CALL_ERROR("E19999", "GetTaskDescInfo of node:%s failed, when %s.", node->GetName().c_str(), __FUNCTION__);
  175. return profiling_ret;
  176. }
  177. auto &profiling_manager = ProfilingManager::Instance();
  178. profiling_manager.ReportProfilingData(model->GetModelId(), task_desc_info);
  179. return SUCCESS;
  180. }
  181. Status NodeDoneCallback::DumpDynamicNode() {
  182. auto node = context_->GetNodeItem().node;
  183. if (node == nullptr) {
  184. GELOGE(PARAM_INVALID, "[Get][Node] value is nullptr.");
  185. REPORT_INNER_ERROR("E19999", "get node is nullptr when %s.", __FUNCTION__);
  186. return PARAM_INVALID;
  187. }
  188. auto op_desc = node->GetOpDesc();
  189. auto stream = context_->GetStream();
  190. vector<uintptr_t> input_addrs;
  191. vector<uintptr_t> output_addrs;
  192. for (int i = 0; i < context_->NumInputs(); i++) {
  193. auto tensor_value = context_->GetInput(i);
  194. GE_CHK_BOOL_RET_STATUS(tensor_value != nullptr, PARAM_INVALID, "[Get][Tensor] value is nullptr.");
  195. uint64_t input_addr = reinterpret_cast<uintptr_t>(tensor_value->GetData());
  196. input_addrs.emplace_back(input_addr);
  197. }
  198. for (int j = 0; j < context_->NumOutputs(); j++) {
  199. auto tensor_value = context_->GetOutput(j);
  200. GE_CHK_BOOL_RET_STATUS(tensor_value != nullptr, PARAM_INVALID, "[Get][Tensor] value is nullptr.");
  201. uint64_t output_addr = reinterpret_cast<uintptr_t>(tensor_value->GetData());
  202. output_addrs.emplace_back(output_addr);
  203. }
  204. dump_op_.SetDumpInfo(context_->GetDumpProperties(), op_desc, input_addrs, output_addrs, stream);
  205. GE_CHECK_NOTNULL(graph_context_);
  206. const HybridModel *model = graph_context_->model;
  207. GE_CHECK_NOTNULL(model);
  208. std::string dynamic_model_name = model->GetModelName();
  209. uint32_t model_id = model->GetModelId();
  210. dump_op_.SetDynamicModelInfo(dynamic_model_name, model_id);
  211. void *loop_per_iter = nullptr;
  212. TensorValue *varible_loop_per_iter = context_->GetVariable(NODE_NAME_FLOWCTRL_LOOP_PER_ITER);
  213. if (varible_loop_per_iter != nullptr) {
  214. loop_per_iter = const_cast<void *>(varible_loop_per_iter->GetData());
  215. }
  216. void *loop_cond = nullptr;
  217. TensorValue *varible_loop_cond = context_->GetVariable(NODE_NAME_FLOWCTRL_LOOP_COND);
  218. if (varible_loop_cond != nullptr) {
  219. loop_cond = const_cast<void *>(varible_loop_cond->GetData());
  220. }
  221. void *global_step = context_->GetExecutionContext()->global_step;
  222. dump_op_.SetLoopAddr(global_step, loop_per_iter, loop_cond);
  223. GE_CHK_STATUS_RET(dump_op_.LaunchDumpOp(), "[Launch][DumpOp] failed in hybird model.");
  224. auto rt_ret = rtStreamSynchronize(stream);
  225. if (rt_ret != RT_ERROR_NONE) {
  226. GELOGE(rt_ret, "[Call][rtStreamSynchronize] failed, ret = %d.", rt_ret);
  227. REPORT_CALL_ERROR("E19999", "call rtStreamSynchronize failed when %s, ret = %d.", __FUNCTION__, rt_ret);
  228. return rt_ret;
  229. }
  230. return SUCCESS;
  231. }
  232. Status NodeDoneCallback::OnNodeDone() {
  233. auto &node_item = context_->GetNodeItem();
  234. GELOGI("[%s] Start callback process.", node_item.NodeName().c_str());
  235. RECORD_CALLBACK_EVENT(graph_context_, context_->GetNodeName(), "[Compute] End");
  236. RECORD_CALLBACK_EVENT(graph_context_, context_->GetNodeName(), "[Callback] Start");
  237. const DumpProperties &dump_properties = context_->GetDumpProperties();
  238. if (dump_properties.IsDumpOpen() || context_->IsOverFlow()) {
  239. GELOGI("Start to dump dynamic shape op");
  240. GE_CHK_STATUS_RET(DumpDynamicNode(), "[Call][DumpDynamicNode] Failed.");
  241. }
  242. if (ProfilingManager::Instance().ProfilingModelExecuteOn()) {
  243. GE_CHK_STATUS_RET(ProfilingReport(), "[Report][Profiling] of node[%s] failed.",
  244. node_item.NodeName().c_str());
  245. }
  246. // release workspace
  247. context_->ReleaseWorkspace();
  248. // release inputs
  249. for (int i = 0; i < context_->NumInputs(); ++i) {
  250. context_->ReleaseInput(i);
  251. }
  252. GE_CHK_STATUS_RET_NOLOG(PrepareConstInputs(node_item));
  253. if (node_item.shape_inference_type == DEPEND_SHAPE_RANGE || node_item.shape_inference_type == DEPEND_COMPUTE) {
  254. // update output tensor sizes
  255. GE_CHK_STATUS_RET_NOLOG(ShapeInferenceEngine::CalcOutputTensorSizes(node_item));
  256. GE_CHK_STATUS_RET_NOLOG(context_->GetNodeState()->GetShapeInferenceState().UpdateOutputDesc());
  257. }
  258. // PropagateOutputs for type == DEPEND_COMPUTE
  259. if (node_item.shape_inference_type == DEPEND_COMPUTE) {
  260. if (graph_context_->trace_enabled) {
  261. (void) LogOutputs(node_item, *context_);
  262. }
  263. GE_CHK_STATUS_RET(context_->PropagateOutputs(),
  264. "[Propagate][Outputs] of [%s] failed.", node_item.NodeName().c_str());
  265. RECORD_CALLBACK_EVENT(graph_context_, context_->GetNodeName(), "[PropagateOutputs] End");
  266. }
  267. // release condition variable
  268. if (node_item.has_observer) {
  269. GELOGI("[%s] Notify observer. node_id = %d", node_item.NodeName().c_str(), node_item.node_id);
  270. context_->NodeDone();
  271. }
  272. RECORD_CALLBACK_EVENT(graph_context_, context_->GetNodeName(), "[Callback] End");
  273. return SUCCESS;
  274. }
  275. Status ExecutionEngine::ExecuteAsync(NodeState &node_state,
  276. const std::shared_ptr<TaskContext> &task_context,
  277. GraphExecutionContext &execution_context) {
  278. GELOGI("[%s] Node is ready for execution", task_context->GetNodeName());
  279. RECORD_EXECUTION_EVENT(&execution_context, task_context->GetNodeName(), "Start");
  280. auto cb = std::shared_ptr<NodeDoneCallback>(new(std::nothrow) NodeDoneCallback(&execution_context, task_context));
  281. GE_CHECK_NOTNULL(cb);
  282. auto callback = [task_context, cb]() {
  283. auto ret = cb->OnNodeDone();
  284. if (ret != SUCCESS) {
  285. task_context->OnError(ret);
  286. }
  287. };
  288. GE_CHK_STATUS_RET_NOLOG(DoExecuteAsync(node_state, *task_context, execution_context, callback));
  289. GE_CHK_STATUS_RET_NOLOG(PropagateOutputs(*node_state.GetNodeItem(), *task_context, execution_context));
  290. return SUCCESS;
  291. }
  292. Status ExecutionEngine::DoExecuteAsync(NodeState &node_state,
  293. TaskContext &task_context,
  294. GraphExecutionContext &context,
  295. const std::function<void()> &callback) {
  296. const auto &task = node_state.GetKernelTask();
  297. if (task == nullptr) {
  298. GELOGE(INTERNAL_ERROR, "[Get][KernelTask] of [%s] is null.", node_state.GetName().c_str());
  299. REPORT_INNER_ERROR("E19999", "GetKernelTask of %s is null when %s.", node_state.GetName().c_str(), __FUNCTION__);
  300. return INTERNAL_ERROR;
  301. }
  302. // Wait for dependent nodes(DEPEND_COMPUTE), so that the input tensors are valid.
  303. RECORD_EXECUTION_EVENT(&context, task_context.GetNodeName(), "[AwaitDependents] Start");
  304. HYBRID_CHK_STATUS_RET(node_state.AwaitInputTensors(context),
  305. "[%s] Failed to wait for dependent nodes.",
  306. node_state.GetName().c_str());
  307. const auto &node_item = *node_state.GetNodeItem();
  308. auto executor = node_item.node_executor;
  309. GE_CHECK_NOTNULL(executor);
  310. RECORD_EXECUTION_EVENT(&context, task_context.GetNodeName(), "[PrepareTask] Start");
  311. GE_CHK_STATUS_RET(executor->PrepareTask(*task, task_context),
  312. "[Prepare][Task] for [%s] failed.", node_state.GetName().c_str());
  313. RECORD_EXECUTION_EVENT(&context, task_context.GetNodeName(), "[PrepareTask] End");
  314. GELOGD("[%s] Done task preparation successfully.", node_state.GetName().c_str());
  315. if (context.trace_enabled) {
  316. LogInputs(node_item, task_context);
  317. if (node_item.shape_inference_type != DEPEND_COMPUTE) {
  318. LogOutputs(node_item, task_context);
  319. }
  320. }
  321. GE_CHK_STATUS_RET(ValidateInputTensors(node_state, task_context), "[Validate][InputTensors] for %s failed.",
  322. node_state.GetName().c_str());
  323. RECORD_EXECUTION_EVENT(&context, task_context.GetNodeName(), "[ValidateInputTensors] End");
  324. if (context.profiling_level > 0) {
  325. auto *ctx = &context;
  326. const string &name = node_state.GetName();
  327. (void)task_context.RegisterCallback([ctx, name]() {
  328. RECORD_CALLBACK_EVENT(ctx, name.c_str(), "[Compute] Start");
  329. });
  330. }
  331. RECORD_EXECUTION_EVENT(&context, task_context.GetNodeName(), "[ExecuteTask] Start");
  332. HYBRID_CHK_STATUS_RET(node_item.node_executor->ExecuteTask(*task, task_context, callback),
  333. "[%s] Failed to execute task",
  334. node_state.GetName().c_str());
  335. RECORD_EXECUTION_EVENT(&context, task_context.GetNodeName(), "[ExecuteTask] End");
  336. GELOGD("[%s] Done task launch successfully.", node_state.GetName().c_str());
  337. return SUCCESS;
  338. }
  339. Status ExecutionEngine::ValidateInputTensors(const NodeState &node_state, const TaskContext &task_context) {
  340. for (auto i = 0; i < task_context.NumInputs(); ++i) {
  341. const auto &input_tensor = task_context.GetInput(i);
  342. GE_CHECK_NOTNULL(input_tensor);
  343. if (input_tensor->GetData() == nullptr) {
  344. GELOGD("[%s] Skipping null input, index = %d", task_context.GetNodeName(), i);
  345. continue;
  346. }
  347. const auto &tensor_desc = task_context.MutableInputDesc(i);
  348. GE_CHECK_NOTNULL(tensor_desc);
  349. if (tensor_desc->GetDataType() == DT_STRING) {
  350. GELOGD("[%s] Skipping DT_STRING input, index = %d", task_context.GetNodeName(), i);
  351. continue;
  352. }
  353. if (input_tensor->GetData() == nullptr) {
  354. GELOGD("[%s] Skipping null input, index = %d", task_context.GetNodeName(), i);
  355. continue;
  356. }
  357. int64_t expected_size;
  358. GE_CHK_GRAPH_STATUS_RET(TensorUtils::GetTensorMemorySizeInBytes(*tensor_desc, expected_size));
  359. GELOGD("[%s] Input[%d] expects [%ld] bytes.", task_context.GetNodeName(), i, expected_size);
  360. auto size_diff = expected_size - static_cast<int64_t>(input_tensor->GetSize());
  361. if (size_diff > 0) {
  362. if (size_diff <= kMaxPadding) {
  363. GELOGW("[%s] Input[%d]: tensor size mismatches. expected: %ld, but given %zu",
  364. task_context.GetNodeName(),
  365. i,
  366. expected_size,
  367. input_tensor->GetSize());
  368. } else {
  369. GELOGE(INTERNAL_ERROR,
  370. "[Check][Size] for [%s] Input[%d]: tensor size mismatches. expected: %ld, but given %zu.",
  371. task_context.GetNodeName(), i, expected_size, input_tensor->GetSize());
  372. REPORT_INNER_ERROR("E19999", "[%s] Input[%d]: tensor size mismatches. expected: %ld, but given %zu when %s.",
  373. task_context.GetNodeName(), i, expected_size, input_tensor->GetSize(), __FUNCTION__);
  374. return INTERNAL_ERROR;
  375. }
  376. }
  377. }
  378. return SUCCESS;
  379. }
  380. Status ExecutionEngine::PropagateOutputs(const NodeItem &node_item,
  381. TaskContext &task_context,
  382. GraphExecutionContext &context) {
  383. if (node_item.shape_inference_type != DEPEND_COMPUTE) {
  384. GE_CHK_STATUS_RET(task_context.PropagateOutputs(),
  385. "[Propagate][Outputs] for [%s] failed.", node_item.NodeName().c_str());
  386. RECORD_EXECUTION_EVENT(&context, task_context.GetNodeName(), "[PropagateOutputs] End");
  387. GELOGD("[%s] Done propagating outputs successfully.", node_item.NodeName().c_str());
  388. }
  389. return SUCCESS;
  390. }
  391. } // namespace hybrid
  392. } // namespace ge

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