Skip to content

Commit f41e309

Browse files
committed
Apply review comments
1 parent 300795a commit f41e309

File tree

9 files changed

+276
-273
lines changed

9 files changed

+276
-273
lines changed

src/plugins/intel_cpu/src/cpu_memory.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,14 @@ void Memory::create(MemoryDescPtr desc, const void* data, bool pads_zeroing) {
9393
m_padsZeroing = pads_zeroing;
9494
dnnlMemHandle.resetDnnlPrim();
9595

96-
if (m_pMemDesc->isDefined()) {
97-
auto memSize = m_pMemDesc->getCurrentMemSize();
98-
if (nullptr != data) {
99-
m_mgrHandle->setExtBuff(const_cast<void*>(data), memSize);
100-
} else {
101-
m_mgrHandle->resize(memSize);
102-
}
96+
if (!m_pMemDesc->isDefined()) {
97+
return;
98+
}
99+
auto memSize = m_pMemDesc->getCurrentMemSize();
100+
if (nullptr != data) {
101+
m_mgrHandle->setExtBuff(const_cast<void*>(data), memSize);
102+
} else {
103+
m_mgrHandle->resize(memSize);
103104
}
104105
}
105106

src/plugins/intel_cpu/src/edge.cpp

Lines changed: 29 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ bool Edge::enforceReorder() {
105105
for (auto& p_edge_peer : portChildEdges) {
106106
if (p_edge_peer.get() == this)
107107
continue;
108-
if (p_edge_peer->inPlace(LOOK_DOWN)) { //p_edge_peer->getChild()->getType() != Type::Reorder &&
108+
if (p_edge_peer->inPlace(LOOK_DOWN)) {
109109
return true;
110110
}
111111
}
@@ -472,22 +472,6 @@ void Edge::init() {
472472
}
473473
sharedMemFrom(edgePtr);
474474
}
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-
// }
491475
}
492476

493477
/**
@@ -550,42 +534,45 @@ bool Edge::inPlace(LOOK look) const {
550534

551535
NodePtr Edge::modifiedInPlace() const {
552536
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+
}
558563
if (childNode->isExecutable()) {
559564
// Node can modify the memory
560565
return childNode;
561566
}
562-
for (auto&& edge : childNode->getChildEdgesAtPort(inPlaceInputPort)) {
567+
for (auto&& edge : childNode->getChildEdgesAtPort(i)) {
563568
// continue searching
564569
if (auto result = edge->modifiedInPlace()) {
565570
return result;
566571
}
567572
}
568573
}
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-
}
588574
}
575+
589576
// nothing has been found
590577
return nullptr;
591578
}

0 commit comments

Comments
 (0)