Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
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_contrib
Commits
1ca1a125
Commit
1ca1a125
authored
May 25, 2017
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1183 from dkurt:fix_allocation_issues
parents
a4cc8014
d5ac902f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
22 deletions
+31
-22
blank_layer.cpp
modules/dnn/src/layers/blank_layer.cpp
+7
-9
elementwise_layers.cpp
modules/dnn/src/layers/elementwise_layers.cpp
+3
-3
pooling_layer.cpp
modules/dnn/src/layers/pooling_layer.cpp
+7
-1
reshape_layer.cpp
modules/dnn/src/layers/reshape_layer.cpp
+14
-9
No files found.
modules/dnn/src/layers/blank_layer.cpp
View file @
1ca1a125
...
...
@@ -49,18 +49,16 @@ class BlankLayerImpl : public BlankLayer
public
:
BlankLayerImpl
(
const
LayerParams
&
)
{}
void
allocate
(
const
std
::
vector
<
Mat
*>
&
inputs
,
std
::
vector
<
Mat
>
&
outputs
)
bool
getMemoryShapes
(
const
std
::
vector
<
MatShape
>
&
inputs
,
const
int
requiredOutputs
,
std
::
vector
<
MatShape
>
&
outputs
,
std
::
vector
<
MatShape
>
&
internals
)
const
{
outputs
.
resize
(
inputs
.
size
());
for
(
size_t
i
=
0
;
i
<
inputs
.
size
();
i
++
)
outputs
[
i
]
=
*
inputs
[
i
];
Layer
::
getMemoryShapes
(
inputs
,
requiredOutputs
,
outputs
,
internals
);
return
true
;
}
void
forward
(
std
::
vector
<
Mat
*>
&
inputs
,
std
::
vector
<
Mat
>
&
outputs
,
std
::
vector
<
Mat
>
&
internals
)
{
for
(
size_t
i
=
0
;
i
<
inputs
.
size
();
i
++
)
outputs
[
i
]
=
*
inputs
[
i
];
}
void
forward
(
std
::
vector
<
Mat
*>
&
inputs
,
std
::
vector
<
Mat
>
&
outputs
,
std
::
vector
<
Mat
>
&
internals
)
{}
};
Ptr
<
BlankLayer
>
BlankLayer
::
create
(
const
LayerParams
&
params
)
...
...
modules/dnn/src/layers/elementwise_layers.cpp
View file @
1ca1a125
...
...
@@ -37,9 +37,9 @@ public:
ElementWiseLayer
(
bool
run_parallel_
=
false
,
const
Func
&
f
=
Func
())
:
func
(
f
),
run_parallel
(
run_parallel_
)
{}
bool
getMemoryShapes
(
const
std
::
vector
<
MatShape
>
&
inputs
,
const
int
requiredOutputs
,
std
::
vector
<
MatShape
>
&
outputs
,
std
::
vector
<
MatShape
>
&
internals
)
const
const
int
requiredOutputs
,
std
::
vector
<
MatShape
>
&
outputs
,
std
::
vector
<
MatShape
>
&
internals
)
const
{
Layer
::
getMemoryShapes
(
inputs
,
requiredOutputs
,
outputs
,
internals
);
return
true
;
...
...
modules/dnn/src/layers/pooling_layer.cpp
View file @
1ca1a125
...
...
@@ -203,7 +203,13 @@ public:
CV_Assert
(
inputs
.
size
()
!=
0
);
Size
in
(
inputs
[
0
][
3
],
inputs
[
0
][
2
]),
out
;
if
(
padMode
.
empty
())
{
if
(
globalPooling
)
{
out
.
height
=
1
;
out
.
width
=
1
;
}
else
if
(
padMode
.
empty
())
{
//Yeah, something strange Caffe scheme-)
out
.
height
=
static_cast
<
int
>
(
ceil
(
static_cast
<
float
>
(
in
.
height
+
2
*
pad
.
height
-
kernel
.
height
)
/
stride
.
height
))
+
1
;
...
...
modules/dnn/src/layers/reshape_layer.cpp
View file @
1ca1a125
...
...
@@ -149,6 +149,7 @@ public:
outputs
.
push_back
(
MatShape
());
computeShapeByReshapeMask
(
inputs
[
i
],
newShapeDesc
,
newShapeRange
,
outputs
.
back
());
}
internals
=
outputs
;
return
true
;
}
...
...
@@ -160,9 +161,16 @@ public:
Mat
srcBlob
=
*
inputs
[
0
];
int
dims
=
srcBlob
.
dims
;
MatShape
inputShape
=
shape
(
srcBlob
),
outShape
=
shape
(
outputs
[
0
]);
bool
channelsReduced
=
dims
>
(
int
)
outShape
.
size
()
||
(
dims
==
4
&&
inputShape
[
1
]
>
outShape
[
1
]);
performReordering
=
enableReordering
&&
dims
==
4
&&
channelsReduced
;
// input.total() == output.total(). So if reordering is require,
// one of the sizes will be are not equal.
// Example where reordering is require: from 1x128x4x4 to 1x2048
// Example where reordering is NOT require: from 1x1024x1x1 to 1x1024.
bool
reorderingRequire
=
false
;
const
int
minDims
=
min
(
dims
,
(
int
)
outShape
.
size
());
for
(
int
i
=
0
;
!
reorderingRequire
&&
i
<
minDims
;
++
i
)
reorderingRequire
=
inputShape
[
i
]
!=
outShape
[
i
];
performReordering
=
enableReordering
&&
reorderingRequire
;
}
void
forward
(
std
::
vector
<
Mat
*>
&
inputs
,
std
::
vector
<
Mat
>
&
outputs
,
std
::
vector
<
Mat
>
&
internals
)
...
...
@@ -170,13 +178,11 @@ public:
for
(
size_t
i
=
0
;
i
<
inputs
.
size
();
i
++
)
{
Mat
srcBlob
=
*
inputs
[
i
];
MatShape
inputShape
=
shape
(
srcBlob
)
,
outShape
=
shape
(
outputs
[
i
])
;
MatShape
inputShape
=
shape
(
srcBlob
);
if
(
performReordering
)
{
Mat
reordered_blob
(
inputShape
,
srcBlob
.
type
());
float
*
dstData
=
reordered_blob
.
ptr
<
float
>
();
float
*
dstData
=
internals
[
i
].
ptr
<
float
>
();
const
float
*
srcData
=
srcBlob
.
ptr
<
float
>
();
int
num
=
inputShape
[
0
],
channels
=
inputShape
[
1
],
height
=
inputShape
[
2
],
width
=
inputShape
[
3
];
...
...
@@ -196,8 +202,7 @@ public:
}
}
}
outputs
[
i
]
=
reordered_blob
.
reshape
(
1
,
outShape
);
internals
[
i
].
copyTo
(
outputs
[
i
]);
}
}
}
...
...
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