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
8c4e0dfd
Commit
8c4e0dfd
authored
Jun 10, 2018
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #11738 from dkurt:dnn_batch_norm_fusion_base
parents
93f2fd39
7d727ac2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
0 deletions
+40
-0
batch_norm_layer.cpp
modules/dnn/src/layers/batch_norm_layer.cpp
+40
-0
No files found.
modules/dnn/src/layers/batch_norm_layer.cpp
View file @
8c4e0dfd
...
...
@@ -96,6 +96,46 @@ public:
shift
=
bias_
;
}
virtual
bool
tryFuse
(
Ptr
<
Layer
>&
top
)
CV_OVERRIDE
{
Mat
w
,
b
;
top
->
getScaleShift
(
w
,
b
);
if
(
w
.
empty
()
&&
b
.
empty
())
return
false
;
const
int
numChannels
=
weights_
.
total
();
const
int
numFusedWeights
=
w
.
total
();
const
int
numFusedBias
=
b
.
total
();
if
((
numFusedWeights
!=
numChannels
&&
numFusedWeights
!=
1
&&
!
w
.
empty
())
||
(
numFusedBias
!=
numChannels
&&
numFusedBias
!=
1
&&
!
b
.
empty
()))
return
false
;
if
(
!
w
.
empty
())
{
w
=
w
.
reshape
(
1
,
1
);
if
(
numFusedWeights
==
1
)
{
multiply
(
weights_
,
w
.
at
<
float
>
(
0
),
weights_
);
multiply
(
bias_
,
w
.
at
<
float
>
(
0
),
bias_
);
}
else
{
multiply
(
weights_
,
w
,
weights_
);
multiply
(
bias_
,
w
,
bias_
);
}
}
if
(
!
b
.
empty
())
{
b
=
b
.
reshape
(
1
,
1
);
if
(
numFusedBias
==
1
)
add
(
bias_
,
b
.
at
<
float
>
(
0
),
bias_
);
else
add
(
bias_
,
b
.
reshape
(
1
,
1
),
bias_
);
}
return
true
;
}
bool
getMemoryShapes
(
const
std
::
vector
<
MatShape
>
&
inputs
,
const
int
requiredOutputs
,
std
::
vector
<
MatShape
>
&
outputs
,
...
...
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