feat: 切换后端至PaddleOCR-NCNN,切换工程为CMake
1.项目后端整体迁移至PaddleOCR-NCNN算法,已通过基本的兼容性测试 2.工程改为使用CMake组织,后续为了更好地兼容第三方库,不再提供QMake工程 3.重整权利声明文件,重整代码工程,确保最小化侵权风险 Log: 切换后端至PaddleOCR-NCNN,切换工程为CMake Change-Id: I4d5d2c5d37505a4a24b389b1a4c5d12f17bfa38c
This commit is contained in:
1186
3rdparty/opencv-4.5.4/modules/core/perf/opencl/perf_arithm.cpp
vendored
Normal file
1186
3rdparty/opencv-4.5.4/modules/core/perf/opencl/perf_arithm.cpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
132
3rdparty/opencv-4.5.4/modules/core/perf/opencl/perf_bufferpool.cpp
vendored
Normal file
132
3rdparty/opencv-4.5.4/modules/core/perf/opencl/perf_bufferpool.cpp
vendored
Normal file
@ -0,0 +1,132 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
//
|
||||
// Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved.
|
||||
|
||||
#include "../perf_precomp.hpp"
|
||||
#include "opencv2/ts/ocl_perf.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
namespace opencv_test {
|
||||
namespace ocl {
|
||||
|
||||
struct BufferPoolState
|
||||
{
|
||||
BufferPoolController* controller_;
|
||||
size_t oldMaxReservedSize_;
|
||||
|
||||
BufferPoolState(BufferPoolController* c, bool enable)
|
||||
: controller_(c)
|
||||
{
|
||||
if (!cv::ocl::useOpenCL())
|
||||
{
|
||||
throw ::perf::TestBase::PerfSkipTestException();
|
||||
}
|
||||
oldMaxReservedSize_ = c->getMaxReservedSize();
|
||||
if (oldMaxReservedSize_ == (size_t)-1)
|
||||
{
|
||||
throw ::perf::TestBase::PerfSkipTestException();
|
||||
}
|
||||
if (!enable)
|
||||
{
|
||||
c->setMaxReservedSize(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
c->freeAllReservedBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
~BufferPoolState()
|
||||
{
|
||||
controller_->setMaxReservedSize(oldMaxReservedSize_);
|
||||
}
|
||||
};
|
||||
|
||||
typedef TestBaseWithParam<bool> BufferPoolFixture;
|
||||
|
||||
OCL_PERF_TEST_P(BufferPoolFixture, BufferPool_UMatCreation100, Bool())
|
||||
{
|
||||
BufferPoolState s(cv::ocl::getOpenCLAllocator()->getBufferPoolController(), GetParam());
|
||||
|
||||
Size sz(1920, 1080);
|
||||
|
||||
OCL_TEST_CYCLE()
|
||||
{
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
UMat u(sz, CV_8UC1);
|
||||
}
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
OCL_PERF_TEST_P(BufferPoolFixture, BufferPool_UMatCountNonZero100, Bool())
|
||||
{
|
||||
BufferPoolState s(cv::ocl::getOpenCLAllocator()->getBufferPoolController(), GetParam());
|
||||
|
||||
Size sz(1920, 1080);
|
||||
|
||||
OCL_TEST_CYCLE()
|
||||
{
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
UMat u(sz, CV_8UC1);
|
||||
countNonZero(u);
|
||||
}
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
OCL_PERF_TEST_P(BufferPoolFixture, BufferPool_UMatCanny10, Bool())
|
||||
{
|
||||
BufferPoolState s(cv::ocl::getOpenCLAllocator()->getBufferPoolController(), GetParam());
|
||||
|
||||
Size sz(1920, 1080);
|
||||
|
||||
int aperture = 3;
|
||||
bool useL2 = false;
|
||||
double thresh_low = 100;
|
||||
double thresh_high = 120;
|
||||
|
||||
OCL_TEST_CYCLE()
|
||||
{
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
UMat src(sz, CV_8UC1);
|
||||
UMat dst;
|
||||
Canny(src, dst, thresh_low, thresh_high, aperture, useL2);
|
||||
dst.getMat(ACCESS_READ); // complete async operations
|
||||
}
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
OCL_PERF_TEST_P(BufferPoolFixture, BufferPool_UMatIntegral10, Bool())
|
||||
{
|
||||
BufferPoolState s(cv::ocl::getOpenCLAllocator()->getBufferPoolController(), GetParam());
|
||||
|
||||
Size sz(1920, 1080);
|
||||
|
||||
OCL_TEST_CYCLE()
|
||||
{
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
UMat src(sz, CV_32FC1);
|
||||
UMat dst;
|
||||
integral(src, dst);
|
||||
dst.getMat(ACCESS_READ); // complete async operations
|
||||
}
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} } // namespace opencv_test::ocl
|
||||
|
||||
#endif // HAVE_OPENCL
|
206
3rdparty/opencv-4.5.4/modules/core/perf/opencl/perf_channels.cpp
vendored
Normal file
206
3rdparty/opencv-4.5.4/modules/core/perf/opencl/perf_channels.cpp
vendored
Normal file
@ -0,0 +1,206 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
|
||||
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// @Authors
|
||||
// Fangfang Bai, fangfang@multicorewareinc.com
|
||||
// Jin Ma, jin@multicorewareinc.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors as is and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "../perf_precomp.hpp"
|
||||
#include "opencv2/ts/ocl_perf.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
namespace opencv_test {
|
||||
namespace ocl {
|
||||
|
||||
///////////// Merge////////////////////////
|
||||
|
||||
typedef tuple<Size, MatDepth, int> MergeParams;
|
||||
typedef TestBaseWithParam<MergeParams> MergeFixture;
|
||||
|
||||
OCL_PERF_TEST_P(MergeFixture, Merge,
|
||||
::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_8U, CV_32F), Values(2, 3)))
|
||||
{
|
||||
const MergeParams params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int depth = get<1>(params), cn = get<2>(params), dtype = CV_MAKE_TYPE(depth, cn);
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, dtype);
|
||||
|
||||
UMat dst(srcSize, dtype);
|
||||
vector<UMat> src(cn);
|
||||
for (vector<UMat>::iterator i = src.begin(), end = src.end(); i != end; ++i)
|
||||
{
|
||||
i->create(srcSize, CV_MAKE_TYPE(depth, 1));
|
||||
declare.in(*i, WARMUP_RNG);
|
||||
}
|
||||
declare.out(dst);
|
||||
|
||||
OCL_TEST_CYCLE() cv::merge(src, dst);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
|
||||
///////////// Split ////////////////////////
|
||||
|
||||
typedef MergeParams SplitParams;
|
||||
typedef TestBaseWithParam<SplitParams> SplitFixture;
|
||||
|
||||
OCL_PERF_TEST_P(SplitFixture, Split,
|
||||
::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_8U, CV_32F), Values(2, 3)))
|
||||
{
|
||||
const SplitParams params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int depth = get<1>(params), cn = get<2>(params), type = CV_MAKE_TYPE(depth, cn);
|
||||
|
||||
ASSERT_TRUE(cn == 3 || cn == 2);
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
|
||||
UMat src(srcSize, type);
|
||||
std::vector<UMat> dst(cn, UMat(srcSize, CV_MAKE_TYPE(depth, 1)));
|
||||
|
||||
declare.in(src, WARMUP_RNG);
|
||||
for (int i = 0; i < cn; ++i)
|
||||
declare.in(dst[i]);
|
||||
|
||||
OCL_TEST_CYCLE() cv::split(src, dst);
|
||||
|
||||
ASSERT_EQ(cn, (int)dst.size());
|
||||
|
||||
if (cn == 2)
|
||||
{
|
||||
UMat & dst0 = dst[0], & dst1 = dst[1];
|
||||
SANITY_CHECK(dst0);
|
||||
SANITY_CHECK(dst1);
|
||||
}
|
||||
else
|
||||
{
|
||||
UMat & dst0 = dst[0], & dst1 = dst[1], & dst2 = dst[2];
|
||||
SANITY_CHECK(dst0);
|
||||
SANITY_CHECK(dst1);
|
||||
SANITY_CHECK(dst2);
|
||||
}
|
||||
}
|
||||
|
||||
///////////// MixChannels ////////////////////////
|
||||
|
||||
typedef tuple<Size, MatDepth> MixChannelsParams;
|
||||
typedef TestBaseWithParam<MixChannelsParams> MixChannelsFixture;
|
||||
|
||||
OCL_PERF_TEST_P(MixChannelsFixture, MixChannels,
|
||||
::testing::Combine(Values(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3),
|
||||
OCL_PERF_ENUM(CV_8U, CV_32F)))
|
||||
{
|
||||
const MixChannelsParams params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int depth = get<1>(params), type = CV_MAKE_TYPE(depth, 2), n = 2;
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
|
||||
std::vector<UMat> src(n), dst(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
src[i] = UMat(srcSize, type);
|
||||
dst[i] = UMat(srcSize, type);
|
||||
declare.in(src[i], WARMUP_RNG).out(dst[i]);
|
||||
}
|
||||
|
||||
int fromTo[] = { 1,2, 2,0, 0,3, 3,1 };
|
||||
|
||||
OCL_TEST_CYCLE() cv::mixChannels(src, dst, fromTo, 4);
|
||||
|
||||
UMat & dst0 = dst[0], & dst1 = dst[1];
|
||||
SANITY_CHECK(dst0);
|
||||
SANITY_CHECK(dst1);
|
||||
}
|
||||
|
||||
///////////// InsertChannel ////////////////////////
|
||||
|
||||
typedef tuple<cv::Size, MatDepth> Size_MatDepth_t;
|
||||
typedef TestBaseWithParam<Size_MatDepth_t> Size_MatDepth;
|
||||
|
||||
typedef Size_MatDepth InsertChannelFixture;
|
||||
|
||||
OCL_PERF_TEST_P(InsertChannelFixture, InsertChannel,
|
||||
::testing::Combine(Values(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3),
|
||||
OCL_PERF_ENUM(CV_8U, CV_32F)))
|
||||
{
|
||||
const Size_MatDepth_t params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int depth = get<1>(params), type = CV_MAKE_TYPE(depth, 3);
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
|
||||
UMat src(srcSize, depth), dst(srcSize, type, Scalar::all(17));
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
|
||||
OCL_TEST_CYCLE() cv::insertChannel(src, dst, 1);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
|
||||
///////////// ExtractChannel ////////////////////////
|
||||
|
||||
typedef Size_MatDepth ExtractChannelFixture;
|
||||
|
||||
OCL_PERF_TEST_P(ExtractChannelFixture, ExtractChannel,
|
||||
::testing::Combine(Values(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3),
|
||||
OCL_PERF_ENUM(CV_8U, CV_32F)))
|
||||
{
|
||||
const Size_MatDepth_t params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int depth = get<1>(params), type = CV_MAKE_TYPE(depth, 3);
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
|
||||
UMat src(srcSize, type), dst(srcSize, depth);
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
|
||||
OCL_TEST_CYCLE() cv::extractChannel(src, dst, 1);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
|
||||
} } // namespace opencv_test::ocl
|
||||
|
||||
#endif // HAVE_OPENCL
|
118
3rdparty/opencv-4.5.4/modules/core/perf/opencl/perf_dxt.cpp
vendored
Normal file
118
3rdparty/opencv-4.5.4/modules/core/perf/opencl/perf_dxt.cpp
vendored
Normal file
@ -0,0 +1,118 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
|
||||
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// @Authors
|
||||
// Fangfang Bai, fangfang@multicorewareinc.com
|
||||
// Jin Ma, jin@multicorewareinc.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors as is and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "../perf_precomp.hpp"
|
||||
#include "opencv2/ts/ocl_perf.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
namespace opencv_test {
|
||||
namespace ocl {
|
||||
|
||||
///////////// dft ////////////////////////
|
||||
|
||||
enum OCL_FFT_TYPE
|
||||
{
|
||||
R2R = 0,
|
||||
C2R = 1,
|
||||
R2C = 2,
|
||||
C2C = 3
|
||||
};
|
||||
|
||||
typedef tuple<OCL_FFT_TYPE, Size, int> DftParams;
|
||||
typedef TestBaseWithParam<DftParams> DftFixture;
|
||||
|
||||
OCL_PERF_TEST_P(DftFixture, Dft, ::testing::Combine(Values(C2C, R2R, C2R, R2C),
|
||||
Values(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3, Size(512, 512), Size(1024, 1024), Size(2048, 2048)),
|
||||
Values((int) 0, (int)DFT_ROWS, (int)DFT_SCALE, (int)DFT_INVERSE,
|
||||
(int)DFT_INVERSE | DFT_SCALE, (int)DFT_ROWS | DFT_INVERSE)))
|
||||
{
|
||||
const DftParams params = GetParam();
|
||||
const int dft_type = get<0>(params);
|
||||
const Size srcSize = get<1>(params);
|
||||
int flags = get<2>(params);
|
||||
|
||||
int in_cn = 0, out_cn = 0;
|
||||
switch (dft_type)
|
||||
{
|
||||
case R2R: flags |= cv::DFT_REAL_OUTPUT; in_cn = 1; out_cn = 1; break;
|
||||
case C2R: flags |= cv::DFT_REAL_OUTPUT; in_cn = 2; out_cn = 2; break;
|
||||
case R2C: flags |= cv::DFT_COMPLEX_OUTPUT; in_cn = 1; out_cn = 2; break;
|
||||
case C2C: flags |= cv::DFT_COMPLEX_OUTPUT; in_cn = 2; out_cn = 2; break;
|
||||
}
|
||||
|
||||
UMat src(srcSize, CV_MAKE_TYPE(CV_32F, in_cn)), dst(srcSize, CV_MAKE_TYPE(CV_32F, out_cn));
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
|
||||
OCL_TEST_CYCLE() cv::dft(src, dst, flags);
|
||||
|
||||
SANITY_CHECK(dst, 1e-5, ERROR_RELATIVE);
|
||||
}
|
||||
|
||||
///////////// MulSpectrums ////////////////////////
|
||||
|
||||
typedef tuple<Size, bool> MulSpectrumsParams;
|
||||
typedef TestBaseWithParam<MulSpectrumsParams> MulSpectrumsFixture;
|
||||
|
||||
OCL_PERF_TEST_P(MulSpectrumsFixture, MulSpectrums,
|
||||
::testing::Combine(Values(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3),
|
||||
Bool()))
|
||||
{
|
||||
const MulSpectrumsParams params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const bool conj = get<1>(params);
|
||||
|
||||
UMat src1(srcSize, CV_32FC2), src2(srcSize, CV_32FC2), dst(srcSize, CV_32FC2);
|
||||
declare.in(src1, src2, WARMUP_RNG).out(dst);
|
||||
|
||||
OCL_TEST_CYCLE() cv::mulSpectrums(src1, src2, dst, 0, conj);
|
||||
|
||||
SANITY_CHECK(dst, 1e-3);
|
||||
}
|
||||
|
||||
} } // namespace opencv_test::ocl
|
||||
|
||||
#endif // HAVE_OPENCL
|
84
3rdparty/opencv-4.5.4/modules/core/perf/opencl/perf_gemm.cpp
vendored
Normal file
84
3rdparty/opencv-4.5.4/modules/core/perf/opencl/perf_gemm.cpp
vendored
Normal file
@ -0,0 +1,84 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
|
||||
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// @Authors
|
||||
// Fangfang Bai, fangfang@multicorewareinc.com
|
||||
// Jin Ma, jin@multicorewareinc.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors as is and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "../perf_precomp.hpp"
|
||||
#include "opencv2/ts/ocl_perf.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
namespace opencv_test {
|
||||
namespace ocl {
|
||||
|
||||
///////////// gemm ////////////////////////
|
||||
|
||||
CV_ENUM(FlagType, 0, GEMM_1_T, GEMM_2_T, GEMM_3_T, GEMM_1_T|GEMM_2_T, GEMM_2_T|GEMM_3_T)
|
||||
|
||||
typedef tuple<Size, FlagType, MatType> GemmParams;
|
||||
typedef TestBaseWithParam<GemmParams> GemmFixture;
|
||||
|
||||
OCL_PERF_TEST_P(GemmFixture, Gemm, ::testing::Combine(
|
||||
::testing::Values(Size(640, 640), Size(1280, 1280)),
|
||||
FlagType::all(), testing::Values(CV_32FC1, CV_32FC2)))
|
||||
{
|
||||
GemmParams params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int flags = get<1>(params);
|
||||
const int type = get<2>(params);
|
||||
|
||||
UMat src1(srcSize, type), src2(srcSize, type), src3(srcSize, type), dst(srcSize, type);
|
||||
declare.in(src1, src2, src3).out(dst);
|
||||
randu(src1, -10.0f, 10.0f);
|
||||
randu(src2, -10.0f, 10.0f);
|
||||
randu(src3, -10.0f, 10.0f);
|
||||
|
||||
OCL_TEST_CYCLE() cv::gemm(src1, src2, 0.6, src3, 1.5, dst, flags);
|
||||
|
||||
SANITY_CHECK(dst, 0.01);
|
||||
}
|
||||
|
||||
} } // namespace opencv_test::ocl
|
||||
|
||||
#endif // HAVE_OPENCL
|
286
3rdparty/opencv-4.5.4/modules/core/perf/opencl/perf_matop.cpp
vendored
Normal file
286
3rdparty/opencv-4.5.4/modules/core/perf/opencl/perf_matop.cpp
vendored
Normal file
@ -0,0 +1,286 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
|
||||
// Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
|
||||
#include "../perf_precomp.hpp"
|
||||
#include "opencv2/ts/ocl_perf.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
namespace opencv_test {
|
||||
namespace ocl {
|
||||
|
||||
///////////// SetTo ////////////////////////
|
||||
|
||||
typedef Size_MatType SetToFixture;
|
||||
|
||||
OCL_PERF_TEST_P(SetToFixture, SetTo,
|
||||
::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);
|
||||
const Scalar s = Scalar::all(17);
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
|
||||
UMat src(srcSize, type);
|
||||
declare.in(src, WARMUP_RNG).out(src);
|
||||
|
||||
OCL_TEST_CYCLE() src.setTo(s);
|
||||
|
||||
SANITY_CHECK(src);
|
||||
}
|
||||
|
||||
///////////// SetTo with mask ////////////////////////
|
||||
|
||||
typedef Size_MatType SetToFixture;
|
||||
|
||||
OCL_PERF_TEST_P(SetToFixture, SetToWithMask,
|
||||
::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);
|
||||
const Scalar s = Scalar::all(17);
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
|
||||
UMat src(srcSize, type), mask(srcSize, CV_8UC1);
|
||||
declare.in(src, mask, WARMUP_RNG).out(src);
|
||||
|
||||
OCL_TEST_CYCLE() src.setTo(s, mask);
|
||||
|
||||
SANITY_CHECK(src);
|
||||
}
|
||||
|
||||
///////////// ConvertTo ////////////////////////
|
||||
|
||||
typedef Size_MatType ConvertToFixture;
|
||||
|
||||
OCL_PERF_TEST_P(ConvertToFixture, ConvertTo,
|
||||
::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), ddepth = CV_MAT_DEPTH(type) == CV_8U ? CV_32F : CV_8U,
|
||||
cn = CV_MAT_CN(type), dtype = CV_MAKE_TYPE(ddepth, cn);
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, dtype);
|
||||
|
||||
UMat src(srcSize, type), dst(srcSize, dtype);
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
|
||||
OCL_TEST_CYCLE() src.convertTo(dst, dtype);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
|
||||
///////////// CopyTo ////////////////////////
|
||||
|
||||
typedef Size_MatType CopyToFixture;
|
||||
|
||||
OCL_PERF_TEST_P(CopyToFixture, CopyTo,
|
||||
::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);
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
|
||||
UMat src(srcSize, type), dst(srcSize, type);
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
|
||||
OCL_TEST_CYCLE() src.copyTo(dst);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
|
||||
///////////// CopyTo with mask ////////////////////////
|
||||
|
||||
typedef Size_MatType CopyToFixture;
|
||||
|
||||
OCL_PERF_TEST_P(CopyToFixture, CopyToWithMask,
|
||||
::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);
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
|
||||
UMat src(srcSize, type), dst(srcSize, type), mask(srcSize, CV_8UC1);
|
||||
declare.in(src, mask, WARMUP_RNG).out(dst);
|
||||
|
||||
OCL_TEST_CYCLE() src.copyTo(dst, mask);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
|
||||
OCL_PERF_TEST_P(CopyToFixture, CopyToWithMaskUninit,
|
||||
::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3), OCL_TEST_TYPES))
|
||||
{
|
||||
const Size_MatType_t params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int type = get<1>(params);
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
|
||||
UMat src(srcSize, type), dst, mask(srcSize, CV_8UC1);
|
||||
declare.in(src, mask, WARMUP_RNG);
|
||||
|
||||
for ( ; next(); )
|
||||
{
|
||||
dst.release();
|
||||
startTimer();
|
||||
src.copyTo(dst, mask);
|
||||
cvtest::ocl::perf::safeFinish();
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
|
||||
|
||||
|
||||
enum ROIType {
|
||||
ROI_FULL,
|
||||
ROI_2_RECT,
|
||||
ROI_2_TOP, // contiguous memory block
|
||||
ROI_2_LEFT,
|
||||
ROI_4,
|
||||
ROI_16,
|
||||
};
|
||||
static Rect getROI(enum ROIType t, const Size& sz)
|
||||
{
|
||||
switch (t)
|
||||
{
|
||||
case ROI_FULL: return Rect(0, 0, sz.width, sz.height);
|
||||
case ROI_2_RECT: return Rect(0, 0, sz.width * 71 / 100, sz.height * 71 / 100); // 71 = sqrt(1/2) * 100
|
||||
case ROI_2_TOP: return Rect(0, 0, sz.width, sz.height / 2); // 71 = sqrt(1/2) * 100
|
||||
case ROI_2_LEFT: return Rect(0, 0, sz.width / 2, sz.height); // 71 = sqrt(1/2) * 100
|
||||
case ROI_4: return Rect(0, 0, sz.width / 2, sz.height / 2);
|
||||
case ROI_16: return Rect(0, 0, sz.width / 4, sz.height / 4);
|
||||
}
|
||||
CV_Assert(false);
|
||||
}
|
||||
|
||||
typedef TestBaseWithParam< tuple<cv::Size, MatType, ROIType> > OpenCLBuffer;
|
||||
|
||||
static inline void PrintTo(const tuple<cv::Size, MatType, enum ROIType>& v, std::ostream* os)
|
||||
{
|
||||
*os << "(" << get<0>(v) << ", " << typeToString(get<1>(v)) << ", ";
|
||||
enum ROIType roiType = get<2>(v);
|
||||
if (roiType == ROI_FULL)
|
||||
*os << "ROI_100_FULL";
|
||||
else if (roiType == ROI_2_RECT)
|
||||
*os << "ROI_050_RECT_HALF";
|
||||
else if (roiType == ROI_2_TOP)
|
||||
*os << "ROI_050_TOP_HALF";
|
||||
else if (roiType == ROI_2_LEFT)
|
||||
*os << "ROI_050_LEFT_HALF";
|
||||
else if (roiType == ROI_4)
|
||||
*os << "ROI_025_1/4";
|
||||
else
|
||||
*os << "ROI_012_1/16";
|
||||
*os << ")";
|
||||
}
|
||||
|
||||
PERF_TEST_P_(OpenCLBuffer, cpu_write)
|
||||
{
|
||||
const Size srcSize = get<0>(GetParam());
|
||||
const int type = get<1>(GetParam());
|
||||
const Rect roi = getROI(get<2>(GetParam()), srcSize);
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
|
||||
UMat src(srcSize, type);
|
||||
declare.in(src(roi), WARMUP_NONE);
|
||||
|
||||
OCL_TEST_CYCLE()
|
||||
{
|
||||
Mat m = src(roi).getMat(ACCESS_WRITE);
|
||||
m.setTo(Scalar(1, 2, 3, 4));
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(OpenCLBuffer, cpu_read)
|
||||
{
|
||||
const Size srcSize = get<0>(GetParam());
|
||||
const int type = get<1>(GetParam());
|
||||
const Rect roi = getROI(get<2>(GetParam()), srcSize);
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
|
||||
UMat src(srcSize, type, Scalar(1, 2, 3, 4));
|
||||
declare.in(src(roi), WARMUP_NONE);
|
||||
|
||||
OCL_TEST_CYCLE()
|
||||
{
|
||||
unsigned counter = 0;
|
||||
Mat m = src(roi).getMat(ACCESS_READ);
|
||||
for (int y = 0; y < m.rows; y++)
|
||||
{
|
||||
uchar* ptr = m.ptr(y);
|
||||
size_t width_bytes = m.cols * m.elemSize();
|
||||
for (size_t x_bytes = 0; x_bytes < width_bytes; x_bytes++)
|
||||
counter += (unsigned)(ptr[x_bytes]);
|
||||
}
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(OpenCLBuffer, cpu_update)
|
||||
{
|
||||
const Size srcSize = get<0>(GetParam());
|
||||
const int type = get<1>(GetParam());
|
||||
const Rect roi = getROI(get<2>(GetParam()), srcSize);
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
|
||||
UMat src(srcSize, type, Scalar(1, 2, 3, 4));
|
||||
declare.in(src(roi), WARMUP_NONE);
|
||||
|
||||
OCL_TEST_CYCLE()
|
||||
{
|
||||
Mat m = src(roi).getMat(ACCESS_READ | ACCESS_WRITE);
|
||||
for (int y = 0; y < m.rows; y++)
|
||||
{
|
||||
uchar* ptr = m.ptr(y);
|
||||
size_t width_bytes = m.cols * m.elemSize();
|
||||
for (size_t x_bytes = 0; x_bytes < width_bytes; x_bytes++)
|
||||
ptr[x_bytes] += 1;
|
||||
}
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(/*FULL*/, OpenCLBuffer,
|
||||
testing::Combine(
|
||||
testing::Values(szVGA, sz720p, sz1080p, sz2160p),
|
||||
testing::Values(CV_8UC1, CV_8UC2, CV_8UC3, CV_8UC4),
|
||||
testing::Values(ROI_FULL)
|
||||
)
|
||||
);
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(ROI, OpenCLBuffer,
|
||||
testing::Combine(
|
||||
testing::Values(sz1080p, sz2160p),
|
||||
testing::Values(CV_8UC1),
|
||||
testing::Values(ROI_16, ROI_4, ROI_2_RECT, ROI_2_LEFT, ROI_2_TOP, ROI_FULL)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
} } // namespace opencv_test::ocl
|
||||
|
||||
#endif // HAVE_OPENCL
|
50
3rdparty/opencv-4.5.4/modules/core/perf/opencl/perf_usage_flags.cpp
vendored
Normal file
50
3rdparty/opencv-4.5.4/modules/core/perf/opencl/perf_usage_flags.cpp
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
//
|
||||
// Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved.
|
||||
|
||||
#include "../perf_precomp.hpp"
|
||||
#include "opencv2/ts/ocl_perf.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
namespace opencv_test {
|
||||
namespace ocl {
|
||||
|
||||
typedef TestBaseWithParam<tuple<cv::Size, UMatUsageFlags, UMatUsageFlags, UMatUsageFlags>> SizeUsageFlagsFixture;
|
||||
|
||||
OCL_PERF_TEST_P(SizeUsageFlagsFixture, UsageFlags_AllocMem,
|
||||
::testing::Combine(
|
||||
OCL_TEST_SIZES,
|
||||
testing::Values(USAGE_DEFAULT, USAGE_ALLOCATE_HOST_MEMORY, USAGE_ALLOCATE_DEVICE_MEMORY), // USAGE_ALLOCATE_SHARED_MEMORY
|
||||
testing::Values(USAGE_DEFAULT, USAGE_ALLOCATE_HOST_MEMORY, USAGE_ALLOCATE_DEVICE_MEMORY), // USAGE_ALLOCATE_SHARED_MEMORY
|
||||
testing::Values(USAGE_DEFAULT, USAGE_ALLOCATE_HOST_MEMORY, USAGE_ALLOCATE_DEVICE_MEMORY) // USAGE_ALLOCATE_SHARED_MEMORY
|
||||
))
|
||||
{
|
||||
Size sz = get<0>(GetParam());
|
||||
UMatUsageFlags srcAllocMem = get<1>(GetParam());
|
||||
UMatUsageFlags dstAllocMem = get<2>(GetParam());
|
||||
UMatUsageFlags finalAllocMem = get<3>(GetParam());
|
||||
|
||||
UMat src(sz, CV_8UC1, Scalar::all(128), srcAllocMem);
|
||||
|
||||
OCL_TEST_CYCLE()
|
||||
{
|
||||
UMat dst(dstAllocMem);
|
||||
|
||||
cv::add(src, Scalar::all(1), dst);
|
||||
{
|
||||
Mat canvas = dst.getMat(ACCESS_RW);
|
||||
cv::putText(canvas, "Test", Point(20, 20), FONT_HERSHEY_PLAIN, 1, Scalar::all(255));
|
||||
}
|
||||
UMat final(finalAllocMem);
|
||||
cv::subtract(dst, Scalar::all(1), final);
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} } // namespace opencv_test::ocl
|
||||
|
||||
#endif // HAVE_OPENCL
|
Reference in New Issue
Block a user