Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
777d7784
Commit
777d7784
authored
May 04, 2018
by
Dmitry Kurtaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Free Convolution and MatMul weights after TensorFlow layers import
parent
9ffe4694
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
3 deletions
+17
-3
tf_graph_simplifier.cpp
modules/dnn/src/tensorflow/tf_graph_simplifier.cpp
+9
-1
tf_graph_simplifier.hpp
modules/dnn/src/tensorflow/tf_graph_simplifier.hpp
+2
-0
tf_importer.cpp
modules/dnn/src/tensorflow/tf_importer.cpp
+6
-2
No files found.
modules/dnn/src/tensorflow/tf_graph_simplifier.cpp
View file @
777d7784
...
...
@@ -612,7 +612,7 @@ void RemoveIdentityOps(tensorflow::GraphDef& net)
Mat
getTensorContent
(
const
tensorflow
::
TensorProto
&
tensor
)
{
std
::
string
content
=
tensor
.
tensor_content
();
const
std
::
string
&
content
=
tensor
.
tensor_content
();
switch
(
tensor
.
dtype
())
{
case
tensorflow
:
:
DT_FLOAT
:
...
...
@@ -681,6 +681,14 @@ Mat getTensorContent(const tensorflow::TensorProto &tensor)
return
Mat
();
}
void
releaseTensor
(
tensorflow
::
TensorProto
*
tensor
)
{
if
(
!
tensor
->
mutable_tensor_content
()
->
empty
())
{
delete
tensor
->
release_tensor_content
();
}
}
CV__DNN_EXPERIMENTAL_NS_END
}}
// namespace dnn, namespace cv
...
...
modules/dnn/src/tensorflow/tf_graph_simplifier.hpp
View file @
777d7784
...
...
@@ -23,6 +23,8 @@ void simplifySubgraphs(tensorflow::GraphDef& net);
Mat
getTensorContent
(
const
tensorflow
::
TensorProto
&
tensor
);
void
releaseTensor
(
tensorflow
::
TensorProto
*
tensor
);
CV__DNN_EXPERIMENTAL_NS_END
}}
// namespace dnn, namespace cv
...
...
modules/dnn/src/tensorflow/tf_importer.cpp
View file @
777d7784
...
...
@@ -677,7 +677,9 @@ void TFImporter::populateNet(Net dstNet)
layers_to_ignore
.
insert
(
next_layers
[
0
].
first
);
}
kernelFromTensor
(
getConstBlob
(
layer
,
value_id
),
layerParams
.
blobs
[
0
]);
const
tensorflow
::
TensorProto
&
kernelTensor
=
getConstBlob
(
layer
,
value_id
);
kernelFromTensor
(
kernelTensor
,
layerParams
.
blobs
[
0
]);
releaseTensor
(
const_cast
<
tensorflow
::
TensorProto
*>
(
&
kernelTensor
));
int
*
kshape
=
layerParams
.
blobs
[
0
].
size
.
p
;
if
(
type
==
"DepthwiseConv2dNative"
)
{
...
...
@@ -788,7 +790,9 @@ void TFImporter::populateNet(Net dstNet)
}
int
kernel_blob_index
=
-
1
;
blobFromTensor
(
getConstBlob
(
layer
,
value_id
,
-
1
,
&
kernel_blob_index
),
layerParams
.
blobs
[
0
]);
const
tensorflow
::
TensorProto
&
kernelTensor
=
getConstBlob
(
layer
,
value_id
,
-
1
,
&
kernel_blob_index
);
blobFromTensor
(
kernelTensor
,
layerParams
.
blobs
[
0
]);
releaseTensor
(
const_cast
<
tensorflow
::
TensorProto
*>
(
&
kernelTensor
));
if
(
kernel_blob_index
==
1
)
{
// In this case output is computed by x*W formula - W should be transposed
Mat
data
=
layerParams
.
blobs
[
0
].
t
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment