Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
7d9e1be5
O
Opencv
项目概览
Greenplum
/
Opencv
大约 1 年 前同步成功
通知
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,发现更多精彩内容 >>
提交
7d9e1be5
编写于
5月 27, 2020
作者:
A
Alexander Alekhin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #17388 from alalek:dnn_update_network_dump
上级
ba3cf476
f0bef94a
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
91 addition
and
26 deletion
+91
-26
modules/dnn/src/dnn.cpp
modules/dnn/src/dnn.cpp
+22
-12
modules/dnn/src/dnn_common.hpp
modules/dnn/src/dnn_common.hpp
+34
-0
modules/dnn/src/ie_ngraph.cpp
modules/dnn/src/ie_ngraph.cpp
+30
-4
modules/dnn/src/ie_ngraph.hpp
modules/dnn/src/ie_ngraph.hpp
+4
-2
modules/dnn/src/precomp.hpp
modules/dnn/src/precomp.hpp
+1
-8
未找到文件。
modules/dnn/src/dnn.cpp
浏览文件 @
7d9e1be5
...
...
@@ -1082,17 +1082,26 @@ static Ptr<BackendWrapper> wrapMat(int backendId, int targetId, cv::Mat& m)
static
int
g_networkId
=
0
;
struct
Net
::
Impl
detail
::
NetImplBase
::
NetImplBase
()
:
networkId
(
CV_XADD
(
&
g_networkId
,
1
))
,
networkDumpCounter
(
0
)
,
dumpLevel
(
DNN_NETWORK_DUMP
)
{
// nothing
}
std
::
string
detail
::
NetImplBase
::
getDumpFileNameBase
()
{
std
::
string
dumpFileNameBase
=
cv
::
format
(
"ocv_dnn_net_%05d_%02d"
,
networkId
,
networkDumpCounter
++
);
return
dumpFileNameBase
;
}
struct
Net
::
Impl
:
public
detail
::
NetImplBase
{
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
());
...
...
@@ -1256,7 +1265,7 @@ struct Net::Impl
{
CV_TRACE_FUNCTION
();
if
(
DNN_NETWORK_DUMP
>
0
&&
networkDumpCounter
==
0
)
if
(
dumpLevel
&&
networkDumpCounter
==
0
)
{
dumpNetworkToFile
();
}
...
...
@@ -1339,7 +1348,7 @@ struct Net::Impl
netWasAllocated
=
true
;
if
(
DNN_NETWORK_DUMP
>
0
)
if
(
dumpLevel
)
{
dumpNetworkToFile
();
}
...
...
@@ -2043,7 +2052,7 @@ struct Net::Impl
}
if
(
net
.
empty
())
{
net
=
Ptr
<
InfEngineNgraphNet
>
(
new
InfEngineNgraphNet
());
net
=
Ptr
<
InfEngineNgraphNet
>
(
new
InfEngineNgraphNet
(
*
this
));
}
if
(
!
fused
)
{
...
...
@@ -2087,7 +2096,7 @@ struct Net::Impl
}
}
else
{
net
=
Ptr
<
InfEngineNgraphNet
>
(
new
InfEngineNgraphNet
());
net
=
Ptr
<
InfEngineNgraphNet
>
(
new
InfEngineNgraphNet
(
*
this
));
}
if
(
!
fused
)
...
...
@@ -3126,7 +3135,8 @@ struct Net::Impl
void
dumpNetworkToFile
()
{
#ifndef OPENCV_DNN_DISABLE_NETWORK_AUTO_DUMP
String
dumpFileName
=
cv
::
format
(
"ocv_dnn_net_%05d_%02d.dot"
,
networkId
,
networkDumpCounter
++
);
string
dumpFileNameBase
=
getDumpFileNameBase
();
string
dumpFileName
=
dumpFileNameBase
+
".dot"
;
try
{
string
dumpStr
=
dump
();
...
...
@@ -3185,7 +3195,7 @@ Net Net::Impl::createNetworkFromModelOptimizer(InferenceEngine::CNNNetwork& ieNe
{
auto
fake_node
=
std
::
make_shared
<
ngraph
::
op
::
Parameter
>
(
ngraph
::
element
::
f32
,
ngraph
::
Shape
{});
Ptr
<
InfEngineNgraphNode
>
backendNodeNGraph
(
new
InfEngineNgraphNode
(
fake_node
));
backendNodeNGraph
->
net
=
Ptr
<
InfEngineNgraphNet
>
(
new
InfEngineNgraphNet
(
ieNet
));
backendNodeNGraph
->
net
=
Ptr
<
InfEngineNgraphNet
>
(
new
InfEngineNgraphNet
(
*
(
cvNet
.
impl
),
ieNet
));
backendNode
=
backendNodeNGraph
;
}
else
...
...
modules/dnn/src/dnn_common.hpp
0 → 100644
浏览文件 @
7d9e1be5
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#ifndef __OPENCV_DNN_COMMON_HPP__
#define __OPENCV_DNN_COMMON_HPP__
#include <opencv2/dnn.hpp>
namespace
cv
{
namespace
dnn
{
CV__DNN_EXPERIMENTAL_NS_BEGIN
#define IS_DNN_OPENCL_TARGET(id) (id == DNN_TARGET_OPENCL || id == DNN_TARGET_OPENCL_FP16)
Mutex
&
getInitializationMutex
();
void
initializeLayerFactory
();
namespace
detail
{
struct
NetImplBase
{
const
int
networkId
;
// network global identifier
int
networkDumpCounter
;
// dump counter
int
dumpLevel
;
// level of information dumps (initialized through OPENCV_DNN_NETWORK_DUMP parameter)
NetImplBase
();
std
::
string
getDumpFileNameBase
();
};
}
// namespace detail
CV__DNN_EXPERIMENTAL_NS_END
}}
// namespace
#endif // __OPENCV_DNN_COMMON_HPP__
modules/dnn/src/ie_ngraph.cpp
浏览文件 @
7d9e1be5
...
...
@@ -6,6 +6,9 @@
// Third party copyrights are property of their respective owners.
#include "precomp.hpp"
#include <fstream>
#include "ie_ngraph.hpp"
#include <opencv2/dnn/shape_utils.hpp>
...
...
@@ -22,6 +25,8 @@ namespace cv { namespace dnn {
#ifdef HAVE_DNN_NGRAPH
static
bool
DNN_IE_SERIALIZE
=
utils
::
getConfigurationParameterBool
(
"OPENCV_DNN_IE_SERIALIZE"
,
false
);
// For networks with input layer which has an empty name, IE generates a name id[some_number].
// OpenCV lets users use an empty input name and to prevent unexpected naming,
// we can use some predefined name.
...
...
@@ -295,13 +300,16 @@ void InfEngineNgraphNode::setName(const std::string& name) {
node
->
set_friendly_name
(
name
);
}
InfEngineNgraphNet
::
InfEngineNgraphNet
()
InfEngineNgraphNet
::
InfEngineNgraphNet
(
detail
::
NetImplBase
&
netImpl
)
:
netImpl_
(
netImpl
)
{
hasNetOwner
=
false
;
device_name
=
"CPU"
;
}
InfEngineNgraphNet
::
InfEngineNgraphNet
(
InferenceEngine
::
CNNNetwork
&
net
)
:
cnn
(
net
)
InfEngineNgraphNet
::
InfEngineNgraphNet
(
detail
::
NetImplBase
&
netImpl
,
InferenceEngine
::
CNNNetwork
&
net
)
:
netImpl_
(
netImpl
)
,
cnn
(
net
)
{
hasNetOwner
=
true
;
device_name
=
"CPU"
;
...
...
@@ -440,10 +448,28 @@ void InfEngineNgraphNet::init(Target targetId)
ngraph_function
->
validate_nodes_and_infer_types
();
}
cnn
=
InferenceEngine
::
CNNNetwork
(
ngraph_function
);
#ifdef _DEBUG // TODO
//cnn.serialize("/tmp/cnn.xml", "/tmp/cnn.bin");
if
(
DNN_IE_SERIALIZE
)
{
#ifndef OPENCV_DNN_DISABLE_NETWORK_AUTO_DUMP
std
::
string
dumpFileNameBase
=
netImpl_
.
getDumpFileNameBase
();
try
{
cnn
.
serialize
(
dumpFileNameBase
+
"_ngraph.xml"
,
dumpFileNameBase
+
"_ngraph.bin"
);
}
catch
(
const
std
::
exception
&
e
)
{
std
::
ofstream
out
((
dumpFileNameBase
+
"_ngraph.error"
).
c_str
(),
std
::
ios
::
out
);
out
<<
"Exception: "
<<
e
.
what
()
<<
std
::
endl
;
}
catch
(...)
{
std
::
ofstream
out
((
dumpFileNameBase
+
"_ngraph.error"
).
c_str
(),
std
::
ios
::
out
);
out
<<
"Can't dump: unknown exception"
<<
std
::
endl
;
}
#endif
}
}
switch
(
targetId
)
{
...
...
modules/dnn/src/ie_ngraph.hpp
浏览文件 @
7d9e1be5
...
...
@@ -34,8 +34,8 @@ class InfEngineNgraphNode;
class
InfEngineNgraphNet
{
public:
InfEngineNgraphNet
();
InfEngineNgraphNet
(
InferenceEngine
::
CNNNetwork
&
net
);
InfEngineNgraphNet
(
detail
::
NetImplBase
&
netImpl
);
InfEngineNgraphNet
(
detail
::
NetImplBase
&
netImpl
,
InferenceEngine
::
CNNNetwork
&
net
);
void
addOutput
(
const
std
::
string
&
name
);
...
...
@@ -55,6 +55,8 @@ public:
void
reset
();
private:
detail
::
NetImplBase
&
netImpl_
;
void
release
();
int
getNumComponents
();
void
dfs
(
std
::
shared_ptr
<
ngraph
::
Node
>&
node
,
std
::
vector
<
std
::
shared_ptr
<
ngraph
::
Node
>>&
comp
,
...
...
modules/dnn/src/precomp.hpp
浏览文件 @
7d9e1be5
...
...
@@ -61,11 +61,4 @@
#include <opencv2/dnn.hpp>
#include <opencv2/dnn/all_layers.hpp>
namespace
cv
{
namespace
dnn
{
CV__DNN_EXPERIMENTAL_NS_BEGIN
#define IS_DNN_OPENCL_TARGET(id) (id == DNN_TARGET_OPENCL || id == DNN_TARGET_OPENCL_FP16)
Mutex
&
getInitializationMutex
();
void
initializeLayerFactory
();
CV__DNN_EXPERIMENTAL_NS_END
}}
// namespace
#include "dnn_common.hpp"
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录