Skip to content

Commit

Permalink
Avoid unnecessary reordering for nodes with several consumers before …
Browse files Browse the repository at this point in the history
…output
  • Loading branch information
v-Golubev committed Jul 11, 2024
1 parent 433456b commit 214d290
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/plugins/intel_cpu/src/graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,17 @@ void Graph::Replicate(const std::shared_ptr<const ov::Model> &model) {
const auto parentEdge = outputNode->getParentEdgeAt(0);
const auto parent = parentEdge->getParent();
parent->setOriginalOutputPrecisionAtPort(parentEdge->getInputNum(), precToSet);
// If the parent has consumers except Output, precToSet is propagated to consumer's inputs
// to avoid precision mismatch (which leads to reaorder insertion and unnecessary performance overheads)
if (parent->getChildEdges().size() > 1) {
for (size_t i = 0; i < parent->getChildEdges().size(); ++i) {
const auto childEdge = parent->getChildEdgeAt(i);
// Consumers from other parent's output shouldn't be changed
if (childEdge->getInputNum() != parentEdge->getInputNum())
continue;
childEdge->getChild()->setOriginalInputPrecisionAtPort(childEdge->getOutputNum(), precToSet);
}
}
}
}

Expand Down

0 comments on commit 214d290

Please sign in to comment.