Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenCV
opencv
提交
21d79abb
O
opencv
项目概览
OpenCV
/
opencv
上一次同步 9 个月
通知
994
Star
71100
Fork
55581
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
21d79abb
编写于
6月 23, 2023
作者:
A
Alexander Smorkalov
提交者:
GitHub
6月 23, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #23859 from TolyaTalamanov:at/ov-backend-core-wa
G-API: Apply ov::Core lifetime WA for OpenVINO Backend
上级
ee97dd52
c0fda696
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
45 addition
and
18 deletion
+45
-18
modules/gapi/src/backends/ov/govbackend.cpp
modules/gapi/src/backends/ov/govbackend.cpp
+34
-8
modules/gapi/src/backends/ov/util.hpp
modules/gapi/src/backends/ov/util.hpp
+7
-3
modules/gapi/test/infer/gapi_infer_ov_tests.cpp
modules/gapi/test/infer/gapi_infer_ov_tests.cpp
+4
-7
未找到文件。
modules/gapi/src/backends/ov/govbackend.cpp
浏览文件 @
21d79abb
...
...
@@ -18,6 +18,7 @@
#include <opencv2/gapi/gcommon.hpp>
#include <opencv2/gapi/infer/ov.hpp>
#include <opencv2/core/utils/configuration.private.hpp> // getConfigurationParameterBool
#if defined(HAVE_TBB)
# include <tbb/concurrent_queue.h> // FIXME: drop it from here!
...
...
@@ -37,11 +38,37 @@ template<typename T> using QueueClass = cv::gapi::own::concurrent_bounded_queue<
using
ParamDesc
=
cv
::
gapi
::
ov
::
detail
::
ParamDesc
;
static
ov
::
Core
getCore
()
{
// NB: Some of OV plugins fail during ov::Core destroying in specific cases.
// Solution is allocate ov::Core in heap and doesn't destroy it, which cause
// leak, but fixes tests on CI. This behaviour is configurable by using
// OPENCV_GAPI_INFERENCE_ENGINE_CORE_LIFETIME_WORKAROUND=0
static
ov
::
Core
create_OV_Core_pointer
()
{
// NB: 'delete' is never called
static
ov
::
Core
*
core
=
new
ov
::
Core
();
return
*
core
;
}
static
ov
::
Core
create_OV_Core_instance
()
{
static
ov
::
Core
core
;
return
core
;
}
ov
::
Core
cv
::
gapi
::
ov
::
wrap
::
getCore
()
{
// NB: to make happy memory leak tools use:
// - OPENCV_GAPI_INFERENCE_ENGINE_CORE_LIFETIME_WORKAROUND=0
static
bool
param_GAPI_INFERENCE_ENGINE_CORE_LIFETIME_WORKAROUND
=
utils
::
getConfigurationParameterBool
(
"OPENCV_GAPI_INFERENCE_ENGINE_CORE_LIFETIME_WORKAROUND"
,
#if defined(_WIN32) || defined(__APPLE__)
true
#else
false
#endif
);
return
param_GAPI_INFERENCE_ENGINE_CORE_LIFETIME_WORKAROUND
?
create_OV_Core_pointer
()
:
create_OV_Core_instance
();
}
static
ov
::
AnyMap
toOV
(
const
ParamDesc
::
PluginConfigT
&
config
)
{
return
{
config
.
begin
(),
config
.
end
()};
}
...
...
@@ -175,7 +202,8 @@ struct OVUnit {
// FIXME: Can this logic be encapsulated to prevent checking every time?
if
(
cv
::
util
::
holds_alternative
<
ParamDesc
::
Model
>
(
params
.
kind
))
{
const
auto
desc
=
cv
::
util
::
get
<
ParamDesc
::
Model
>
(
params
.
kind
);
model
=
getCore
().
read_model
(
desc
.
model_path
,
desc
.
bin_path
);
model
=
cv
::
gapi
::
ov
::
wrap
::
getCore
()
.
read_model
(
desc
.
model_path
,
desc
.
bin_path
);
GAPI_Assert
(
model
);
if
(
params
.
num_in
==
1u
&&
params
.
input_names
.
empty
())
{
...
...
@@ -190,9 +218,8 @@ struct OVUnit {
std
::
ifstream
file
(
cv
::
util
::
get
<
ParamDesc
::
CompiledModel
>
(
params
.
kind
).
blob_path
,
std
::
ios_base
::
in
|
std
::
ios_base
::
binary
);
GAPI_Assert
(
file
.
is_open
());
compiled_model
=
getCore
().
import_model
(
file
,
params
.
device
,
toOV
(
params
.
config
));
compiled_model
=
cv
::
gapi
::
ov
::
wrap
::
getCore
()
.
import_model
(
file
,
params
.
device
,
toOV
(
params
.
config
));
if
(
params
.
num_in
==
1u
&&
params
.
input_names
.
empty
())
{
params
.
input_names
=
{
compiled_model
.
inputs
().
begin
()
->
get_any_name
()
};
...
...
@@ -205,9 +232,8 @@ struct OVUnit {
cv
::
gimpl
::
ov
::
OVCompiled
compile
()
{
if
(
cv
::
util
::
holds_alternative
<
ParamDesc
::
Model
>
(
params
.
kind
))
{
compiled_model
=
getCore
().
compile_model
(
model
,
params
.
device
,
toOV
(
params
.
config
));
compiled_model
=
cv
::
gapi
::
ov
::
wrap
::
getCore
()
.
compile_model
(
model
,
params
.
device
,
toOV
(
params
.
config
));
}
return
{
compiled_model
};
}
...
...
modules/gapi/src/backends/ov/util.hpp
浏览文件 @
21d79abb
...
...
@@ -22,15 +22,19 @@ namespace cv {
namespace
gapi
{
namespace
ov
{
namespace
util
{
// NB: These functions are EXPORTed to make them accessible by the
// test suite only.
GAPI_EXPORTS
std
::
vector
<
int
>
to_ocv
(
const
::
ov
::
Shape
&
shape
);
GAPI_EXPORTS
int
to_ocv
(
const
::
ov
::
element
::
Type
&
type
);
GAPI_EXPORTS
void
to_ov
(
const
cv
::
Mat
&
mat
,
::
ov
::
Tensor
&
tensor
);
GAPI_EXPORTS
void
to_ocv
(
const
::
ov
::
Tensor
&
tensor
,
cv
::
Mat
&
mat
);
}}}}
}
// namespace util
namespace
wrap
{
GAPI_EXPORTS
::
ov
::
Core
getCore
();
}
// namespace wrap
}
// namespace ov
}
// namespace gapi
}
// namespace cv
#endif // HAVE_INF_ENGINE && INF_ENGINE_RELEASE >= 2022010000
...
...
modules/gapi/test/infer/gapi_infer_ov_tests.cpp
浏览文件 @
21d79abb
...
...
@@ -52,11 +52,6 @@ void normAssert(cv::InputArray ref, cv::InputArray test,
EXPECT_LE
(
normInf
,
lInf
)
<<
comment
;
}
ov
::
Core
getCore
()
{
static
ov
::
Core
core
;
return
core
;
}
// TODO: AGNetGenComp, AGNetTypedComp, AGNetOVComp, AGNetOVCompiled
// can be generalized to work with any model and used as parameters for tests.
...
...
@@ -228,7 +223,8 @@ public:
const
std
::
string
&
bin_path
,
const
std
::
string
&
device
)
:
m_device
(
device
)
{
m_model
=
getCore
().
read_model
(
xml_path
,
bin_path
);
m_model
=
cv
::
gapi
::
ov
::
wrap
::
getCore
()
.
read_model
(
xml_path
,
bin_path
);
}
using
PrePostProcessF
=
std
::
function
<
void
(
ov
::
preprocess
::
PrePostProcessor
&
)
>
;
...
...
@@ -240,7 +236,8 @@ public:
}
AGNetOVCompiled
compile
()
{
auto
compiled_model
=
getCore
().
compile_model
(
m_model
,
m_device
);
auto
compiled_model
=
cv
::
gapi
::
ov
::
wrap
::
getCore
()
.
compile_model
(
m_model
,
m_device
);
return
{
std
::
move
(
compiled_model
)};
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录