Merge pull request #12579 from dkurt:dnn_reset_myriad_device

This commit is contained in:
Alexander Alekhin 2018-09-18 16:14:38 +00:00
commit 15e9e3304c
3 changed files with 28 additions and 3 deletions

View File

@ -944,6 +944,13 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
CV_OUT std::vector<int>& indices,
const float eta = 1.f, const int top_k = 0);
/** @brief Release a Myriad device is binded by OpenCV.
*
* Single Myriad device cannot be shared across multiple processes which uses
* Inference Engine's Myriad plugin.
*/
CV_EXPORTS_W void resetMyriadDevice();
//! @}
CV__DNN_EXPERIMENTAL_NS_END
}

View File

@ -443,13 +443,14 @@ void InfEngineBackendNet::init(int targetId)
initPlugin(*this);
}
static std::map<InferenceEngine::TargetDevice, InferenceEngine::InferenceEnginePluginPtr> sharedPlugins;
void InfEngineBackendNet::initPlugin(InferenceEngine::ICNNNetwork& net)
{
CV_Assert(!isInitialized());
try
{
static std::map<InferenceEngine::TargetDevice, InferenceEngine::InferenceEnginePluginPtr> sharedPlugins;
auto pluginIt = sharedPlugins.find(targetDevice);
if (pluginIt != sharedPlugins.end())
{
@ -589,4 +590,14 @@ void forwardInfEngine(Ptr<BackendNode>& node)
#endif // HAVE_INF_ENGINE
}
CV__DNN_EXPERIMENTAL_NS_BEGIN
void resetMyriadDevice()
{
#ifdef HAVE_INF_ENGINE
sharedPlugins.erase(InferenceEngine::TargetDevice::eMYRIAD);
#endif // HAVE_INF_ENGINE
}
CV__DNN_EXPERIMENTAL_NS_END
}} // namespace dnn, namespace cv

View File

@ -177,6 +177,11 @@ TEST_P(DNNTestOpenVINO, models)
Target target = (dnn::Target)(int)get<0>(GetParam());
std::string modelName = get<1>(GetParam());
if (target == DNN_TARGET_MYRIAD && (modelName == "landmarks-regression-retail-0001" ||
modelName == "semantic-segmentation-adas-0001" ||
modelName == "face-reidentification-retail-0001"))
throw SkipTestException("");
std::string precision = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? "FP16" : "FP32";
std::string prefix = utils::fs::join("intel_models",
utils::fs::join(modelName,
@ -186,6 +191,8 @@ TEST_P(DNNTestOpenVINO, models)
std::map<std::string, cv::Mat> inputsMap;
std::map<std::string, cv::Mat> ieOutputsMap, cvOutputsMap;
// Single Myriad device cannot be shared across multiple processes.
resetMyriadDevice();
runIE(target, xmlPath, binPath, inputsMap, ieOutputsMap);
runCV(target, xmlPath, binPath, inputsMap, cvOutputsMap);
@ -238,8 +245,8 @@ static testing::internal::ParamGenerator<Target> dnnDLIETargets()
targets.push_back(DNN_TARGET_OPENCL_FP16);
}
#endif
//if (checkMyriadTarget())
// targets.push_back(DNN_TARGET_MYRIAD);
if (checkMyriadTarget())
targets.push_back(DNN_TARGET_MYRIAD);
return testing::ValuesIn(targets);
}