Skip to content

Commit

Permalink
Remove unnecessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
riverlijunjie committed Sep 13, 2023
1 parent cbd2c5f commit 75aa3bd
Showing 1 changed file with 1 addition and 52 deletions.
53 changes: 1 addition & 52 deletions src/plugins/intel_cpu/src/graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,33 +445,6 @@ void Graph::CreatePrimitivesAndExecConstants() const {
}
}

static bool isReorderAvailable(const MemoryDescPtr& parentDesc, const MemoryDescPtr& childDesc, const dnnl::engine& eng) {
auto definedParentDesc = parentDesc->isDefined() ? parentDesc : MemoryDescUtils::makeDummyDesc(*parentDesc);
memory::desc srcMemDesc = MemoryDescUtils::convertToDnnlMemoryDesc(definedParentDesc)->getDnnlDesc();

auto definedChildDesc = childDesc->isDefined() ? childDesc : MemoryDescUtils::makeDummyDesc(*childDesc);
memory::desc dstMemDesc = MemoryDescUtils::convertToDnnlMemoryDesc(definedChildDesc)->getDnnlDesc();

dnnl::primitive_attr attr;

dnnl_primitive_desc_t result = nullptr;
auto status = dnnl_reorder_primitive_desc_create(&result, srcMemDesc.get(), eng.get(), dstMemDesc.get(), eng.get(),
attr.get());
#if defined(OV_CPU_ARM_ENABLE_FP16)
// temporary WA for slow FP32->FP16 conversion reorder in oneDNN on ARM
// pretend the reorder is not available to use Convert node instead
if (result && parse_impl_name(result->impl()->name()) == ref_any) {
dnnl_primitive_desc_destroy(result);
return false;
}
#endif
if (result) {
dnnl_primitive_desc_destroy(result);
}

return dnnl_success == status;
}

void Graph::InitEdges() {
OV_ITT_SCOPE(FIRST_INFERENCE, itt::domains::intel_cpu_LT, "Graph::InitEdges");

Expand Down Expand Up @@ -519,31 +492,7 @@ void Graph::InitEdges() {
auto reorderStatus = graphEdges[i]->needReorder();
DEBUG_LOG(graphEdges[i]->name(), " reorderStatus = ", reorderStatus);
if (reorderStatus == Edge::ReorderStatus::Regular) {
Edge::ReorderStatus reorderStatusInternal = Edge::ReorderStatus::Regular;
// Check if there is a reorder that needs the precision conversion
if (edge->getInputDesc().getPrecision() != edge->getOutputDesc().getPrecision() &&
!isReorderAvailable(edge->getInputPortDesc()->getMemDesc(),
edge->getOutputPortDesc()->getMemDesc(),
this->getEngine())) {
// If we are here, then we need to insert Convert, because there are no reorders that support such type conversion
const auto& inDesc = edge->getInputDesc();
const auto& outDesc = edge->getOutputDesc();

std::string convertName = edge->getParent()->getName() + "_" +
inDesc.getPrecision().name() + "_" + outDesc.getPrecision().name();
auto convertNode = std::make_shared<node::Convert>(inDesc.getShape(), inDesc.getPrecision(), outDesc.getPrecision(),
convertName, context);
convertNode->setDescs(inDesc, outDesc);
InsertNode(edge, convertNode, true);

//Check if reorder is still needed
reorderStatusInternal = convertNode->getChildEdgeAt(0)->needReorder();
if (reorderStatusInternal != Edge::ReorderStatus::No)
edge = convertNode->getChildEdgeAt(0);
}
if (reorderStatusInternal != Edge::ReorderStatus::No) {
insertReorder(edge, reorderStatusInternal == Edge::ReorderStatus::Optimized);
}
insertReorder(edge, false);
updateEdge(i);
} else if (reorderStatus == Edge::ReorderStatus::Optimized) {
insertReorder(edge, true);
Expand Down

0 comments on commit 75aa3bd

Please sign in to comment.