Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
bc4e4718
O
Opencv
项目概览
Greenplum
/
Opencv
11 个月 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bc4e4718
编写于
1月 31, 2019
作者:
D
Dmitry Kurtaev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add a mutex for shared Inference Engine plugins
上级
2f5af1bd
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
43 addition
and
2 deletion
+43
-2
modules/dnn/src/op_inf_engine.cpp
modules/dnn/src/op_inf_engine.cpp
+9
-2
modules/dnn/test/test_layers.cpp
modules/dnn/test/test_layers.cpp
+34
-0
未找到文件。
modules/dnn/src/op_inf_engine.cpp
浏览文件 @
bc4e4718
...
...
@@ -622,7 +622,11 @@ void InfEngineBackendNet::init(int targetId)
#endif // IE < R5
static
std
::
map
<
InferenceEngine
::
TargetDevice
,
InferenceEngine
::
InferenceEnginePluginPtr
>
sharedPlugins
;
static
std
::
map
<
InferenceEngine
::
TargetDevice
,
InferenceEngine
::
InferenceEnginePluginPtr
>&
getSharedPlugins
()
{
static
std
::
map
<
InferenceEngine
::
TargetDevice
,
InferenceEngine
::
InferenceEnginePluginPtr
>
sharedPlugins
;
return
sharedPlugins
;
}
void
InfEngineBackendNet
::
initPlugin
(
InferenceEngine
::
ICNNNetwork
&
net
)
{
...
...
@@ -630,6 +634,8 @@ void InfEngineBackendNet::initPlugin(InferenceEngine::ICNNNetwork& net)
try
{
AutoLock
lock
(
getInitializationMutex
());
auto
&
sharedPlugins
=
getSharedPlugins
();
auto
pluginIt
=
sharedPlugins
.
find
(
targetDevice
);
if
(
pluginIt
!=
sharedPlugins
.
end
())
{
...
...
@@ -797,7 +803,8 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
void
resetMyriadDevice
()
{
#ifdef HAVE_INF_ENGINE
sharedPlugins
.
erase
(
InferenceEngine
::
TargetDevice
::
eMYRIAD
);
AutoLock
lock
(
getInitializationMutex
());
getSharedPlugins
().
erase
(
InferenceEngine
::
TargetDevice
::
eMYRIAD
);
#endif // HAVE_INF_ENGINE
}
...
...
modules/dnn/test/test_layers.cpp
浏览文件 @
bc4e4718
...
...
@@ -46,6 +46,10 @@
#include <opencv2/dnn/all_layers.hpp>
#include <opencv2/dnn/layer.details.hpp> // CV_DNN_REGISTER_LAYER_CLASS
#ifdef HAVE_INF_ENGINE
#include <thread>
#endif
namespace
opencv_test
{
namespace
{
template
<
typename
TString
>
...
...
@@ -970,6 +974,36 @@ TEST_P(Layer_Test_Convolution_DLDT, setInput_uint8)
if
(
targetId
!=
DNN_TARGET_MYRIAD
)
normAssert
(
outs
[
0
],
outs
[
1
]);
}
TEST_P
(
Layer_Test_Convolution_DLDT
,
multithreading
)
{
Target
targetId
=
GetParam
();
std
::
string
suffix
=
(
targetId
==
DNN_TARGET_OPENCL_FP16
||
targetId
==
DNN_TARGET_MYRIAD
)
?
"_fp16"
:
""
;
std
::
string
xmlPath
=
_tf
(
"layer_convolution"
+
suffix
+
".xml"
);
std
::
string
binPath
=
_tf
(
"layer_convolution"
+
suffix
+
".bin"
);
Net
firstNet
=
readNet
(
xmlPath
,
binPath
);
Net
secondNet
=
readNet
(
xmlPath
,
binPath
);
Mat
inp
=
blobFromNPY
(
_tf
(
"blob.npy"
));
firstNet
.
setInput
(
inp
);
secondNet
.
setInput
(
inp
);
firstNet
.
setPreferableTarget
(
targetId
);
secondNet
.
setPreferableTarget
(
targetId
);
Mat
out1
,
out2
;
std
::
thread
t1
([
&
]{
out1
=
firstNet
.
forward
();});
std
::
thread
t2
([
&
]{
out2
=
secondNet
.
forward
();});
t1
.
join
();
t2
.
join
();
Mat
ref
=
blobFromNPY
(
_tf
(
"layer_convolution.npy"
));
double
l1
=
(
targetId
==
DNN_TARGET_OPENCL_FP16
||
targetId
==
DNN_TARGET_MYRIAD
)
?
1.5e-3
:
1e-5
;
double
lInf
=
(
targetId
==
DNN_TARGET_OPENCL_FP16
||
targetId
==
DNN_TARGET_MYRIAD
)
?
1.8e-2
:
1e-4
;
normAssert
(
out1
,
ref
,
"first thread"
,
l1
,
lInf
);
normAssert
(
out2
,
ref
,
"second thread"
,
l1
,
lInf
);
}
INSTANTIATE_TEST_CASE_P
(
/**/
,
Layer_Test_Convolution_DLDT
,
testing
::
ValuesIn
(
getAvailableTargets
(
DNN_BACKEND_INFERENCE_ENGINE
)));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录