Skip to content

Commit

Permalink
Apply review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnick committed Jul 6, 2023
1 parent c41bf41 commit 97b8873
Show file tree
Hide file tree
Showing 9 changed files with 276 additions and 273 deletions.
15 changes: 8 additions & 7 deletions src/plugins/intel_cpu/src/cpu_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,14 @@ void Memory::create(MemoryDescPtr desc, const void* data, bool pads_zeroing) {
m_padsZeroing = pads_zeroing;
dnnlMemHandle.resetDnnlPrim();

if (m_pMemDesc->isDefined()) {
auto memSize = m_pMemDesc->getCurrentMemSize();
if (nullptr != data) {
m_mgrHandle->setExtBuff(const_cast<void*>(data), memSize);
} else {
m_mgrHandle->resize(memSize);
}
if (!m_pMemDesc->isDefined()) {
return;
}
auto memSize = m_pMemDesc->getCurrentMemSize();
if (nullptr != data) {
m_mgrHandle->setExtBuff(const_cast<void*>(data), memSize);
} else {
m_mgrHandle->resize(memSize);
}
}

Expand Down
71 changes: 29 additions & 42 deletions src/plugins/intel_cpu/src/edge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ bool Edge::enforceReorder() {
for (auto& p_edge_peer : portChildEdges) {
if (p_edge_peer.get() == this)
continue;
if (p_edge_peer->inPlace(LOOK_DOWN)) { //p_edge_peer->getChild()->getType() != Type::Reorder &&
if (p_edge_peer->inPlace(LOOK_DOWN)) {
return true;
}
}
Expand Down Expand Up @@ -472,22 +472,6 @@ void Edge::init() {
}
sharedMemFrom(edgePtr);
}
//
// auto port = getInputNum();
// if (port < 0)
// return;
// auto edges_at_same_port = getParent()->getChildEdgesAtPort(static_cast<size_t>(port));
// for (auto edge : edges_at_same_port) {
// if (edge->getStatus() != Status::NeedAllocation && edge->getStatus() != Status::Uninitialized) {
// if (edge->getSharedEdge() != edgePtr)
// IE_THROW() << "Unsupported behavior. Cannot mark edge "
// << getParent()->getChildEdgeAt(0)->getParent()->getName() << "->"
// << getParent()->getChildEdgeAt(0)->getChild()->getName() << " as not allocated!";
// } else {
// if (edge != edgePtr)
// edge->sharedMemFrom(edgePtr);
// }
// }
}

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

NodePtr Edge::modifiedInPlace() const {
auto childNode = getChild();
if (childNode && childNode->isInPlace()) {
// check if the children nodes are able to modify the memory
auto childPort = getOutputNum();
auto inPlaceInputPort = childNode->inPlaceInputPort(childPort);
if (inPlaceInputPort >= 0) {
if (!childNode || !childNode->isInPlace()) {
return nullptr;
}
// check if the children nodes are able to modify the memory
auto childPort = getOutputNum();
auto inPlaceInputPort = childNode->inPlaceInputPort(childPort);
if (inPlaceInputPort >= 0) {
if (childNode->isExecutable()) {
// Node can modify the memory
return childNode;
}
for (auto&& edge : childNode->getChildEdgesAtPort(inPlaceInputPort)) {
// continue searching
if (auto result = edge->modifiedInPlace()) {
return result;
}
}
}
// check backward dependency
if (auto childSPD = childNode->getSelectedPrimitiveDescriptor()) {
auto& outConfs = childSPD->getConfig().outConfs;
for (size_t i = 0; i < outConfs.size(); ++i) {
const auto& conf = outConfs[i];
if (childPort < 0 || conf.inPlace() != childPort) {
continue;
}
if (childNode->isExecutable()) {
// Node can modify the memory
return childNode;
}
for (auto&& edge : childNode->getChildEdgesAtPort(inPlaceInputPort)) {
for (auto&& edge : childNode->getChildEdgesAtPort(i)) {
// continue searching
if (auto result = edge->modifiedInPlace()) {
return result;
}
}
}
// check backward dependency
if (auto childSPD = childNode->getSelectedPrimitiveDescriptor()) {
auto& outConfs = childSPD->getConfig().outConfs;
for (size_t i = 0; i < outConfs.size(); ++i) {
const auto& conf = outConfs[i];
if (childPort >= 0 && conf.inPlace() == childPort) {
if (childNode->isExecutable()) {
// Node can modify the memory
return childNode;
}
for (auto&& edge : childNode->getChildEdgesAtPort(i)) {
// continue searching
if (auto result = edge->modifiedInPlace()) {
return result;
}
}
}
}
}
}

// nothing has been found
return nullptr;
}
Expand Down
Loading

0 comments on commit 97b8873

Please sign in to comment.