From: Dmitry Kurtaev Date: Wed, 7 Mar 2018 09:59:38 +0000 (+0300) Subject: Replace DNNTarget and DNNBackend in tests X-Git-Tag: accepted/tizen/6.0/unified/20201030.111113~1^2~746^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0a61ebdd66aba1ecb586c596fae20685e56b7525;p=platform%2Fupstream%2Fopencv.git Replace DNNTarget and DNNBackend in tests --- diff --git a/modules/dnn/test/test_backends.cpp b/modules/dnn/test/test_backends.cpp index 2f6c780..b6d5240 100644 --- a/modules/dnn/test/test_backends.cpp +++ b/modules/dnn/test/test_backends.cpp @@ -10,9 +10,6 @@ namespace opencv_test { namespace { -CV_ENUM(DNNBackend, DNN_BACKEND_DEFAULT, DNN_BACKEND_HALIDE, DNN_BACKEND_INFERENCE_ENGINE) -CV_ENUM(DNNTarget, DNN_TARGET_CPU, DNN_TARGET_OPENCL) - static void loadNet(const std::string& weights, const std::string& proto, const std::string& framework, Net* net) { diff --git a/modules/dnn/test/test_caffe_importer.cpp b/modules/dnn/test/test_caffe_importer.cpp index aebd007..42a5f4f 100644 --- a/modules/dnn/test/test_caffe_importer.cpp +++ b/modules/dnn/test/test_caffe_importer.cpp @@ -42,26 +42,9 @@ #include "test_precomp.hpp" #include "npy_blob.hpp" #include -#include -#include namespace opencv_test { namespace { -CV_ENUM(DNNTarget, DNN_TARGET_CPU, DNN_TARGET_OPENCL) -static testing::internal::ParamGenerator availableBackends() -{ - static std::vector targets; - if (targets.empty()) - { - targets.push_back(DNN_TARGET_CPU); -#ifdef HAVE_OPENCL - if (cv::ocl::useOpenCL()) - targets.push_back(DNN_TARGET_OPENCL); -#endif - } - return testing::ValuesIn(targets); -} - template static std::string _tf(TString filename) { @@ -132,7 +115,7 @@ TEST_P(Reproducibility_AlexNet, Accuracy) normAssert(ref, out); } -INSTANTIATE_TEST_CASE_P(/**/, Reproducibility_AlexNet, Combine(testing::Bool(), availableBackends())); +INSTANTIATE_TEST_CASE_P(/**/, Reproducibility_AlexNet, Combine(testing::Bool(), availableDnnTargets())); #if !defined(_WIN32) || defined(_WIN64) TEST(Reproducibility_FCN, Accuracy) @@ -232,7 +215,7 @@ TEST_P(Reproducibility_MobileNet_SSD, Accuracy) normAssert(outBatch.rowRange(0, numDetections), ref); normAssert(outBatch.rowRange(numDetections, 2 * numDetections).colRange(1, 7), ref.colRange(1, 7)); } -INSTANTIATE_TEST_CASE_P(/**/, Reproducibility_MobileNet_SSD, availableBackends()); +INSTANTIATE_TEST_CASE_P(/**/, Reproducibility_MobileNet_SSD, availableDnnTargets()); typedef testing::TestWithParam Reproducibility_ResNet50; TEST_P(Reproducibility_ResNet50, Accuracy) @@ -263,7 +246,7 @@ TEST_P(Reproducibility_ResNet50, Accuracy) normAssert(ref, out_umats[0], "out_umat_vector"); } } -INSTANTIATE_TEST_CASE_P(/**/, Reproducibility_ResNet50, availableBackends()); +INSTANTIATE_TEST_CASE_P(/**/, Reproducibility_ResNet50, availableDnnTargets()); typedef testing::TestWithParam Reproducibility_SqueezeNet_v1_1; TEST_P(Reproducibility_SqueezeNet_v1_1, Accuracy) @@ -291,7 +274,7 @@ TEST_P(Reproducibility_SqueezeNet_v1_1, Accuracy) Mat ref = blobFromNPY(_tf("squeezenet_v1.1_prob.npy")); normAssert(ref, out); } -INSTANTIATE_TEST_CASE_P(/**/, Reproducibility_SqueezeNet_v1_1, availableBackends()); +INSTANTIATE_TEST_CASE_P(/**/, Reproducibility_SqueezeNet_v1_1, availableDnnTargets()); TEST(Reproducibility_AlexNet_fp16, Accuracy) { diff --git a/modules/dnn/test/test_precomp.hpp b/modules/dnn/test/test_precomp.hpp index f71befc..b4bb97d 100644 --- a/modules/dnn/test/test_precomp.hpp +++ b/modules/dnn/test/test_precomp.hpp @@ -44,12 +44,31 @@ #include "opencv2/ts.hpp" #include "opencv2/ts/ts_perf.hpp" #include "opencv2/core/utility.hpp" +#include "opencv2/core/ocl.hpp" #include "opencv2/dnn.hpp" #include "test_common.hpp" namespace opencv_test { using namespace cv::dnn; + +CV_ENUM(DNNBackend, DNN_BACKEND_DEFAULT, DNN_BACKEND_HALIDE, DNN_BACKEND_INFERENCE_ENGINE) +CV_ENUM(DNNTarget, DNN_TARGET_CPU, DNN_TARGET_OPENCL) + +static testing::internal::ParamGenerator availableDnnTargets() +{ + static std::vector targets; + if (targets.empty()) + { + targets.push_back(DNN_TARGET_CPU); +#ifdef HAVE_OPENCL + if (cv::ocl::useOpenCL()) + targets.push_back(DNN_TARGET_OPENCL); +#endif + } + return testing::ValuesIn(targets); +} + } #endif diff --git a/modules/dnn/test/test_tf_importer.cpp b/modules/dnn/test/test_tf_importer.cpp index cf11dbc..b3b9959 100644 --- a/modules/dnn/test/test_tf_importer.cpp +++ b/modules/dnn/test/test_tf_importer.cpp @@ -11,8 +11,6 @@ Test for Tensorflow models loading #include "test_precomp.hpp" #include "npy_blob.hpp" -#include -#include namespace opencv_test { @@ -26,21 +24,6 @@ static std::string _tf(TString filename) return (getOpenCVExtraDir() + "/dnn/") + filename; } -CV_ENUM(DNNTarget, DNN_TARGET_CPU, DNN_TARGET_OPENCL) -static testing::internal::ParamGenerator availableBackends() -{ - static std::vector targets; - if (targets.empty()) - { - targets.push_back(DNN_TARGET_CPU); -#ifdef HAVE_OPENCL - if (cv::ocl::useOpenCL()) - targets.push_back(DNN_TARGET_OPENCL); -#endif - } - return testing::ValuesIn(targets); -} - TEST(Test_TensorFlow, read_inception) { Net net; @@ -204,7 +187,7 @@ TEST_P(Test_TensorFlow_layers, reshape) runTensorFlowNet("flatten", targetId, true); } -INSTANTIATE_TEST_CASE_P(/**/, Test_TensorFlow_layers, availableBackends()); +INSTANTIATE_TEST_CASE_P(/**/, Test_TensorFlow_layers, availableDnnTargets()); typedef testing::TestWithParam Test_TensorFlow_nets; @@ -302,7 +285,7 @@ TEST_P(Test_TensorFlow_nets, opencv_face_detector_uint8) normAssert(out.reshape(1, out.total() / 7).rowRange(0, 6).colRange(2, 7), ref, "", 2.8e-4, 3.4e-3); } -INSTANTIATE_TEST_CASE_P(/**/, Test_TensorFlow_nets, availableBackends()); +INSTANTIATE_TEST_CASE_P(/**/, Test_TensorFlow_nets, availableDnnTargets()); TEST(Test_TensorFlow, defun) { diff --git a/modules/dnn/test/test_torch_importer.cpp b/modules/dnn/test/test_torch_importer.cpp index c62949b..621d3ef 100644 --- a/modules/dnn/test/test_torch_importer.cpp +++ b/modules/dnn/test/test_torch_importer.cpp @@ -42,7 +42,6 @@ #include "test_precomp.hpp" #include "npy_blob.hpp" #include -#include namespace opencv_test { @@ -62,21 +61,6 @@ static std::string _tf(TStr filename, bool inTorchDir = true) return findDataFile(path, false); } -CV_ENUM(DNNTarget, DNN_TARGET_CPU, DNN_TARGET_OPENCL) -static testing::internal::ParamGenerator availableBackends() -{ - static std::vector targets; - if (targets.empty()) - { - targets.push_back(DNN_TARGET_CPU); -#ifdef HAVE_OPENCL - if (cv::ocl::useOpenCL()) - targets.push_back(DNN_TARGET_OPENCL); -#endif - } - return testing::ValuesIn(targets); -} - TEST(Torch_Importer, simple_read) { Net net; @@ -221,7 +205,7 @@ TEST_P(Test_Torch_layers, net_non_spatial) runTorchNet("net_non_spatial", GetParam(), "", false, true); } -INSTANTIATE_TEST_CASE_P(/**/, Test_Torch_layers, availableBackends()); +INSTANTIATE_TEST_CASE_P(/**/, Test_Torch_layers, availableDnnTargets()); typedef testing::TestWithParam Test_Torch_nets; @@ -323,7 +307,7 @@ TEST_P(Test_Torch_nets, FastNeuralStyle_accuracy) } } -INSTANTIATE_TEST_CASE_P(/**/, Test_Torch_nets, availableBackends()); +INSTANTIATE_TEST_CASE_P(/**/, Test_Torch_nets, availableDnnTargets()); // TODO: fix OpenCL and add to the rest of tests TEST(Torch_Importer, run_paralel)