mirror of
https://github.com/opencv/opencv.git
synced 2025-06-11 11:45:30 +08:00
Merge pull request #14895 from alalek:dnn_ie_extensions_path
This commit is contained in:
commit
c251915198
@ -409,6 +409,14 @@ void InfEngineBackendNet::initPlugin(InferenceEngine::ICNNNetwork& net)
|
||||
enginePtr = dispatcher.getSuitablePlugin(targetDevice);
|
||||
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 ||
|
||||
targetDevice == InferenceEngine::TargetDevice::eFPGA)
|
||||
{
|
||||
@ -422,24 +430,36 @@ void InfEngineBackendNet::initPlugin(InferenceEngine::ICNNNetwork& net)
|
||||
{
|
||||
if (!haveFeature[i])
|
||||
continue;
|
||||
#ifdef _WIN32
|
||||
std::string libName = "cpu_extension" + suffixes[i] + ".dll";
|
||||
#elif defined(__APPLE__)
|
||||
std::string libName = "libcpu_extension" + suffixes[i] + ".dylib";
|
||||
#else
|
||||
std::string libName = "libcpu_extension" + suffixes[i] + ".so";
|
||||
#endif // _WIN32
|
||||
try
|
||||
{
|
||||
InferenceEngine::IExtensionPtr extension =
|
||||
InferenceEngine::make_so_pointer<InferenceEngine::IExtension>(libName);
|
||||
enginePtr->AddExtension(extension, 0);
|
||||
break;
|
||||
}
|
||||
catch(...) {}
|
||||
#ifdef _WIN32
|
||||
candidates.push_back("cpu_extension" + suffixes[i] + ".dll");
|
||||
#elif defined(__APPLE__)
|
||||
candidates.push_back("libcpu_extension" + suffixes[i] + ".so"); // built as loadable module
|
||||
candidates.push_back("libcpu_extension" + suffixes[i] + ".dylib"); // built as shared library
|
||||
#else
|
||||
candidates.push_back("libcpu_extension" + suffixes[i] + ".so");
|
||||
#endif // _WIN32
|
||||
}
|
||||
// Some of networks can work without a library of extra layers.
|
||||
}
|
||||
bool found = false;
|
||||
for (size_t i = 0; i != candidates.size(); ++i)
|
||||
{
|
||||
const std::string& libName = candidates[i];
|
||||
try
|
||||
{
|
||||
InferenceEngine::IExtensionPtr extension =
|
||||
InferenceEngine::make_so_pointer<InferenceEngine::IExtension>(libName);
|
||||
enginePtr->AddExtension(extension, 0);
|
||||
CV_LOG_INFO(NULL, "DNN-IE: Loaded extension plugin: " << libName);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
catch(...) {}
|
||||
}
|
||||
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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user