diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_graph_optimizer.cpp b/inference-engine/src/mkldnn_plugin/mkldnn_graph_optimizer.cpp index 9811b683ad19e3..b298d930d6aa9f 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_graph_optimizer.cpp +++ b/inference-engine/src/mkldnn_plugin/mkldnn_graph_optimizer.cpp @@ -452,7 +452,7 @@ void MKLDNNGraphOptimizer::FuseConvolutionAndZeroPoints(MKLDNNGraph &graph) { return false; auto arg0 = parent0->getParentEdgesAtPort(1)[0]->getParent(); - if (arg0->getType() == Input && arg0->isConstant()) { + if (arg0->getChildEdges().size() == 1 && arg0->getType() == Input && arg0->isConstant()) { if (arg0->getOriginalOutputPrecisionAtPort(0) != Precision::U8) return false; @@ -864,7 +864,11 @@ void MKLDNNGraphOptimizer::FusePoolingAndFakeQuantize(MKLDNNGraph &graph) { }; auto isSutableChildNode = [](MKLDNNNodePtr node) { - return node->getType() == FakeQuantize && node->getAlgorithm() != Algorithm::FQBinarization; + bool ret = node->getType() == FakeQuantize && node->getAlgorithm() != Algorithm::FQBinarization; + for (size_t i = 1; i < node->getParentEdges().size(); i++) { + ret &= node->getParentEdgesAtPort(i)[0]->getParent()->getChildEdges().size() == 1; + } + return ret; }; for (int i = 0; i < graphNodes.size(); i++) { @@ -1440,12 +1444,17 @@ void MKLDNNGraphOptimizer::FuseBroadcastAndEltwise(MKLDNNGraph &graph) { std::vector& graphNodes = graph.GetNodes(); for (auto &graphNode : graphNodes) { - if (graphNode->getType() != Generic - || graphNode->getTypeStr() != "Broadcast" + if (graphNode->getType() != Broadcast || graphNode->getChildEdges().size() != 1lu || graphNode->getChildEdgeAt(0)->getChild()->getType() != Eltwise) continue; + bool ret = true; + for (size_t i = 1; i < graphNode->getParentEdges().size(); i++) { + ret &= graphNode->getParentEdgesAtPort(i)[0]->getParent()->getChildEdges().size() == 1; + } + if (!ret) continue; + MKLDNNNodePtr& broadcastNode = graphNode; MKLDNNNodePtr eltwiseNode = broadcastNode->getChildEdgeAt(0)->getChild(); eltwiseNode->inDims[broadcastNode->getChildEdgeAt(0)->getOutputNum()] diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_node.cpp b/inference-engine/src/mkldnn_plugin/mkldnn_node.cpp index e46c7a7b0bdf9e..771fcb39d090c1 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_node.cpp +++ b/inference-engine/src/mkldnn_plugin/mkldnn_node.cpp @@ -1328,7 +1328,7 @@ bool MKLDNNNode::canBePerformedAsScaleShift(const MKLDNNNode *parentNode) const if (i == fusingPort) continue; auto weightShape = getParentEdgeAt(i)->getDims().ToSizeVector(); - if (!isPerTensorOrPerChannelBroadcastable(dataShape, weightShape)) + if (getParentEdgesAtPort(i)[0]->getParent()->getChildEdges().size() != 1 || !isPerTensorOrPerChannelBroadcastable(dataShape, weightShape)) return false; } return true; @@ -1351,7 +1351,11 @@ bool MKLDNNNode::canBePerformedAsScaleShift(const MKLDNNNode *parentNode) const bool MKLDNNNode::canFuseSimpleOperation(const MKLDNNNodePtr& node) const { if (node->getType() == FakeQuantize) { - return node->getAlgorithm() != FQBinarization; + bool ret = node->getAlgorithm() != FQBinarization; + for (size_t i = 1; i < node->getParentEdges().size(); i++) { + ret &= node->getParentEdgesAtPort(i)[0]->getParent()->getChildEdges().size() == 1; + } + return ret; } else if (node->getType() == Eltwise) { return one_of(node->getAlgorithm(), EltwiseRelu, EltwiseGelu, EltwiseElu, EltwiseSigmoid, EltwiseClamp, EltwiseTanh, EltwiseSwish, EltwiseHswish, EltwiseMish, EltwiseHsigmoid, EltwiseRoundHalfToEven, diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_bin_conv_node.cpp b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_bin_conv_node.cpp index 517066d6f32806..9066b263a82035 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_bin_conv_node.cpp +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_bin_conv_node.cpp @@ -1093,7 +1093,11 @@ bool MKLDNNBinaryConvolutionNode::canFuse(const MKLDNNNodePtr& node) const { return false; if (node->getType() == FakeQuantize) { - return node->getAlgorithm() == FQBinarization; + bool ret = node->getAlgorithm() == FQBinarization; + for (size_t i = 1; i < node->getParentEdges().size(); i++) { + ret &= node->getParentEdgesAtPort(i)[0]->getParent()->getChildEdges().size() == 1; + } + return ret; } else { return canFuseSimpleOperation(node); } diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_conv_node.cpp b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_conv_node.cpp index 36de12e94d938c..f73140065587df 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_conv_node.cpp +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_conv_node.cpp @@ -229,7 +229,8 @@ void MKLDNNConvolutionNode::getSupportedDescriptors() { } if (getParentEdges().size() != expectedInputEdgesNum) - IE_THROW() << "Incorrect number of input edges for layer " << getName(); + IE_THROW() << "Incorrect number of input edges for layer " << getName() << ", expected: " << expectedInputEdgesNum + << " actual: " << getParentEdges().size(); if (getChildEdges().empty()) IE_THROW() << "Incorrect number of output edges for layer " << getName();