Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenCV
opencv
提交
6eba1a4d
O
opencv
项目概览
OpenCV
/
opencv
上一次同步 9 个月
通知
992
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 搜索 >>
提交
6eba1a4d
编写于
2月 05, 2020
作者:
A
Alexander Alekhin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
dnn: auto network dump through parameter
上级
fa4871b0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
54 addition
and
3 deletion
+54
-3
modules/dnn/src/dnn.cpp
modules/dnn/src/dnn.cpp
+54
-3
未找到文件。
modules/dnn/src/dnn.cpp
浏览文件 @
6eba1a4d
...
...
@@ -62,6 +62,8 @@ namespace cv {
namespace
dnn
{
CV__DNN_EXPERIMENTAL_NS_BEGIN
static
size_t
DNN_NETWORK_DUMP
=
utils
::
getConfigurationParameterSizeT
(
"OPENCV_DNN_NETWORK_DUMP"
,
0
);
// this option is useful to run valgrind memory errors detection
static
bool
DNN_DISABLE_MEMORY_OPTIMIZATIONS
=
utils
::
getConfigurationParameterBool
(
"OPENCV_DNN_DISABLE_MEMORY_OPTIMIZATIONS"
,
false
);
...
...
@@ -1055,12 +1057,19 @@ static Ptr<BackendWrapper> wrapMat(int backendId, int targetId, cv::Mat& m)
return
Ptr
<
BackendWrapper
>
();
// TODO Error?
}
static
int
g_networkId
=
0
;
struct
Net
::
Impl
{
typedef
std
::
map
<
int
,
LayerShapes
>
LayersShapesMap
;
typedef
std
::
map
<
int
,
LayerData
>
MapIdToLayerData
;
const
int
networkId
;
// network global identifier
int
networkDumpCounter
;
// dump counter
Impl
()
:
networkId
(
CV_XADD
(
&
g_networkId
,
1
))
,
networkDumpCounter
(
0
)
{
//allocate fake net input layer
netInputLayer
=
Ptr
<
DataLayer
>
(
new
DataLayer
());
...
...
@@ -1224,6 +1233,11 @@ struct Net::Impl
{
CV_TRACE_FUNCTION
();
if
(
DNN_NETWORK_DUMP
>
0
&&
networkDumpCounter
==
0
)
{
dumpNetworkToFile
();
}
if
(
preferableBackend
==
DNN_BACKEND_DEFAULT
)
preferableBackend
=
(
Backend
)
PARAM_DNN_BACKEND_DEFAULT
;
#ifdef HAVE_INF_ENGINE
...
...
@@ -1300,6 +1314,11 @@ struct Net::Impl
netWasAllocated
=
true
;
this
->
blobsToKeep
=
blobsToKeep_
;
if
(
DNN_NETWORK_DUMP
>
0
)
{
dumpNetworkToFile
();
}
}
}
...
...
@@ -2980,6 +2999,31 @@ struct Net::Impl
static
Net
createNetworkFromModelOptimizer
(
InferenceEngine
::
CNNNetwork
&
ieNet
);
#endif
string
dump
();
void
dumpNetworkToFile
()
{
#ifndef OPENCV_DNN_DISABLE_NETWORK_AUTO_DUMP
String
dumpFileName
=
cv
::
format
(
"ocv_dnn_net_%05d_%02d.dot"
,
networkId
,
networkDumpCounter
++
);
try
{
string
dumpStr
=
dump
();
std
::
ofstream
out
(
dumpFileName
.
c_str
(),
std
::
ios
::
out
|
std
::
ios
::
binary
);
out
<<
dumpStr
;
}
catch
(
const
std
::
exception
&
e
)
{
std
::
ofstream
out
((
dumpFileName
+
".error"
).
c_str
(),
std
::
ios
::
out
);
out
<<
"Exception: "
<<
e
.
what
()
<<
std
::
endl
;
}
catch
(...)
{
std
::
ofstream
out
((
dumpFileName
+
".error"
).
c_str
(),
std
::
ios
::
out
);
out
<<
"Can't dump: unknown exception"
<<
std
::
endl
;
}
#endif
}
};
Net
::
Net
()
:
impl
(
new
Net
::
Impl
)
...
...
@@ -3532,10 +3576,17 @@ String Net::dump()
impl
->
setUpNet
();
}
return
impl
->
dump
();
}
string
Net
::
Impl
::
dump
()
{
bool
hasInput
=
!
netInputLayer
->
inputsData
.
empty
();
std
::
ostringstream
out
;
const
std
::
map
<
int
,
LayerData
>&
map
=
impl
->
layers
;
const
std
::
map
<
int
,
LayerData
>&
map
=
layers
;
Backend
prefBackend
=
(
Backend
)
impl
->
preferableBackend
;
Backend
prefBackend
=
(
Backend
)
preferableBackend
;
std
::
vector
<
std
::
vector
<
int
>
>
skippedLayers
;
std
::
vector
<
int
>
skipId
;
std
::
vector
<
int
>
allLayers
(
map
.
size
(),
-
1
);
...
...
@@ -3736,7 +3787,7 @@ String Net::dump()
}
out
<<
'\n'
;
// Add edges
int
inputsSize
=
hasInput
?
impl
->
netInputLayer
->
outNames
.
size
()
:
0
;
int
inputsSize
=
hasInput
?
netInputLayer
->
outNames
.
size
()
:
0
;
for
(
std
::
map
<
int
,
LayerData
>::
const_iterator
it
=
map
.
begin
();
it
!=
map
.
end
();
++
it
)
{
const
LayerData
&
ld
=
it
->
second
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录