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.

variable_prepare_op_pass.cc 19 kB

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
4 years ago
4 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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  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. #include "graph/passes/variable_prepare_op_pass.h"
  17. #include <map>
  18. #include <memory>
  19. #include <string>
  20. #include "common/ge/ge_util.h"
  21. #include "external/graph/graph.h"
  22. #include "framework/common/debug/ge_log.h"
  23. #include "graph/common/omg_util.h"
  24. #include "graph/debug/ge_attr_define.h"
  25. #include "graph/node.h"
  26. #include "graph/utils/tensor_utils.h"
  27. namespace ge {
  28. std::map<std::string, std::map<int, std::vector<int>>> VariablePrepareOpPass::ref_node_without_prototype_map_ = {
  29. {REFSWITCH, {{0, {0, 1}}}}};
  30. Status VariablePrepareOpPass::Run(ComputeGraphPtr graph) {
  31. GE_CHECK_NOTNULL(graph);
  32. for (const auto &node : graph->GetDirectNode()) {
  33. auto iter = ref_input_output_map_.find(node->GetType());
  34. if (iter == ref_input_output_map_.end()) {
  35. GenerateRefTypeAndInputOutputMap(node);
  36. }
  37. }
  38. if (ref_input_output_map_.empty()) {
  39. GELOGI("No need to add variable_ref.");
  40. return SUCCESS;
  41. }
  42. for (auto &node : graph->GetDirectNode()) {
  43. GE_IF_BOOL_EXEC(node->GetOpDesc() == nullptr, continue);
  44. if (node->GetOpDesc()->GetType() == VARIABLE) {
  45. Status ret = DealVariableNode(node);
  46. if (ret != SUCCESS) {
  47. GELOGE(ret, "variable add back edge failed");
  48. return FAILED;
  49. }
  50. }
  51. }
  52. return SUCCESS;
  53. }
  54. Status VariablePrepareOpPass::DealVariableNode(NodePtr &var_node) {
  55. GE_CHECK_NOTNULL(var_node);
  56. for (auto &dst_node_and_inanchor : var_node->GetOutDataNodesAndAnchors()) {
  57. NodePtr dst_node = dst_node_and_inanchor.first;
  58. GE_CHECK_NOTNULL(dst_node);
  59. InDataAnchorPtr dst_in_data_anchor = dst_node_and_inanchor.second;
  60. GE_CHECK_NOTNULL(dst_in_data_anchor);
  61. auto input_index = dst_in_data_anchor->GetIdx();
  62. vector<int> ref_output_indexes;
  63. GetWritableNodeOutIndex(dst_node, input_index, ref_output_indexes);
  64. if (!ref_output_indexes.empty()) {
  65. for (auto output_index : ref_output_indexes) {
  66. Status ret = DealWritableNode(dst_node, input_index, output_index, var_node);
  67. if (ret != SUCCESS) {
  68. GELOGE(FAILED, "Deal writable node[%s] failed, input index: %d, var: %s.", dst_node->GetName().c_str(),
  69. input_index, var_node->GetName().c_str());
  70. return FAILED;
  71. }
  72. }
  73. }
  74. }
  75. return SUCCESS;
  76. }
  77. Status VariablePrepareOpPass::DealWritableNode(const ge::NodePtr &writable_node, int input_index, int output_index,
  78. const ge::NodePtr &var_node) {
  79. // Find the last ref node:
  80. // If the ref input has corresponding output, add variable ref after it.
  81. // If the ref input has no corresponding output, insert RefIdentity and variable ref before it.
  82. // If ref node with control output was found while finding the last ref node, add variable ref after it.
  83. std::stack<pair<NodePtr, pair<int, int>>> nodes_to_check;
  84. nodes_to_check.push({writable_node, {input_index, output_index}});
  85. while (!nodes_to_check.empty()) {
  86. auto node_index = nodes_to_check.top();
  87. nodes_to_check.pop();
  88. auto cur_node = node_index.first;
  89. int cur_input_index = node_index.second.first;
  90. int cur_output_index = node_index.second.second;
  91. // Collect ref node after cur node
  92. const auto nodes_size = nodes_to_check.size();
  93. // Add peer ref output node of current node to stack
  94. CHECK_FALSE_EXEC(GetPeerNodeOfRefOutput(cur_node, cur_output_index, nodes_to_check) == SUCCESS,
  95. GELOGE(FAILED, "GetPeerNodeOfRefOutput for node[%s] failed.", cur_node->GetName().c_str());
  96. return FAILED);
  97. if (nodes_size == nodes_to_check.size()) {
  98. const auto &op_desc = cur_node->GetOpDesc();
  99. GE_CHECK_NOTNULL(op_desc);
  100. // No need to add variable_ref for framework op
  101. if (op_desc->GetType() == FRAMEWORKOP) {
  102. GELOGD("No need to add variable_ref for frameworkop");
  103. continue;
  104. }
  105. if (static_cast<uint32_t>(cur_output_index) < op_desc->GetOutputsSize()) {
  106. // Add variable ref node after ref output for final ref node
  107. CHECK_FALSE_EXEC(AddVariableRef(cur_node, var_node, cur_output_index) == SUCCESS,
  108. GELOGE(FAILED, "Add variable ref failed");
  109. return FAILED);
  110. } else {
  111. // Insert variable ref node before ref input without corresponding ref output
  112. CHECK_FALSE_EXEC(InsertVariableRef(cur_node, cur_input_index, var_node) == SUCCESS,
  113. GELOGE(FAILED, "Insert variable ref and ref identity failed");
  114. return FAILED);
  115. }
  116. continue;
  117. }
  118. if (HasControlOut(cur_node)) {
  119. // Add variable ref node after ref output for ref node has control output.
  120. CHECK_FALSE_EXEC(AddVariableRef(cur_node, var_node, cur_output_index) == SUCCESS,
  121. GELOGE(FAILED, "Add variable ref failed");
  122. return FAILED);
  123. }
  124. }
  125. return SUCCESS;
  126. }
  127. Status VariablePrepareOpPass::GetPeerNodeOfRefOutput(const ge::NodePtr &node, int output_index,
  128. std::stack<pair<NodePtr, pair<int, int>>> &nodes) {
  129. if (output_index < 0) {
  130. GELOGE(PARAM_INVALID, "Invalid ref output index: %s-%d.", node->GetName().c_str(), output_index);
  131. return PARAM_INVALID;
  132. }
  133. const auto &op_desc = node->GetOpDesc();
  134. GE_CHECK_NOTNULL(op_desc);
  135. if (static_cast<uint32_t>(output_index) == op_desc->GetOutputsSize()) {
  136. return SUCCESS;
  137. }
  138. if (output_index >= static_cast<int>(node->GetAllOutDataAnchorsSize())) {
  139. GELOGW("Can not get %d th output anchor of %s", output_index, node->GetName().c_str());
  140. return SUCCESS;
  141. }
  142. const auto &out_anchor = node->GetOutDataAnchor(output_index);
  143. GE_CHECK_NOTNULL(out_anchor);
  144. for (const auto &peer_in_anchor : out_anchor->GetPeerInDataAnchors()) {
  145. auto peer_node = peer_in_anchor->GetOwnerNode();
  146. if (peer_node == nullptr) {
  147. continue;
  148. }
  149. const int peer_in_index = peer_in_anchor->GetIdx();
  150. vector<int> ref_output_indexes;
  151. GetWritableNodeOutIndex(peer_node, peer_in_index, ref_output_indexes);
  152. for (auto ref_output_index : ref_output_indexes) {
  153. nodes.push({peer_node, {peer_in_index, ref_output_index}});
  154. }
  155. }
  156. return SUCCESS;
  157. }
  158. Status VariablePrepareOpPass::AddVariableRef(ge::NodePtr &final_writable_node, const ge::NodePtr &var_node, int index) {
  159. GE_CHECK_NOTNULL(final_writable_node);
  160. GE_CHECK_NOTNULL(var_node);
  161. if (index >= static_cast<int>(final_writable_node->GetAllOutDataAnchorsSize())) {
  162. GELOGW("Can not get %d th output anchor of %s", index, final_writable_node->GetName().c_str());
  163. return SUCCESS;
  164. }
  165. // Check for duplicate creation
  166. OutDataAnchorPtr out_anchor = final_writable_node->GetOutDataAnchor(index);
  167. GE_CHECK_NOTNULL(out_anchor);
  168. for (const auto &peer_anchor : out_anchor->GetPeerAnchors()) {
  169. NodePtr peer_node = peer_anchor->GetOwnerNode();
  170. OpDescPtr peer_opdesc = peer_node->GetOpDesc();
  171. GE_CHECK_NOTNULL(peer_opdesc);
  172. string src_var_name;
  173. (void)ge::AttrUtils::GetStr(peer_opdesc, REF_VAR_SRC_VAR_NAME, src_var_name);
  174. if (peer_node->GetType() == VARIABLE && var_node->GetName() == src_var_name) {
  175. GELOGI("The corresponding variable_ref has been added to this connection.");
  176. return SUCCESS;
  177. }
  178. }
  179. // creat variable_ref
  180. std::stringstream variable_ref_name;
  181. variable_ref_name << "_TO_" << final_writable_node->GetName() << "_REF_" << index;
  182. NodePtr variable_ref_node = CreateVariableRef(var_node->GetName() + variable_ref_name.str(), var_node);
  183. GE_CHECK_NOTNULL(variable_ref_node);
  184. Status ret_check = CheckStreamLabel(variable_ref_node, final_writable_node);
  185. if (ret_check != SUCCESS) {
  186. GELOGE(FAILED, "check stream lable failed");
  187. return FAILED;
  188. }
  189. GELOGI("Add variable_ref between [%s] and [%s]", var_node->GetName().c_str(), variable_ref_node->GetName().c_str());
  190. // add control anchor between variable_ref and final peer node
  191. // variable_ref_node need to execute before other nodes
  192. CHECK_FALSE_EXEC(AddControlEdge(final_writable_node, variable_ref_node) == SUCCESS,
  193. GELOGE(FAILED, "Add control edges between variable ref node and output nodes of ref node failed");
  194. return FAILED);
  195. graphStatus ret = ge::GraphUtils::AddEdge(out_anchor, variable_ref_node->GetInDataAnchor(0));
  196. if (ret != GRAPH_SUCCESS) {
  197. GELOGE(FAILED, "add data anchor between variable_ref and final_writable peer node failed");
  198. return FAILED;
  199. }
  200. return SUCCESS;
  201. }
  202. Status VariablePrepareOpPass::InsertVariableRef(ge::NodePtr &node, int in_index, const ge::NodePtr &var_node) {
  203. GE_CHECK_NOTNULL(node);
  204. GE_CHECK_NOTNULL(var_node);
  205. // Check connection between two nodes
  206. const auto in_anchor = node->GetInDataAnchor(in_index);
  207. GE_CHECK_NOTNULL(in_anchor);
  208. auto peer_out_anchor = in_anchor->GetPeerOutAnchor();
  209. GE_CHECK_NOTNULL(peer_out_anchor);
  210. auto peer_in_node = peer_out_anchor->GetOwnerNode();
  211. GE_CHECK_NOTNULL(peer_in_node);
  212. // Create ref_identity
  213. std::stringstream ref_identity_name;
  214. ref_identity_name << "RefIdentity_" << peer_in_node->GetName() << "_" << peer_out_anchor->GetIdx() << "_TO_"
  215. << node->GetName() << "_" << in_index;
  216. NodePtr ref_identity_node = CreateRefIdentity(ref_identity_name.str(), node, static_cast<uint32_t>(in_index));
  217. GE_CHECK_NOTNULL(ref_identity_node);
  218. // Create variable_ref
  219. std::stringstream variable_ref_name;
  220. variable_ref_name << "_TO_" << node->GetName() << "_REF_" << in_index;
  221. NodePtr variable_ref_node = CreateVariableRef(var_node->GetName() + variable_ref_name.str(), var_node);
  222. GE_CHECK_NOTNULL(variable_ref_node);
  223. Status ret_check = CheckStreamLabel(variable_ref_node, node);
  224. if (ret_check != SUCCESS) {
  225. GELOGE(FAILED, "check stream lable failed");
  226. return FAILED;
  227. }
  228. GELOGI("Insert variable_ref of [%s] between [%s] and [%s]", var_node->GetName().c_str(),
  229. peer_in_node->GetName().c_str(), node->GetName().c_str());
  230. // add control anchor between variable_ref and node
  231. // variable_ref_node need to execute before other nodes
  232. CHECK_FALSE_EXEC(AddControlEdge(node, variable_ref_node) == SUCCESS,
  233. GELOGE(FAILED, "Add control edges between variable ref node and output nodes of ref node failed");
  234. return FAILED);
  235. // Insert variable ref node between two nodes and remove the original edge.
  236. CHECK_FALSE_EXEC(ge::GraphUtils::RemoveEdge(peer_out_anchor, in_anchor) == SUCCESS,
  237. GELOGE(FAILED, "Remove edge between ref node and its peer node failed");
  238. return FAILED);
  239. CHECK_FALSE_EXEC(ge::GraphUtils::AddEdge(peer_out_anchor, ref_identity_node->GetInDataAnchor(0)) == SUCCESS,
  240. GELOGE(FAILED, "Add data edge between pre node and ref_identity failed");
  241. return FAILED);
  242. CHECK_FALSE_EXEC(ge::GraphUtils::AddEdge(ref_identity_node->GetOutDataAnchor(0), in_anchor) == SUCCESS,
  243. GELOGE(FAILED, "Add data edge between ref_identity and ref node failed");
  244. return FAILED);
  245. // Add edge from ref identity node to variable ref node.
  246. CHECK_FALSE_EXEC(
  247. ge::GraphUtils::AddEdge(ref_identity_node->GetOutDataAnchor(0), variable_ref_node->GetInDataAnchor(0)) == SUCCESS,
  248. GELOGE(FAILED, "Add data edge between ref_identity and variable_ref failed");
  249. return FAILED);
  250. CHECK_FALSE_EXEC(
  251. ge::GraphUtils::AddEdge(node->GetOutControlAnchor(), variable_ref_node->GetInControlAnchor()) == SUCCESS,
  252. GELOGE(FAILED, "Add control edge between ref_identity and variable_ref failed");
  253. return FAILED);
  254. return SUCCESS;
  255. }
  256. Status VariablePrepareOpPass::AddControlEdge(const ge::NodePtr &node, const ge::NodePtr &variable_ref_node) {
  257. auto out_anchors = node->GetAllOutAnchors();
  258. for (auto &out_anchor : out_anchors) {
  259. GE_CHECK_NOTNULL(out_anchor);
  260. for (auto &peer_in_anchor : out_anchor->GetPeerAnchors()) {
  261. GE_CHECK_NOTNULL(peer_in_anchor);
  262. NodePtr peer_node = peer_in_anchor->GetOwnerNode();
  263. GE_CHECK_NOTNULL(peer_node);
  264. CHECK_FALSE_EXEC(
  265. ge::GraphUtils::AddEdge(variable_ref_node->GetOutControlAnchor(), peer_node->GetInControlAnchor()) == SUCCESS,
  266. GELOGE(FAILED, "Add control edge between variable_ref and ref node's peer node failed");
  267. return FAILED);
  268. }
  269. }
  270. return SUCCESS;
  271. }
  272. ge::NodePtr VariablePrepareOpPass::CreateRefIdentity(const std::string &ref_identity_name, const ge::NodePtr &node,
  273. uint32_t input_index) {
  274. OpDescPtr op_desc = node->GetOpDesc();
  275. if (op_desc == nullptr) {
  276. GELOGE(FAILED, "opdesc is nullptr");
  277. return nullptr;
  278. }
  279. OpDescPtr ref_identity_op_desc = MakeShared<OpDesc>(ref_identity_name.c_str(), REFIDENTITY);
  280. if (ref_identity_op_desc == nullptr) {
  281. GELOGE(FAILED, "ref_identity op desc is nullptr");
  282. return nullptr;
  283. }
  284. GE_IF_BOOL_EXEC(ref_identity_op_desc->AddOutputDesc(op_desc->GetInputDesc(input_index)) != SUCCESS,
  285. GELOGW("add output desc edge failed");
  286. return nullptr);
  287. GE_IF_BOOL_EXEC(ref_identity_op_desc->AddInputDesc(op_desc->GetInputDesc(input_index)) != SUCCESS,
  288. GELOGW("add input desc edge failed");
  289. return nullptr);
  290. NodePtr ref_identity_node = node->GetOwnerComputeGraph()->AddNode(ref_identity_op_desc);
  291. GE_IF_BOOL_EXEC(ref_identity_node == nullptr, GELOGW("ref_identity_node is null"); return nullptr);
  292. return ref_identity_node;
  293. }
  294. ge::NodePtr VariablePrepareOpPass::CreateVariableRef(const std::string &variable_ref_name,
  295. const ge::NodePtr &var_node) {
  296. OpDescPtr var_op_desc = var_node->GetOpDesc();
  297. if (var_op_desc == nullptr) {
  298. GELOGE(FAILED, "get var opdesc is nullptr");
  299. return nullptr;
  300. }
  301. OpDescPtr var_ref_op_desc = MakeShared<OpDesc>(variable_ref_name.c_str(), var_op_desc->GetType());
  302. if (var_ref_op_desc == nullptr) {
  303. GELOGE(FAILED, "var_ref opdesc is nullptr");
  304. return nullptr;
  305. }
  306. GE_IF_BOOL_EXEC(var_ref_op_desc->AddOutputDesc(var_op_desc->GetOutputDesc(0)) != SUCCESS,
  307. GELOGW("add output desc edge failed");
  308. return nullptr);
  309. GE_IF_BOOL_EXEC(var_ref_op_desc->AddInputDesc(var_op_desc->GetOutputDesc(0)) != SUCCESS,
  310. GELOGW("add input desc edge failed");
  311. return nullptr);
  312. NodePtr variable_ref_node = var_node->GetOwnerComputeGraph()->AddNode(var_ref_op_desc);
  313. GE_IF_BOOL_EXEC(variable_ref_node == nullptr, GELOGW("variable_ref_node is null"); return nullptr);
  314. bool is_set_str = ge::AttrUtils::SetStr(var_ref_op_desc, REF_VAR_SRC_VAR_NAME, var_op_desc->GetName());
  315. if (is_set_str) {
  316. GELOGD("Set node [%s] REF_VAR_SRC_VAR_NAME [%s]", variable_ref_node->GetName().c_str(),
  317. var_op_desc->GetName().c_str());
  318. }
  319. return variable_ref_node;
  320. }
  321. void VariablePrepareOpPass::GetWritableNodeOutIndex(const NodePtr &node, int input_index,
  322. std::vector<int> &output_indexes) {
  323. if (node == nullptr) {
  324. return;
  325. }
  326. GELOGD("get writable node and input index %s:%d", node->GetName().c_str(), input_index);
  327. auto node_type = node->GetType();
  328. if (node_type == FRAMEWORKOP) {
  329. std::string original_type;
  330. GE_IF_BOOL_EXEC(GetOriginalType(node, original_type) != SUCCESS, GELOGW("Get node original type fail"));
  331. GELOGD("find frameworkop: [%s], original type is %s", node->GetName().c_str(), original_type.c_str());
  332. FindRefOutIndex(original_type, input_index, ref_node_without_prototype_map_, output_indexes);
  333. return;
  334. }
  335. FindRefOutIndex(node_type, input_index, ref_input_output_map_, output_indexes);
  336. return;
  337. }
  338. void VariablePrepareOpPass::GenerateRefTypeAndInputOutputMap(const NodePtr &node) {
  339. auto op_desc = node->GetOpDesc();
  340. if (op_desc == nullptr) {
  341. GELOGW("op_desc in null, please check node:[%s]", node->GetName().c_str());
  342. return;
  343. }
  344. for (const auto &name_index : op_desc->GetAllInputName()) {
  345. // Record the index of output with the same name as input, thinking of them as a pair of ref input and output.
  346. const int out_index = op_desc->GetOutputIndexByName(name_index.first);
  347. if (out_index != -1) {
  348. ref_input_output_map_[node->GetType()][name_index.second] = {out_index};
  349. continue;
  350. }
  351. // Record the ref input without corresponding output.
  352. const auto &input_desc = op_desc->GetInputDesc(name_index.second);
  353. if (!input_desc.GetRefPortIndex().empty()) {
  354. ref_input_output_map_[node->GetType()][name_index.second] = {static_cast<int>(op_desc->GetOutputsSize())};
  355. }
  356. }
  357. }
  358. void VariablePrepareOpPass::FindRefOutIndex(const std::string &node_type, int input_index,
  359. const std::map<std::string, std::map<int, vector<int>>> &ref_map,
  360. std::vector<int> &output_indexes) {
  361. auto node_iter = ref_map.find(node_type);
  362. if (node_iter == ref_map.end()) {
  363. return;
  364. }
  365. auto index_iter = node_iter->second.find(input_index);
  366. if (index_iter == node_iter->second.end()) {
  367. return;
  368. }
  369. for (const auto &out_index : index_iter->second) {
  370. output_indexes.emplace_back(out_index);
  371. }
  372. }
  373. Status VariablePrepareOpPass::CheckStreamLabel(const ge::NodePtr &var_ref_node,
  374. const ge::NodePtr &final_writable_node) {
  375. // Solve the problem that the writable node is not in the same stream as the subsequent node.
  376. // Causes the stream to not trigger properly.
  377. // The label of node should be handled uniformly.
  378. OpDescPtr writable_desc = final_writable_node->GetOpDesc();
  379. GE_CHECK_NOTNULL(writable_desc);
  380. std::string stream_label;
  381. (void)AttrUtils::GetStr(writable_desc, ATTR_NAME_STREAM_LABEL, stream_label);
  382. if (!stream_label.empty()) {
  383. GE_CHK_STATUS_RET(SetStreamLabel(var_ref_node, stream_label), "set stream label failed");
  384. }
  385. return SUCCESS;
  386. }
  387. bool VariablePrepareOpPass::HasControlOut(const ge::NodePtr &node) {
  388. const auto &out_control_anchor = node->GetOutControlAnchor();
  389. for (const auto &peer_in_control_anchor : out_control_anchor->GetPeerInControlAnchors()) {
  390. if (peer_in_control_anchor == nullptr || peer_in_control_anchor->GetOwnerNode() == nullptr) {
  391. continue;
  392. }
  393. return true;
  394. }
  395. return false;
  396. }
  397. } // namespace ge

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