Skip to content

Commit

Permalink
Add perf test for crop
Browse files Browse the repository at this point in the history
  • Loading branch information
MengqingCao authored and hipudding committed Nov 3, 2023
1 parent 7ab8521 commit d9dc1e5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions modules/cannops/include/opencv2/cann_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ CV_EXPORTS_W void resize(InputArray _src, OutputArray _dst, Size dsize, double i
CV_EXPORTS_W void resize(const AscendMat& src, CV_OUT AscendMat& dst, Size dsize, double inv_scale_x,
double inv_scale_y, int interpolation,
AscendStream& stream = AscendStream::Null());

//! @} cannops_core

//! @addtogroup cannimgproc
Expand Down
11 changes: 11 additions & 0 deletions modules/cannops/perf/perf_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,16 @@ PERF_TEST_P(CPU, CROP, TYPICAL_ASCEND_MAT_SIZES)
SANITY_CHECK_NOTHING();
}

PERF_TEST_P(NPU, CROP_OVERLOAD, TYPICAL_ASCEND_MAT_SIZES)
{
Mat mat(GET_PARAM(0), CV_8UC3);
Mat dst;
declare.in(mat, WARMUP_RNG);
Rect b(1, 2, 4, 4);
cv::cann::setDevice(DEVICE_ID);
TEST_CYCLE() { cv::cann::crop(mat, b); }
cv::cann::resetDevice();
SANITY_CHECK_NOTHING();
}
} // namespace
} // namespace opencv_test
2 changes: 2 additions & 0 deletions modules/cannops/test/test_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ TEST(CORE, RESIZE)
// only support {2 INTER_CUBIC} and {3 INTER_AREA}
// only the resize result of INTER_AREA is close to CV's.
int flags = 3;
cv::cann::setDevice(0);
cv::resize(cpuMat, resized_cv, dsize, 0, 0, flags);
cv::cann::resize(cpuMat, checker, dsize, 0, 0, flags);
EXPECT_MAT_NEAR(resized_cv, checker, 1e-4);
Expand All @@ -208,6 +209,7 @@ TEST(CORE, RESIZE)
cv::cann::resize(npuMat, npuChecker, Size(), 0.5, 0.5, flags);
npuChecker.download(checker);
EXPECT_MAT_NEAR(resized_cv, checker, 1e-4);
cv::cann::resetDevice();
}


Expand Down

0 comments on commit d9dc1e5

Please sign in to comment.