Commit 0a61ebdd authored by Dmitry Kurtaev's avatar Dmitry Kurtaev

Replace DNNTarget and DNNBackend in tests

parent e1c32375
......@@ -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)
{
......
......@@ -42,26 +42,9 @@
#include "test_precomp.hpp"
#include "npy_blob.hpp"
#include <opencv2/dnn/shape_utils.hpp>
#include <opencv2/core/ocl.hpp>
#include <opencv2/ts/ocl_test.hpp>
namespace opencv_test { namespace {
CV_ENUM(DNNTarget, DNN_TARGET_CPU, DNN_TARGET_OPENCL)
static testing::internal::ParamGenerator<DNNTarget> availableBackends()
{
static std::vector<DNNTarget> 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<typename TString>
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<DNNTarget> 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<DNNTarget> 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)
{
......
......@@ -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<DNNTarget> availableDnnTargets()
{
static std::vector<DNNTarget> 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
......@@ -11,8 +11,6 @@ Test for Tensorflow models loading
#include "test_precomp.hpp"
#include "npy_blob.hpp"
#include <opencv2/core/ocl.hpp>
#include <opencv2/ts/ocl_test.hpp>
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<DNNTarget> availableBackends()
{
static std::vector<DNNTarget> 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<DNNTarget> 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)
{
......
......@@ -42,7 +42,6 @@
#include "test_precomp.hpp"
#include "npy_blob.hpp"
#include <opencv2/dnn/shape_utils.hpp>
#include <opencv2/ts/ocl_test.hpp>
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<DNNTarget> availableBackends()
{
static std::vector<DNNTarget> 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<DNNTarget> 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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment