Skip to content

Commit 1fac142

Browse files
YashasSamagaalalek
authored andcommitted
Merge pull request opencv#16010 from YashasSamaga:cuda4dnn-fp16-tests
* enable tests for DNN_TARGET_CUDA_FP16 * disable deconvolution tests * disable shortcut tests * fix typos and some minor changes * dnn(test): skip CUDA FP16 test too (run_pool_max)
1 parent 4de1efd commit 1fac142

10 files changed

+461
-107
lines changed

modules/dnn/test/test_backends.cpp

Lines changed: 101 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ TEST_P(DNNTestNetwork, ENet)
168168
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
169169
if (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16)
170170
applyTestTag(CV_TEST_TAG_DNN_SKIP_OPENCL_FP16);
171+
if (backend == DNN_BACKEND_CUDA && target == DNN_TARGET_CUDA_FP16)
172+
applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA_FP16);
171173
processNet("dnn/Enet-model-best.net", "", Size(512, 512), "l367_Deconvolution",
172174
target == DNN_TARGET_OPENCL ? "dnn/halide_scheduler_opencl_enet.yml" :
173175
"dnn/halide_scheduler_enet.yml",
@@ -182,11 +184,11 @@ TEST_P(DNNTestNetwork, MobileNet_SSD_Caffe)
182184
applyTestTag(CV_TEST_TAG_DNN_SKIP_HALIDE);
183185
Mat sample = imread(findDataFile("dnn/street.png"));
184186
Mat inp = blobFromImage(sample, 1.0f / 127.5, Size(300, 300), Scalar(127.5, 127.5, 127.5), false);
185-
float diffScores = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 1.5e-2 : 0.0;
186-
float diffSquares = (target == DNN_TARGET_MYRIAD) ? 0.063 : 0.0;
187+
float scoreDiff = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 1.5e-2 : 0.0;
188+
float iouDiff = (target == DNN_TARGET_MYRIAD) ? 0.063 : 0.0;
187189
float detectionConfThresh = (target == DNN_TARGET_MYRIAD) ? 0.252 : FLT_MIN;
188190
processNet("dnn/MobileNetSSD_deploy.caffemodel", "dnn/MobileNetSSD_deploy.prototxt",
189-
inp, "detection_out", "", diffScores, diffSquares, detectionConfThresh);
191+
inp, "detection_out", "", scoreDiff, iouDiff, detectionConfThresh);
190192
expectNoFallbacksFromIE(net);
191193
}
192194

@@ -201,10 +203,19 @@ TEST_P(DNNTestNetwork, MobileNet_SSD_Caffe_Different_Width_Height)
201203
#endif
202204
Mat sample = imread(findDataFile("dnn/street.png"));
203205
Mat inp = blobFromImage(sample, 1.0f / 127.5, Size(300, 560), Scalar(127.5, 127.5, 127.5), false);
204-
float diffScores = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.029 : 0.0;
205-
float diffSquares = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.09 : 0.0;
206+
float scoreDiff = 0.0, iouDiff = 0.0;
207+
if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD)
208+
{
209+
scoreDiff = 0.029;
210+
iouDiff = 0.09;
211+
}
212+
else if (target == DNN_TARGET_CUDA_FP16)
213+
{
214+
scoreDiff = 0.03;
215+
iouDiff = 0.08;
216+
}
206217
processNet("dnn/MobileNetSSD_deploy.caffemodel", "dnn/MobileNetSSD_deploy.prototxt",
207-
inp, "detection_out", "", diffScores, diffSquares);
218+
inp, "detection_out", "", scoreDiff, iouDiff);
208219
expectNoFallbacksFromIE(net);
209220
}
210221

@@ -216,11 +227,20 @@ TEST_P(DNNTestNetwork, MobileNet_SSD_v1_TensorFlow)
216227

217228
Mat sample = imread(findDataFile("dnn/street.png"));
218229
Mat inp = blobFromImage(sample, 1.0f, Size(300, 300), Scalar(), false);
219-
float l1 = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.095 : 0.0;
220-
float lInf = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.09 : 0.0;
221230
float detectionConfThresh = (target == DNN_TARGET_MYRIAD) ? 0.216 : 0.2;
231+
float scoreDiff = 0.0, iouDiff = 0.0;
232+
if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD)
233+
{
234+
scoreDiff = 0.095;
235+
iouDiff = 0.09;
236+
}
237+
else if (target == DNN_TARGET_CUDA_FP16)
238+
{
239+
scoreDiff = 0.007;
240+
iouDiff = 0.08;
241+
}
222242
processNet("dnn/ssd_mobilenet_v1_coco_2017_11_17.pb", "dnn/ssd_mobilenet_v1_coco_2017_11_17.pbtxt",
223-
inp, "detection_out", "", l1, lInf, detectionConfThresh);
243+
inp, "detection_out", "", scoreDiff, iouDiff, detectionConfThresh);
224244
expectNoFallbacksFromIE(net);
225245
}
226246

@@ -240,10 +260,19 @@ TEST_P(DNNTestNetwork, MobileNet_SSD_v1_TensorFlow_Different_Width_Height)
240260

241261
Mat sample = imread(findDataFile("dnn/street.png"));
242262
Mat inp = blobFromImage(sample, 1.0f, Size(300, 560), Scalar(), false);
243-
float l1 = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.012 : 0.0;
244-
float lInf = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.06 : 0.0;
263+
float scoreDiff = 0.0, iouDiff = 0.0;
264+
if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD)
265+
{
266+
scoreDiff = 0.012;
267+
iouDiff = 0.06;
268+
}
269+
else if (target == DNN_TARGET_CUDA_FP16)
270+
{
271+
scoreDiff = 0.007;
272+
iouDiff = 0.06;
273+
}
245274
processNet("dnn/ssd_mobilenet_v1_coco_2017_11_17.pb", "dnn/ssd_mobilenet_v1_coco_2017_11_17.pbtxt",
246-
inp, "detection_out", "", l1, lInf);
275+
inp, "detection_out", "", scoreDiff, iouDiff);
247276
expectNoFallbacksFromIE(net);
248277
}
249278

@@ -255,10 +284,19 @@ TEST_P(DNNTestNetwork, MobileNet_SSD_v2_TensorFlow)
255284

256285
Mat sample = imread(findDataFile("dnn/street.png"));
257286
Mat inp = blobFromImage(sample, 1.0f, Size(300, 300), Scalar(), false);
258-
float l1 = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.013 : 2e-5;
259-
float lInf = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.062 : 0.0;
287+
float scoreDiff = 2e-5, iouDiff = 0.0;
288+
if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD)
289+
{
290+
scoreDiff = 0.013;
291+
iouDiff = 0.062;
292+
}
293+
else if (target == DNN_TARGET_CUDA_FP16)
294+
{
295+
scoreDiff = 0.02;
296+
iouDiff = 0.07;
297+
}
260298
processNet("dnn/ssd_mobilenet_v2_coco_2018_03_29.pb", "dnn/ssd_mobilenet_v2_coco_2018_03_29.pbtxt",
261-
inp, "detection_out", "", l1, lInf, 0.25);
299+
inp, "detection_out", "", scoreDiff, iouDiff, 0.25);
262300
expectNoFallbacksFromIE(net);
263301
}
264302

@@ -268,12 +306,25 @@ TEST_P(DNNTestNetwork, SSD_VGG16)
268306
CV_TEST_TAG_DEBUG_VERYLONG);
269307
if (backend == DNN_BACKEND_HALIDE && target == DNN_TARGET_CPU)
270308
applyTestTag(CV_TEST_TAG_DNN_SKIP_HALIDE); // TODO HALIDE_CPU
271-
double scoreThreshold = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.0325 : 0.0;
272-
const float lInf = (target == DNN_TARGET_MYRIAD) ? 0.032 : 0.0;
273309
Mat sample = imread(findDataFile("dnn/street.png"));
274310
Mat inp = blobFromImage(sample, 1.0f, Size(300, 300), Scalar(), false);
311+
float scoreDiff = 0.0, iouDiff = 0.0;
312+
if (target == DNN_TARGET_OPENCL_FP16)
313+
{
314+
scoreDiff = 0.0325;
315+
}
316+
else if (target == DNN_TARGET_MYRIAD)
317+
{
318+
scoreDiff = 0.0325;
319+
iouDiff = 0.032;
320+
}
321+
else if (target == DNN_TARGET_CUDA_FP16)
322+
{
323+
scoreDiff = 0.03;
324+
}
325+
275326
processNet("dnn/VGG_ILSVRC2016_SSD_300x300_iter_440000.caffemodel",
276-
"dnn/ssd_vgg16.prototxt", inp, "detection_out", "", scoreThreshold, lInf);
327+
"dnn/ssd_vgg16.prototxt", inp, "detection_out", "", scoreDiff, iouDiff);
277328
expectNoFallbacksFromIE(net);
278329
}
279330

@@ -384,10 +435,19 @@ TEST_P(DNNTestNetwork, Inception_v2_SSD_TensorFlow)
384435
applyTestTag(CV_TEST_TAG_DNN_SKIP_HALIDE);
385436
Mat sample = imread(findDataFile("dnn/street.png"));
386437
Mat inp = blobFromImage(sample, 1.0f, Size(300, 300), Scalar(), false);
387-
float l1 = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.015 : 0.0;
388-
float lInf = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.0731 : 0.0;
438+
float scoreDiff = 0.0, iouDiff = 0.0;
439+
if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD)
440+
{
441+
scoreDiff = 0.015;
442+
iouDiff = 0.0731;
443+
}
444+
else if (target == DNN_TARGET_CUDA_FP16)
445+
{
446+
scoreDiff = 0.015;
447+
iouDiff = 0.08;
448+
}
389449
processNet("dnn/ssd_inception_v2_coco_2017_11_17.pb", "dnn/ssd_inception_v2_coco_2017_11_17.pbtxt",
390-
inp, "detection_out", "", l1, lInf);
450+
inp, "detection_out", "", scoreDiff, iouDiff);
391451
expectNoFallbacksFromIE(net);
392452
}
393453

@@ -400,11 +460,18 @@ TEST_P(DNNTestNetwork, DenseNet_121)
400460
float l1 = 0.0, lInf = 0.0;
401461
if (target == DNN_TARGET_OPENCL_FP16)
402462
{
403-
l1 = 2e-2; lInf = 9e-2;
463+
l1 = 2e-2;
464+
lInf = 9e-2;
404465
}
405466
else if (target == DNN_TARGET_MYRIAD)
406467
{
407-
l1 = 0.1; lInf = 0.6;
468+
l1 = 0.1;
469+
lInf = 0.6;
470+
}
471+
else if (target == DNN_TARGET_CUDA_FP16)
472+
{
473+
l1 = 0.008;
474+
lInf = 0.05;
408475
}
409476
processNet("dnn/DenseNet_121.caffemodel", "dnn/DenseNet_121.prototxt", Size(224, 224), "", "", l1, lInf);
410477
if (target != DNN_TARGET_MYRIAD || getInferenceEngineVPUType() != CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X)
@@ -431,8 +498,17 @@ TEST_P(DNNTestNetwork, FastNeuralStyle_eccv16)
431498
Mat img = imread(findDataFile("dnn/googlenet_1.png"));
432499
Mat inp = blobFromImage(img, 1.0, Size(320, 240), Scalar(103.939, 116.779, 123.68), false, false);
433500
// Output image has values in range [-143.526, 148.539].
434-
float l1 = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.4 : 4e-5;
435-
float lInf = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 7.45 : 2e-3;
501+
float l1 = 4e-5, lInf = 2e-3;
502+
if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD)
503+
{
504+
l1 = 0.4;
505+
lInf = 7.45;
506+
}
507+
else if (target == DNN_TARGET_CUDA_FP16)
508+
{
509+
l1 = 0.3;
510+
lInf = 7.2;
511+
}
436512
processNet("dnn/fast_neural_style_eccv16_starry_night.t7", "", inp, "", "", l1, lInf);
437513
#if defined(HAVE_INF_ENGINE) && INF_ENGINE_VER_MAJOR_GE(2019010000)
438514
expectNoFallbacksFromIE(net);

modules/dnn/test/test_caffe_importer.cpp

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,17 @@ TEST_P(Test_Caffe_nets, Axpy)
150150
}
151151
}
152152
}
153-
float l1 = (target == DNN_TARGET_OPENCL_FP16) ? 2e-4 : 1e-5;
154-
float lInf = (target == DNN_TARGET_OPENCL_FP16) ? 1e-3 : 1e-4;
153+
float l1 = 1e-5, lInf = 1e-4;
154+
if (target == DNN_TARGET_OPENCL_FP16)
155+
{
156+
l1 = 2e-4;
157+
lInf = 1e-3;
158+
}
159+
else if(target == DNN_TARGET_CUDA_FP16)
160+
{
161+
l1 = 0.0002;
162+
lInf = 0.0007;
163+
}
155164
normAssert(ref, out, "", l1, lInf);
156165
}
157166

@@ -287,8 +296,17 @@ TEST_P(Reproducibility_MobileNet_SSD, Accuracy)
287296

288297
ASSERT_EQ(out.size[2], 100);
289298

290-
const float scores_diff = (targetId == DNN_TARGET_OPENCL_FP16 || targetId == DNN_TARGET_MYRIAD) ? 1.5e-2 : 1e-5;
291-
const float boxes_iou_diff = (targetId == DNN_TARGET_OPENCL_FP16 || targetId == DNN_TARGET_MYRIAD) ? 6.3e-2 : 1e-4;
299+
float scores_diff = 1e-5, boxes_iou_diff = 1e-4;
300+
if (targetId == DNN_TARGET_OPENCL_FP16 || targetId == DNN_TARGET_MYRIAD)
301+
{
302+
scores_diff = 1.5e-2;
303+
boxes_iou_diff = 6.3e-2;
304+
}
305+
else if (targetId == DNN_TARGET_CUDA_FP16)
306+
{
307+
scores_diff = 0.015;
308+
boxes_iou_diff = 0.07;
309+
}
292310
Mat ref = blobFromNPY(_tf("mobilenet_ssd_caffe_out.npy"));
293311
normAssertDetections(ref, out, "", FLT_MIN, scores_diff, boxes_iou_diff);
294312

@@ -477,11 +495,21 @@ TEST_P(Test_Caffe_nets, Colorization)
477495
Mat out = net.forward();
478496

479497
// Reference output values are in range [-29.1, 69.5]
480-
double l1 = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.25 : 4e-4;
481-
double lInf = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 5.3 : 3e-3;
482-
if (target == DNN_TARGET_MYRIAD && getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X)
498+
double l1 = 4e-4, lInf = 3e-3;
499+
if (target == DNN_TARGET_OPENCL_FP16)
483500
{
484-
l1 = 0.5; lInf = 11;
501+
l1 = 0.25;
502+
lInf = 5.3;
503+
}
504+
else if (target == DNN_TARGET_MYRIAD)
505+
{
506+
l1 = (getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X) ? 0.5 : 0.25;
507+
lInf = (getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X) ? 11 : 5.3;
508+
}
509+
else if(target == DNN_TARGET_CUDA_FP16)
510+
{
511+
l1 = 0.21;
512+
lInf = 4.5;
485513
}
486514
normAssert(out, ref, "", l1, lInf);
487515
expectNoFallbacksFromIE(net);
@@ -518,6 +546,10 @@ TEST_P(Test_Caffe_nets, DenseNet_121)
518546
{
519547
l1 = 0.11; lInf = 0.5;
520548
}
549+
else if (target == DNN_TARGET_CUDA_FP16)
550+
{
551+
l1 = 0.04; lInf = 0.2;
552+
}
521553
normAssert(outs[0], ref, "", l1, lInf);
522554
if (target != DNN_TARGET_MYRIAD || getInferenceEngineVPUType() != CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X)
523555
expectNoFallbacksFromIE(model);
@@ -663,6 +695,8 @@ TEST_P(Test_Caffe_nets, FasterRCNN_zf)
663695
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16);
664696
if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target == DNN_TARGET_MYRIAD)
665697
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD);
698+
if (target == DNN_TARGET_CUDA_FP16)
699+
applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA_FP16);
666700
static Mat ref = (Mat_<float>(3, 7) << 0, 2, 0.90121, 120.407, 115.83, 570.586, 528.395,
667701
0, 7, 0.988779, 469.849, 75.1756, 718.64, 186.762,
668702
0, 12, 0.967198, 138.588, 206.843, 329.766, 553.176);
@@ -680,8 +714,17 @@ TEST_P(Test_Caffe_nets, RFCN)
680714
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16);
681715
if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target == DNN_TARGET_MYRIAD)
682716
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD);
683-
double scoreDiff = (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16) ? 4e-3 : default_l1;
684-
double iouDiff = (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16) ? 8e-2 : default_lInf;
717+
float scoreDiff = default_l1, iouDiff = default_lInf;
718+
if (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16)
719+
{
720+
scoreDiff = 4e-3;
721+
iouDiff = 8e-2;
722+
}
723+
if (target == DNN_TARGET_CUDA_FP16)
724+
{
725+
scoreDiff = 0.0034;
726+
iouDiff = 0.11;
727+
}
685728
static Mat ref = (Mat_<float>(2, 7) << 0, 7, 0.991359, 491.822, 81.1668, 702.573, 178.234,
686729
0, 12, 0.94786, 132.093, 223.903, 338.077, 566.16);
687730
testFaster("rfcn_pascal_voc_resnet50.prototxt", "resnet50_rfcn_final.caffemodel", ref, scoreDiff, iouDiff);

modules/dnn/test/test_common.impl.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,8 @@ testing::internal::ParamGenerator< tuple<Backend, Target> > dnnBackendsAndTarget
239239
#ifdef HAVE_CUDA
240240
if(withCUDA)
241241
{
242-
//for (auto target : getAvailableTargets(DNN_BACKEND_CUDA))
243-
// targets.push_back(make_tuple(DNN_BACKEND_CUDA, target));
244-
targets.push_back(make_tuple(DNN_BACKEND_CUDA, DNN_TARGET_CUDA));
242+
for (auto target : getAvailableTargets(DNN_BACKEND_CUDA))
243+
targets.push_back(make_tuple(DNN_BACKEND_CUDA, target));
245244
}
246245
#endif
247246

modules/dnn/test/test_darknet_importer.cpp

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,18 @@ TEST_P(Test_Darknet_nets, YoloVoc)
320320
1, 6, 0.667770f, 0.446555f, 0.453578f, 0.499986f, 0.519167f, // a car
321321
1, 6, 0.844947f, 0.637058f, 0.460398f, 0.828508f, 0.66427f); // a car
322322

323-
double scoreDiff = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 1e-2 : 8e-5;
324-
double iouDiff = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.018 : 3e-4;
325323
double nmsThreshold = (target == DNN_TARGET_MYRIAD) ? 0.397 : 0.4;
324+
double scoreDiff = 8e-5, iouDiff = 3e-4;
325+
if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD)
326+
{
327+
scoreDiff = 1e-2;
328+
iouDiff = 0.018;
329+
}
330+
else if (target == DNN_TARGET_CUDA_FP16)
331+
{
332+
scoreDiff = 0.03;
333+
iouDiff = 0.018;
334+
}
326335

327336
std::string config_file = "yolo-voc.cfg";
328337
std::string weights_file = "yolo-voc.weights";
@@ -353,8 +362,17 @@ TEST_P(Test_Darknet_nets, TinyYoloVoc)
353362
1, 6, 0.651450f, 0.460526f, 0.458019f, 0.522527f, 0.5341f, // a car
354363
1, 6, 0.928758f, 0.651024f, 0.463539f, 0.823784f, 0.654998f); // a car
355364

356-
double scoreDiff = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 8e-3 : 8e-5;
357-
double iouDiff = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.018 : 3e-4;
365+
double scoreDiff = 8e-5, iouDiff = 3e-4;
366+
if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD)
367+
{
368+
scoreDiff = 8e-3;
369+
iouDiff = 0.018;
370+
}
371+
else if(target == DNN_TARGET_CUDA_FP16)
372+
{
373+
scoreDiff = 0.008;
374+
iouDiff = 0.02;
375+
}
358376

359377
std::string config_file = "tiny-yolo-voc.cfg";
360378
std::string weights_file = "tiny-yolo-voc.weights";
@@ -453,9 +471,17 @@ TEST_P(Test_Darknet_nets, YOLOv3)
453471
1, 2, 0.989633f, 0.450719f, 0.463353f, 0.496305f, 0.522258f, // a car
454472
1, 2, 0.997412f, 0.647584f, 0.459939f, 0.821038f, 0.663947f); // a car
455473

456-
double scoreDiff = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.006 : 8e-5;
457-
double iouDiff = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.018 : 3e-4;
458-
474+
double scoreDiff = 8e-5, iouDiff = 3e-4;
475+
if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD)
476+
{
477+
scoreDiff = 0.006;
478+
iouDiff = 0.018;
479+
}
480+
else if (target == DNN_TARGET_CUDA_FP16)
481+
{
482+
scoreDiff = 0.04;
483+
iouDiff = 0.03;
484+
}
459485
std::string config_file = "yolov3.cfg";
460486
std::string weights_file = "yolov3.weights";
461487

@@ -501,6 +527,8 @@ INSTANTIATE_TEST_CASE_P(/**/, Test_Darknet_nets, dnnBackendsAndTargets());
501527

502528
TEST_P(Test_Darknet_layers, shortcut)
503529
{
530+
if (backend == DNN_BACKEND_CUDA)
531+
applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA);
504532
testDarknetLayer("shortcut");
505533
testDarknetLayer("shortcut_leaky");
506534
testDarknetLayer("shortcut_unequal");

0 commit comments

Comments
 (0)