Skip to content

Commit

Permalink
Add CPU default extensions loading in IE dnn backend (opencv#11252)
Browse files Browse the repository at this point in the history
* Add CPU default extensions loading in IE dnn backend

* Load cpu_extensions for the future Intel's Inference Engine
  • Loading branch information
sovrasov authored and vpisarev committed Apr 9, 2018
1 parent 20334e3 commit 0d9c637
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
1 change: 1 addition & 0 deletions cmake/OpenCVDetectInferenceEngine.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ set(ie_lib_list inference_engine)
link_directories(
${INTEL_CVSDK_DIR}/external/mklml_lnx/lib
${INTEL_CVSDK_DIR}/inference_engine/external/mklml_lnx/lib
${INTEL_CVSDK_DIR}/inference_engine/external/mkltiny_lnx/lib
${INTEL_CVSDK_DIR}/external/cldnn/lib
${INTEL_CVSDK_DIR}/inference_engine/external/cldnn/lib
)
Expand Down
26 changes: 22 additions & 4 deletions modules/dnn/src/op_inf_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
#include "op_inf_engine.hpp"
#include <opencv2/dnn/shape_utils.hpp>

#ifdef HAVE_INF_ENGINE
#include <ie_extension.h>
#include <ie_plugin_dispatcher.hpp>
#endif // HAVE_INF_ENGINE

namespace cv { namespace dnn {

#ifdef HAVE_INF_ENGINE
Expand Down Expand Up @@ -309,13 +314,26 @@ void InfEngineBackendNet::init()
void InfEngineBackendNet::initPlugin(InferenceEngine::ICNNNetwork& net)
{
CV_Assert(!isInitialized());

InferenceEngine::StatusCode status;
InferenceEngine::ResponseDesc resp;
const InferenceEngine::Version* v = InferenceEngine::GetInferenceEngineVersion();

plugin = InferenceEngine::PluginDispatcher({""}).getSuitablePlugin(InferenceEngine::TargetDevice::eCPU);
if (std::atoi(v->buildNumber) > 5855)
{
#ifdef _WIN32
plugin = InferenceEngine::InferenceEnginePluginPtr("MKLDNNPlugin.dll");
InferenceEngine::IExtensionPtr extension =
InferenceEngine::make_so_pointer<InferenceEngine::IExtension>("cpu_extension.dll");
#else
plugin = InferenceEngine::InferenceEnginePluginPtr("libMKLDNNPlugin.so");
InferenceEngine::IExtensionPtr extension =
InferenceEngine::make_so_pointer<InferenceEngine::IExtension>("libcpu_extension.so");
#endif // _WIN32
InferenceEngine::ResponseDesc resp;
InferenceEngine::StatusCode status = plugin->LoadNetwork(net, &resp);
status = plugin->AddExtension(extension, &resp);
if (status != InferenceEngine::StatusCode::OK)
CV_Error(Error::StsAssert, resp.msg);
}
status = plugin->LoadNetwork(net, &resp);
if (status != InferenceEngine::StatusCode::OK)
CV_Error(Error::StsAssert, resp.msg);
}
Expand Down

0 comments on commit 0d9c637

Please sign in to comment.