Enable Myriad device for OpenVINO models test

This commit is contained in:
Dmitry Kurtaev 2018-09-18 11:21:08 +03:00
parent 70f38b4dfa
commit 8ac7b21716
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, CV_OUT std::vector<int>& indices,
const float eta = 1.f, const int top_k = 0); 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 CV__DNN_EXPERIMENTAL_NS_END
} }

View File

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

View File

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