@@ -410,6 +410,14 @@ void InfEngineBackendNet::initPlugin(InferenceEngine::ICNNNetwork& net)
410410 enginePtr = dispatcher.getSuitablePlugin (targetDevice);
411411 sharedPlugins[targetDevice] = enginePtr;
412412
413+ std::vector<std::string> candidates;
414+
415+ std::string param_pluginPath = utils::getConfigurationParameterString (" OPENCV_DNN_IE_EXTRA_PLUGIN_PATH" , " " );
416+ if (!param_pluginPath.empty ())
417+ {
418+ candidates.push_back (param_pluginPath);
419+ }
420+
413421 if (targetDevice == InferenceEngine::TargetDevice::eCPU ||
414422 targetDevice == InferenceEngine::TargetDevice::eFPGA)
415423 {
@@ -423,24 +431,36 @@ void InfEngineBackendNet::initPlugin(InferenceEngine::ICNNNetwork& net)
423431 {
424432 if (!haveFeature[i])
425433 continue ;
426- #ifdef _WIN32
427- std::string libName = " cpu_extension" + suffixes[i] + " .dll" ;
428- #elif defined(__APPLE__)
429- std::string libName = " libcpu_extension" + suffixes[i] + " .dylib" ;
430- #else
431- std::string libName = " libcpu_extension" + suffixes[i] + " .so" ;
432- #endif // _WIN32
433- try
434- {
435- InferenceEngine::IExtensionPtr extension =
436- InferenceEngine::make_so_pointer<InferenceEngine::IExtension>(libName);
437- enginePtr->AddExtension (extension, 0 );
438- break ;
439- }
440- catch (...) {}
434+ #ifdef _WIN32
435+ candidates.push_back (" cpu_extension" + suffixes[i] + " .dll" );
436+ #elif defined(__APPLE__)
437+ candidates.push_back (" libcpu_extension" + suffixes[i] + " .so" ); // built as loadable module
438+ candidates.push_back (" libcpu_extension" + suffixes[i] + " .dylib" ); // built as shared library
439+ #else
440+ candidates.push_back (" libcpu_extension" + suffixes[i] + " .so" );
441+ #endif // _WIN32
441442 }
442- // Some of networks can work without a library of extra layers.
443443 }
444+ bool found = false ;
445+ for (size_t i = 0 ; i != candidates.size (); ++i)
446+ {
447+ const std::string& libName = candidates[i];
448+ try
449+ {
450+ InferenceEngine::IExtensionPtr extension =
451+ InferenceEngine::make_so_pointer<InferenceEngine::IExtension>(libName);
452+ enginePtr->AddExtension (extension, 0 );
453+ CV_LOG_INFO (NULL , " DNN-IE: Loaded extension plugin: " << libName);
454+ found = true ;
455+ break ;
456+ }
457+ catch (...) {}
458+ }
459+ if (!found && !candidates.empty ())
460+ {
461+ 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" );
462+ }
463+ // Some of networks can work without a library of extra layers.
444464 }
445465 plugin = InferenceEngine::InferencePlugin (enginePtr);
446466
0 commit comments