mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
Merge pull request #13879 from chacha21:REDUCE_SUM2
add REDUCE_SUM2 #13879 proposal to add REDUCE_SUM2 to cv::reduce, an operation that sums up the square of elements
This commit is contained in:
@@ -1150,7 +1150,7 @@ OCL_PERF_TEST_P(ReduceMinMaxFixture, Reduce,
|
||||
SANITY_CHECK(dst, eps);
|
||||
}
|
||||
|
||||
CV_ENUM(ReduceAccOp, CV_REDUCE_SUM, CV_REDUCE_AVG)
|
||||
CV_ENUM(ReduceAccOp, REDUCE_SUM, REDUCE_AVG, REDUCE_SUM2)
|
||||
|
||||
typedef tuple<Size, std::pair<MatType, MatType>, int, ReduceAccOp> ReduceAccParams;
|
||||
typedef TestBaseWithParam<ReduceAccParams> ReduceAccFixture;
|
||||
@@ -1168,7 +1168,6 @@ OCL_PERF_TEST_P(ReduceAccFixture, Reduce,
|
||||
dim = get<2>(params), op = get<3>(params);
|
||||
const Size srcSize = get<0>(params),
|
||||
dstSize(dim == 0 ? srcSize.width : 1, dim == 0 ? 1 : srcSize.height);
|
||||
const double eps = CV_MAT_DEPTH(dtype) <= CV_32S ? 1 : 3e-4;
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, stype);
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, dtype);
|
||||
@@ -1178,7 +1177,7 @@ OCL_PERF_TEST_P(ReduceAccFixture, Reduce,
|
||||
|
||||
OCL_TEST_CYCLE() cv::reduce(src, dst, dim, op, dtype);
|
||||
|
||||
SANITY_CHECK(dst, eps);
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} } // namespace opencv_test::ocl
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace opencv_test
|
||||
{
|
||||
using namespace perf;
|
||||
|
||||
CV_ENUM(ROp, CV_REDUCE_SUM, CV_REDUCE_AVG, CV_REDUCE_MAX, CV_REDUCE_MIN)
|
||||
CV_ENUM(ROp, REDUCE_SUM, REDUCE_AVG, REDUCE_MAX, REDUCE_MIN, REDUCE_SUM2)
|
||||
typedef tuple<Size, MatType, ROp> Size_MatType_ROp_t;
|
||||
typedef perf::TestBaseWithParam<Size_MatType_ROp_t> Size_MatType_ROp;
|
||||
|
||||
@@ -23,7 +23,7 @@ PERF_TEST_P(Size_MatType_ROp, reduceR,
|
||||
int reduceOp = get<2>(GetParam());
|
||||
|
||||
int ddepth = -1;
|
||||
if( CV_MAT_DEPTH(matType) < CV_32S && (reduceOp == REDUCE_SUM || reduceOp == REDUCE_AVG) )
|
||||
if( CV_MAT_DEPTH(matType) < CV_32S && (reduceOp == REDUCE_SUM || reduceOp == REDUCE_AVG || reduceOp == REDUCE_SUM2) )
|
||||
ddepth = CV_32S;
|
||||
|
||||
Mat src(sz, matType);
|
||||
@@ -35,7 +35,7 @@ PERF_TEST_P(Size_MatType_ROp, reduceR,
|
||||
int runs = 15;
|
||||
TEST_CYCLE_MULTIRUN(runs) reduce(src, vec, 0, reduceOp, ddepth);
|
||||
|
||||
SANITY_CHECK(vec, 1);
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P(Size_MatType_ROp, reduceC,
|
||||
@@ -51,7 +51,7 @@ PERF_TEST_P(Size_MatType_ROp, reduceC,
|
||||
int reduceOp = get<2>(GetParam());
|
||||
|
||||
int ddepth = -1;
|
||||
if( CV_MAT_DEPTH(matType)< CV_32S && (reduceOp == REDUCE_SUM || reduceOp == REDUCE_AVG) )
|
||||
if( CV_MAT_DEPTH(matType)< CV_32S && (reduceOp == REDUCE_SUM || reduceOp == REDUCE_AVG || reduceOp == REDUCE_SUM2) )
|
||||
ddepth = CV_32S;
|
||||
|
||||
Mat src(sz, matType);
|
||||
@@ -62,7 +62,7 @@ PERF_TEST_P(Size_MatType_ROp, reduceC,
|
||||
|
||||
TEST_CYCLE() reduce(src, vec, 1, reduceOp, ddepth);
|
||||
|
||||
SANITY_CHECK(vec, 1);
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
typedef tuple<Size, MatType, int> Size_MatType_RMode_t;
|
||||
|
||||
Reference in New Issue
Block a user