Commit fa66c6b7 authored by Alexander Alekhin's avatar Alexander Alekhin

Merge remote-tracking branch 'upstream/3.4' into merge-3.4

parents 2da96be2 82c7ab02
...@@ -1318,7 +1318,7 @@ public: ...@@ -1318,7 +1318,7 @@ public:
/** @brief Returns a zero array of the specified size and type. /** @brief Returns a zero array of the specified size and type.
The method returns a Matlab-style zero array initializer. It can be used to quickly form a constant The method returns a Matlab-style zero array initializer. It can be used to quickly form a constant
array as a function parameter, part of a matrix expression, or as a matrix initializer. : array as a function parameter, part of a matrix expression, or as a matrix initializer:
@code @code
Mat A; Mat A;
A = Mat::zeros(3, 3, CV_32F); A = Mat::zeros(3, 3, CV_32F);
...@@ -1354,6 +1354,8 @@ public: ...@@ -1354,6 +1354,8 @@ public:
The above operation does not form a 100x100 matrix of 1's and then multiply it by 3. Instead, it The above operation does not form a 100x100 matrix of 1's and then multiply it by 3. Instead, it
just remembers the scale factor (3 in this case) and use it when actually invoking the matrix just remembers the scale factor (3 in this case) and use it when actually invoking the matrix
initializer. initializer.
@note In case of multi-channels type, only the first channel will be initialized with 1's, the
others will be set to 0's.
@param rows Number of rows. @param rows Number of rows.
@param cols Number of columns. @param cols Number of columns.
@param type Created matrix type. @param type Created matrix type.
...@@ -1381,6 +1383,8 @@ public: ...@@ -1381,6 +1383,8 @@ public:
// make a 4x4 diagonal matrix with 0.1's on the diagonal. // make a 4x4 diagonal matrix with 0.1's on the diagonal.
Mat A = Mat::eye(4, 4, CV_32F)*0.1; Mat A = Mat::eye(4, 4, CV_32F)*0.1;
@endcode @endcode
@note In case of multi-channels type, identity matrix will be initialized only for the first channel,
the others will be set to 0's
@param rows Number of rows. @param rows Number of rows.
@param cols Number of columns. @param cols Number of columns.
@param type Created matrix type. @param type Created matrix type.
......
...@@ -278,19 +278,19 @@ TEST_P(DNNTestNetwork, FastNeuralStyle_eccv16) ...@@ -278,19 +278,19 @@ TEST_P(DNNTestNetwork, FastNeuralStyle_eccv16)
processNet("dnn/fast_neural_style_eccv16_starry_night.t7", "", inp, "", "", l1, lInf); processNet("dnn/fast_neural_style_eccv16_starry_night.t7", "", inp, "", "", l1, lInf);
} }
const tuple<DNNBackend, DNNTarget> testCases[] = { const tuple<Backend, Target> testCases[] = {
#ifdef HAVE_HALIDE #ifdef HAVE_HALIDE
tuple<DNNBackend, DNNTarget>(DNN_BACKEND_HALIDE, DNN_TARGET_CPU), tuple<Backend, Target>(DNN_BACKEND_HALIDE, DNN_TARGET_CPU),
tuple<DNNBackend, DNNTarget>(DNN_BACKEND_HALIDE, DNN_TARGET_OPENCL), tuple<Backend, Target>(DNN_BACKEND_HALIDE, DNN_TARGET_OPENCL),
#endif #endif
#ifdef HAVE_INF_ENGINE #ifdef HAVE_INF_ENGINE
tuple<DNNBackend, DNNTarget>(DNN_BACKEND_INFERENCE_ENGINE, DNN_TARGET_CPU), tuple<Backend, Target>(DNN_BACKEND_INFERENCE_ENGINE, DNN_TARGET_CPU),
tuple<DNNBackend, DNNTarget>(DNN_BACKEND_INFERENCE_ENGINE, DNN_TARGET_OPENCL), tuple<Backend, Target>(DNN_BACKEND_INFERENCE_ENGINE, DNN_TARGET_OPENCL),
tuple<DNNBackend, DNNTarget>(DNN_BACKEND_INFERENCE_ENGINE, DNN_TARGET_OPENCL_FP16), tuple<Backend, Target>(DNN_BACKEND_INFERENCE_ENGINE, DNN_TARGET_OPENCL_FP16),
tuple<DNNBackend, DNNTarget>(DNN_BACKEND_INFERENCE_ENGINE, DNN_TARGET_MYRIAD), tuple<Backend, Target>(DNN_BACKEND_INFERENCE_ENGINE, DNN_TARGET_MYRIAD),
#endif #endif
tuple<DNNBackend, DNNTarget>(DNN_BACKEND_OPENCV, DNN_TARGET_OPENCL), tuple<Backend, Target>(DNN_BACKEND_OPENCV, DNN_TARGET_OPENCL),
tuple<DNNBackend, DNNTarget>(DNN_BACKEND_OPENCV, DNN_TARGET_OPENCL_FP16) tuple<Backend, Target>(DNN_BACKEND_OPENCV, DNN_TARGET_OPENCL_FP16)
}; };
INSTANTIATE_TEST_CASE_P(/*nothing*/, DNNTestNetwork, testing::ValuesIn(testCases)); INSTANTIATE_TEST_CASE_P(/*nothing*/, DNNTestNetwork, testing::ValuesIn(testCases));
......
...@@ -82,7 +82,7 @@ TEST(Test_Caffe, read_googlenet) ...@@ -82,7 +82,7 @@ TEST(Test_Caffe, read_googlenet)
ASSERT_FALSE(net.empty()); ASSERT_FALSE(net.empty());
} }
typedef testing::TestWithParam<tuple<bool, DNNTarget> > Reproducibility_AlexNet; typedef testing::TestWithParam<tuple<bool, Target> > Reproducibility_AlexNet;
TEST_P(Reproducibility_AlexNet, Accuracy) TEST_P(Reproducibility_AlexNet, Accuracy)
{ {
bool readFromMemory = get<0>(GetParam()); bool readFromMemory = get<0>(GetParam());
...@@ -179,7 +179,7 @@ TEST(Reproducibility_SSD, Accuracy) ...@@ -179,7 +179,7 @@ TEST(Reproducibility_SSD, Accuracy)
normAssertDetections(ref, out); normAssertDetections(ref, out);
} }
typedef testing::TestWithParam<DNNTarget> Reproducibility_MobileNet_SSD; typedef testing::TestWithParam<Target> Reproducibility_MobileNet_SSD;
TEST_P(Reproducibility_MobileNet_SSD, Accuracy) TEST_P(Reproducibility_MobileNet_SSD, Accuracy)
{ {
const string proto = findDataFile("dnn/MobileNetSSD_deploy.prototxt", false); const string proto = findDataFile("dnn/MobileNetSSD_deploy.prototxt", false);
...@@ -234,7 +234,7 @@ TEST_P(Reproducibility_MobileNet_SSD, Accuracy) ...@@ -234,7 +234,7 @@ TEST_P(Reproducibility_MobileNet_SSD, Accuracy)
INSTANTIATE_TEST_CASE_P(/**/, Reproducibility_MobileNet_SSD, INSTANTIATE_TEST_CASE_P(/**/, Reproducibility_MobileNet_SSD,
Values(DNN_TARGET_CPU, DNN_TARGET_OPENCL, DNN_TARGET_OPENCL_FP16)); Values(DNN_TARGET_CPU, DNN_TARGET_OPENCL, DNN_TARGET_OPENCL_FP16));
typedef testing::TestWithParam<DNNTarget> Reproducibility_ResNet50; typedef testing::TestWithParam<Target> Reproducibility_ResNet50;
TEST_P(Reproducibility_ResNet50, Accuracy) TEST_P(Reproducibility_ResNet50, Accuracy)
{ {
Net net = readNetFromCaffe(findDataFile("dnn/ResNet-50-deploy.prototxt", false), Net net = readNetFromCaffe(findDataFile("dnn/ResNet-50-deploy.prototxt", false),
...@@ -270,7 +270,7 @@ TEST_P(Reproducibility_ResNet50, Accuracy) ...@@ -270,7 +270,7 @@ TEST_P(Reproducibility_ResNet50, Accuracy)
INSTANTIATE_TEST_CASE_P(/**/, Reproducibility_ResNet50, INSTANTIATE_TEST_CASE_P(/**/, Reproducibility_ResNet50,
Values(DNN_TARGET_CPU, DNN_TARGET_OPENCL, DNN_TARGET_OPENCL_FP16)); Values(DNN_TARGET_CPU, DNN_TARGET_OPENCL, DNN_TARGET_OPENCL_FP16));
typedef testing::TestWithParam<DNNTarget> Reproducibility_SqueezeNet_v1_1; typedef testing::TestWithParam<Target> Reproducibility_SqueezeNet_v1_1;
TEST_P(Reproducibility_SqueezeNet_v1_1, Accuracy) TEST_P(Reproducibility_SqueezeNet_v1_1, Accuracy)
{ {
Net net = readNetFromCaffe(findDataFile("dnn/squeezenet_v1.1.prototxt", false), Net net = readNetFromCaffe(findDataFile("dnn/squeezenet_v1.1.prototxt", false),
...@@ -413,7 +413,7 @@ TEST(Test_Caffe, multiple_inputs) ...@@ -413,7 +413,7 @@ TEST(Test_Caffe, multiple_inputs)
normAssert(out, first_image + second_image); normAssert(out, first_image + second_image);
} }
typedef testing::TestWithParam<tuple<std::string, DNNTarget> > opencv_face_detector; typedef testing::TestWithParam<tuple<std::string, Target> > opencv_face_detector;
TEST_P(opencv_face_detector, Accuracy) TEST_P(opencv_face_detector, Accuracy)
{ {
std::string proto = findDataFile("dnn/opencv_face_detector.prototxt", false); std::string proto = findDataFile("dnn/opencv_face_detector.prototxt", false);
......
...@@ -52,7 +52,7 @@ static std::string _tf(TString filename) ...@@ -52,7 +52,7 @@ static std::string _tf(TString filename)
return (getOpenCVExtraDir() + "/dnn/") + filename; return (getOpenCVExtraDir() + "/dnn/") + filename;
} }
typedef testing::TestWithParam<DNNTarget> Reproducibility_GoogLeNet; typedef testing::TestWithParam<Target> Reproducibility_GoogLeNet;
TEST_P(Reproducibility_GoogLeNet, Batching) TEST_P(Reproducibility_GoogLeNet, Batching)
{ {
Net net = readNetFromCaffe(findDataFile("dnn/bvlc_googlenet.prototxt", false), Net net = readNetFromCaffe(findDataFile("dnn/bvlc_googlenet.prototxt", false),
......
...@@ -41,21 +41,21 @@ static void test(LayerParams& params, Mat& input, int backendId, int targetId) ...@@ -41,21 +41,21 @@ static void test(LayerParams& params, Mat& input, int backendId, int targetId)
test(input, net, backendId, targetId); test(input, net, backendId, targetId);
} }
static testing::internal::ParamGenerator<tuple<DNNBackend, DNNTarget> > dnnBackendsAndTargetsWithHalide() static testing::internal::ParamGenerator<tuple<Backend, Target> > dnnBackendsAndTargetsWithHalide()
{ {
static const tuple<DNNBackend, DNNTarget> testCases[] = { static const tuple<Backend, Target> testCases[] = {
#ifdef HAVE_HALIDE #ifdef HAVE_HALIDE
tuple<DNNBackend, DNNTarget>(DNN_BACKEND_HALIDE, DNN_TARGET_CPU), tuple<Backend, Target>(DNN_BACKEND_HALIDE, DNN_TARGET_CPU),
tuple<DNNBackend, DNNTarget>(DNN_BACKEND_HALIDE, DNN_TARGET_OPENCL), tuple<Backend, Target>(DNN_BACKEND_HALIDE, DNN_TARGET_OPENCL),
#endif #endif
#ifdef HAVE_INF_ENGINE #ifdef HAVE_INF_ENGINE
tuple<DNNBackend, DNNTarget>(DNN_BACKEND_INFERENCE_ENGINE, DNN_TARGET_CPU), tuple<Backend, Target>(DNN_BACKEND_INFERENCE_ENGINE, DNN_TARGET_CPU),
tuple<DNNBackend, DNNTarget>(DNN_BACKEND_INFERENCE_ENGINE, DNN_TARGET_OPENCL), tuple<Backend, Target>(DNN_BACKEND_INFERENCE_ENGINE, DNN_TARGET_OPENCL),
tuple<DNNBackend, DNNTarget>(DNN_BACKEND_INFERENCE_ENGINE, DNN_TARGET_OPENCL_FP16), tuple<Backend, Target>(DNN_BACKEND_INFERENCE_ENGINE, DNN_TARGET_OPENCL_FP16),
tuple<DNNBackend, DNNTarget>(DNN_BACKEND_INFERENCE_ENGINE, DNN_TARGET_MYRIAD), tuple<Backend, Target>(DNN_BACKEND_INFERENCE_ENGINE, DNN_TARGET_MYRIAD),
#endif #endif
tuple<DNNBackend, DNNTarget>(DNN_BACKEND_OPENCV, DNN_TARGET_OPENCL), tuple<Backend, Target>(DNN_BACKEND_OPENCV, DNN_TARGET_OPENCL),
tuple<DNNBackend, DNNTarget>(DNN_BACKEND_OPENCV, DNN_TARGET_OPENCL_FP16) tuple<Backend, Target>(DNN_BACKEND_OPENCV, DNN_TARGET_OPENCL_FP16)
}; };
return testing::ValuesIn(testCases); return testing::ValuesIn(testCases);
} }
...@@ -89,7 +89,7 @@ TEST_P(Test_Halide_layers, Padding) ...@@ -89,7 +89,7 @@ TEST_P(Test_Halide_layers, Padding)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Convolution // Convolution
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
typedef TestWithParam<tuple<Vec3i, Size, Size, Size, Size, Size, bool, tuple<DNNBackend, DNNTarget> > > Convolution; typedef TestWithParam<tuple<Vec3i, Size, Size, Size, Size, Size, bool, tuple<Backend, Target> > > Convolution;
TEST_P(Convolution, Accuracy) TEST_P(Convolution, Accuracy)
{ {
int inChannels = get<0>(GetParam())[0]; int inChannels = get<0>(GetParam())[0];
...@@ -154,7 +154,7 @@ INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, Convolution, Combine( ...@@ -154,7 +154,7 @@ INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, Convolution, Combine(
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Deconvolution // Deconvolution
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
typedef TestWithParam<tuple<Vec3i, Size, Size, Size, Size, Vec4i, bool, tuple<DNNBackend, DNNTarget> > > Deconvolution; typedef TestWithParam<tuple<Vec3i, Size, Size, Size, Size, Vec4i, bool, tuple<Backend, Target> > > Deconvolution;
TEST_P(Deconvolution, Accuracy) TEST_P(Deconvolution, Accuracy)
{ {
int inChannels = get<0>(GetParam())[0]; int inChannels = get<0>(GetParam())[0];
...@@ -220,7 +220,7 @@ INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, Deconvolution, Combine( ...@@ -220,7 +220,7 @@ INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, Deconvolution, Combine(
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// LRN // LRN
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
typedef TestWithParam<tuple<Vec3i, int, Vec3f, bool, std::string, tuple<DNNBackend, DNNTarget> > > LRN; typedef TestWithParam<tuple<Vec3i, int, Vec3f, bool, std::string, tuple<Backend, Target> > > LRN;
TEST_P(LRN, Accuracy) TEST_P(LRN, Accuracy)
{ {
int inChannels = get<0>(GetParam())[0]; int inChannels = get<0>(GetParam())[0];
...@@ -265,7 +265,7 @@ INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, LRN, Combine( ...@@ -265,7 +265,7 @@ INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, LRN, Combine(
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Average pooling // Average pooling
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
typedef TestWithParam<tuple<int, Size, Size, Size, tuple<DNNBackend, DNNTarget> > > AvePooling; typedef TestWithParam<tuple<int, Size, Size, Size, tuple<Backend, Target> > > AvePooling;
TEST_P(AvePooling, Accuracy) TEST_P(AvePooling, Accuracy)
{ {
int inChannels = get<0>(GetParam()); int inChannels = get<0>(GetParam());
...@@ -305,7 +305,7 @@ INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, AvePooling, Combine( ...@@ -305,7 +305,7 @@ INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, AvePooling, Combine(
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Maximum pooling // Maximum pooling
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
typedef TestWithParam<tuple<int, Size, Size, Size, Size, tuple<DNNBackend, DNNTarget> > > MaxPooling; typedef TestWithParam<tuple<int, Size, Size, Size, Size, tuple<Backend, Target> > > MaxPooling;
TEST_P(MaxPooling, Accuracy) TEST_P(MaxPooling, Accuracy)
{ {
int inChannels = get<0>(GetParam()); int inChannels = get<0>(GetParam());
...@@ -344,7 +344,7 @@ INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, MaxPooling, Combine( ...@@ -344,7 +344,7 @@ INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, MaxPooling, Combine(
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Fully-connected // Fully-connected
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
typedef TestWithParam<tuple<int, Size, int, bool, tuple<DNNBackend, DNNTarget> > > FullyConnected; typedef TestWithParam<tuple<int, Size, int, bool, tuple<Backend, Target> > > FullyConnected;
TEST_P(FullyConnected, Accuracy) TEST_P(FullyConnected, Accuracy)
{ {
int inChannels = get<0>(GetParam()); int inChannels = get<0>(GetParam());
...@@ -387,7 +387,7 @@ INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, FullyConnected, Combine( ...@@ -387,7 +387,7 @@ INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, FullyConnected, Combine(
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// SoftMax // SoftMax
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
typedef TestWithParam<tuple<int, tuple<DNNBackend, DNNTarget> > > SoftMax; typedef TestWithParam<tuple<int, tuple<Backend, Target> > > SoftMax;
TEST_P(SoftMax, Accuracy) TEST_P(SoftMax, Accuracy)
{ {
int inChannels = get<0>(GetParam()); int inChannels = get<0>(GetParam());
...@@ -476,7 +476,7 @@ void testInPlaceActivation(LayerParams& lp, int backendId, int targetId) ...@@ -476,7 +476,7 @@ void testInPlaceActivation(LayerParams& lp, int backendId, int targetId)
test(input, net, backendId, targetId); test(input, net, backendId, targetId);
} }
typedef TestWithParam<tuple<bool, bool, float, tuple<DNNBackend, DNNTarget> > > BatchNorm; typedef TestWithParam<tuple<bool, bool, float, tuple<Backend, Target> > > BatchNorm;
TEST_P(BatchNorm, Accuracy) TEST_P(BatchNorm, Accuracy)
{ {
bool hasWeights = get<0>(GetParam()); bool hasWeights = get<0>(GetParam());
...@@ -511,7 +511,7 @@ INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, BatchNorm, Combine( ...@@ -511,7 +511,7 @@ INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, BatchNorm, Combine(
dnnBackendsAndTargetsWithHalide() dnnBackendsAndTargetsWithHalide()
)); ));
typedef TestWithParam<tuple<float, tuple<DNNBackend, DNNTarget> > > ReLU; typedef TestWithParam<tuple<float, tuple<Backend, Target> > > ReLU;
TEST_P(ReLU, Accuracy) TEST_P(ReLU, Accuracy)
{ {
float negativeSlope = get<0>(GetParam()); float negativeSlope = get<0>(GetParam());
...@@ -530,7 +530,7 @@ INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, ReLU, Combine( ...@@ -530,7 +530,7 @@ INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, ReLU, Combine(
dnnBackendsAndTargetsWithHalide() dnnBackendsAndTargetsWithHalide()
)); ));
typedef TestWithParam<tuple<std::string, tuple<DNNBackend, DNNTarget> > > NoParamActivation; typedef TestWithParam<tuple<std::string, tuple<Backend, Target> > > NoParamActivation;
TEST_P(NoParamActivation, Accuracy) TEST_P(NoParamActivation, Accuracy)
{ {
int backendId = get<0>(get<1>(GetParam())); int backendId = get<0>(get<1>(GetParam()));
...@@ -546,7 +546,7 @@ INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, NoParamActivation, Combine( ...@@ -546,7 +546,7 @@ INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, NoParamActivation, Combine(
dnnBackendsAndTargetsWithHalide() dnnBackendsAndTargetsWithHalide()
)); ));
typedef TestWithParam<tuple<Vec3f, tuple<DNNBackend, DNNTarget> > > Power; typedef TestWithParam<tuple<Vec3f, tuple<Backend, Target> > > Power;
TEST_P(Power, Accuracy) TEST_P(Power, Accuracy)
{ {
float power = get<0>(GetParam())[0]; float power = get<0>(GetParam())[0];
...@@ -582,7 +582,7 @@ TEST_P(Test_Halide_layers, ChannelsPReLU) ...@@ -582,7 +582,7 @@ TEST_P(Test_Halide_layers, ChannelsPReLU)
testInPlaceActivation(lp, backend, target); testInPlaceActivation(lp, backend, target);
} }
typedef TestWithParam<tuple<bool, tuple<DNNBackend, DNNTarget> > > Scale; typedef TestWithParam<tuple<bool, tuple<Backend, Target> > > Scale;
TEST_P(Scale, Accuracy) TEST_P(Scale, Accuracy)
{ {
bool hasBias = get<0>(GetParam()); bool hasBias = get<0>(GetParam());
...@@ -616,7 +616,7 @@ INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, Scale, Combine( ...@@ -616,7 +616,7 @@ INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, Scale, Combine(
// `--- conv ----^ ^ ^ // `--- conv ----^ ^ ^
// `---- ... ------' ' // `---- ... ------' '
// `-----------------' // `-----------------'
typedef TestWithParam<tuple<Vec3i, Vec3i, tuple<DNNBackend, DNNTarget> > > Concat; typedef TestWithParam<tuple<Vec3i, Vec3i, tuple<Backend, Target> > > Concat;
TEST_P(Concat, Accuracy) TEST_P(Concat, Accuracy)
{ {
Vec3i inSize = get<0>(GetParam()); Vec3i inSize = get<0>(GetParam());
...@@ -682,7 +682,7 @@ INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, Concat, Combine( ...@@ -682,7 +682,7 @@ INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, Concat, Combine(
// `--- conv ----^ ^ ^ // `--- conv ----^ ^ ^
// `---- ... ------' ' // `---- ... ------' '
// `-----------------' // `-----------------'
typedef TestWithParam<tuple<Vec3i, std::string, int, bool, tuple<DNNBackend, DNNTarget> > > Eltwise; typedef TestWithParam<tuple<Vec3i, std::string, int, bool, tuple<Backend, Target> > > Eltwise;
TEST_P(Eltwise, Accuracy) TEST_P(Eltwise, Accuracy)
{ {
Vec3i inSize = get<0>(GetParam()); Vec3i inSize = get<0>(GetParam());
......
...@@ -49,15 +49,41 @@ ...@@ -49,15 +49,41 @@
#include "opencv2/dnn.hpp" #include "opencv2/dnn.hpp"
#include "test_common.hpp" #include "test_common.hpp"
namespace opencv_test { namespace { namespace cv {
using namespace cv::dnn; namespace dnn {
CV__DNN_EXPERIMENTAL_NS_BEGIN
static inline void PrintTo(const cv::dnn::Backend& v, std::ostream* os)
{
switch (v) {
case DNN_BACKEND_DEFAULT: *os << "DNN_BACKEND_DEFAULT"; return;
case DNN_BACKEND_HALIDE: *os << "DNN_BACKEND_HALIDE"; return;
case DNN_BACKEND_INFERENCE_ENGINE: *os << "DNN_BACKEND_INFERENCE_ENGINE"; return;
case DNN_BACKEND_OPENCV: *os << "DNN_BACKEND_OPENCV"; return;
} // don't use "default:" to emit compiler warnings
*os << "DNN_BACKEND_UNKNOWN(" << v << ")";
}
static inline void PrintTo(const cv::dnn::Target& v, std::ostream* os)
{
switch (v) {
case DNN_TARGET_CPU: *os << "DNN_TARGET_CPU"; return;
case DNN_TARGET_OPENCL: *os << "DNN_TARGET_OPENCL"; return;
case DNN_TARGET_OPENCL_FP16: *os << "DNN_TARGET_OPENCL_FP16"; return;
case DNN_TARGET_MYRIAD: *os << "DNN_TARGET_MYRIAD"; return;
} // don't use "default:" to emit compiler warnings
*os << "DNN_TARGET_UNKNOWN(" << v << ")";
}
CV_ENUM(DNNBackend, DNN_BACKEND_DEFAULT, DNN_BACKEND_HALIDE, DNN_BACKEND_INFERENCE_ENGINE, DNN_BACKEND_OPENCV) CV__DNN_EXPERIMENTAL_NS_END
CV_ENUM(DNNTarget, DNN_TARGET_CPU, DNN_TARGET_OPENCL, DNN_TARGET_OPENCL_FP16, DNN_TARGET_MYRIAD) }} // namespace
static testing::internal::ParamGenerator<DNNTarget> availableDnnTargets() namespace opencv_test {
using namespace cv::dnn;
static testing::internal::ParamGenerator<Target> availableDnnTargets()
{ {
static std::vector<DNNTarget> targets; static std::vector<Target> targets;
if (targets.empty()) if (targets.empty())
{ {
targets.push_back(DNN_TARGET_CPU); targets.push_back(DNN_TARGET_CPU);
...@@ -69,23 +95,23 @@ static testing::internal::ParamGenerator<DNNTarget> availableDnnTargets() ...@@ -69,23 +95,23 @@ static testing::internal::ParamGenerator<DNNTarget> availableDnnTargets()
return testing::ValuesIn(targets); return testing::ValuesIn(targets);
} }
static testing::internal::ParamGenerator<tuple<DNNBackend, DNNTarget> > dnnBackendsAndTargets() static testing::internal::ParamGenerator<tuple<Backend, Target> > dnnBackendsAndTargets()
{ {
static const tuple<DNNBackend, DNNTarget> testCases[] = { static const tuple<Backend, Target> testCases[] = {
#ifdef HAVE_INF_ENGINE #ifdef HAVE_INF_ENGINE
tuple<DNNBackend, DNNTarget>(DNN_BACKEND_INFERENCE_ENGINE, DNN_TARGET_CPU), tuple<Backend, Target>(DNN_BACKEND_INFERENCE_ENGINE, DNN_TARGET_CPU),
tuple<DNNBackend, DNNTarget>(DNN_BACKEND_INFERENCE_ENGINE, DNN_TARGET_OPENCL), tuple<Backend, Target>(DNN_BACKEND_INFERENCE_ENGINE, DNN_TARGET_OPENCL),
tuple<DNNBackend, DNNTarget>(DNN_BACKEND_INFERENCE_ENGINE, DNN_TARGET_OPENCL_FP16), tuple<Backend, Target>(DNN_BACKEND_INFERENCE_ENGINE, DNN_TARGET_OPENCL_FP16),
tuple<DNNBackend, DNNTarget>(DNN_BACKEND_INFERENCE_ENGINE, DNN_TARGET_MYRIAD), tuple<Backend, Target>(DNN_BACKEND_INFERENCE_ENGINE, DNN_TARGET_MYRIAD),
#endif #endif
tuple<DNNBackend, DNNTarget>(DNN_BACKEND_OPENCV, DNN_TARGET_CPU), tuple<Backend, Target>(DNN_BACKEND_OPENCV, DNN_TARGET_CPU),
tuple<DNNBackend, DNNTarget>(DNN_BACKEND_OPENCV, DNN_TARGET_OPENCL), tuple<Backend, Target>(DNN_BACKEND_OPENCV, DNN_TARGET_OPENCL),
tuple<DNNBackend, DNNTarget>(DNN_BACKEND_OPENCV, DNN_TARGET_OPENCL_FP16) tuple<Backend, Target>(DNN_BACKEND_OPENCV, DNN_TARGET_OPENCL_FP16)
}; };
return testing::ValuesIn(testCases); return testing::ValuesIn(testCases);
} }
class DNNTestLayer : public TestWithParam <tuple<DNNBackend, DNNTarget> > class DNNTestLayer : public TestWithParam<tuple<Backend, Target> >
{ {
public: public:
dnn::Backend backend; dnn::Backend backend;
...@@ -156,6 +182,5 @@ protected: ...@@ -156,6 +182,5 @@ protected:
} }
}; };
}} } // namespace
#endif #endif
...@@ -243,7 +243,7 @@ TEST_P(Test_TensorFlow_layers, l2_normalize_3d) ...@@ -243,7 +243,7 @@ TEST_P(Test_TensorFlow_layers, l2_normalize_3d)
runTensorFlowNet("l2_normalize_3d"); runTensorFlowNet("l2_normalize_3d");
} }
typedef testing::TestWithParam<DNNTarget> Test_TensorFlow_nets; typedef testing::TestWithParam<Target> Test_TensorFlow_nets;
TEST_P(Test_TensorFlow_nets, MobileNet_SSD) TEST_P(Test_TensorFlow_nets, MobileNet_SSD)
{ {
......
...@@ -100,7 +100,7 @@ static void runTorchNet(String prefix, int targetId = DNN_TARGET_CPU, String out ...@@ -100,7 +100,7 @@ static void runTorchNet(String prefix, int targetId = DNN_TARGET_CPU, String out
} }
} }
typedef testing::TestWithParam<DNNTarget> Test_Torch_layers; typedef testing::TestWithParam<Target> Test_Torch_layers;
TEST_P(Test_Torch_layers, run_convolution) TEST_P(Test_Torch_layers, run_convolution)
{ {
...@@ -208,7 +208,7 @@ TEST_P(Test_Torch_layers, net_non_spatial) ...@@ -208,7 +208,7 @@ TEST_P(Test_Torch_layers, net_non_spatial)
INSTANTIATE_TEST_CASE_P(/**/, Test_Torch_layers, availableDnnTargets()); INSTANTIATE_TEST_CASE_P(/**/, Test_Torch_layers, availableDnnTargets());
typedef testing::TestWithParam<DNNTarget> Test_Torch_nets; typedef testing::TestWithParam<Target> Test_Torch_nets;
TEST_P(Test_Torch_nets, OpenFace_accuracy) TEST_P(Test_Torch_nets, OpenFace_accuracy)
{ {
......
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