Skip to content

Commit

Permalink
GetBlob performance fix
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnick committed May 27, 2021
1 parent c2448d6 commit 7ced6a2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
8 changes: 8 additions & 0 deletions inference-engine/src/mkldnn_plugin/mkldnn_graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ class MKLDNNGraph {
return outputNodesMap;
}

bool hasInputWithName(const std::string& name) const {
return inputNodesMap.count(name);
}

bool hasOutputWithName(const std::string& name) const {
return outputNodesMap.count(name);
}

mkldnn::engine getEngine() const {
return eng;
}
Expand Down
13 changes: 6 additions & 7 deletions inference-engine/src/mkldnn_plugin/mkldnn_infer_request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,9 @@ InferenceEngine::Blob::Ptr MKLDNNPlugin::MKLDNNInferRequest::GetBlob(const std::

InferenceEngine::Blob::Ptr data;

InferenceEngine::BlobMap blobs;
graph->getInputBlobs(blobs);

if (blobs.find(name) != blobs.end()) {
if (graph->hasInputWithName(name)) {
InferenceEngine::BlobMap blobs;
graph->getInputBlobs(blobs);
// ROI blob is returned only if it was set previously.
auto it = _preProcData.find(name);
if (it != _preProcData.end()) {
Expand Down Expand Up @@ -245,9 +244,9 @@ InferenceEngine::Blob::Ptr MKLDNNPlugin::MKLDNNInferRequest::GetBlob(const std::
checkBlob(data, name, true);
}

blobs.clear();
graph->getOutputBlobs(blobs);
if (blobs.find(name) != blobs.end()) {
if (graph->hasOutputWithName(name)) {
InferenceEngine::BlobMap blobs;
graph->getOutputBlobs(blobs);
if (_outputs.find(name) == _outputs.end()) {
if (!data) {
InferenceEngine::TensorDesc desc = _networkOutputs[name]->getTensorDesc();
Expand Down

0 comments on commit 7ced6a2

Please sign in to comment.