@@ -105,7 +105,7 @@ bool Edge::enforceReorder() {
105
105
for (auto & p_edge_peer : portChildEdges) {
106
106
if (p_edge_peer.get () == this )
107
107
continue ;
108
- if (p_edge_peer->inPlace (LOOK_DOWN)) { // p_edge_peer->getChild()->getType() != Type::Reorder &&
108
+ if (p_edge_peer->inPlace (LOOK_DOWN)) {
109
109
return true ;
110
110
}
111
111
}
@@ -472,22 +472,6 @@ void Edge::init() {
472
472
}
473
473
sharedMemFrom (edgePtr);
474
474
}
475
- //
476
- // auto port = getInputNum();
477
- // if (port < 0)
478
- // return;
479
- // auto edges_at_same_port = getParent()->getChildEdgesAtPort(static_cast<size_t>(port));
480
- // for (auto edge : edges_at_same_port) {
481
- // if (edge->getStatus() != Status::NeedAllocation && edge->getStatus() != Status::Uninitialized) {
482
- // if (edge->getSharedEdge() != edgePtr)
483
- // IE_THROW() << "Unsupported behavior. Cannot mark edge "
484
- // << getParent()->getChildEdgeAt(0)->getParent()->getName() << "->"
485
- // << getParent()->getChildEdgeAt(0)->getChild()->getName() << " as not allocated!";
486
- // } else {
487
- // if (edge != edgePtr)
488
- // edge->sharedMemFrom(edgePtr);
489
- // }
490
- // }
491
475
}
492
476
493
477
/* *
@@ -550,42 +534,45 @@ bool Edge::inPlace(LOOK look) const {
550
534
551
535
NodePtr Edge::modifiedInPlace () const {
552
536
auto childNode = getChild ();
553
- if (childNode && childNode->isInPlace ()) {
554
- // check if the children nodes are able to modify the memory
555
- auto childPort = getOutputNum ();
556
- auto inPlaceInputPort = childNode->inPlaceInputPort (childPort);
557
- if (inPlaceInputPort >= 0 ) {
537
+ if (!childNode || !childNode->isInPlace ()) {
538
+ return nullptr ;
539
+ }
540
+ // check if the children nodes are able to modify the memory
541
+ auto childPort = getOutputNum ();
542
+ auto inPlaceInputPort = childNode->inPlaceInputPort (childPort);
543
+ if (inPlaceInputPort >= 0 ) {
544
+ if (childNode->isExecutable ()) {
545
+ // Node can modify the memory
546
+ return childNode;
547
+ }
548
+ for (auto && edge : childNode->getChildEdgesAtPort (inPlaceInputPort)) {
549
+ // continue searching
550
+ if (auto result = edge->modifiedInPlace ()) {
551
+ return result;
552
+ }
553
+ }
554
+ }
555
+ // check backward dependency
556
+ if (auto childSPD = childNode->getSelectedPrimitiveDescriptor ()) {
557
+ auto & outConfs = childSPD->getConfig ().outConfs ;
558
+ for (size_t i = 0 ; i < outConfs.size (); ++i) {
559
+ const auto & conf = outConfs[i];
560
+ if (childPort < 0 || conf.inPlace () != childPort) {
561
+ continue ;
562
+ }
558
563
if (childNode->isExecutable ()) {
559
564
// Node can modify the memory
560
565
return childNode;
561
566
}
562
- for (auto && edge : childNode->getChildEdgesAtPort (inPlaceInputPort )) {
567
+ for (auto && edge : childNode->getChildEdgesAtPort (i )) {
563
568
// continue searching
564
569
if (auto result = edge->modifiedInPlace ()) {
565
570
return result;
566
571
}
567
572
}
568
573
}
569
- // check backward dependency
570
- if (auto childSPD = childNode->getSelectedPrimitiveDescriptor ()) {
571
- auto & outConfs = childSPD->getConfig ().outConfs ;
572
- for (size_t i = 0 ; i < outConfs.size (); ++i) {
573
- const auto & conf = outConfs[i];
574
- if (childPort >= 0 && conf.inPlace () == childPort) {
575
- if (childNode->isExecutable ()) {
576
- // Node can modify the memory
577
- return childNode;
578
- }
579
- for (auto && edge : childNode->getChildEdgesAtPort (i)) {
580
- // continue searching
581
- if (auto result = edge->modifiedInPlace ()) {
582
- return result;
583
- }
584
- }
585
- }
586
- }
587
- }
588
574
}
575
+
589
576
// nothing has been found
590
577
return nullptr ;
591
578
}
0 commit comments