8000 add REDUCE_SUM2 by chacha21 · Pull Request #13879 · opencv/opencv · GitHub
[go: up one dir, main page]

Skip to content

add REDUCE_SUM2 #13879

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
change implementation of SUM_REDUCE2 with init functor
+prefer cv::REDUCE_* instead of CV_REDUCE throughout the code, so that core_c.h remains untouched and doesn't know about CV_REDUCE_SUM2
+get rid of GET_OPTIMIZED() in reduceR  and reduceC
+add an additional Operator template functor to reduceR and reduceC that is responsible for the very first value (by default just copies the value, and will square it for REDUCE_SUM2)
  • Loading branch information
chacha21 committed Feb 21, 2019
commit fc2e03ef9cb267e1103958b29e0e86b9a72a3a62
1 change: 0 additions & 1 deletion modules/core/include/opencv2/core/core_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -1490,7 +1490,6 @@ CVAPI(void) cvNormalize( const CvArr* src, CvArr* dst,
#define CV_REDUCE_AVG 1
#define CV_REDUCE_MAX 2
#define CV_REDUCE_MIN 3
#define CV_REDUCE_SUM2 4
/** @} */

/** @see @ref core_c_ReduceFlags "flags" */
Expand Down
2 changes: 1 addition & 1 deletion modules/core/perf/opencl/perf_arithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1145,7 +1145,7 @@ OCL_PERF_TEST_P(ReduceMinMaxFixture, Reduce,
SANITY_CHECK(dst, eps);
}

CV_ENUM(ReduceAccOp, CV_REDUCE_SUM, CV_REDUCE_AVG, CV_REDUCE_SUM2)
CV_ENUM(ReduceAccOp, REDUCE_SUM, REDUCE_AVG, REDUCE_SUM2)

typedef tuple<Size, std::pair<MatType, MatType>, int, ReduceAccOp> ReduceAccParams;
typedef TestBaseWithParam<ReduceAccParams> ReduceAccFixture;
Expand Down
6 changes: 3 additions & 3 deletions modules/core/perf/perf_reduce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_REDUCE_SUM2)
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;

Expand All @@ -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 == CV_REDUCE_SUM || reduceOp == CV_REDUCE_AVG || reduceOp == CV_REDUCE_SUM2) )
if( CV_MAT_DEPTH(matType) < CV_32S && (reduceOp == REDUCE_SUM || reduceOp == REDUCE_AVG || reduceOp == REDUCE_SUM2) )
ddepth = CV_32S;

Mat src(sz, matType);
Expand Down Expand Up @@ -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 == CV_REDUCE_SUM || reduceOp == CV_REDUCE_AVG || reduceOp == CV_REDUCE_SUM2) )
if( CV_MAT_DEPTH(matType)< CV_32S && (reduceOp == REDUCE_SUM || reduceOp == REDUCE_AVG || reduceOp == REDUCE_SUM2) )
ddepth = CV_32S;

Mat src(sz, matType);
Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/matmul.dispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ void calcCovarMatrix( InputArray _src, OutputArray _covar, InputOutputArray _mea
else
{
ctype = std::max(CV_MAT_DEPTH(ctype >= 0 ? ctype : type), CV_32F);
reduce( _src, _mean, takeRows ? 0 : 1, CV_REDUCE_AVG, ctype );
reduce( _src, _mean, takeRows ? 0 : 1, REDUCE_AVG, ctype );
mean = _mean.getMat();
}

Expand Down
Loading
0