Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-lavrenov committed Mar 1, 2014
1 parent c1c3139 commit 767b28f
Show file tree
Hide file tree
Showing 13 changed files with 364 additions and 296 deletions.
194 changes: 38 additions & 156 deletions modules/ocl/perf/perf_arithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,14 @@ OCL_PERF_TEST_P(LUTFixture, LUT,
// getting params
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
const int type = get<1>(params), cn = CV_MAT_CN(type);

// creating src data
Mat src(srcSize, CV_8UC1), lut(1, 256, type);
Mat src(srcSize, CV_8UC(cn)), lut(1, 256, type);
int dstType = CV_MAKETYPE(lut.depth(), src.channels());
Mat dst(srcSize, dstType);

randu(lut, 0, 2);
declare.in(src, WARMUP_RNG).in(lut).out(dst);
declare.in(src, lut, WARMUP_RNG).out(dst);

// select implementation
if (RUN_OCL_IMPL)
Expand Down Expand Up @@ -564,158 +563,6 @@ OCL_PERF_TEST_P(FlipFixture, Flip,
OCL_PERF_ELSE
}

///////////// MinMax ////////////////////////

typedef Size_MatType MinMaxFixture;

PERF_TEST_P(MinMaxFixture, MinMax,
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
OCL_PERF_ENUM(CV_8UC1, CV_32FC1)))
{
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);

Mat src(srcSize, type);
declare.in(src, WARMUP_RNG);

double min_val = std::numeric_limits<double>::max(),
max_val = std::numeric_limits<double>::min();

if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc(src);

OCL_TEST_CYCLE() cv::ocl::minMax(oclSrc, &min_val, &max_val);

ASSERT_GE(max_val, min_val);
SANITY_CHECK(min_val);
SANITY_CHECK(max_val);
}
else if (RUN_PLAIN_IMPL)
{
Point min_loc, max_loc;

TEST_CYCLE() cv::minMaxLoc(src, &min_val, &max_val, &min_loc, &max_loc);

ASSERT_GE(max_val, min_val);
SANITY_CHECK(min_val);
SANITY_CHECK(max_val);
}
else
OCL_PERF_ELSE
}

///////////// MinMaxLoc ////////////////////////

typedef Size_MatType MinMaxLocFixture;

OCL_PERF_TEST_P(MinMaxLocFixture, MinMaxLoc,
::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_8UC1, CV_32FC1)))
{
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);

Mat src(srcSize, type);
randu(src, 0, 1);
declare.in(src);

double min_val = 0.0, max_val = 0.0;
Point min_loc, max_loc;

if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc(src);

OCL_TEST_CYCLE() cv::ocl::minMaxLoc(oclSrc, &min_val, &max_val, &min_loc, &max_loc);

ASSERT_GE(max_val, min_val);
SANITY_CHECK(min_val);
SANITY_CHECK(max_val);
}
else if (RUN_PLAIN_IMPL)
{
TEST_CYCLE() cv::minMaxLoc(src, &min_val, &max_val, &min_loc, &max_loc);

ASSERT_GE(max_val, min_val);
SANITY_CHECK(min_val);
SANITY_CHECK(max_val);
}
else
OCL_PERF_ELSE
}

///////////// Sum ////////////////////////

typedef Size_MatType SumFixture;

OCL_PERF_TEST_P(SumFixture, Sum,
::testing::Combine(OCL_TEST_SIZES,
OCL_TEST_TYPES))
{
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);

Mat src(srcSize, type);
Scalar result;
randu(src, 0, 60);
declare.in(src);

if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc(src);

OCL_TEST_CYCLE() result = cv::ocl::sum(oclSrc);

SANITY_CHECK(result, 1e-6, ERROR_RELATIVE);
}
else if (RUN_PLAIN_IMPL)
{
TEST_CYCLE() result = cv::sum(src);

SANITY_CHECK(result, 1e-6, ERROR_RELATIVE);
}
else
OCL_PERF_ELSE
}

///////////// countNonZero ////////////////////////

typedef Size_MatType CountNonZeroFixture;

OCL_PERF_TEST_P(CountNonZeroFixture, CountNonZero,
::testing::Combine(OCL_TEST_SIZES,
OCL_PERF_ENUM(CV_8UC1, CV_32FC1)))
{
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);

Mat src(srcSize, type);
int result = 0;
randu(src, 0, 256);
declare.in(src);

if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc(src);

OCL_TEST_CYCLE() result = cv::ocl::countNonZero(oclSrc);

SANITY_CHECK(result);
}
else if (RUN_PLAIN_IMPL)
{
TEST_CYCLE() result = cv::countNonZero(src);

SANITY_CHECK(result);
}
else
OCL_PERF_ELSE
}

///////////// Phase ////////////////////////

typedef Size_MatType PhaseFixture;
Expand Down Expand Up @@ -895,6 +742,41 @@ OCL_PERF_TEST_P(BitwiseNotFixture, Bitwise_not,
OCL_PERF_ELSE
}

///////////// SetIdentity ////////////////////////

typedef Size_MatType SetIdentityFixture;

OCL_PERF_TEST_P(SetIdentityFixture, SetIdentity,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
{
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);

Mat src(srcSize, type);
Scalar s = Scalar::all(17);
declare.in(src, WARMUP_RNG).out(src);

if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc(src);

OCL_TEST_CYCLE() cv::ocl::setIdentity(oclSrc, s);

oclSrc.download(src);

SANITY_CHECK(src);
}
else if (RUN_PLAIN_IMPL)
{
TEST_CYCLE() cv::setIdentity(src, s);

SANITY_CHECK(src);
}
else
OCL_PERF_ELSE
}

///////////// compare////////////////////////

CV_ENUM(CmpCode, CMP_LT, CMP_LE, CMP_EQ, CMP_NE, CMP_GE, CMP_GT)
Expand Down
33 changes: 23 additions & 10 deletions modules/ocl/perf/perf_brute_force_matcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,22 @@
#include "perf_precomp.hpp"

using namespace perf;
using std::tr1::get;

//////////////////// BruteForceMatch /////////////////

typedef TestBaseWithParam<Size> BruteForceMatcherFixture;
typedef Size_MatType BruteForceMatcherFixture;

OCL_PERF_TEST_P(BruteForceMatcherFixture, Match, OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3))
OCL_PERF_TEST_P(BruteForceMatcherFixture, Match,
::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3),
OCL_PERF_ENUM(MatType(CV_32FC1))))
{
const Size srcSize = GetParam();
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);

vector<DMatch> matches;
Mat query(srcSize, CV_32FC1), train(srcSize, CV_32FC1);
Mat query(srcSize, type), train(srcSize, type);
declare.in(query, train);
randu(query, 0.0f, 1.0f);
randu(train, 0.0f, 1.0f);
Expand All @@ -82,12 +87,16 @@ OCL_PERF_TEST_P(BruteForceMatcherFixture, Match, OCL_PERF_ENUM(OCL_SIZE_1, OCL_S
OCL_PERF_ELSE
}

OCL_PERF_TEST_P(BruteForceMatcherFixture, KnnMatch, OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3))
OCL_PERF_TEST_P(BruteForceMatcherFixture, KnnMatch,
::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3),
OCL_PERF_ENUM(MatType(CV_32FC1))))
{
const Size srcSize = GetParam();
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);

vector<vector<DMatch> > matches(2);
Mat query(srcSize, CV_32F), train(srcSize, CV_32F);
Mat query(srcSize, type), train(srcSize, type);
randu(query, 0.0f, 1.0f);
randu(train, 0.0f, 1.0f);

Expand Down Expand Up @@ -121,13 +130,17 @@ OCL_PERF_TEST_P(BruteForceMatcherFixture, KnnMatch, OCL_PERF_ENUM(OCL_SIZE_1, OC
OCL_PERF_ELSE
}

OCL_PERF_TEST_P(BruteForceMatcherFixture, RadiusMatch, OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3))
OCL_PERF_TEST_P(BruteForceMatcherFixture, RadiusMatch,
::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3),
OCL_PERF_ENUM(MatType(CV_32FC1))))
{
const Size srcSize = GetParam();
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);

const float max_distance = 2.0f;
vector<vector<DMatch> > matches(2);
Mat query(srcSize, CV_32FC1), train(srcSize, CV_32FC1);
Mat query(srcSize, type), train(srcSize, type);
declare.in(query, train);

randu(query, 0.0f, 1.0f);
Expand Down
3 changes: 0 additions & 3 deletions modules/ocl/perf/perf_fft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ OCL_PERF_TEST_P(DftFixture, Dft, ::testing::Combine(testing::Values(OCL_SIZE_1,
randu(src, 0.0f, 1.0f);
declare.in(src);

if (srcSize == OCL_SIZE_4000)
declare.time(7.4);

if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc(src), oclDst;
Expand Down
12 changes: 8 additions & 4 deletions modules/ocl/perf/perf_gemm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,28 +47,32 @@

using namespace perf;
using std::tr1::get;
using std::tr1::tuple;

///////////// gemm ////////////////////////

typedef Size_MatType GemmFixture;

#ifdef HAVE_CLAMDBLAS

typedef tuple<Size, int> GemmParams;
typedef TestBaseWithParam<GemmParams> GemmFixture;

OCL_PERF_TEST_P(GemmFixture, Gemm, ::testing::Combine(
::testing::Values(Size(1000, 1000), Size(1500, 1500)),
::testing::Values((int)cv::GEMM_1_T, (int)cv::GEMM_1_T | (int)cv::GEMM_2_T)))
{
const Size_MatType_t params = GetParam();
const GemmParams params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);

Mat src1(srcSize, CV_32FC1), src2(srcSize, CV_32FC1),
src3(srcSize, CV_32FC1), dst(srcSize, CV_32FC1);
declare.in(src1, src2, src3).out(dst).time(srcSize == OCL_SIZE_2000 ? 65 : 8);

randu(src1, -10.0f, 10.0f);
randu(src2, -10.0f, 10.0f);
randu(src3, -10.0f, 10.0f);

declare.in(src1, src2, src3).out(dst);

if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc1(src1), oclSrc2(src2),
Expand Down
2 changes: 1 addition & 1 deletion modules/ocl/perf/perf_hog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ OCL_PERF_TEST(HOGFixture, HOG)
ASSERT_TRUE(!src.empty()) << "can't open input image road.png";

vector<cv::Rect> found_locations;
declare.in(src).time(5);
declare.in(src);

if (RUN_PLAIN_IMPL)
{
Expand Down
Loading

0 comments on commit 767b28f

Please sign in to comment.