diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_infer_request.cpp b/inference-engine/src/mkldnn_plugin/mkldnn_infer_request.cpp index 00092f42e0e..0498eeefd63 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_infer_request.cpp +++ b/inference-engine/src/mkldnn_plugin/mkldnn_infer_request.cpp @@ -425,10 +425,18 @@ void MKLDNNPlugin::MKLDNNInferRequest::SetBlob(const std::string& name, const In IE_THROW(ParameterMismatch) << "Failed to set input blob. Blocking descriptor mismatch."; } - const auto &actualDesc = graph->getInputNodeByName(name)->getChildEdgesAtPort(0)[0]->getMemory().getDesc(); - if (blobDesc.getLayout() != InferenceEngine::Layout::ANY && - actualDesc.isCompatible(MemoryDescUtils::convertToCpuBlockedMemoryDesc(blobDesc)) && - graph->_normalizePreprocMap.find(name) == graph->_normalizePreprocMap.end() && !graph->getProperty().batchLimit) { + MemoryDescPtr actualDesc = graph->getInputNodeByName(name)->getBaseMemDescAtOutputPort(0); + bool blobHasAnyLayout = blobDesc.getLayout() == InferenceEngine::Layout::ANY; + if (!blobHasAnyLayout && !actualDesc->isDefined()) { + // we must define desc for dynamic case + // otherwise we got incorrect check on shape compatibility inside isCompatible + // because lower and upper bound will be compared + actualDesc = actualDesc->cloneWithNewDims(blobDesc.getLayout() == InferenceEngine::Layout::SCALAR ? InferenceEngine::SizeVector{1} : + blobDesc.getDims()); + } + if (!blobHasAnyLayout && + actualDesc->isCompatible(MemoryDescUtils::convertToCpuBlockedMemoryDesc(blobDesc)) && + graph->_normalizePreprocMap.find(name) == graph->_normalizePreprocMap.end() && !graph->getProperty().batchLimit) { externalPtr[name] = data->buffer(); } else if (externalPtr.find(name) != externalPtr.end()) { externalPtr.erase(name); diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/batch_to_space.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/batch_to_space.cpp index 35f17a23b60..44f4a882e50 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/batch_to_space.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/batch_to_space.cpp @@ -254,7 +254,16 @@ std::vector> staticInputShapes5D2 = { std::vector> dynamicInputShapes5D2 = { { {{{-1, -1, -1, -1, -1}, {{48, 4, 3, 3, 3}, {24, 16, 5, 3, 5}, {24, 8, 7, 5, 5}}}}, - {{{24, {8, 16}, {3, 5}, -1, -1}, {{24, 16, 3, 4, 3}, {24, 12, 5, 3, 5}, {24, 8, 4, 5, 5}}}} + {{{24, {8, 16}, {3, 5}, -1, -1}, {{24, 16, 3, 4, 3}, {24, 12, 5, 3, 5}, {24, 8, 4, 5, 5}}}}, + // special case + { + {{{1, 24}, {1, 16}, {1, 10}, {1, 10}, {1, 10}}, + { + {24, 16, 5, 3, 5}, + {24, 16, 5, 3, 5}, + {24, 16, 7, 5, 5} + }} + } } };