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.

node.cc 35 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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842
  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 "graph/node.h"
  17. #include <utility>
  18. #include "debug/ge_op_types.h"
  19. #include "debug/ge_util.h"
  20. #include "external/graph/operator_factory.h"
  21. #include "framework/common/debug/ge_log.h"
  22. #include "graph/ge_tensor.h"
  23. #include "graph/operator_factory_impl.h"
  24. #include "graph/shape_refiner.h"
  25. #include "utils/ge_ir_utils.h"
  26. #include "utils/node_utils.h"
  27. #include "utils/op_desc_utils.h"
  28. using std::string;
  29. using std::vector;
  30. namespace ge {
  31. Node::Node(const OpDescPtr &op, const ComputeGraphPtr &owner_graph)
  32. : op_(op),
  33. owner_graph_(owner_graph),
  34. in_data_anchors_(),
  35. out_data_anchors_(),
  36. in_control_anchor_(nullptr),
  37. out_control_anchor_(nullptr),
  38. attrs_(),
  39. has_init_(false) {
  40. anchor_status_updated_ = false;
  41. }
  42. Node::~Node() {
  43. for (const auto &in_data_anchor : in_data_anchors_) {
  44. if (in_data_anchor != nullptr) {
  45. in_data_anchor->UnlinkAll();
  46. }
  47. }
  48. for (const auto &out_data_anchor : out_data_anchors_) {
  49. if (out_data_anchor != nullptr) {
  50. out_data_anchor->UnlinkAll();
  51. }
  52. }
  53. if (in_control_anchor_ != nullptr) {
  54. in_control_anchor_->UnlinkAll();
  55. }
  56. if (out_control_anchor_ != nullptr) {
  57. out_control_anchor_->UnlinkAll();
  58. }
  59. }
  60. graphStatus Node::Init() {
  61. if (has_init_) {
  62. return GRAPH_SUCCESS;
  63. }
  64. GE_CHK_BOOL_EXEC(op_ != nullptr, return GRAPH_FAILED, "original OpDesc is nullptr");
  65. size_t size = op_->GetInputsSize();
  66. for (size_t i = 0; i < size; i++) {
  67. std::shared_ptr<InDataAnchor> anchor = ComGraphMakeShared<InDataAnchor>(shared_from_this(), i);
  68. if (anchor == nullptr) {
  69. GELOGE(GRAPH_FAILED, "Current in_data_anchor is null, malloc shared_ptr failed.");
  70. return GRAPH_FAILED;
  71. }
  72. in_data_anchors_.push_back(anchor);
  73. }
  74. size = op_->GetOutputsSize();
  75. for (size_t i = 0; i < size; i++) {
  76. std::shared_ptr<OutDataAnchor> anchor = ComGraphMakeShared<OutDataAnchor>(shared_from_this(), i);
  77. if (anchor == nullptr) {
  78. GELOGE(GRAPH_FAILED, "Current out_data_anchor is null, malloc shared_ptr failed.");
  79. return GRAPH_FAILED;
  80. }
  81. out_data_anchors_.push_back(anchor);
  82. }
  83. in_control_anchor_ = ComGraphMakeShared<InControlAnchor>(shared_from_this(), -1);
  84. out_control_anchor_ = ComGraphMakeShared<OutControlAnchor>(shared_from_this(), -1);
  85. if (in_control_anchor_ == nullptr || out_control_anchor_ == nullptr) {
  86. GELOGE(GRAPH_FAILED, "Current in_control_anchor or out_control_anchor is null, malloc shared_ptr failed.");
  87. return GRAPH_FAILED;
  88. }
  89. has_init_ = true;
  90. return GRAPH_SUCCESS;
  91. }
  92. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY std::string Node::GetName() const {
  93. GE_CHK_BOOL_EXEC(op_ != nullptr, return string(), "original OpDesc is nullptr");
  94. return op_->GetName();
  95. }
  96. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY std::string Node::GetType() const {
  97. GE_CHK_BOOL_EXEC(op_ != nullptr, return string(), "original OpDesc is nullptr");
  98. return op_->GetType();
  99. }
  100. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool Node::NodeAttrsAreEqual(const Node &r_node) const {
  101. const auto &attr_map = this->attrs_;
  102. const auto &r_attr_map = r_node.attrs_;
  103. // 1.Verify node's map<string, AttrValue> size
  104. if (attr_map.size() != r_attr_map.size()) {
  105. GELOGE(GRAPH_FAILED, "Size of node's attr map verify failed, node name: %s.", this->GetName().c_str());
  106. return false;
  107. }
  108. // 2.Verify node's map<string, AttrValue> key, verify values is temporarily not implemented
  109. for (const auto &it : attr_map) {
  110. if (r_attr_map.count(it.first) == 0) {
  111. GELOGE(GRAPH_FAILED, "Key of node's attr map verify failed, node name: %s key name: %s.", this->GetName().c_str(),
  112. it.first.c_str());
  113. return false;
  114. }
  115. }
  116. return true;
  117. }
  118. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool Node::NodeMembersAreEqual(const Node &r_node) const {
  119. return ((((this->op_ != nullptr) && (r_node.op_ != nullptr) && (IsEqual(*(this->op_), *(r_node.op_), "node.op_"))) ||
  120. ((this->op_ == nullptr) && (r_node.op_ == nullptr))) &&
  121. IsEqual(this->has_init_, r_node.has_init_, "node.has_init_") &&
  122. IsEqual(this->anchor_status_updated_, r_node.anchor_status_updated_, "node.anchor_status_updated_") &&
  123. IsEqual(this->send_event_id_list_, r_node.send_event_id_list_, "node.send_event_id_list_") &&
  124. IsEqual(this->recv_event_id_list_, r_node.recv_event_id_list_, "node.recv_event_id_list_"));
  125. }
  126. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool Node::NodeAnchorIsEqual(const AnchorPtr &left_anchor,
  127. const AnchorPtr &right_anchor,
  128. size_t i) const {
  129. GE_IF_BOOL_EXEC(left_anchor == nullptr, GELOGE(GRAPH_FAILED, "left_anchor is null."); return false);
  130. GE_IF_BOOL_EXEC(right_anchor == nullptr, GELOGE(GRAPH_FAILED, "right_anchor is null."); return false);
  131. const auto anchor_peer_size = left_anchor->GetPeerAnchors().size();
  132. const auto right_anchor_peer_size = right_anchor->GetPeerAnchors().size();
  133. // Firstly, verify anchor's peer anchors size equal or not
  134. if (anchor_peer_size != right_anchor_peer_size) {
  135. GELOGE(GRAPH_FAILED,
  136. "Size of anchor's peer anchors verify failed, node name: %s "
  137. "anchor_peer_size [%zu] is different form [%zu] at index [%zu].",
  138. this->GetName().c_str(), anchor_peer_size, right_anchor_peer_size, i);
  139. return false;
  140. }
  141. // Secondly, verify anchor's peer anchor owner node equal or not
  142. for (size_t j = 0; j < anchor_peer_size; j++) {
  143. const auto &peer_node = left_anchor->GetPeerAnchors().at(j)->GetOwnerNode();
  144. const auto &r_peer_node = right_anchor->GetPeerAnchors().at(j)->GetOwnerNode();
  145. if (peer_node == nullptr || r_peer_node == nullptr) {
  146. GELOGE(GRAPH_FAILED, "Error: anchor's peer node is null, node name: %s index[%zu] peer node index[%zu]. ",
  147. this->GetName().c_str(), i, j);
  148. return false;
  149. }
  150. // Determine the connection relationship by linking the node's name
  151. if (peer_node->GetName() != r_peer_node->GetName()) {
  152. GELOGE(GRAPH_FAILED,
  153. "anchor's peer node name verify failed, node name: %s index[%zu]"
  154. "peer node name %s is different from %s at index [%zu].",
  155. this->GetName().c_str(), i, peer_node->GetName().c_str(), r_peer_node->GetName().c_str(), j);
  156. return false;
  157. }
  158. }
  159. return true;
  160. }
  161. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool Node::NodeInConnectsAreEqual(const Node &r_node) const {
  162. // 1.Verify all in data and control anchors size
  163. const auto in_data_anchor_size = this->GetAllInDataAnchors().size();
  164. const auto r_in_data_anchor_size = r_node.GetAllInDataAnchors().size();
  165. if (in_data_anchor_size != r_in_data_anchor_size) {
  166. GELOGE(GRAPH_FAILED, "Size of node's in data anchors verify failed, node name: %s.", this->GetName().c_str());
  167. return false;
  168. }
  169. const auto l_in_anchors = this->GetAllInAnchors();
  170. const auto r_in_anchors = r_node.GetAllInAnchors();
  171. // Data anchors size equal, all anchors size not equal, means control anchor size not equal
  172. const auto in_control_anchor_size = l_in_anchors.size() - in_data_anchor_size;
  173. const auto r_in_control_anchor_size = r_in_anchors.size() - r_in_data_anchor_size;
  174. if (in_control_anchor_size != r_in_control_anchor_size) {
  175. GELOGE(GRAPH_FAILED, "Size of node's in control anchors verify failed, node name: %s.", this->GetName().c_str());
  176. return false;
  177. }
  178. // 2.Verify all in data and control anchors connect info
  179. for (size_t i = 0; i < this->GetAllInAnchors().size(); i++) {
  180. // Verify data anchors
  181. if (i < in_data_anchor_size) {
  182. const auto &in_anchor = l_in_anchors.at(i);
  183. const auto &r_in_anchor = r_in_anchors.at(i);
  184. if (!(NodeAnchorIsEqual(in_anchor, r_in_anchor, i))) {
  185. GELOGE(GRAPH_FAILED, "Node's in data control anchor verify failed, node name: %s.", this->GetName().c_str());
  186. return false;
  187. }
  188. } else {
  189. // Verify control anchors
  190. const auto &in_control_anchor = l_in_anchors.at(i);
  191. const auto &r_in_control_anchor = r_in_anchors.at(i);
  192. if (!(NodeAnchorIsEqual(in_control_anchor, r_in_control_anchor, i - in_data_anchor_size))) {
  193. GELOGE(GRAPH_FAILED, "Node's in control anchor verify failed, node name: %s.", this->GetName().c_str());
  194. return false;
  195. }
  196. }
  197. }
  198. return true;
  199. }
  200. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool Node::NodeOutConnectsAreEqual(const Node &r_node) const {
  201. // 1.Verify all out data and control anchors size
  202. const auto l_out_data_anchors = this->GetAllOutDataAnchors();
  203. const auto r_out_data_anchors = r_node.GetAllOutDataAnchors();
  204. const auto out_data_anchor_size = l_out_data_anchors.size();
  205. const auto r_out_data_anchor_size = r_out_data_anchors.size();
  206. if (out_data_anchor_size != r_out_data_anchor_size) {
  207. GELOGE(GRAPH_FAILED, "Size of node's out data anchors verify failed, node name: %s.", this->GetName().c_str());
  208. return false;
  209. }
  210. const auto l_out_anchors = this->GetAllOutAnchors();
  211. const auto r_out_anchors = r_node.GetAllOutAnchors();
  212. // Data anchors size equal, all anchors size not equal, means control anchor size not equal
  213. const auto out_control_anchor_size = l_out_anchors.size() - out_data_anchor_size;
  214. const auto r_out_control_anchor_size = r_out_anchors.size() - r_out_data_anchor_size;
  215. if (out_control_anchor_size != r_out_control_anchor_size) {
  216. GELOGE(GRAPH_FAILED, "Size of node's out control anchors verify failed, node name: %s.", this->GetName().c_str());
  217. return false;
  218. }
  219. // 2.Verify all out data and control anchors connect info
  220. for (size_t i = 0; i < this->GetAllOutAnchors().size(); i++) {
  221. // Verify data anchors
  222. if (i < out_data_anchor_size) {
  223. const auto &out_anchor = l_out_data_anchors.at(i);
  224. const auto &r_out_anchor = r_out_data_anchors.at(i);
  225. if (!(NodeAnchorIsEqual(out_anchor, r_out_anchor, i))) {
  226. GELOGE(GRAPH_FAILED, "Node's out data control anchor verify failed, node name: %s.", this->GetName().c_str());
  227. return false;
  228. }
  229. } else {
  230. // Verify control anchors
  231. const auto &out_control_anchor = l_out_anchors.at(i);
  232. const auto &r_out_control_anchor = r_out_anchors.at(i);
  233. if (!(NodeAnchorIsEqual(out_control_anchor, r_out_control_anchor, i - out_data_anchor_size))) {
  234. GELOGE(GRAPH_FAILED, "Node's out control anchor verify failed, node name: %s.", this->GetName().c_str());
  235. return false;
  236. }
  237. }
  238. }
  239. return true;
  240. }
  241. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool Node::operator==(const Node &r_node) const {
  242. return (NodeMembersAreEqual(r_node) && NodeAttrsAreEqual(r_node) && NodeInConnectsAreEqual(r_node) &&
  243. NodeOutConnectsAreEqual(r_node));
  244. }
  245. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus Node::AddLinkFrom(const NodePtr &input_node) {
  246. // This function is deprecated, please use other two overloaded functions
  247. GE_CHECK_NOTNULL(input_node);
  248. // Input_node ---> this
  249. auto out_anchors = input_node->GetAllOutDataAnchors();
  250. if (out_anchors.size() != 1) {
  251. GELOGE(GRAPH_FAILED, "out_anchor size is:%zu, only support 1", out_anchors.size());
  252. return GRAPH_PARAM_INVALID;
  253. }
  254. GE_CHK_BOOL_EXEC(op_ != nullptr, return GRAPH_FAILED, "original OpDesc is nullptr");
  255. auto op_desc = input_node->GetOpDesc();
  256. GE_CHECK_NOTNULL(op_desc);
  257. if (op_->AddInputDesc(op_desc->GetOutputDesc(0)) != GRAPH_SUCCESS) {
  258. GELOGE(GRAPH_FAILED, "add input desc failed.");
  259. return GRAPH_FAILED;
  260. }
  261. std::shared_ptr<InDataAnchor> anchor = ComGraphMakeShared<InDataAnchor>(shared_from_this(), in_data_anchors_.size());
  262. if (anchor == nullptr) {
  263. GELOGE(GRAPH_FAILED, "out_anchor size is:%zu, malloc shared_ptr failed.", out_anchors.size());
  264. return GRAPH_FAILED;
  265. }
  266. in_data_anchors_.push_back(anchor);
  267. (void)out_anchors.at(0)->LinkTo(in_data_anchors_.back());
  268. return GRAPH_SUCCESS;
  269. }
  270. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus Node::AddLinkFrom(const uint32_t &index,
  271. NodePtr input_node) {
  272. GE_CHECK_NOTNULL(input_node);
  273. // Input_node ---> this
  274. auto out_anchors = input_node->GetAllOutDataAnchors();
  275. if (out_anchors.size() != 1) {
  276. GELOGE(GRAPH_FAILED, "out_anchor size is:%zu, only support 1", out_anchors.size());
  277. return GRAPH_PARAM_INVALID;
  278. }
  279. GE_CHECK_NOTNULL(op_);
  280. auto op_desc = input_node->GetOpDesc();
  281. GE_CHECK_NOTNULL(op_desc);
  282. if (op_->AddInputDesc(index, op_desc->GetOutputDesc(0)) != GRAPH_SUCCESS) {
  283. GELOGE(GRAPH_FAILED, "add input desc failed.");
  284. return GRAPH_FAILED;
  285. }
  286. std::shared_ptr<InDataAnchor> anchor = ComGraphMakeShared<InDataAnchor>(shared_from_this(), in_data_anchors_.size());
  287. if (anchor == nullptr) {
  288. GELOGE(GRAPH_FAILED, "out_anchor size is:%zu, malloc shared_ptr failed.", out_anchors.size());
  289. return GRAPH_FAILED;
  290. }
  291. in_data_anchors_.push_back(anchor);
  292. (void)out_anchors.at(0)->LinkTo(in_data_anchors_.back());
  293. return GRAPH_SUCCESS;
  294. }
  295. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus Node::AddLinkFromForParse(const NodePtr &input_node) {
  296. // This function is used for ParseWeights.
  297. GE_CHECK_NOTNULL(input_node);
  298. // Input_node ---> this
  299. auto out_anchors = input_node->GetAllOutDataAnchors();
  300. if (out_anchors.size() != 1) {
  301. GELOGE(GRAPH_PARAM_INVALID, "out_anchor size is:%zu, only support 1", out_anchors.size());
  302. return GRAPH_PARAM_INVALID;
  303. }
  304. std::shared_ptr<InDataAnchor> anchor = ComGraphMakeShared<InDataAnchor>(shared_from_this(), in_data_anchors_.size());
  305. if (anchor == nullptr) {
  306. GELOGE(GRAPH_FAILED, "out_anchor size is:%zu, make anchor failed", out_anchors.size());
  307. return GRAPH_FAILED;
  308. }
  309. in_data_anchors_.push_back(anchor);
  310. (void)out_anchors.at(0)->LinkTo(in_data_anchors_.back());
  311. return GRAPH_SUCCESS;
  312. }
  313. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus Node::AddLinkFrom(const string &name, NodePtr input_node) {
  314. GE_CHECK_NOTNULL(input_node);
  315. // Input_node ---> this
  316. auto out_anchors = input_node->GetAllOutDataAnchors();
  317. if (out_anchors.size() != 1) {
  318. GELOGE(GRAPH_PARAM_INVALID, "out_anchor size is:%zu, only support 1", out_anchors.size());
  319. return GRAPH_PARAM_INVALID;
  320. }
  321. GE_CHECK_NOTNULL(op_);
  322. auto op_desc = input_node->GetOpDesc();
  323. GE_CHECK_NOTNULL(op_desc);
  324. if (op_->AddInputDesc(name, op_desc->GetOutputDesc(0)) != GRAPH_SUCCESS) {
  325. GELOGE(GRAPH_FAILED, "add input desc failed.");
  326. return GRAPH_FAILED;
  327. }
  328. std::shared_ptr<InDataAnchor> anchor = ComGraphMakeShared<InDataAnchor>(shared_from_this(), in_data_anchors_.size());
  329. if (anchor == nullptr) {
  330. GELOGE(GRAPH_FAILED, "out_anchor size is:%zu, malloc shared_ptr failed.", out_anchors.size());
  331. return GRAPH_FAILED;
  332. }
  333. in_data_anchors_.push_back(anchor);
  334. (void)out_anchors.at(0)->LinkTo(in_data_anchors_.back());
  335. return GRAPH_SUCCESS;
  336. }
  337. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY ComputeGraphPtr Node::GetOwnerComputeGraph() const {
  338. return owner_graph_.lock();
  339. }
  340. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus Node::SetOwnerComputeGraph(const ComputeGraphPtr &graph) {
  341. if (graph == nullptr) {
  342. return GRAPH_PARAM_INVALID;
  343. }
  344. owner_graph_ = graph;
  345. return GRAPH_SUCCESS;
  346. }
  347. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Node::Vistor<InDataAnchorPtr> Node::GetAllInDataAnchors() const {
  348. return Vistor<InDataAnchorPtr>(shared_from_this(), in_data_anchors_);
  349. }
  350. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Node::Vistor<OutDataAnchorPtr> Node::GetAllOutDataAnchors() const {
  351. return Vistor<OutDataAnchorPtr>(shared_from_this(), out_data_anchors_);
  352. }
  353. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY uint32_t Node::GetAllInDataAnchorsSize() const {
  354. return in_data_anchors_.size();
  355. }
  356. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY uint32_t Node::GetAllOutDataAnchorsSize() const {
  357. return out_data_anchors_.size();
  358. }
  359. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Node::Vistor<AnchorPtr> Node::GetAllInAnchors() const {
  360. std::vector<AnchorPtr> vec;
  361. // Push back in_data_anchors_
  362. for (const auto &in_anchor_iter : Vistor<InDataAnchorPtr>(shared_from_this(), in_data_anchors_)) {
  363. auto in_anchor = Anchor::DynamicAnchorCast<Anchor>(in_anchor_iter);
  364. if (in_anchor != nullptr) {
  365. vec.push_back(in_anchor);
  366. }
  367. }
  368. // Push back in_control_anchor_
  369. if ((in_control_anchor_->GetPeerOutControlAnchors().size() > 0) ||
  370. (in_control_anchor_->GetPeerOutDataAnchors().size() > 0)) {
  371. auto in_anchor = Anchor::DynamicAnchorCast<Anchor>(in_control_anchor_);
  372. if (in_anchor != nullptr) {
  373. vec.push_back(in_anchor);
  374. }
  375. }
  376. return Node::Vistor<AnchorPtr>(shared_from_this(), vec);
  377. }
  378. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Node::Vistor<AnchorPtr> Node::GetAllOutAnchors() const {
  379. std::vector<AnchorPtr> vec;
  380. // Push back out_data_anchors_
  381. for (const auto &out_anchor_iter : Vistor<OutDataAnchorPtr>(shared_from_this(), out_data_anchors_)) {
  382. auto out_anchor = Anchor::DynamicAnchorCast<Anchor>(out_anchor_iter);
  383. if (out_anchor != nullptr) {
  384. vec.push_back(out_anchor);
  385. }
  386. }
  387. // Push back out_control_anchor_
  388. if (out_control_anchor_->GetPeerInControlAnchors().size() > 0 ||
  389. out_control_anchor_->GetPeerInDataAnchors().size() > 0) {
  390. auto out_anchor = Anchor::DynamicAnchorCast<Anchor>(out_control_anchor_);
  391. if (out_anchor != nullptr) {
  392. vec.push_back(out_anchor);
  393. }
  394. }
  395. return Node::Vistor<AnchorPtr>(shared_from_this(), vec);
  396. }
  397. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY InDataAnchorPtr Node::GetInDataAnchor(int idx) const {
  398. if (idx < 0 || idx >= static_cast<int>(in_data_anchors_.size())) {
  399. GELOGE(GRAPH_FAILED, "the node doesn't have %d th in_data_anchor, node %s:%s", idx, GetType().c_str(),
  400. GetName().c_str());
  401. return nullptr;
  402. } else {
  403. return in_data_anchors_[idx];
  404. }
  405. }
  406. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY AnchorPtr Node::GetInAnchor(int idx) const {
  407. // Idx can't be less than -1 or >= in_data_anchors_.size(), -1 means index of control anchor_
  408. if (idx < -1 || idx >= static_cast<int>(in_data_anchors_.size())) {
  409. GELOGW("the node doesn't have %d th in_anchor, node %s:%s", idx, GetType().c_str(), GetName().c_str());
  410. return nullptr;
  411. } else {
  412. // Return control anchor
  413. if (idx == -1) {
  414. auto in_anchor = Anchor::DynamicAnchorCast<Anchor>(in_control_anchor_);
  415. return in_anchor;
  416. }
  417. // Return data anchor
  418. return in_data_anchors_[idx];
  419. }
  420. }
  421. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY AnchorPtr Node::GetOutAnchor(int idx) const {
  422. // Idx can't be less than -1 or >= out_data_anchors_.size(), -1 means index of control anchor_
  423. if (idx < -1 || idx >= static_cast<int>(out_data_anchors_.size())) {
  424. GELOGE(GRAPH_FAILED, "the node doesn't have %d th out_anchor, node %s:%s", idx, GetType().c_str(),
  425. GetName().c_str());
  426. return nullptr;
  427. } else {
  428. // Return control anchor
  429. if (idx == -1) {
  430. auto out_anchor = Anchor::DynamicAnchorCast<Anchor>(out_control_anchor_);
  431. return out_anchor;
  432. }
  433. // Return data anchor
  434. return out_data_anchors_[idx];
  435. }
  436. }
  437. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OutDataAnchorPtr Node::GetOutDataAnchor(int idx) const {
  438. if (idx < 0 || idx >= static_cast<int>(out_data_anchors_.size())) {
  439. GELOGE(GRAPH_FAILED, "the node doesn't have %d th out_data_anchor, node %s:%s", idx, GetType().c_str(),
  440. GetName().c_str());
  441. return nullptr;
  442. } else {
  443. return out_data_anchors_[idx];
  444. }
  445. }
  446. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY InControlAnchorPtr Node::GetInControlAnchor() const {
  447. return in_control_anchor_;
  448. }
  449. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OutControlAnchorPtr Node::GetOutControlAnchor() const {
  450. return out_control_anchor_;
  451. }
  452. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Node::Vistor<NodePtr> Node::GetInNodes() const {
  453. std::vector<NodePtr> vec;
  454. for (const auto &in_anchor : in_data_anchors_) {
  455. GE_CHK_BOOL_EXEC((in_anchor != nullptr), continue, "in_data_anchor is nullptr");
  456. auto out_anchor = in_anchor->GetPeerOutAnchor();
  457. if (out_anchor == nullptr) {
  458. continue;
  459. }
  460. auto node = out_anchor->GetOwnerNode();
  461. GE_CHK_BOOL_EXEC(node != nullptr, continue, "GetOwnerNode is nullptr");
  462. vec.push_back(node);
  463. }
  464. if (in_control_anchor_ != nullptr) {
  465. if (in_control_anchor_->IsPeerOutAnchorsEmpty()) {
  466. return Node::Vistor<NodePtr>(shared_from_this(), vec);
  467. }
  468. auto peer_out_anchors = in_control_anchor_->GetPeerOutDataAnchors();
  469. for (const auto &out_anchor : peer_out_anchors) {
  470. GE_CHK_BOOL_EXEC(out_anchor != nullptr, continue, "in_control_anchor_ peer out data anchors is nullptr");
  471. auto node = out_anchor->GetOwnerNode();
  472. GE_CHK_BOOL_EXEC(node != nullptr, continue, "GetOwnerNode is nullptr");
  473. vec.push_back(node);
  474. }
  475. auto peer_out_control_anchors = in_control_anchor_->GetPeerOutControlAnchors();
  476. for (const auto &out_control_anchor : peer_out_control_anchors) {
  477. GE_CHK_BOOL_EXEC(out_control_anchor != nullptr, continue,
  478. "in_control_anchor_ peer out control anchors is nullptr");
  479. auto node = out_control_anchor->GetOwnerNode();
  480. GE_CHK_BOOL_EXEC(node != nullptr, continue, "GetOwnerNode is nullptr");
  481. vec.push_back(node);
  482. }
  483. }
  484. return Node::Vistor<NodePtr>(shared_from_this(), vec);
  485. }
  486. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool Node::IsAllInNodesSeen(
  487. std::unordered_set<Node *> &nodes_seen) const {
  488. for (const auto &in_anchor : in_data_anchors_) {
  489. GE_CHK_BOOL_EXEC((in_anchor != nullptr), continue, "in_data_anchor is nullptr");
  490. auto out_anchor = in_anchor->GetPeerOutAnchor();
  491. if (out_anchor == nullptr) {
  492. continue;
  493. }
  494. auto node = out_anchor->GetOwnerNode();
  495. GE_CHK_BOOL_EXEC(node != nullptr, continue, "GetOwnerNode is nullptr");
  496. if ((node->GetType() == NEXTITERATION) || (node->GetType() == REFNEXTITERATION)) {
  497. continue;
  498. }
  499. if (nodes_seen.count(node.get()) == 0) {
  500. return false;
  501. }
  502. }
  503. if (in_control_anchor_ != nullptr) {
  504. if (in_control_anchor_->IsPeerOutAnchorsEmpty()) {
  505. return true;
  506. }
  507. auto peer_out_control_anchors = in_control_anchor_->GetPeerOutControlAnchors();
  508. for (const auto &out_control_anchor : peer_out_control_anchors) {
  509. GE_CHK_BOOL_EXEC(out_control_anchor != nullptr, continue, "out_control_anchor is nullptr");
  510. auto node = out_control_anchor->GetOwnerNode();
  511. GE_CHK_BOOL_EXEC(node != nullptr, continue, "GetOwnerNode is nullptr");
  512. if ((node->GetType() == NEXTITERATION) || (node->GetType() == REFNEXTITERATION)) {
  513. continue;
  514. }
  515. if (nodes_seen.count(node.get()) == 0) {
  516. return false;
  517. }
  518. }
  519. }
  520. return true;
  521. }
  522. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Node::Vistor<NodePtr> Node::GetInDataNodes() const {
  523. std::vector<NodePtr> vec;
  524. for (const auto &in_anchor : in_data_anchors_) {
  525. GE_CHK_BOOL_EXEC((in_anchor != nullptr), continue, "in_data_anchor is nullptr");
  526. auto anchor_ptr = in_anchor->GetPeerOutAnchor();
  527. if (anchor_ptr == nullptr) {
  528. continue;
  529. }
  530. auto node = anchor_ptr->GetOwnerNode();
  531. GE_CHK_BOOL_EXEC(node != nullptr, continue, "GetOwnerNode is nullptr");
  532. vec.push_back(node);
  533. }
  534. return Node::Vistor<NodePtr>(shared_from_this(), vec);
  535. }
  536. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Node::Vistor<NodePtr> Node::GetInControlNodes() const {
  537. std::vector<NodePtr> vec;
  538. if (in_control_anchor_ != nullptr) {
  539. for (const auto &in_anchor : in_control_anchor_->GetPeerOutControlAnchors()) {
  540. GE_CHK_BOOL_EXEC(in_anchor != nullptr, continue, "GetPeerOutControlAnchors is nullptr");
  541. auto node = in_anchor->GetOwnerNode();
  542. GE_CHK_BOOL_EXEC(node != nullptr, continue, "GetOwnerNode is nullptr");
  543. vec.push_back(node);
  544. }
  545. }
  546. return Node::Vistor<NodePtr>(shared_from_this(), vec);
  547. }
  548. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Node::Vistor<NodePtr> Node::GetOutNodes() const {
  549. std::vector<NodePtr> vec;
  550. for (const auto &out_anchor : out_data_anchors_) {
  551. GE_CHK_BOOL_EXEC((out_anchor != nullptr), continue, "out_data_anchors_ is nullptr");
  552. for (const auto &peer_in_anchor : out_anchor->GetPeerInDataAnchors()) {
  553. GE_CHK_BOOL_EXEC((peer_in_anchor != nullptr), continue, "GetPeerInDataAnchors is nullptr");
  554. auto node = peer_in_anchor->GetOwnerNode();
  555. GE_CHK_BOOL_EXEC(node != nullptr, continue, "GetOwnerNode is nullptr");
  556. vec.push_back(node);
  557. }
  558. }
  559. if (out_control_anchor_ != nullptr) {
  560. auto peer_in_control_anchors = out_control_anchor_->GetPeerInControlAnchors();
  561. for (const auto &in_control_anchor : peer_in_control_anchors) {
  562. GE_CHK_BOOL_EXEC(in_control_anchor != nullptr, continue,
  563. "out_control_anchor_ peer in control anchors is nullptr");
  564. auto node = in_control_anchor->GetOwnerNode();
  565. GE_CHK_BOOL_EXEC(node != nullptr, continue, "GetOwnerNode is nullptr");
  566. vec.push_back(node);
  567. }
  568. }
  569. return Node::Vistor<NodePtr>(shared_from_this(), vec);
  570. }
  571. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Node::Vistor<NodePtr> Node::GetInAllNodes() const {
  572. std::vector<NodePtr> vec;
  573. for (const auto &in_node : GetInDataNodes()) {
  574. vec.push_back(in_node);
  575. }
  576. for (const auto &in_control_node : GetInControlNodes()) {
  577. vec.push_back(in_control_node);
  578. }
  579. return Node::Vistor<NodePtr>(shared_from_this(), vec);
  580. }
  581. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Node::Vistor<NodePtr> Node::GetOutDataNodes() const {
  582. std::vector<NodePtr> vec;
  583. for (const auto &out_anchor : out_data_anchors_) {
  584. GE_CHK_BOOL_EXEC((out_anchor != nullptr), continue, "out_data_anchors_ is nullptr");
  585. for (const auto &in_anchor : out_anchor->GetPeerInDataAnchors()) {
  586. GE_CHK_BOOL_EXEC((in_anchor != nullptr), continue, "GetPeerInDataAnchors is nullptr");
  587. auto node = in_anchor->GetOwnerNode();
  588. GE_CHK_BOOL_EXEC(node != nullptr, continue, "GetOwnerNode is nullptr");
  589. vec.push_back(node);
  590. }
  591. }
  592. return Node::Vistor<NodePtr>(shared_from_this(), vec);
  593. }
  594. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY uint32_t Node::GetOutDataNodesSize() const {
  595. uint32_t out_nums = 0;
  596. for (const auto &out_anchor : out_data_anchors_) {
  597. GE_CHK_BOOL_EXEC((out_anchor != nullptr), continue, "out_data_anchors_ is nullptr");
  598. out_nums += out_anchor->GetPeerInDataNodesSize();
  599. }
  600. return out_nums;
  601. }
  602. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Node::Vistor<NodePtr> Node::GetOutControlNodes() const {
  603. std::vector<NodePtr> vec;
  604. for (const auto &out_anchor : out_data_anchors_) {
  605. GE_CHK_BOOL_EXEC((out_anchor != nullptr), continue, "out_data_anchors_ is nullptr");
  606. for (const auto &in_anchor : out_anchor->GetPeerInControlAnchors()) {
  607. GE_CHK_BOOL_EXEC((in_anchor != nullptr), continue, "GetPeerInControlAnchors is nullptr");
  608. auto node = in_anchor->GetOwnerNode();
  609. GE_CHK_BOOL_EXEC(node != nullptr, continue, "GetOwnerNode is nullptr");
  610. vec.push_back(node);
  611. }
  612. }
  613. if (out_control_anchor_ != nullptr) {
  614. for (const auto &in_anchor : out_control_anchor_->GetPeerAnchors()) {
  615. GE_CHK_BOOL_EXEC(in_anchor != nullptr, continue, "GetPeerInControlAnchors is nullptr");
  616. auto node = in_anchor->GetOwnerNode();
  617. GE_CHK_BOOL_EXEC(node != nullptr, continue, "GetOwnerNode is nullptr");
  618. vec.push_back(node);
  619. }
  620. }
  621. return Node::Vistor<NodePtr>(shared_from_this(), vec);
  622. }
  623. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Node::Vistor<NodePtr> Node::GetOutAllNodes() const {
  624. std::vector<NodePtr> vec;
  625. for (const auto &out_anchor : out_data_anchors_) {
  626. GE_CHK_BOOL_EXEC((out_anchor != nullptr), { continue; }, "out_data_anchors_ is nullptr");
  627. for (const auto &in_anchor : out_anchor->GetPeerInDataAnchors()) {
  628. GE_CHK_BOOL_EXEC((in_anchor != nullptr), { continue; }, "GetPeerInDataAnchors is nullptr");
  629. auto node = in_anchor->GetOwnerNode();
  630. GE_CHK_BOOL_EXEC(node != nullptr, continue, "GetOwnerNode is nullptr");
  631. vec.push_back(node);
  632. }
  633. for (const auto &in_anchor : out_anchor->GetPeerInControlAnchors()) {
  634. GE_CHK_BOOL_EXEC(in_anchor != nullptr, continue, "GetPeerInControlAnchors is nullptr");
  635. auto node = in_anchor->GetOwnerNode();
  636. GE_CHK_BOOL_EXEC(node != nullptr, continue, "GetOwnerNode is nullptr");
  637. vec.push_back(node);
  638. }
  639. }
  640. if (out_control_anchor_ != nullptr) {
  641. for (const auto &in_anchor : out_control_anchor_->GetPeerAnchors()) {
  642. GE_CHK_BOOL_EXEC(in_anchor != nullptr, continue, "GetPeerInControlAnchors is nullptr");
  643. auto node = in_anchor->GetOwnerNode();
  644. GE_CHK_BOOL_EXEC(node != nullptr, continue, "GetOwnerNode is nullptr");
  645. vec.push_back(node);
  646. }
  647. }
  648. return Node::Vistor<NodePtr>(shared_from_this(), vec);
  649. }
  650. graphStatus Node::InferShapeAndType() const {
  651. Operator op = ge::OpDescUtils::CreateOperatorFromNode(shared_from_this());
  652. graphStatus ret = ShapeRefiner::InferShapeAndType(shared_from_this(), op);
  653. return ret;
  654. }
  655. graphStatus Node::InferOriginFormat() const {
  656. Operator op = ge::OpDescUtils::CreateOperatorFromNode(shared_from_this());
  657. // Get infer func and execute
  658. GE_CHK_BOOL_EXEC(op_ != nullptr, return GRAPH_FAILED, "original OpDesc is nullptr");
  659. return op_->CallInferFormatFunc(op);
  660. }
  661. graphStatus Node::Verify() const {
  662. const string data_type = "Data";
  663. const string aipp_data_type = "AippData";
  664. const string const_type = "Const";
  665. const string variable_type = "Variable";
  666. GE_CHK_BOOL_EXEC(op_ != nullptr, return GRAPH_FAILED, "original OpDesc is nullptr");
  667. for (const auto &in_anchor_ptr : GetAllInDataAnchors()) {
  668. if (in_anchor_ptr == nullptr) {
  669. GELOGW("in anchor ptr is null");
  670. continue;
  671. }
  672. GE_CHK_BOOL_RET_STATUS(
  673. op_->GetType() == data_type || op_->GetType() == aipp_data_type || op_->GetType() == const_type ||
  674. op_->GetType() == variable_type || op_->IsOptionalInput(in_anchor_ptr->GetIdx()) ||
  675. in_anchor_ptr->GetPeerAnchors().size() > 0,
  676. GRAPH_FAILED, "operator %s's input %d is not linked.", GetName().c_str(), in_anchor_ptr->GetIdx());
  677. }
  678. string frameworkop_type = "FrameworkOp";
  679. if (op_->GetType() != frameworkop_type) {
  680. auto node_op = ge::OperatorFactoryImpl::CreateOperator("node_op", op_->GetType());
  681. if (node_op.IsEmpty()) {
  682. GELOGW("get op from OperatorFactory fail. opType: %s", op_->GetType().c_str());
  683. } else {
  684. GELOGD("get op from OperatorFactory success. opType: %s", op_->GetType().c_str());
  685. auto temp_op_desc = ge::OpDescUtils::GetOpDescFromOperator(node_op);
  686. if (temp_op_desc == nullptr) {
  687. GELOGE(GRAPH_FAILED, "temp op desc is null");
  688. return GRAPH_FAILED;
  689. }
  690. if (!op_->UpdateInputName(temp_op_desc->GetAllInputName())) {
  691. GELOGW("Verify UpdateInputName failed");
  692. }
  693. if (!op_->UpdateOutputName(temp_op_desc->GetAllOutputName())) {
  694. GELOGW("Verify UpdateOutputName failed");
  695. }
  696. }
  697. node_op.BreakConnect();
  698. }
  699. if (op_->CommonVerify() == GRAPH_SUCCESS) {
  700. Operator op_proxy = ge::OpDescUtils::CreateOperatorFromNode(shared_from_this());
  701. auto verify_func = op_->GetVerifyFunc();
  702. if (verify_func == nullptr) {
  703. verify_func = OperatorFactoryImpl::GetVerifyFunc(GetType());
  704. }
  705. if (verify_func != nullptr) {
  706. return (graphStatus)verify_func(op_proxy);
  707. }
  708. return GRAPH_SUCCESS;
  709. } else {
  710. GELOGE(GRAPH_FAILED, "%s Verify failed.", op_->GetType().c_str());
  711. return GRAPH_FAILED;
  712. }
  713. }
  714. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OpDescPtr Node::GetOpDesc() const { return op_; }
  715. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus Node::UpdateOpDesc(const OpDescPtr &op_desc) {
  716. GE_CHK_BOOL_EXEC(op_ != nullptr, return GRAPH_FAILED, "original OpDesc is nullptr");
  717. GE_CHK_BOOL_EXEC(op_desc != nullptr, return GRAPH_PARAM_INVALID, "Param OpDesc is nullptr");
  718. GE_CHK_BOOL_EXEC(op_->GetInputsSize() == op_desc->GetInputsSize(), return GRAPH_PARAM_INVALID,
  719. "Inputs count expected to be same, orginial OpDesc %zu, Param OpDesc %zu", op_->GetInputsSize(),
  720. op_desc->GetInputsSize());
  721. GE_CHK_BOOL_EXEC(op_->GetOutputsSize() == op_desc->GetOutputsSize(), return GRAPH_PARAM_INVALID,
  722. "Outputs count expected to be same, orginial OpDesc %zu, Param OpDesc %zu", op_->GetOutputsSize(),
  723. op_desc->GetOutputsSize());
  724. op_ = op_desc;
  725. return GRAPH_SUCCESS;
  726. }
  727. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Node::Vistor<std::pair<NodePtr, OutDataAnchorPtr>>
  728. Node::GetInDataNodesAndAnchors() const {
  729. std::vector<std::pair<NodePtr, OutDataAnchorPtr>> vec;
  730. for (const auto &p : in_data_anchors_) {
  731. if (p == nullptr) {
  732. GELOGW("indata anchor is nullptr, node %s:%s", GetType().c_str(), GetName().c_str());
  733. continue;
  734. }
  735. auto anchor_ptr = p->GetPeerOutAnchor();
  736. if (anchor_ptr == nullptr) {
  737. continue;
  738. }
  739. auto node = anchor_ptr->GetOwnerNode();
  740. if (node == nullptr) {
  741. GELOGW("src node is nullptr, node %s:%s", GetType().c_str(), GetName().c_str());
  742. continue;
  743. }
  744. vec.push_back(std::make_pair(node, anchor_ptr));
  745. }
  746. return Node::Vistor<std::pair<NodePtr, OutDataAnchorPtr>>(shared_from_this(), vec);
  747. }
  748. GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Node::Vistor<std::pair<NodePtr, InDataAnchorPtr>>
  749. Node::GetOutDataNodesAndAnchors() const {
  750. std::vector<std::pair<NodePtr, InDataAnchorPtr>> vec;
  751. for (const auto &p : out_data_anchors_) {
  752. if (p == nullptr) {
  753. GELOGW("out data anchor is nullptr, node %s:%s", GetType().c_str(), GetName().c_str());
  754. continue;
  755. }
  756. for (const auto &in_anchor : p->GetPeerInDataAnchors()) {
  757. if (in_anchor == nullptr) {
  758. GELOGW("dst in data anchor is nullptr, node %s:%s", GetType().c_str(), GetName().c_str());
  759. continue;
  760. }
  761. auto node = in_anchor->GetOwnerNode();
  762. if (node == nullptr) {
  763. GELOGW("dst node is nullptr, node %s:%s", GetType().c_str(), GetName().c_str());
  764. continue;
  765. }
  766. vec.push_back(std::make_pair(node, in_anchor));
  767. }
  768. }
  769. return Node::Vistor<std::pair<NodePtr, InDataAnchorPtr>>(shared_from_this(), vec);
  770. }
  771. } // namespace ge

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