@@ -341,10 +341,8 @@ TEST_P(Test_Int8_layers, Eltwise)
341341testLayer (" split_max" ," ONNX" ,0.004 ,0.012 );
342342}
343343
344- // TODO : Only CPU backend has int8 implementation, so testing is done on OCV/CPU and OCV/OCL backend.
345- // Need to test the behaviour of int8 layers on other backends.
346- INSTANTIATE_TEST_CASE_P (/* */ , Test_Int8_layers, Combine(Values(DNN_BACKEND_OPENCV), Values(DNN_TARGET_CPU, DNN_TARGET_OPENCL)));
347-
344+ // TODO : Only CPU backend has int8 implementation. Need to test the behaviour of int8 layers on other backends.
345+ INSTANTIATE_TEST_CASE_P (/* */ , Test_Int8_layers, Combine(Values(DNN_BACKEND_OPENCV), ValuesIn(getAvailableTargets(DNN_BACKEND_OPENCV))));
348346
349347class Test_Int8_nets :public DNNTestLayer
350348{
@@ -399,18 +397,24 @@ class Test_Int8_nets : public DNNTestLayer
399397 baseNet.setPreferableBackend (backend);
400398 baseNet.setPreferableTarget (target);
401399
400+ Net qnet = baseNet.quantize (blob, CV_32F, CV_32F);
401+ qnet.setInput (blob);
402+ Mat out = qnet.forward ();
403+
402404if (useSoftmax)
403405 {
404406 LayerParams lp;
405- baseNet.addLayerToPrev (" softmaxLayer" ," Softmax" , lp);
407+ Net netSoftmax;
408+ netSoftmax.addLayerToPrev (" softmaxLayer" ," Softmax" , lp);
409+ netSoftmax.setPreferableBackend (DNN_BACKEND_OPENCV);
406410
407- baseNet.setInput (blob);
408- ref = baseNet.forward ();
411+ netSoftmax.setInput (out);
412+ out = netSoftmax.forward ();
413+
414+ netSoftmax.setInput (ref);
415+ ref = netSoftmax.forward ();
409416 }
410417
411- Net qnet = baseNet.quantize (blob, CV_32F, CV_32F);
412- qnet.setInput (blob);
413- Mat out = qnet.forward ();
414418normAssert (ref, out," " , l1, lInf);
415419 }
416420
@@ -547,7 +551,7 @@ TEST_P(Test_Int8_nets, AlexNet)
547551 Mat blob =blobFromImage (inp,1.0 ,Size (227 ,227 ),Scalar (),false );
548552 Mat ref =blobFromNPY (_tf (" caffe_alexnet_prob.npy" ));
549553
550- float l1 =1e-5 , lInf =0.0013 ;
554+ float l1 =1e-4 , lInf =0.003 ;
551555testClassificationNet (net, blob, ref, l1, lInf);
552556}
553557
@@ -578,7 +582,7 @@ TEST_P(Test_Int8_nets, ResNet50)
578582 Mat blob =blobFromImage (inp,1.0 ,Size (224 ,224 ),Scalar (),false );
579583 Mat ref =blobFromNPY (_tf (" resnet50_prob.npy" ));
580584
581- float l1 =2e -4 , lInf =0.035 ;
585+ float l1 =3e -4 , lInf =0.035 ;
582586testClassificationNet (net, blob, ref, l1, lInf);
583587}
584588
@@ -626,7 +630,7 @@ TEST_P(Test_Int8_nets, CaffeNet)
626630 &&getInferenceEngineVPUType () == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X)
627631applyTestTag (CV_TEST_TAG_DNN_SKIP_IE_MYRIAD_X, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER, CV_TEST_TAG_DNN_SKIP_IE_VERSION);
628632#endif
629- float l1 =1e -5 , lInf =0.0022 ;
633+ float l1 =4e -5 , lInf =0.0025 ;
630634testONNXNet (" caffenet" , l1, lInf);
631635}
632636
@@ -751,7 +755,7 @@ TEST_P(Test_Int8_nets, opencv_face_detector)
7517550 ,1 ,0.97203469 ,0.67965847 ,0.06876482 ,0.73999709 ,0.1513494 ,
7527560 ,1 ,0.95097077 ,0.51901293 ,0.45863652 ,0.5777427 ,0.5347801 );
753757
754- float confThreshold =0.5 , scoreDiff =0.002 , iouDiff =0.2 ;
758+ float confThreshold =0.5 , scoreDiff =0.002 , iouDiff =0.21 ;
755759testDetectionNet (net, blob, ref, confThreshold, scoreDiff, iouDiff);
756760}
757761
@@ -1122,7 +1126,7 @@ TEST_P(Test_Int8_nets, YOLOv4)
11221126
11231127 std::string config_file =" yolov4.cfg" ;
11241128 std::string weights_file =" yolov4.weights" ;
1125- double scoreDiff =0.1 , iouDiff =0.15 ;
1129+ double scoreDiff =0.1 , iouDiff =0.17 ;
11261130 {
11271131SCOPED_TRACE (" batch size 1" );
11281132testDarknetModel (config_file, weights_file, ref.rowRange (0 , N0), scoreDiff, iouDiff);
@@ -1175,7 +1179,8 @@ TEST_P(Test_Int8_nets, YOLOv4_tiny)
11751179
11761180 std::string config_file =" yolov4-tiny.cfg" ;
11771181 std::string weights_file =" yolov4-tiny.weights" ;
1178- double scoreDiff =0.11 , iouDiff =0.082 ;
1182+ double scoreDiff =0.12 ;
1183+ double iouDiff = target == DNN_TARGET_OPENCL_FP16 ?0.2 :0.082 ;
11791184
11801185#if defined(INF_ENGINE_RELEASE)
11811186if (target == DNN_TARGET_MYRIAD)// bad accuracy
@@ -1210,7 +1215,6 @@ TEST_P(Test_Int8_nets, YOLOv4_tiny)
12101215#endif
12111216}
12121217
1213- // TODO : Only CPU backend has int8 implementation, so testing is done on OCV/CPU and OCV/OCL backend.
1214- // Need to test the behaviour of int8 layers on other backends.
1215- INSTANTIATE_TEST_CASE_P (/* */ , Test_Int8_nets, Combine(Values(DNN_BACKEND_OPENCV), Values(DNN_TARGET_CPU, DNN_TARGET_OPENCL)));
1218+ // TODO : Only CPU backend has int8 implementation. Need to test the behaviour of int8 layers on other backends.
1219+ INSTANTIATE_TEST_CASE_P (/* */ , Test_Int8_nets, Combine(Values(DNN_BACKEND_OPENCV), ValuesIn(getAvailableTargets(DNN_BACKEND_OPENCV))));
12161220}}// namespace