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
0f01b40d
Commit
0f01b40d
authored
Mar 07, 2018
by
Dmitry Kurtaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reset OpenCL kernels if batch size changes
parent
0a61ebdd
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
34 additions
and
8 deletions
+34
-8
convolution_layer.cpp
modules/dnn/src/layers/convolution_layer.cpp
+3
-0
fully_connected_layer.cpp
modules/dnn/src/layers/fully_connected_layer.cpp
+5
-0
lrn_layer.cpp
modules/dnn/src/layers/lrn_layer.cpp
+5
-0
pooling_layer.cpp
modules/dnn/src/layers/pooling_layer.cpp
+4
-0
softmax_layer.cpp
modules/dnn/src/layers/softmax_layer.cpp
+13
-8
test_googlenet.cpp
modules/dnn/test/test_googlenet.cpp
+4
-0
No files found.
modules/dnn/src/layers/convolution_layer.cpp
View file @
0f01b40d
...
...
@@ -273,6 +273,9 @@ public:
for
(
int
i
=
0
;
i
<
outCn
;
i
++
)
biasvec
[
i
]
=
biasMat
.
at
<
float
>
(
i
);
}
#ifdef HAVE_OPENCL
convolutionOp
.
release
();
#endif
}
bool
setActivation
(
const
Ptr
<
ActivationLayer
>&
layer
)
...
...
modules/dnn/src/layers/fully_connected_layer.cpp
View file @
0f01b40d
...
...
@@ -267,6 +267,11 @@ public:
};
#ifdef HAVE_OPENCL
void
finalize
(
const
std
::
vector
<
Mat
*>
&
inputs
,
std
::
vector
<
Mat
>
&
outputs
)
{
innerProductOp
.
release
();
}
bool
forward_ocl
(
InputArrayOfArrays
inps
,
OutputArrayOfArrays
outs
,
InputArrayOfArrays
internals
)
{
std
::
vector
<
UMat
>
inputs
;
...
...
modules/dnn/src/layers/lrn_layer.cpp
View file @
0f01b40d
...
...
@@ -96,6 +96,11 @@ public:
}
#ifdef HAVE_OPENCL
void
finalize
(
const
std
::
vector
<
Mat
*>
&
inputs
,
std
::
vector
<
Mat
>
&
outputs
)
{
lrnOp
.
release
();
}
bool
forward_ocl
(
InputArrayOfArrays
inps
,
OutputArrayOfArrays
outs
,
OutputArrayOfArrays
internals
)
{
std
::
vector
<
UMat
>
inputs
;
...
...
modules/dnn/src/layers/pooling_layer.cpp
View file @
0f01b40d
...
...
@@ -126,6 +126,10 @@ public:
}
getConvPoolPaddings
(
inp
,
out
,
kernel
,
stride
,
padMode
,
Size
(
1
,
1
),
pad
);
#ifdef HAVE_OPENCL
poolOp
.
release
();
#endif
}
virtual
bool
supportBackend
(
int
backendId
)
...
...
modules/dnn/src/layers/softmax_layer.cpp
View file @
0f01b40d
...
...
@@ -95,14 +95,7 @@ public:
#ifdef HAVE_OPENCL
virtual
void
finalize
(
const
std
::
vector
<
Mat
*>
&
inputs
,
std
::
vector
<
Mat
>
&
outputs
)
{
OCL4DNNSoftmaxConfig
config
;
config
.
in_shape
=
shape
(
*
inputs
[
0
]);
config
.
axis
=
axisRaw
;
config
.
channels
=
inputs
[
0
]
->
size
[
axisRaw
];
config
.
logsoftmax
=
logSoftMax
;
softmaxOp
=
Ptr
<
OCL4DNNSoftmax
<
float
>
>
(
new
OCL4DNNSoftmax
<
float
>
(
config
));
softmaxOp
.
release
();
}
bool
forward_ocl
(
InputArrayOfArrays
inps
,
OutputArrayOfArrays
outs
,
OutputArrayOfArrays
itns
)
...
...
@@ -115,6 +108,18 @@ public:
outs
.
getUMatVector
(
outputs
);
itns
.
getUMatVector
(
internals
);
if
(
softmaxOp
.
empty
())
{
OCL4DNNSoftmaxConfig
config
;
config
.
in_shape
=
shape
(
inputs
[
0
]);
config
.
axis
=
axisRaw
;
config
.
channels
=
inputs
[
0
].
size
[
axisRaw
];
config
.
logsoftmax
=
logSoftMax
;
softmaxOp
=
Ptr
<
OCL4DNNSoftmax
<
float
>
>
(
new
OCL4DNNSoftmax
<
float
>
(
config
));
}
UMat
&
src
=
inputs
[
0
];
UMat
&
dstMat
=
outputs
[
0
];
...
...
modules/dnn/test/test_googlenet.cpp
View file @
0f01b40d
...
...
@@ -77,6 +77,10 @@ OCL_TEST(Reproducibility_GoogLeNet, Accuracy)
net
.
setPreferableBackend
(
DNN_BACKEND_DEFAULT
);
net
.
setPreferableTarget
(
DNN_TARGET_OPENCL
);
// Initialize network for a single image in the batch but test with batch size=2.
net
.
setInput
(
blobFromImage
(
Mat
(
224
,
224
,
CV_8UC3
)));
net
.
forward
();
std
::
vector
<
Mat
>
inpMats
;
inpMats
.
push_back
(
imread
(
_tf
(
"googlenet_0.png"
))
);
inpMats
.
push_back
(
imread
(
_tf
(
"googlenet_1.png"
))
);
...
...
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