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
2f0fc920
Commit
2f0fc920
authored
Jul 26, 2018
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12061 from alalek:dnn_test_skip_checks_only
parents
9137e2d6
dd8701c1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
34 deletions
+40
-34
test_halide_layers.cpp
modules/dnn/test/test_halide_layers.cpp
+40
-34
No files found.
modules/dnn/test/test_halide_layers.cpp
View file @
2f0fc920
...
...
@@ -16,7 +16,7 @@ using namespace cv;
using
namespace
cv
::
dnn
;
using
namespace
testing
;
static
void
test
(
Mat
&
input
,
Net
&
net
,
int
backendId
,
int
targetId
)
static
void
test
(
Mat
&
input
,
Net
&
net
,
Backend
backendId
,
Target
targetId
,
bool
skipCheck
=
false
)
{
DNNTestLayer
::
checkBackend
(
backendId
,
targetId
);
randu
(
input
,
-
1.0
f
,
1.0
f
);
...
...
@@ -29,16 +29,19 @@ static void test(Mat& input, Net& net, int backendId, int targetId)
net
.
setPreferableTarget
(
targetId
);
Mat
outputHalide
=
net
.
forward
().
clone
();
if
(
skipCheck
)
return
;
double
l1
,
lInf
;
DNNTestLayer
::
getDefaultThresholds
(
backendId
,
targetId
,
&
l1
,
&
lInf
);
normAssert
(
outputDefault
,
outputHalide
,
""
,
l1
,
lInf
);
}
static
void
test
(
LayerParams
&
params
,
Mat
&
input
,
int
backendId
,
int
targetId
)
static
void
test
(
LayerParams
&
params
,
Mat
&
input
,
Backend
backendId
,
Target
targetId
,
bool
skipCheck
=
false
)
{
Net
net
;
net
.
addLayerToPrev
(
params
.
name
,
params
.
type
,
params
);
test
(
input
,
net
,
backendId
,
targetId
);
test
(
input
,
net
,
backendId
,
targetId
,
skipCheck
);
}
static
testing
::
internal
::
ParamGenerator
<
tuple
<
Backend
,
Target
>
>
dnnBackendsAndTargetsWithHalide
()
...
...
@@ -101,16 +104,17 @@ TEST_P(Convolution, Accuracy)
Size
pad
=
get
<
4
>
(
GetParam
());
Size
dilation
=
get
<
5
>
(
GetParam
());
bool
hasBias
=
get
<
6
>
(
GetParam
());
int
backendId
=
get
<
0
>
(
get
<
7
>
(
GetParam
()));
in
t
targetId
=
get
<
1
>
(
get
<
7
>
(
GetParam
()));
Backend
backendId
=
get
<
0
>
(
get
<
7
>
(
GetParam
()));
Targe
t
targetId
=
get
<
1
>
(
get
<
7
>
(
GetParam
()));
if
(
backendId
==
DNN_BACKEND_INFERENCE_ENGINE
&&
targetId
==
DNN_TARGET_MYRIAD
)
throw
SkipTestException
(
""
);
bool
skipCheck
=
false
;
if
(
cvtest
::
skipUnstableTests
&&
backendId
==
DNN_BACKEND_OPENCV
&&
(
targetId
==
DNN_TARGET_OPENCL
||
targetId
==
DNN_TARGET_OPENCL_FP16
)
&&
kernel
==
Size
(
3
,
1
)
&&
stride
==
Size
(
1
,
1
)
&&
pad
==
Size
(
0
,
1
))
throw
SkipTestException
(
"Skip unstable test"
)
;
skipCheck
=
true
;
int
sz
[]
=
{
outChannels
,
inChannels
/
group
,
kernel
.
height
,
kernel
.
width
};
Mat
weights
(
4
,
&
sz
[
0
],
CV_32F
);
...
...
@@ -139,7 +143,9 @@ TEST_P(Convolution, Accuracy)
}
int
inpSz
[]
=
{
1
,
inChannels
,
inSize
.
height
,
inSize
.
width
};
Mat
input
(
4
,
&
inpSz
[
0
],
CV_32F
);
test
(
lp
,
input
,
backendId
,
targetId
);
test
(
lp
,
input
,
backendId
,
targetId
,
skipCheck
);
if
(
skipCheck
)
throw
SkipTestException
(
"Skip checks in unstable test"
);
}
INSTANTIATE_TEST_CASE_P
(
Layer_Test_Halide
,
Convolution
,
Combine
(
...
...
@@ -171,8 +177,8 @@ TEST_P(Deconvolution, Accuracy)
Size
stride
=
Size
(
get
<
5
>
(
GetParam
())[
0
],
get
<
5
>
(
GetParam
())[
1
]);
Size
adjPad
=
Size
(
get
<
5
>
(
GetParam
())[
2
],
get
<
5
>
(
GetParam
())[
3
]);
bool
hasBias
=
get
<
6
>
(
GetParam
());
int
backendId
=
get
<
0
>
(
get
<
7
>
(
GetParam
()));
in
t
targetId
=
get
<
1
>
(
get
<
7
>
(
GetParam
()));
Backend
backendId
=
get
<
0
>
(
get
<
7
>
(
GetParam
()));
Targe
t
targetId
=
get
<
1
>
(
get
<
7
>
(
GetParam
()));
if
(
backendId
==
DNN_BACKEND_INFERENCE_ENGINE
&&
targetId
==
DNN_TARGET_CPU
&&
dilation
.
width
==
2
&&
dilation
.
height
==
2
)
throw
SkipTestException
(
""
);
...
...
@@ -235,8 +241,8 @@ TEST_P(LRN, Accuracy)
float
bias
=
get
<
2
>
(
GetParam
())[
2
];
bool
normBySize
=
get
<
3
>
(
GetParam
());
std
::
string
nrmType
=
get
<
4
>
(
GetParam
());
int
backendId
=
get
<
0
>
(
get
<
5
>
(
GetParam
()));
in
t
targetId
=
get
<
1
>
(
get
<
5
>
(
GetParam
()));
Backend
backendId
=
get
<
0
>
(
get
<
5
>
(
GetParam
()));
Targe
t
targetId
=
get
<
1
>
(
get
<
5
>
(
GetParam
()));
if
(
backendId
==
DNN_BACKEND_INFERENCE_ENGINE
)
throw
SkipTestException
(
""
);
...
...
@@ -276,8 +282,8 @@ TEST_P(AvePooling, Accuracy)
Size
outSize
=
get
<
1
>
(
GetParam
());;
// Input size will be computed from parameters.
Size
kernel
=
get
<
2
>
(
GetParam
());
Size
stride
=
get
<
3
>
(
GetParam
());
int
backendId
=
get
<
0
>
(
get
<
4
>
(
GetParam
()));
in
t
targetId
=
get
<
1
>
(
get
<
4
>
(
GetParam
()));
Backend
backendId
=
get
<
0
>
(
get
<
4
>
(
GetParam
()));
Targe
t
targetId
=
get
<
1
>
(
get
<
4
>
(
GetParam
()));
if
(
backendId
==
DNN_BACKEND_INFERENCE_ENGINE
&&
targetId
==
DNN_TARGET_MYRIAD
)
throw
SkipTestException
(
""
);
...
...
@@ -317,8 +323,8 @@ TEST_P(MaxPooling, Accuracy)
Size
kernel
=
get
<
2
>
(
GetParam
());
Size
stride
=
get
<
3
>
(
GetParam
());
Size
pad
=
get
<
4
>
(
GetParam
());
int
backendId
=
get
<
0
>
(
get
<
5
>
(
GetParam
()));
in
t
targetId
=
get
<
1
>
(
get
<
5
>
(
GetParam
()));
Backend
backendId
=
get
<
0
>
(
get
<
5
>
(
GetParam
()));
Targe
t
targetId
=
get
<
1
>
(
get
<
5
>
(
GetParam
()));
LayerParams
lp
;
lp
.
set
(
"pool"
,
"max"
);
...
...
@@ -355,8 +361,8 @@ TEST_P(FullyConnected, Accuracy)
Size
inSize
=
get
<
1
>
(
GetParam
());
int
outChannels
=
get
<
2
>
(
GetParam
());
bool
hasBias
=
get
<
3
>
(
GetParam
());
int
backendId
=
get
<
0
>
(
get
<
4
>
(
GetParam
()));
in
t
targetId
=
get
<
1
>
(
get
<
4
>
(
GetParam
()));
Backend
backendId
=
get
<
0
>
(
get
<
4
>
(
GetParam
()));
Targe
t
targetId
=
get
<
1
>
(
get
<
4
>
(
GetParam
()));
if
(
backendId
==
DNN_BACKEND_INFERENCE_ENGINE
)
throw
SkipTestException
(
""
);
...
...
@@ -394,8 +400,8 @@ typedef TestWithParam<tuple<int, tuple<Backend, Target> > > SoftMax;
TEST_P
(
SoftMax
,
Accuracy
)
{
int
inChannels
=
get
<
0
>
(
GetParam
());
int
backendId
=
get
<
0
>
(
get
<
1
>
(
GetParam
()));
in
t
targetId
=
get
<
1
>
(
get
<
1
>
(
GetParam
()));
Backend
backendId
=
get
<
0
>
(
get
<
1
>
(
GetParam
()));
Targe
t
targetId
=
get
<
1
>
(
get
<
1
>
(
GetParam
()));
LayerParams
lp
;
lp
.
type
=
"SoftMax"
;
lp
.
name
=
"testLayer"
;
...
...
@@ -457,7 +463,7 @@ TEST_P(Test_Halide_layers, MaxPoolUnpool)
////////////////////////////////////////////////////////////////////////////////
static
const
int
kNumChannels
=
3
;
void
testInPlaceActivation
(
LayerParams
&
lp
,
int
backendId
,
in
t
targetId
)
void
testInPlaceActivation
(
LayerParams
&
lp
,
Backend
backendId
,
Targe
t
targetId
)
{
EXPECT_FALSE
(
lp
.
name
.
empty
());
...
...
@@ -485,8 +491,8 @@ TEST_P(BatchNorm, Accuracy)
bool
hasWeights
=
get
<
0
>
(
GetParam
());
bool
hasBias
=
get
<
1
>
(
GetParam
());
float
epsilon
=
get
<
2
>
(
GetParam
());
int
backendId
=
get
<
0
>
(
get
<
3
>
(
GetParam
()));
in
t
targetId
=
get
<
1
>
(
get
<
3
>
(
GetParam
()));
Backend
backendId
=
get
<
0
>
(
get
<
3
>
(
GetParam
()));
Targe
t
targetId
=
get
<
1
>
(
get
<
3
>
(
GetParam
()));
LayerParams
lp
;
lp
.
set
(
"has_weight"
,
hasWeights
);
...
...
@@ -518,8 +524,8 @@ typedef TestWithParam<tuple<float, tuple<Backend, Target> > > ReLU;
TEST_P
(
ReLU
,
Accuracy
)
{
float
negativeSlope
=
get
<
0
>
(
GetParam
());
int
backendId
=
get
<
0
>
(
get
<
1
>
(
GetParam
()));
in
t
targetId
=
get
<
1
>
(
get
<
1
>
(
GetParam
()));
Backend
backendId
=
get
<
0
>
(
get
<
1
>
(
GetParam
()));
Targe
t
targetId
=
get
<
1
>
(
get
<
1
>
(
GetParam
()));
LayerParams
lp
;
lp
.
set
(
"negative_slope"
,
negativeSlope
);
...
...
@@ -536,8 +542,8 @@ INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, ReLU, Combine(
typedef
TestWithParam
<
tuple
<
std
::
string
,
tuple
<
Backend
,
Target
>
>
>
NoParamActivation
;
TEST_P
(
NoParamActivation
,
Accuracy
)
{
int
backendId
=
get
<
0
>
(
get
<
1
>
(
GetParam
()));
in
t
targetId
=
get
<
1
>
(
get
<
1
>
(
GetParam
()));
Backend
backendId
=
get
<
0
>
(
get
<
1
>
(
GetParam
()));
Targe
t
targetId
=
get
<
1
>
(
get
<
1
>
(
GetParam
()));
LayerParams
lp
;
lp
.
type
=
get
<
0
>
(
GetParam
());
...
...
@@ -555,8 +561,8 @@ TEST_P(Power, Accuracy)
float
power
=
get
<
0
>
(
GetParam
())[
0
];
float
scale
=
get
<
0
>
(
GetParam
())[
1
];
float
shift
=
get
<
0
>
(
GetParam
())[
2
];
int
backendId
=
get
<
0
>
(
get
<
1
>
(
GetParam
()));
in
t
targetId
=
get
<
1
>
(
get
<
1
>
(
GetParam
()));
Backend
backendId
=
get
<
0
>
(
get
<
1
>
(
GetParam
()));
Targe
t
targetId
=
get
<
1
>
(
get
<
1
>
(
GetParam
()));
LayerParams
lp
;
lp
.
set
(
"power"
,
power
);
...
...
@@ -589,8 +595,8 @@ typedef TestWithParam<tuple<bool, tuple<Backend, Target> > > Scale;
TEST_P
(
Scale
,
Accuracy
)
{
bool
hasBias
=
get
<
0
>
(
GetParam
());
int
backendId
=
get
<
0
>
(
get
<
1
>
(
GetParam
()));
in
t
targetId
=
get
<
1
>
(
get
<
1
>
(
GetParam
()));
Backend
backendId
=
get
<
0
>
(
get
<
1
>
(
GetParam
()));
Targe
t
targetId
=
get
<
1
>
(
get
<
1
>
(
GetParam
()));
LayerParams
lp
;
lp
.
set
(
"bias_term"
,
hasBias
);
...
...
@@ -624,8 +630,8 @@ TEST_P(Concat, Accuracy)
{
Vec3i
inSize
=
get
<
0
>
(
GetParam
());
Vec3i
numChannels
=
get
<
1
>
(
GetParam
());
int
backendId
=
get
<
0
>
(
get
<
2
>
(
GetParam
()));
in
t
targetId
=
get
<
1
>
(
get
<
2
>
(
GetParam
()));
Backend
backendId
=
get
<
0
>
(
get
<
2
>
(
GetParam
()));
Targe
t
targetId
=
get
<
1
>
(
get
<
2
>
(
GetParam
()));
Net
net
;
...
...
@@ -692,8 +698,8 @@ TEST_P(Eltwise, Accuracy)
std
::
string
op
=
get
<
1
>
(
GetParam
());
int
numConv
=
get
<
2
>
(
GetParam
());
bool
weighted
=
get
<
3
>
(
GetParam
());
int
backendId
=
get
<
0
>
(
get
<
4
>
(
GetParam
()));
in
t
targetId
=
get
<
1
>
(
get
<
4
>
(
GetParam
()));
Backend
backendId
=
get
<
0
>
(
get
<
4
>
(
GetParam
()));
Targe
t
targetId
=
get
<
1
>
(
get
<
4
>
(
GetParam
()));
Net
net
;
...
...
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