Merge pull request #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)
pull/16211/head
Yashas Samaga B L 5 years ago committed by Alexander Alekhin
parent 4de1efd3c8
commit 1fac1421e5
  1. 126
      modules/dnn/test/test_backends.cpp
  2. 63
      modules/dnn/test/test_caffe_importer.cpp
  3. 5
      modules/dnn/test/test_common.impl.hpp
  4. 42
      modules/dnn/test/test_darknet_importer.cpp
  5. 27
      modules/dnn/test/test_halide_layers.cpp
  6. 43
      modules/dnn/test/test_layers.cpp
  7. 55
      modules/dnn/test/test_model.cpp
  8. 35
      modules/dnn/test/test_onnx_importer.cpp
  9. 94
      modules/dnn/test/test_tf_importer.cpp
  10. 78
      modules/dnn/test/test_torch_importer.cpp

@ -168,6 +168,8 @@ TEST_P(DNNTestNetwork, ENet)
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
if (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16)
applyTestTag(CV_TEST_TAG_DNN_SKIP_OPENCL_FP16);
if (backend == DNN_BACKEND_CUDA && target == DNN_TARGET_CUDA_FP16)
applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA_FP16);
processNet("dnn/Enet-model-best.net", "", Size(512, 512), "l367_Deconvolution",
target == DNN_TARGET_OPENCL ? "dnn/halide_scheduler_opencl_enet.yml" :
"dnn/halide_scheduler_enet.yml",
@ -182,11 +184,11 @@ TEST_P(DNNTestNetwork, MobileNet_SSD_Caffe)
applyTestTag(CV_TEST_TAG_DNN_SKIP_HALIDE);
Mat sample = imread(findDataFile("dnn/street.png"));
Mat inp = blobFromImage(sample, 1.0f / 127.5, Size(300, 300), Scalar(127.5, 127.5, 127.5), false);
float diffScores = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 1.5e-2 : 0.0;
float diffSquares = (target == DNN_TARGET_MYRIAD) ? 0.063 : 0.0;
float scoreDiff = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 1.5e-2 : 0.0;
float iouDiff = (target == DNN_TARGET_MYRIAD) ? 0.063 : 0.0;
float detectionConfThresh = (target == DNN_TARGET_MYRIAD) ? 0.252 : FLT_MIN;
processNet("dnn/MobileNetSSD_deploy.caffemodel", "dnn/MobileNetSSD_deploy.prototxt",
inp, "detection_out", "", diffScores, diffSquares, detectionConfThresh);
inp, "detection_out", "", scoreDiff, iouDiff, detectionConfThresh);
expectNoFallbacksFromIE(net);
}
@ -201,10 +203,19 @@ TEST_P(DNNTestNetwork, MobileNet_SSD_Caffe_Different_Width_Height)
#endif
Mat sample = imread(findDataFile("dnn/street.png"));
Mat inp = blobFromImage(sample, 1.0f / 127.5, Size(300, 560), Scalar(127.5, 127.5, 127.5), false);
float diffScores = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.029 : 0.0;
float diffSquares = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.09 : 0.0;
float scoreDiff = 0.0, iouDiff = 0.0;
if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD)
{
scoreDiff = 0.029;
iouDiff = 0.09;
}
else if (target == DNN_TARGET_CUDA_FP16)
{
scoreDiff = 0.03;
iouDiff = 0.08;
}
processNet("dnn/MobileNetSSD_deploy.caffemodel", "dnn/MobileNetSSD_deploy.prototxt",
inp, "detection_out", "", diffScores, diffSquares);
inp, "detection_out", "", scoreDiff, iouDiff);
expectNoFallbacksFromIE(net);
}
@ -216,11 +227,20 @@ TEST_P(DNNTestNetwork, MobileNet_SSD_v1_TensorFlow)
Mat sample = imread(findDataFile("dnn/street.png"));
Mat inp = blobFromImage(sample, 1.0f, Size(300, 300), Scalar(), false);
float l1 = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.095 : 0.0;
float lInf = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.09 : 0.0;
float detectionConfThresh = (target == DNN_TARGET_MYRIAD) ? 0.216 : 0.2;
float scoreDiff = 0.0, iouDiff = 0.0;
if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD)
{
scoreDiff = 0.095;
iouDiff = 0.09;
}
else if (target == DNN_TARGET_CUDA_FP16)
{
scoreDiff = 0.007;
iouDiff = 0.08;
}
processNet("dnn/ssd_mobilenet_v1_coco_2017_11_17.pb", "dnn/ssd_mobilenet_v1_coco_2017_11_17.pbtxt",
inp, "detection_out", "", l1, lInf, detectionConfThresh);
inp, "detection_out", "", scoreDiff, iouDiff, detectionConfThresh);
expectNoFallbacksFromIE(net);
}
@ -240,10 +260,19 @@ TEST_P(DNNTestNetwork, MobileNet_SSD_v1_TensorFlow_Different_Width_Height)
Mat sample = imread(findDataFile("dnn/street.png"));
Mat inp = blobFromImage(sample, 1.0f, Size(300, 560), Scalar(), false);
float l1 = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.012 : 0.0;
float lInf = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.06 : 0.0;
float scoreDiff = 0.0, iouDiff = 0.0;
if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD)
{
scoreDiff = 0.012;
iouDiff = 0.06;
}
else if (target == DNN_TARGET_CUDA_FP16)
{
scoreDiff = 0.007;
iouDiff = 0.06;
}
processNet("dnn/ssd_mobilenet_v1_coco_2017_11_17.pb", "dnn/ssd_mobilenet_v1_coco_2017_11_17.pbtxt",
inp, "detection_out", "", l1, lInf);
inp, "detection_out", "", scoreDiff, iouDiff);
expectNoFallbacksFromIE(net);
}
@ -255,10 +284,19 @@ TEST_P(DNNTestNetwork, MobileNet_SSD_v2_TensorFlow)
Mat sample = imread(findDataFile("dnn/street.png"));
Mat inp = blobFromImage(sample, 1.0f, Size(300, 300), Scalar(), false);
float l1 = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.013 : 2e-5;
float lInf = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.062 : 0.0;
float scoreDiff = 2e-5, iouDiff = 0.0;
if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD)
{
scoreDiff = 0.013;
iouDiff = 0.062;
}
else if (target == DNN_TARGET_CUDA_FP16)
{
scoreDiff = 0.02;
iouDiff = 0.07;
}
processNet("dnn/ssd_mobilenet_v2_coco_2018_03_29.pb", "dnn/ssd_mobilenet_v2_coco_2018_03_29.pbtxt",
inp, "detection_out", "", l1, lInf, 0.25);
inp, "detection_out", "", scoreDiff, iouDiff, 0.25);
expectNoFallbacksFromIE(net);
}
@ -268,12 +306,25 @@ TEST_P(DNNTestNetwork, SSD_VGG16)
CV_TEST_TAG_DEBUG_VERYLONG);
if (backend == DNN_BACKEND_HALIDE && target == DNN_TARGET_CPU)
applyTestTag(CV_TEST_TAG_DNN_SKIP_HALIDE); // TODO HALIDE_CPU
double scoreThreshold = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.0325 : 0.0;
const float lInf = (target == DNN_TARGET_MYRIAD) ? 0.032 : 0.0;
Mat sample = imread(findDataFile("dnn/street.png"));
Mat inp = blobFromImage(sample, 1.0f, Size(300, 300), Scalar(), false);
float scoreDiff = 0.0, iouDiff = 0.0;
if (target == DNN_TARGET_OPENCL_FP16)
{
scoreDiff = 0.0325;
}
else if (target == DNN_TARGET_MYRIAD)
{
scoreDiff = 0.0325;
iouDiff = 0.032;
}
else if (target == DNN_TARGET_CUDA_FP16)
{
scoreDiff = 0.03;
}
processNet("dnn/VGG_ILSVRC2016_SSD_300x300_iter_440000.caffemodel",
"dnn/ssd_vgg16.prototxt", inp, "detection_out", "", scoreThreshold, lInf);
"dnn/ssd_vgg16.prototxt", inp, "detection_out", "", scoreDiff, iouDiff);
expectNoFallbacksFromIE(net);
}
@ -384,10 +435,19 @@ TEST_P(DNNTestNetwork, Inception_v2_SSD_TensorFlow)
applyTestTag(CV_TEST_TAG_DNN_SKIP_HALIDE);
Mat sample = imread(findDataFile("dnn/street.png"));
Mat inp = blobFromImage(sample, 1.0f, Size(300, 300), Scalar(), false);
float l1 = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.015 : 0.0;
float lInf = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.0731 : 0.0;
float scoreDiff = 0.0, iouDiff = 0.0;
if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD)
{
scoreDiff = 0.015;
iouDiff = 0.0731;
}
else if (target == DNN_TARGET_CUDA_FP16)
{
scoreDiff = 0.015;
iouDiff = 0.08;
}
processNet("dnn/ssd_inception_v2_coco_2017_11_17.pb", "dnn/ssd_inception_v2_coco_2017_11_17.pbtxt",
inp, "detection_out", "", l1, lInf);
inp, "detection_out", "", scoreDiff, iouDiff);
expectNoFallbacksFromIE(net);
}
@ -400,11 +460,18 @@ TEST_P(DNNTestNetwork, DenseNet_121)
float l1 = 0.0, lInf = 0.0;
if (target == DNN_TARGET_OPENCL_FP16)
{
l1 = 2e-2; lInf = 9e-2;
l1 = 2e-2;
lInf = 9e-2;
}
else if (target == DNN_TARGET_MYRIAD)
{
l1 = 0.1; lInf = 0.6;
l1 = 0.1;
lInf = 0.6;
}
else if (target == DNN_TARGET_CUDA_FP16)
{
l1 = 0.008;
lInf = 0.05;
}
processNet("dnn/DenseNet_121.caffemodel", "dnn/DenseNet_121.prototxt", Size(224, 224), "", "", l1, lInf);
if (target != DNN_TARGET_MYRIAD || getInferenceEngineVPUType() != CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X)
@ -431,8 +498,17 @@ TEST_P(DNNTestNetwork, FastNeuralStyle_eccv16)
Mat img = imread(findDataFile("dnn/googlenet_1.png"));
Mat inp = blobFromImage(img, 1.0, Size(320, 240), Scalar(103.939, 116.779, 123.68), false, false);
// Output image has values in range [-143.526, 148.539].
float l1 = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.4 : 4e-5;
float lInf = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 7.45 : 2e-3;
float l1 = 4e-5, lInf = 2e-3;
if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD)
{
l1 = 0.4;
lInf = 7.45;
}
else if (target == DNN_TARGET_CUDA_FP16)
{
l1 = 0.3;
lInf = 7.2;
}
processNet("dnn/fast_neural_style_eccv16_starry_night.t7", "", inp, "", "", l1, lInf);
#if defined(HAVE_INF_ENGINE) && INF_ENGINE_VER_MAJOR_GE(2019010000)
expectNoFallbacksFromIE(net);

@ -150,8 +150,17 @@ TEST_P(Test_Caffe_nets, Axpy)
}
}
}
float l1 = (target == DNN_TARGET_OPENCL_FP16) ? 2e-4 : 1e-5;
float lInf = (target == DNN_TARGET_OPENCL_FP16) ? 1e-3 : 1e-4;
float l1 = 1e-5, lInf = 1e-4;
if (target == DNN_TARGET_OPENCL_FP16)
{
l1 = 2e-4;
lInf = 1e-3;
}
else if(target == DNN_TARGET_CUDA_FP16)
{
l1 = 0.0002;
lInf = 0.0007;
}
normAssert(ref, out, "", l1, lInf);
}
@ -287,8 +296,17 @@ TEST_P(Reproducibility_MobileNet_SSD, Accuracy)
ASSERT_EQ(out.size[2], 100);
const float scores_diff = (targetId == DNN_TARGET_OPENCL_FP16 || targetId == DNN_TARGET_MYRIAD) ? 1.5e-2 : 1e-5;
const float boxes_iou_diff = (targetId == DNN_TARGET_OPENCL_FP16 || targetId == DNN_TARGET_MYRIAD) ? 6.3e-2 : 1e-4;
float scores_diff = 1e-5, boxes_iou_diff = 1e-4;
if (targetId == DNN_TARGET_OPENCL_FP16 || targetId == DNN_TARGET_MYRIAD)
{
scores_diff = 1.5e-2;
boxes_iou_diff = 6.3e-2;
}
else if (targetId == DNN_TARGET_CUDA_FP16)
{
scores_diff = 0.015;
boxes_iou_diff = 0.07;
}
Mat ref = blobFromNPY(_tf("mobilenet_ssd_caffe_out.npy"));
normAssertDetections(ref, out, "", FLT_MIN, scores_diff, boxes_iou_diff);
@ -477,11 +495,21 @@ TEST_P(Test_Caffe_nets, Colorization)
Mat out = net.forward();
// Reference output values are in range [-29.1, 69.5]
double l1 = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.25 : 4e-4;
double lInf = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 5.3 : 3e-3;
if (target == DNN_TARGET_MYRIAD && getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X)
double l1 = 4e-4, lInf = 3e-3;
if (target == DNN_TARGET_OPENCL_FP16)
{
l1 = 0.5; lInf = 11;
l1 = 0.25;
lInf = 5.3;
}
else if (target == DNN_TARGET_MYRIAD)
{
l1 = (getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X) ? 0.5 : 0.25;
lInf = (getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X) ? 11 : 5.3;
}
else if(target == DNN_TARGET_CUDA_FP16)
{
l1 = 0.21;
lInf = 4.5;
}
normAssert(out, ref, "", l1, lInf);
expectNoFallbacksFromIE(net);
@ -518,6 +546,10 @@ TEST_P(Test_Caffe_nets, DenseNet_121)
{
l1 = 0.11; lInf = 0.5;
}
else if (target == DNN_TARGET_CUDA_FP16)
{
l1 = 0.04; lInf = 0.2;
}
normAssert(outs[0], ref, "", l1, lInf);
if (target != DNN_TARGET_MYRIAD || getInferenceEngineVPUType() != CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X)
expectNoFallbacksFromIE(model);
@ -663,6 +695,8 @@ TEST_P(Test_Caffe_nets, FasterRCNN_zf)
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16);
if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target == DNN_TARGET_MYRIAD)
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD);
if (target == DNN_TARGET_CUDA_FP16)
applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA_FP16);
static Mat ref = (Mat_<float>(3, 7) << 0, 2, 0.90121, 120.407, 115.83, 570.586, 528.395,
0, 7, 0.988779, 469.849, 75.1756, 718.64, 186.762,
0, 12, 0.967198, 138.588, 206.843, 329.766, 553.176);
@ -680,8 +714,17 @@ TEST_P(Test_Caffe_nets, RFCN)
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16);
if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target == DNN_TARGET_MYRIAD)
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD);
double scoreDiff = (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16) ? 4e-3 : default_l1;
double iouDiff = (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16) ? 8e-2 : default_lInf;
float scoreDiff = default_l1, iouDiff = default_lInf;
if (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16)
{
scoreDiff = 4e-3;
iouDiff = 8e-2;
}
if (target == DNN_TARGET_CUDA_FP16)
{
scoreDiff = 0.0034;
iouDiff = 0.11;
}
static Mat ref = (Mat_<float>(2, 7) << 0, 7, 0.991359, 491.822, 81.1668, 702.573, 178.234,
0, 12, 0.94786, 132.093, 223.903, 338.077, 566.16);
testFaster("rfcn_pascal_voc_resnet50.prototxt", "resnet50_rfcn_final.caffemodel", ref, scoreDiff, iouDiff);

@ -239,9 +239,8 @@ testing::internal::ParamGenerator< tuple<Backend, Target> > dnnBackendsAndTarget
#ifdef HAVE_CUDA
if(withCUDA)
{
//for (auto target : getAvailableTargets(DNN_BACKEND_CUDA))
// targets.push_back(make_tuple(DNN_BACKEND_CUDA, target));
targets.push_back(make_tuple(DNN_BACKEND_CUDA, DNN_TARGET_CUDA));
for (auto target : getAvailableTargets(DNN_BACKEND_CUDA))
targets.push_back(make_tuple(DNN_BACKEND_CUDA, target));
}
#endif

@ -320,9 +320,18 @@ TEST_P(Test_Darknet_nets, YoloVoc)
1, 6, 0.667770f, 0.446555f, 0.453578f, 0.499986f, 0.519167f, // a car
1, 6, 0.844947f, 0.637058f, 0.460398f, 0.828508f, 0.66427f); // a car
double scoreDiff = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 1e-2 : 8e-5;
double iouDiff = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.018 : 3e-4;
double nmsThreshold = (target == DNN_TARGET_MYRIAD) ? 0.397 : 0.4;
double scoreDiff = 8e-5, iouDiff = 3e-4;
if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD)
{
scoreDiff = 1e-2;
iouDiff = 0.018;
}
else if (target == DNN_TARGET_CUDA_FP16)
{
scoreDiff = 0.03;
iouDiff = 0.018;
}
std::string config_file = "yolo-voc.cfg";
std::string weights_file = "yolo-voc.weights";
@ -353,8 +362,17 @@ TEST_P(Test_Darknet_nets, TinyYoloVoc)
1, 6, 0.651450f, 0.460526f, 0.458019f, 0.522527f, 0.5341f, // a car
1, 6, 0.928758f, 0.651024f, 0.463539f, 0.823784f, 0.654998f); // a car
double scoreDiff = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 8e-3 : 8e-5;
double iouDiff = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.018 : 3e-4;
double scoreDiff = 8e-5, iouDiff = 3e-4;
if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD)
{
scoreDiff = 8e-3;
iouDiff = 0.018;
}
else if(target == DNN_TARGET_CUDA_FP16)
{
scoreDiff = 0.008;
iouDiff = 0.02;
}
std::string config_file = "tiny-yolo-voc.cfg";
std::string weights_file = "tiny-yolo-voc.weights";
@ -453,9 +471,17 @@ TEST_P(Test_Darknet_nets, YOLOv3)
1, 2, 0.989633f, 0.450719f, 0.463353f, 0.496305f, 0.522258f, // a car
1, 2, 0.997412f, 0.647584f, 0.459939f, 0.821038f, 0.663947f); // a car
double scoreDiff = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.006 : 8e-5;
double iouDiff = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.018 : 3e-4;
double scoreDiff = 8e-5, iouDiff = 3e-4;
if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD)
{
scoreDiff = 0.006;
iouDiff = 0.018;
}
else if (target == DNN_TARGET_CUDA_FP16)
{
scoreDiff = 0.04;
iouDiff = 0.03;
}
std::string config_file = "yolov3.cfg";
std::string weights_file = "yolov3.weights";
@ -501,6 +527,8 @@ INSTANTIATE_TEST_CASE_P(/**/, Test_Darknet_nets, dnnBackendsAndTargets());
TEST_P(Test_Darknet_layers, shortcut)
{
if (backend == DNN_BACKEND_CUDA)
applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA);
testDarknetLayer("shortcut");
testDarknetLayer("shortcut_leaky");
testDarknetLayer("shortcut_unequal");

@ -16,7 +16,7 @@ using namespace cv;
using namespace cv::dnn;
using namespace testing;
static void test(Mat& input, Net& net, Backend backendId, Target targetId, bool skipCheck = false, bool randInput = true)
static void test(Mat& input, Net& net, Backend backendId, Target targetId, bool skipCheck = false, bool randInput = true, double l1 = 0.0, double lInf = 0.0)
{
DNNTestLayer::checkBackend(backendId, targetId);
if (randInput)
@ -33,8 +33,12 @@ static void test(Mat& input, Net& net, Backend backendId, Target targetId, bool
if (skipCheck)
return;
double l1, lInf;
DNNTestLayer::getDefaultThresholds(backendId, targetId, &l1, &lInf);
double default_l1, default_lInf;
DNNTestLayer::getDefaultThresholds(backendId, targetId, &default_l1, &default_lInf);
if (l1 == 0.0)
l1 = default_l1;
if (lInf == 0.0)
lInf = default_lInf;
#if 0
std::cout << "l1=" << l1 << " lInf=" << lInf << std::endl;
std::cout << outputDefault.reshape(1, outputDefault.total()).t() << std::endl;
@ -43,11 +47,11 @@ static void test(Mat& input, Net& net, Backend backendId, Target targetId, bool
normAssert(outputDefault, outputHalide, "", l1, lInf);
}
static void test(LayerParams& params, Mat& input, Backend backendId, Target targetId, bool skipCheck = false)
static void test(LayerParams& params, Mat& input, Backend backendId, Target targetId, bool skipCheck = false, double l1 = 0.0, double lInf = 0.0)
{
Net net;
net.addLayerToPrev(params.name, params.type, params);
test(input, net, backendId, targetId, skipCheck);
test(input, net, backendId, targetId, skipCheck, true, l1, lInf);
}
static inline testing::internal::ParamGenerator<tuple<Backend, Target> > dnnBackendsAndTargetsWithHalide()
@ -174,6 +178,9 @@ TEST_P(Deconvolution, Accuracy)
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD_X);
#endif
if (targetId == DNN_TARGET_CUDA_FP16)
applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA_FP16);
int sz[] = {inChannels, outChannels / group, kernel.height, kernel.width};
Mat weights(4, &sz[0], CV_32F);
randu(weights, -1.0f, 1.0f);
@ -414,7 +421,11 @@ TEST_P(FullyConnected, Accuracy)
int sz[] = {1, inChannels, inSize.height, inSize.width};
Mat input(4, &sz[0], CV_32F);
test(lp, input, backendId, targetId);
double l1 = 0.0;
if (targetId == DNN_TARGET_CUDA_FP16)
l1 = 0.015;
test(lp, input, backendId, targetId, false, true, l1);
}
INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, FullyConnected, Combine(
@ -497,7 +508,7 @@ TEST_P(Test_Halide_layers, MaxPoolUnpool)
////////////////////////////////////////////////////////////////////////////////
static const int kNumChannels = 3;
void testInPlaceActivation(LayerParams& lp, Backend backendId, Target targetId)
void testInPlaceActivation(LayerParams& lp, Backend backendId, Target targetId, double l1 = 0.0, double lInf = 0.0)
{
EXPECT_FALSE(lp.name.empty());
@ -517,7 +528,7 @@ void testInPlaceActivation(LayerParams& lp, Backend backendId, Target targetId)
int sz[] = {1, kNumChannels, 10, 10};
Mat input(4, &sz[0], CV_32F);
test(input, net, backendId, targetId);
test(input, net, backendId, targetId, false, true, l1, lInf);
}
typedef TestWithParam<tuple<bool, bool, float, tuple<Backend, Target> > > BatchNorm;

@ -141,6 +141,8 @@ TEST_P(Test_Caffe_layers, Convolution)
TEST_P(Test_Caffe_layers, DeConvolution)
{
if(target == DNN_TARGET_CUDA_FP16)
applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA_FP16);
testLayerUsingCaffeModels("layer_deconvolution", true, false);
}
@ -372,7 +374,13 @@ TEST_P(Test_Caffe_layers, Conv_Elu)
net.setPreferableTarget(target);
Mat out = net.forward();
normAssert(ref, out, "", default_l1, default_lInf);
double l1 = default_l1, lInf = default_lInf;
if (target == DNN_TARGET_CUDA_FP16)
{
l1 = 0.0002;
lInf = 0.0005;
}
normAssert(ref, out, "", l1, lInf);
}
class Layer_LSTM_Test : public ::testing::Test
@ -843,6 +851,11 @@ TEST_P(Test_Caffe_layers, PriorBox_repeated)
double l1 = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 1e-3 : 1e-5;
double lInf = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 1e-3 : 1e-4;
if (target == DNN_TARGET_CUDA_FP16)
{
l1 = 7e-5;
lInf = 0.0005;
}
normAssert(out, ref, "", l1, lInf);
}
@ -876,7 +889,9 @@ TEST_P(Test_Caffe_layers, PriorBox_squares)
0.25, 0.0, 1.0, 1.0,
0.1f, 0.1f, 0.2f, 0.2f,
0.1f, 0.1f, 0.2f, 0.2f);
double l1 = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 2e-5 : 1e-5;
double l1 = 1e-5;
if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD || target == DNN_TARGET_CUDA_FP16)
l1 = 2e-5;
normAssert(out.reshape(1, 4), ref, "", l1);
}
@ -1225,6 +1240,11 @@ TEST_P(Test_DLDT_two_inputs, as_backend)
// Output values are in range [0, 637.5].
double l1 = (targetId == DNN_TARGET_OPENCL_FP16 || targetId == DNN_TARGET_MYRIAD) ? 0.06 : 1e-6;
double lInf = (targetId == DNN_TARGET_OPENCL_FP16 || targetId == DNN_TARGET_MYRIAD) ? 0.3 : 1e-5;
if (targetId == DNN_TARGET_CUDA_FP16)
{
l1 = 0.06;
lInf = 0.3;
}
normAssert(out, ref, "", l1, lInf);
}
@ -1537,8 +1557,17 @@ TEST_P(Layer_Test_ShuffleChannel, Accuracy)
net.setPreferableTarget(targetId);
Mat out = net.forward();
double l1 = (targetId == DNN_TARGET_OPENCL_FP16) ? 5e-2 : 1e-5;
double lInf = (targetId == DNN_TARGET_OPENCL_FP16) ? 7e-2 : 1e-4;
double l1 = 1e-5, lInf = 1e-4;
if (targetId == DNN_TARGET_OPENCL_FP16)
{
l1 = 5e-2;
lInf = 7e-2;
}
else if (targetId == DNN_TARGET_CUDA_FP16)
{
l1 = 0.06;
lInf = 0.07;
}
for (int n = 0; n < inpShapeVec[0]; ++n)
{
for (int c = 0; c < inpShapeVec[1]; ++c)
@ -1593,6 +1622,9 @@ TEST_P(Layer_Test_Eltwise_unequal, accuracy_input_0_truncate)
int backendId = get<0>(get<1>(GetParam()));
int targetId = get<1>(get<1>(GetParam()));
if (backendId == DNN_BACKEND_CUDA)
applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA);
Net net;
LayerParams lp;
lp.type = "Eltwise";
@ -1656,6 +1688,9 @@ TEST_P(Layer_Test_Eltwise_unequal, accuracy_input_0)
int backendId = get<0>(get<1>(GetParam()));
int targetId = get<1>(get<1>(GetParam()));
if (backendId == DNN_BACKEND_CUDA)
applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA);
Net net;
LayerParams lp;
lp.type = "Eltwise";

@ -157,9 +157,13 @@ TEST_P(Test_Model, DetectRegion)
bool swapRB = true;
double confThreshold = 0.24;
double scoreDiff = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 1e-2 : 8e-5;
double iouDiff = (target == DNN_TARGET_MYRIAD || target == DNN_TARGET_OPENCL_FP16) ? 1.6e-2 : 1e-5;
double nmsThreshold = (target == DNN_TARGET_MYRIAD) ? 0.397 : 0.4;
double scoreDiff = 8e-5, iouDiff = 1e-5;
if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD || target == DNN_TARGET_CUDA_FP16)
{
scoreDiff = 1e-2;
iouDiff = 1.6e-2;
}
testDetectModel(weights_file, config_file, img_path, refClassIds, refConfidences,
refBoxes, scoreDiff, iouDiff, confThreshold, nmsThreshold, size,
@ -188,11 +192,15 @@ TEST_P(Test_Model, DetectionOutput)
Scalar mean = Scalar(102.9801, 115.9465, 122.7717);
Size size{800, 600};
double scoreDiff = (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16) ?
4e-3 : default_l1;
double iouDiff = (target == DNN_TARGET_OPENCL_FP16) ? 1.8e-1 : 1e-5;
double scoreDiff = default_l1, iouDiff = 1e-5;
float confThreshold = 0.8;
double nmsThreshold = 0.0;
if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_CUDA_FP16)
{
if (backend == DNN_BACKEND_OPENCV)
scoreDiff = 4e-3;
iouDiff = 1.8e-1;
}
testDetectModel(weights_file, config_file, img_path, refClassIds, refConfidences, refBoxes,
scoreDiff, iouDiff, confThreshold, nmsThreshold, size, mean);
@ -232,10 +240,22 @@ TEST_P(Test_Model, DetectionMobilenetSSD)
double scale = 1.0 / 127.5;
Size size{300, 300};
double scoreDiff = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 1.7e-2 : 1e-5;
double iouDiff = (target == DNN_TARGET_OPENCL_FP16 || (target == DNN_TARGET_MYRIAD &&
getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X)) ? 6.91e-2 : 1e-5;
double scoreDiff = 1e-5, iouDiff = 1e-5;
if (target == DNN_TARGET_OPENCL_FP16)
{
scoreDiff = 1.7e-2;
iouDiff = 6.91e-2;
}
else if (target == DNN_TARGET_MYRIAD)
{
scoreDiff = 1.7e-2;
if (getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X)
iouDiff = 6.91e-2;
}
else if (target == DNN_TARGET_CUDA_FP16)
{
scoreDiff = 4e-4;
}
float confThreshold = FLT_MIN;
double nmsThreshold = 0.0;
@ -263,6 +283,10 @@ TEST_P(Test_Model, Keypoints_pose)
Scalar mean = Scalar(128, 128, 128);
bool swapRB = false;
// Ref. Range: [58.6875, 508.625]
if (target == DNN_TARGET_CUDA_FP16)
norm = 20; // l1 = 1.5, lInf = 20
testKeypointsModel(weights, "", inp, exp, norm, size, mean, scale, swapRB);
}
@ -283,8 +307,11 @@ TEST_P(Test_Model, Keypoints_face)
Scalar mean = Scalar();
bool swapRB = false;
testKeypointsModel(weights, "", inp, exp, norm, size, mean, scale, swapRB);
// Ref. Range: [-1.1784188, 1.7758257]
if (target == DNN_TARGET_CUDA_FP16)
norm = 0.004; // l1 = 0.0006, lInf = 0.004
testKeypointsModel(weights, "", inp, exp, norm, size, mean, scale, swapRB);
}
TEST_P(Test_Model, Detection_normalized)
@ -301,10 +328,14 @@ TEST_P(Test_Model, Detection_normalized)
double scale = 1.0 / 127.5;
Size size{300, 300};
double scoreDiff = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 5e-3 : 1e-5;
double iouDiff = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.09 : 1e-5;
double scoreDiff = 1e-5, iouDiff = 1e-5;
float confThreshold = FLT_MIN;
double nmsThreshold = 0.0;
if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD || target == DNN_TARGET_CUDA_FP16)
{
scoreDiff = 5e-3;
iouDiff = 0.09;
}
testDetectModel(weights_file, config_file, img_path, refClassIds, refConfidences, refBoxes,
scoreDiff, iouDiff, confThreshold, nmsThreshold, size, mean, scale);
}

@ -590,8 +590,17 @@ TEST_P(Test_ONNX_nets, TinyYolov2)
#endif
// output range: [-11; 8]
double l1 = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.017 : default_l1;
double lInf = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.14 : default_lInf;
double l1 = default_l1, lInf = default_lInf;
if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD)
{
l1 = 0.017;
lInf = 0.14;
}
else if (target == DNN_TARGET_CUDA_FP16)
{
l1 = 0.018;
lInf = 0.16;
}
testONNXModels("tiny_yolo2", pb, l1, lInf);
}
@ -620,17 +629,23 @@ TEST_P(Test_ONNX_nets, LResNet100E_IR)
if (target == DNN_TARGET_MYRIAD) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
}
double l1 = default_l1;
double lInf = default_lInf;
double l1 = default_l1, lInf = default_lInf;
// output range: [-3; 3]
if (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16) {
if (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16)
{
l1 = 0.009;
lInf = 0.035;
}
else if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target == DNN_TARGET_CPU) {
else if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target == DNN_TARGET_CPU)
{
l1 = 4.6e-5;
lInf = 1.9e-4;
}
else if (target == DNN_TARGET_CUDA_FP16)
{
l1 = 0.008;
lInf = 0.04;
}
testONNXModels("LResNet100E_IR", pb, l1, lInf);
}
@ -747,8 +762,12 @@ TEST_P(Test_ONNX_nets, Resnet34_kinetics)
net.setPreferableTarget(target);
// output range [-5, 11]
float l1 = 0.0013;
float lInf = 0.009;
float l1 = 0.0013, lInf = 0.009;
if (target == DNN_TARGET_CUDA_FP16)
{
l1 = 0.008;
lInf = 0.04;
}
checkBackend(&input0, &ref0);
net.setInput(input0);

@ -225,8 +225,17 @@ TEST_P(Test_TensorFlow_layers, slim_batch_norm)
if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
// Output values range: [-40.0597, 207.827]
double l1 = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.041 : default_l1;
double lInf = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.33 : default_lInf;
double l1 = default_l1, lInf = default_lInf;
if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD)
{
l1 = 0.041;
lInf = 0.33;
}
else if (target == DNN_TARGET_CUDA_FP16)
{
l1 = 0.005;
lInf = 0.33;
}
runTensorFlowNet("slim_batch_norm", false, l1, lInf);
}
@ -300,9 +309,8 @@ TEST_P(Test_TensorFlow_layers, AvePooling3D)
TEST_P(Test_TensorFlow_layers, deconvolution)
{
if(backend == DNN_BACKEND_CUDA)
applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA); /* bugged */
if (backend == DNN_BACKEND_CUDA)
applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA);
runTensorFlowNet("deconvolution");
runTensorFlowNet("deconvolution_same");
runTensorFlowNet("deconvolution_stride_2_same");
@ -428,8 +436,16 @@ TEST_P(Test_TensorFlow_nets, MobileNet_SSD)
net.setInput(inp);
Mat out = net.forward();
double scoreDiff = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.0043 : default_l1;
double iouDiff = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.037 : default_lInf;
double scoreDiff = default_l1, iouDiff = default_lInf;
if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD)
{
scoreDiff = 0.0043;
iouDiff = 0.037;
}
else if (target == DNN_TARGET_CUDA_FP16)
{
iouDiff = 0.04;
}
normAssertDetections(ref, out, "", 0.2, scoreDiff, iouDiff);
#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_RELEASE >= 2019010000
expectNoFallbacksFromIE(net);
@ -466,8 +482,17 @@ TEST_P(Test_TensorFlow_nets, Inception_v2_SSD)
0, 10, 0.95932811, 0.38349164, 0.32528657, 0.40387636, 0.39165527,
0, 10, 0.93973452, 0.66561931, 0.37841269, 0.68074018, 0.42907384);
double scoreDiff = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.0097 : default_l1;
double iouDiff = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.09 : default_lInf;
double scoreDiff = default_l1, iouDiff = default_lInf;
if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD)
{
scoreDiff = 0.0097;
iouDiff = 0.09;
}
else if (target == DNN_TARGET_CUDA_FP16)
{
scoreDiff = 6e-3;
iouDiff = 0.05;
}
normAssertDetections(ref, out, "", 0.5, scoreDiff, iouDiff);
expectNoFallbacksFromIE(net);
}
@ -489,10 +514,18 @@ TEST_P(Test_TensorFlow_nets, MobileNet_v1_SSD)
Mat out = net.forward();
Mat ref = blobFromNPY(findDataFile("dnn/tensorflow/ssd_mobilenet_v1_coco_2017_11_17.detection_out.npy"));
float scoreDiff = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.011 : 1.5e-5;
float iouDiff = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.012 : 1e-3;
float scoreDiff = 1.5e-5, iouDiff = 1e-3;
float detectionConfThresh = (target == DNN_TARGET_MYRIAD) ? 0.35 : 0.3;
if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD)
{
scoreDiff = 0.011;
iouDiff = 0.012;
}
else if (target == DNN_TARGET_CUDA_FP16)
{
scoreDiff = 0.006;
iouDiff = 0.01;
}
#if defined(INF_ENGINE_RELEASE)
if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target == DNN_TARGET_MYRIAD &&
getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X)
@ -530,6 +563,9 @@ TEST_P(Test_TensorFlow_nets, Faster_RCNN)
if (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16)
applyTestTag(CV_TEST_TAG_DNN_SKIP_OPENCL_FP16);
if (backend == DNN_BACKEND_CUDA && target == DNN_TARGET_CUDA_FP16)
applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA_FP16);
checkBackend();
double scoresDiff = backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 ? 2.9e-5 : 1e-5;
@ -574,8 +610,17 @@ TEST_P(Test_TensorFlow_nets, MobileNet_v1_SSD_PPN)
net.setInput(blob);
Mat out = net.forward();
double scoreDiff = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.048 : 1.1e-5;
double iouDiff = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.058 : default_lInf;
double scoreDiff = 1.1e-5, iouDiff = default_lInf;
if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD)
{
scoreDiff = 0.048;
iouDiff = 0.058;
}
else if (target == DNN_TARGET_CUDA_FP16)
{
scoreDiff = 0.006;
iouDiff = 0.05;
}
normAssertDetections(ref, out, "", 0.45, scoreDiff, iouDiff);
expectNoFallbacksFromIE(net);
}
@ -604,8 +649,17 @@ TEST_P(Test_TensorFlow_nets, opencv_face_detector_uint8)
0, 1, 0.98977017, 0.23901358, 0.09084064, 0.29902688, 0.1769477,
0, 1, 0.97203469, 0.67965847, 0.06876482, 0.73999709, 0.1513494,
0, 1, 0.95097077, 0.51901293, 0.45863652, 0.5777427, 0.5347801);
double scoreDiff = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 4e-3 : 3.4e-3;
double iouDiff = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.024 : 1e-2;
double scoreDiff = 3.4e-3, iouDiff = 1e-2;
if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD)
{
scoreDiff = 4e-3;
iouDiff = 0.024;
}
else if (target == DNN_TARGET_CUDA_FP16)
{
scoreDiff = 4e-3;
iouDiff = 0.02;
}
normAssertDetections(ref, out, "", 0.9, scoreDiff, iouDiff);
expectNoFallbacksFromIE(net);
}
@ -673,6 +727,11 @@ TEST_P(Test_TensorFlow_nets, EAST_text_detection)
lInf_scores = 0.41;
l1_geometry = 0.28; lInf_geometry = 5.94;
}
else if (target == DNN_TARGET_CUDA_FP16)
{
lInf_scores = 0.1;
l1_geometry = 0.3; lInf_geometry = 7;
}
else
{
l1_geometry = 1e-4, lInf_geometry = 3e-3;
@ -695,7 +754,8 @@ TEST_P(Test_TensorFlow_layers, fp16_weights)
runTensorFlowNet("fp16_padding_valid", false, l1, lInf);
// Reference output values are in range [0.0889, 1.651]
runTensorFlowNet("fp16_max_pool_even", false, (target == DNN_TARGET_MYRIAD) ? 0.003 : l1, lInf);
if (target == DNN_TARGET_MYRIAD) {
if (target == DNN_TARGET_MYRIAD)
{
l1 = 0.0041;
lInf = 0.024;
}

@ -112,8 +112,17 @@ public:
TEST_P(Test_Torch_layers, run_convolution)
{
// Output reference values are in range [23.4018, 72.0181]
double l1 = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.08 : default_l1;
double lInf = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.42 : default_lInf;
double l1 = default_l1, lInf = default_lInf;
if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD)
{
l1 = 0.08;
lInf = 0.42;
}
else if (target == DNN_TARGET_CUDA_FP16)
{
l1 = 0.08;
lInf = 0.5;
}
runTorchNet("net_conv", "", false, true, true, l1, lInf);
}
@ -121,7 +130,10 @@ TEST_P(Test_Torch_layers, run_pool_max)
{
if (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16)
applyTestTag(CV_TEST_TAG_DNN_SKIP_OPENCL_FP16);
runTorchNet("net_pool_max", "", true);
if (target == DNN_TARGET_CUDA_FP16)
applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA_FP16);
double l1 = 0.0, lInf = 0.0;
runTorchNet("net_pool_max", "", true, false, true, l1, lInf);
}
TEST_P(Test_Torch_layers, run_pool_ave)
@ -145,9 +157,17 @@ TEST_P(Test_Torch_layers, run_reshape)
TEST_P(Test_Torch_layers, run_reshape_single_sample)
{
// Reference output values in range [14.4586, 18.4492].
runTorchNet("net_reshape_single_sample", "", false, false, true,
(target == DNN_TARGET_MYRIAD || target == DNN_TARGET_OPENCL_FP16) ? 0.033 : default_l1,
(target == DNN_TARGET_MYRIAD || target == DNN_TARGET_OPENCL_FP16) ? 0.05 : default_lInf);
double l1 = default_l1, lInf = default_lInf;
if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD)
{
l1 = 0.033;
lInf = 0.05;
}
else if (target == DNN_TARGET_CUDA_FP16)
{
l1 = 0.01;
}
runTorchNet("net_reshape_single_sample", "", false, false, true, l1, lInf);
}
TEST_P(Test_Torch_layers, run_linear)
@ -164,8 +184,16 @@ TEST_P(Test_Torch_layers, run_concat)
TEST_P(Test_Torch_layers, run_depth_concat)
{
runTorchNet("net_depth_concat", "", false, true, true, 0.0,
target == DNN_TARGET_OPENCL_FP16 ? 0.021 : 0.0);
double lInf = 0.0;
if (target == DNN_TARGET_OPENCL_FP16)
{
lInf = 0.021;
}
else if (target == DNN_TARGET_CUDA_FP16)
{
lInf = 0.03;
}
runTorchNet("net_depth_concat", "", false, true, true, 0.0, lInf);
}
TEST_P(Test_Torch_layers, run_deconv)
@ -211,9 +239,18 @@ TEST_P(Test_Torch_layers, net_conv_gemm_lrn)
{
if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target == DNN_TARGET_MYRIAD)
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
runTorchNet("net_conv_gemm_lrn", "", false, true, true,
target == DNN_TARGET_OPENCL_FP16 ? 0.046 : 0.0,
target == DNN_TARGET_OPENCL_FP16 ? 0.023 : 0.0);
double l1 = 0.0, lInf = 0.0;
if (target == DNN_TARGET_OPENCL_FP16)
{
l1 = 0.046;
lInf = 0.023;
}
else if (target == DNN_TARGET_CUDA_FP16)
{
l1 = 0.0042;
lInf = 0.021;
}
runTorchNet("net_conv_gemm_lrn", "", false, true, true, l1, lInf);
}
TEST_P(Test_Torch_layers, net_inception_block)
@ -291,8 +328,17 @@ TEST_P(Test_Torch_nets, OpenFace_accuracy)
// Reference output values are in range [-0.17212, 0.263492]
// on Myriad problem layer: l4_Pooling - does not use pads_begin
float l1 = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 2e-3 : 1e-5;
float lInf = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 5e-3 : 1e-3;
float l1 = 1e-5, lInf = 1e-3;
if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD)
{
l1 = 2e-3;
lInf = 5e-3;
}
else if (target == DNN_TARGET_CUDA_FP16)
{
l1 = 0.0004;
lInf = 0.0012;
}
Mat outRef = readTorchBlob(_tf("net_openface_output.dat"), true);
normAssert(out, outRef, "", l1, lInf);
}
@ -343,6 +389,8 @@ TEST_P(Test_Torch_nets, ENet_accuracy)
checkBackend();
if (backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16)
throw SkipTestException("");
if (backend == DNN_BACKEND_CUDA && target == DNN_TARGET_CUDA_FP16)
applyTestTag(CV_TEST_TAG_DNN_SKIP_CUDA_FP16);
if (backend == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 && target != DNN_TARGET_CPU)
{
if (target == DNN_TARGET_OPENCL_FP16) applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16, CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER);
@ -448,6 +496,10 @@ TEST_P(Test_Torch_nets, FastNeuralStyle_accuracy)
else
EXPECT_LE(normL1, 0.6f);
}
else if(target == DNN_TARGET_CUDA_FP16)
{
normAssert(out, refBlob, "", 0.6, 25);
}
else
normAssert(out, refBlob, "", 0.5, 1.1);
}

Loading…
Cancel
Save