dnn: configure plugin path for InferenceEngine

pull/14895/head
Alexander Alekhin 6 years ago
parent 8fd87033ef
commit 333e51b217
  1. 36
      modules/dnn/src/op_inf_engine.cpp

@ -409,6 +409,14 @@ void InfEngineBackendNet::initPlugin(InferenceEngine::ICNNNetwork& net)
enginePtr = dispatcher.getSuitablePlugin(targetDevice); enginePtr = dispatcher.getSuitablePlugin(targetDevice);
sharedPlugins[targetDevice] = enginePtr; sharedPlugins[targetDevice] = enginePtr;
std::vector<std::string> candidates;
std::string param_pluginPath = utils::getConfigurationParameterString("OPENCV_DNN_IE_EXTRA_PLUGIN_PATH", "");
if (!param_pluginPath.empty())
{
candidates.push_back(param_pluginPath);
}
if (targetDevice == InferenceEngine::TargetDevice::eCPU || if (targetDevice == InferenceEngine::TargetDevice::eCPU ||
targetDevice == InferenceEngine::TargetDevice::eFPGA) targetDevice == InferenceEngine::TargetDevice::eFPGA)
{ {
@ -422,24 +430,36 @@ void InfEngineBackendNet::initPlugin(InferenceEngine::ICNNNetwork& net)
{ {
if (!haveFeature[i]) if (!haveFeature[i])
continue; continue;
#ifdef _WIN32 #ifdef _WIN32
std::string libName = "cpu_extension" + suffixes[i] + ".dll"; candidates.push_back("cpu_extension" + suffixes[i] + ".dll");
#elif defined(__APPLE__) #elif defined(__APPLE__)
std::string libName = "libcpu_extension" + suffixes[i] + ".dylib"; candidates.push_back("libcpu_extension" + suffixes[i] + ".so"); // built as loadable module
#else candidates.push_back("libcpu_extension" + suffixes[i] + ".dylib"); // built as shared library
std::string libName = "libcpu_extension" + suffixes[i] + ".so"; #else
#endif // _WIN32 candidates.push_back("libcpu_extension" + suffixes[i] + ".so");
#endif // _WIN32
}
}
bool found = false;
for (size_t i = 0; i != candidates.size(); ++i)
{
const std::string& libName = candidates[i];
try try
{ {
InferenceEngine::IExtensionPtr extension = InferenceEngine::IExtensionPtr extension =
InferenceEngine::make_so_pointer<InferenceEngine::IExtension>(libName); InferenceEngine::make_so_pointer<InferenceEngine::IExtension>(libName);
enginePtr->AddExtension(extension, 0); enginePtr->AddExtension(extension, 0);
CV_LOG_INFO(NULL, "DNN-IE: Loaded extension plugin: " << libName);
found = true;
break; break;
} }
catch(...) {} catch(...) {}
} }
// Some of networks can work without a library of extra layers. if (!found && !candidates.empty())
{
CV_LOG_WARNING(NULL, "DNN-IE: Can't load extension plugin (extra layers for some networks). Specify path via OPENCV_DNN_IE_EXTRA_PLUGIN_PATH parameter");
} }
// Some of networks can work without a library of extra layers.
} }
plugin = InferenceEngine::InferencePlugin(enginePtr); plugin = InferenceEngine::InferencePlugin(enginePtr);

Loading…
Cancel
Save