mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 00:03:03 +04:00
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
This commit is contained in:
@@ -3,6 +3,10 @@ set(the_description "The Core Functionality")
|
||||
ocv_add_dispatched_file(mathfuncs_core SSE2 AVX AVX2)
|
||||
ocv_add_dispatched_file(stat SSE4_2 AVX2)
|
||||
|
||||
# dispatching for accuracy tests
|
||||
ocv_add_dispatched_file_force_all(test_intrin128 TEST SSE2 SSE3 SSSE3 SSE4_1 SSE4_2 AVX FP16 AVX2)
|
||||
ocv_add_dispatched_file_force_all(test_intrin256 TEST AVX2)
|
||||
|
||||
ocv_add_module(core
|
||||
OPTIONAL opencv_cudev
|
||||
WRAP java python js)
|
||||
|
||||
@@ -204,20 +204,6 @@ CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN
|
||||
#define CV_SIMD512_64F 0
|
||||
#endif
|
||||
|
||||
#if CV_SIMD512
|
||||
#define CV_SIMD 1
|
||||
#define CV_SIMD_64F CV_SIMD512_64F
|
||||
#define CV_SIMD_WIDTH 64
|
||||
#elif CV_SIMD256
|
||||
#define CV_SIMD 1
|
||||
#define CV_SIMD_64F CV_SIMD256_64F
|
||||
#define CV_SIMD_WIDTH 32
|
||||
#else
|
||||
#define CV_SIMD CV_SIMD128
|
||||
#define CV_SIMD_64F CV_SIMD128_64F
|
||||
#define CV_SIMD_WIDTH 16
|
||||
#endif
|
||||
|
||||
//==================================================================================================
|
||||
|
||||
#define CV_INTRIN_DEFINE_WIDE_INTRIN(typ, vtyp, short_typ, prefix, loadsfx) \
|
||||
@@ -309,7 +295,21 @@ template<typename _Tp> struct V_RegTraits
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if CV_SIMD256
|
||||
#if CV_SIMD512 && (!defined(CV__SIMD_FORCE_WIDTH) || CV__SIMD_FORCE_WIDTH == 512)
|
||||
#define CV__SIMD_NAMESPACE simd512
|
||||
namespace CV__SIMD_NAMESPACE {
|
||||
#define CV_SIMD 1
|
||||
#define CV_SIMD_64F CV_SIMD512_64F
|
||||
#define CV_SIMD_WIDTH 64
|
||||
// TODO typedef v_uint8 / v_int32 / etc types here
|
||||
} // namespace
|
||||
using namespace CV__SIMD_NAMESPACE;
|
||||
#elif CV_SIMD256 && (!defined(CV__SIMD_FORCE_WIDTH) || CV__SIMD_FORCE_WIDTH == 256)
|
||||
#define CV__SIMD_NAMESPACE simd256
|
||||
namespace CV__SIMD_NAMESPACE {
|
||||
#define CV_SIMD 1
|
||||
#define CV_SIMD_64F CV_SIMD256_64F
|
||||
#define CV_SIMD_WIDTH 32
|
||||
typedef v_uint8x32 v_uint8;
|
||||
typedef v_int8x32 v_int8;
|
||||
typedef v_uint16x16 v_uint16;
|
||||
@@ -329,7 +329,14 @@ template<typename _Tp> struct V_RegTraits
|
||||
CV_INTRIN_DEFINE_WIDE_INTRIN_ALL_TYPES(v256)
|
||||
CV_INTRIN_DEFINE_WIDE_INTRIN(double, v_float64, f64, v256, load)
|
||||
inline void vx_cleanup() { v256_cleanup(); }
|
||||
#elif CV_SIMD128 || CV_SIMD128_CPP
|
||||
} // namespace
|
||||
using namespace CV__SIMD_NAMESPACE;
|
||||
#elif (CV_SIMD128 || CV_SIMD128_CPP) && (!defined(CV__SIMD_FORCE_WIDTH) || CV__SIMD_FORCE_WIDTH == 128)
|
||||
#define CV__SIMD_NAMESPACE simd128
|
||||
namespace CV__SIMD_NAMESPACE {
|
||||
#define CV_SIMD CV_SIMD128
|
||||
#define CV_SIMD_64F CV_SIMD128_64F
|
||||
#define CV_SIMD_WIDTH 16
|
||||
typedef v_uint8x16 v_uint8;
|
||||
typedef v_int8x16 v_int8;
|
||||
typedef v_uint16x8 v_uint16;
|
||||
@@ -351,6 +358,8 @@ template<typename _Tp> struct V_RegTraits
|
||||
CV_INTRIN_DEFINE_WIDE_INTRIN(double, v_float64, f64, v, load)
|
||||
#endif
|
||||
inline void vx_cleanup() { v_cleanup(); }
|
||||
} // namespace
|
||||
using namespace CV__SIMD_NAMESPACE;
|
||||
#endif
|
||||
|
||||
inline unsigned int trailingZeros32(unsigned int value) {
|
||||
@@ -380,6 +389,14 @@ inline unsigned int trailingZeros32(unsigned int value) {
|
||||
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END
|
||||
#endif
|
||||
|
||||
#ifndef CV_SIMD_64F
|
||||
#define CV_SIMD_64F 0
|
||||
#endif
|
||||
|
||||
#ifndef CV_SIMD
|
||||
#define CV_SIMD 0
|
||||
#endif
|
||||
|
||||
} // cv::
|
||||
|
||||
//! @endcond
|
||||
|
||||
@@ -494,7 +494,12 @@ void v_rshr_pack_store(ushort* ptr, const v_uint32x4& a)
|
||||
inline v_uint16x8 v_pack_u(const v_int32x4& a, const v_int32x4& b)
|
||||
{
|
||||
__m128i delta32 = _mm_set1_epi32(32768);
|
||||
__m128i r = _mm_packs_epi32(_mm_sub_epi32(a.val, delta32), _mm_sub_epi32(b.val, delta32));
|
||||
|
||||
// preliminary saturate negative values to zero
|
||||
__m128i a1 = _mm_and_si128(a.val, _mm_cmpgt_epi32(a.val, _mm_set1_epi32(0)));
|
||||
__m128i b1 = _mm_and_si128(b.val, _mm_cmpgt_epi32(b.val, _mm_set1_epi32(0)));
|
||||
|
||||
__m128i r = _mm_packs_epi32(_mm_sub_epi32(a1, delta32), _mm_sub_epi32(b1, delta32));
|
||||
return v_uint16x8(_mm_sub_epi16(r, _mm_set1_epi16(-32768)));
|
||||
}
|
||||
|
||||
|
||||
@@ -1764,7 +1764,7 @@ typedef struct CvString
|
||||
}
|
||||
CvString;
|
||||
|
||||
/** All the keys (names) of elements in the readed file storage
|
||||
/** All the keys (names) of elements in the read file storage
|
||||
are stored in the hash to speed up the lookup operations: */
|
||||
typedef struct CvStringHashNode
|
||||
{
|
||||
|
||||
@@ -453,9 +453,9 @@ struct Cvt_SIMD<int, uchar>
|
||||
{
|
||||
v_int32x4 v_src1 = v_load(src + x), v_src2 = v_load(src + x + cWidth);
|
||||
v_int32x4 v_src3 = v_load(src + x + cWidth * 2), v_src4 = v_load(src + x + cWidth * 3);
|
||||
v_uint16x8 v_dst1 = v_pack_u(v_src1, v_src2);
|
||||
v_uint16x8 v_dst2 = v_pack_u(v_src3, v_src4);
|
||||
v_store(dst + x, v_pack(v_dst1, v_dst2));
|
||||
v_int16x8 v_dst1 = v_pack(v_src1, v_src2);
|
||||
v_int16x8 v_dst2 = v_pack(v_src3, v_src4);
|
||||
v_store(dst + x, v_pack_u(v_dst1, v_dst2));
|
||||
}
|
||||
}
|
||||
return x;
|
||||
|
||||
@@ -2779,7 +2779,7 @@ cvGraphAddEdgeByPtr( CvGraph* graph,
|
||||
|
||||
if( start_vtx == end_vtx )
|
||||
CV_Error( start_vtx ? CV_StsBadArg : CV_StsNullPtr,
|
||||
"vertex pointers coinside (or set to NULL)" );
|
||||
"vertex pointers coincide (or set to NULL)" );
|
||||
|
||||
edge = (CvGraphEdge*)cvSetNew( (CvSet*)(graph->edges) );
|
||||
assert( edge->flags >= 0 );
|
||||
|
||||
@@ -36,13 +36,14 @@ vecmerge_( const T** src, T* dst, int len, int cn )
|
||||
const T* src0 = src[0];
|
||||
const T* src1 = src[1];
|
||||
|
||||
const int dstElemSize = cn * sizeof(T);
|
||||
int r = (int)((size_t)(void*)dst % (VECSZ*sizeof(T)));
|
||||
hal::StoreMode mode = hal::STORE_ALIGNED_NOCACHE;
|
||||
if( r != 0 )
|
||||
{
|
||||
mode = hal::STORE_UNALIGNED;
|
||||
if( r % cn == 0 && len > VECSZ )
|
||||
i0 = VECSZ - (r / cn);
|
||||
if (r % dstElemSize == 0 && len > VECSZ*2)
|
||||
i0 = VECSZ - (r / dstElemSize);
|
||||
}
|
||||
|
||||
if( cn == 2 )
|
||||
|
||||
@@ -1063,7 +1063,7 @@ cvReadRawDataSlice( const CvFileStorage* fs, CvSeqReader* reader,
|
||||
CV_Error( CV_StsNullPtr, "Null pointer to reader or destination array" );
|
||||
|
||||
if( !reader->seq && len != 1 )
|
||||
CV_Error( CV_StsBadSize, "The readed sequence is a scalar, thus len must be 1" );
|
||||
CV_Error( CV_StsBadSize, "The read sequence is a scalar, thus len must be 1" );
|
||||
|
||||
fmt_pair_count = icvDecodeFormat( dt, fmt_pairs, CV_FS_MAX_FMT_PAIRS );
|
||||
size_t step = ::icvCalcStructSize(dt, 0);
|
||||
|
||||
@@ -27,8 +27,8 @@ vecsplit_( const T* src, T** dst, int len, int cn )
|
||||
if( (r0|r1|r2|r3) != 0 )
|
||||
{
|
||||
mode = hal::STORE_UNALIGNED;
|
||||
if( r0 == r1 && r0 == r2 && r0 == r3 && r0 % cn == 0 && len > VECSZ )
|
||||
i0 = VECSZ - (r0 / cn);
|
||||
if( r0 == r1 && r0 == r2 && r0 == r3 && r0 % sizeof(T) == 0 && len > VECSZ*2 )
|
||||
i0 = VECSZ - (r0 / sizeof(T));
|
||||
}
|
||||
|
||||
if( cn == 2 )
|
||||
|
||||
@@ -469,7 +469,32 @@ cv::String getCacheDirectory(const char* sub_directory_name, const char* configu
|
||||
{
|
||||
if (utils::fs::isDirectory(default_cache_path))
|
||||
{
|
||||
default_cache_path = utils::fs::join(default_cache_path, utils::fs::join("opencv", CV_VERSION));
|
||||
cv::String default_cache_path_base = utils::fs::join(default_cache_path, "opencv");
|
||||
default_cache_path = utils::fs::join(default_cache_path_base, "4.0" CV_VERSION_STATUS);
|
||||
if (utils::getConfigurationParameterBool("OPENCV_CACHE_SHOW_CLEANUP_MESSAGE", true)
|
||||
&& !utils::fs::isDirectory(default_cache_path))
|
||||
{
|
||||
std::vector<cv::String> existedCacheDirs;
|
||||
try
|
||||
{
|
||||
utils::fs::glob_relative(default_cache_path_base, "*", existedCacheDirs, false, true);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
if (!existedCacheDirs.empty())
|
||||
{
|
||||
CV_LOG_WARNING(NULL, "Creating new OpenCV cache directory: " << default_cache_path);
|
||||
CV_LOG_WARNING(NULL, "There are several neighbour directories, probably created by old OpenCV versions.");
|
||||
CV_LOG_WARNING(NULL, "Feel free to cleanup these unused directories:");
|
||||
for (size_t i = 0; i < existedCacheDirs.size(); i++)
|
||||
{
|
||||
CV_LOG_WARNING(NULL, " - " << existedCacheDirs[i]);
|
||||
}
|
||||
CV_LOG_WARNING(NULL, "Note: This message is showed only once.");
|
||||
}
|
||||
}
|
||||
if (sub_directory_name && sub_directory_name[0] != '\0')
|
||||
default_cache_path = utils::fs::join(default_cache_path, cv::String(sub_directory_name) + native_separator);
|
||||
if (!utils::fs::createDirectories(default_cache_path))
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
// 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.
|
||||
#include "test_precomp.hpp"
|
||||
#include "test_intrin.simd.hpp"
|
||||
@@ -2,101 +2,100 @@
|
||||
// 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.
|
||||
#include "test_precomp.hpp"
|
||||
#include "test_intrin.simd.hpp"
|
||||
|
||||
#define CV_CPU_SIMD_FILENAME "test_intrin.simd.hpp"
|
||||
#define CV_CPU_DISPATCH_MODE FP16
|
||||
#include "opencv2/core/private/cv_cpu_include_simd_declarations.hpp"
|
||||
#include "test_intrin128.simd.hpp"
|
||||
#include "test_intrin128.simd_declarations.hpp"
|
||||
|
||||
#undef CV_CPU_DISPATCH_MODES_ALL
|
||||
|
||||
#include "opencv2/core/cv_cpu_dispatch.h"
|
||||
#include "test_intrin256.simd.hpp"
|
||||
#include "test_intrin256.simd_declarations.hpp"
|
||||
|
||||
#define CV_CPU_DISPATCH_MODE AVX2
|
||||
#include "opencv2/core/private/cv_cpu_include_simd_declarations.hpp"
|
||||
|
||||
namespace opencv_test { namespace hal {
|
||||
using namespace CV_CPU_OPTIMIZATION_NAMESPACE;
|
||||
|
||||
TEST(hal_intrin, uint8x16)
|
||||
{ test_hal_intrin_uint8(); }
|
||||
#define CV_CPU_CALL_BASELINE_(fn, args) CV_CPU_CALL_BASELINE(fn, args)
|
||||
|
||||
TEST(hal_intrin, int8x16)
|
||||
{ test_hal_intrin_int8(); }
|
||||
#define DISPATCH_SIMD128(fn, cpu_opt) do { \
|
||||
CV_CPU_CALL_ ## cpu_opt ## _(fn, ()); \
|
||||
throw SkipTestException("SIMD128 (" #cpu_opt ") is not available or disabled"); \
|
||||
} while(0)
|
||||
|
||||
TEST(hal_intrin, uint16x8)
|
||||
{ test_hal_intrin_uint16(); }
|
||||
#define DISPATCH_SIMD256(fn, cpu_opt) do { \
|
||||
CV_CPU_CALL_ ## cpu_opt ## _(fn, ()); \
|
||||
throw SkipTestException("SIMD256 (" #cpu_opt ") is not available or disabled"); \
|
||||
} while(0)
|
||||
|
||||
TEST(hal_intrin, int16x8)
|
||||
{ test_hal_intrin_int16(); }
|
||||
#define DEFINE_SIMD_TESTS(simd_size, cpu_opt) \
|
||||
TEST(hal_intrin ## simd_size, uint8x16_ ## cpu_opt) { DISPATCH_SIMD ## simd_size(test_hal_intrin_uint8, cpu_opt); } \
|
||||
TEST(hal_intrin ## simd_size, int8x16_ ## cpu_opt) { DISPATCH_SIMD ## simd_size(test_hal_intrin_int8, cpu_opt); } \
|
||||
TEST(hal_intrin ## simd_size, uint16x8_ ## cpu_opt) { DISPATCH_SIMD ## simd_size(test_hal_intrin_uint16, cpu_opt); } \
|
||||
TEST(hal_intrin ## simd_size, int16x8_ ## cpu_opt) { DISPATCH_SIMD ## simd_size(test_hal_intrin_int16, cpu_opt); } \
|
||||
TEST(hal_intrin ## simd_size, int32x4_ ## cpu_opt) { DISPATCH_SIMD ## simd_size(test_hal_intrin_int32, cpu_opt); } \
|
||||
TEST(hal_intrin ## simd_size, uint32x4_ ## cpu_opt) { DISPATCH_SIMD ## simd_size(test_hal_intrin_uint32, cpu_opt); } \
|
||||
TEST(hal_intrin ## simd_size, uint64x2_ ## cpu_opt) { DISPATCH_SIMD ## simd_size(test_hal_intrin_uint64, cpu_opt); } \
|
||||
TEST(hal_intrin ## simd_size, int64x2_ ## cpu_opt) { DISPATCH_SIMD ## simd_size(test_hal_intrin_int64, cpu_opt); } \
|
||||
TEST(hal_intrin ## simd_size, float32x4_ ## cpu_opt) { DISPATCH_SIMD ## simd_size(test_hal_intrin_float32, cpu_opt); } \
|
||||
TEST(hal_intrin ## simd_size, float64x2_ ## cpu_opt) { DISPATCH_SIMD ## simd_size(test_hal_intrin_float64, cpu_opt); } \
|
||||
|
||||
TEST(hal_intrin, int32x4)
|
||||
{ test_hal_intrin_int32(); }
|
||||
namespace intrin128 {
|
||||
|
||||
TEST(hal_intrin, uint32x4)
|
||||
{ test_hal_intrin_uint32(); }
|
||||
DEFINE_SIMD_TESTS(128, BASELINE)
|
||||
|
||||
TEST(hal_intrin, uint64x2)
|
||||
{ test_hal_intrin_uint64(); }
|
||||
#if defined CV_CPU_DISPATCH_COMPILE_SSE2 || defined CV_CPU_BASELINE_COMPILE_SSE2
|
||||
DEFINE_SIMD_TESTS(128, SSE2)
|
||||
#endif
|
||||
#if defined CV_CPU_DISPATCH_COMPILE_SSE3 || defined CV_CPU_BASELINE_COMPILE_SSE3
|
||||
DEFINE_SIMD_TESTS(128, SSE3)
|
||||
#endif
|
||||
#if defined CV_CPU_DISPATCH_COMPILE_SSSE3 || defined CV_CPU_BASELINE_COMPILE_SSSE3
|
||||
DEFINE_SIMD_TESTS(128, SSSE3)
|
||||
#endif
|
||||
#if defined CV_CPU_DISPATCH_COMPILE_SSE4_1 || defined CV_CPU_BASELINE_COMPILE_SSE4_1
|
||||
DEFINE_SIMD_TESTS(128, SSE4_1)
|
||||
#endif
|
||||
#if defined CV_CPU_DISPATCH_COMPILE_SSE4_2 || defined CV_CPU_BASELINE_COMPILE_SSE4_2
|
||||
DEFINE_SIMD_TESTS(128, SSE4_2)
|
||||
#endif
|
||||
#if defined CV_CPU_DISPATCH_COMPILE_AVX || defined CV_CPU_BASELINE_COMPILE_AVX
|
||||
DEFINE_SIMD_TESTS(128, AVX)
|
||||
#endif
|
||||
#if defined CV_CPU_DISPATCH_COMPILE_AVX2 || defined CV_CPU_BASELINE_COMPILE_AVX2
|
||||
DEFINE_SIMD_TESTS(128, AVX2)
|
||||
#endif
|
||||
|
||||
TEST(hal_intrin, int64x2)
|
||||
{ test_hal_intrin_int64(); }
|
||||
|
||||
TEST(hal_intrin, float32x4)
|
||||
{ test_hal_intrin_float32(); }
|
||||
|
||||
TEST(hal_intrin, float64x2)
|
||||
{ test_hal_intrin_float64(); }
|
||||
|
||||
TEST(hal_intrin, float16x8)
|
||||
TEST(hal_intrin128, float16x8_FP16)
|
||||
{
|
||||
CV_CPU_CALL_FP16_(test_hal_intrin_float16, ());
|
||||
throw SkipTestException("Unsupported hardware: FP16 is not available");
|
||||
}
|
||||
|
||||
#define DISPATCH_SIMD_MODES AVX2
|
||||
#define DISPATCH_SIMD_NAME "SIMD256"
|
||||
#define DISPATCH_SIMD(fun) \
|
||||
do { \
|
||||
CV_CPU_DISPATCH(fun, (), DISPATCH_SIMD_MODES); \
|
||||
throw SkipTestException( \
|
||||
"Unsupported hardware: " \
|
||||
DISPATCH_SIMD_NAME \
|
||||
" is not available" \
|
||||
); \
|
||||
} while(0)
|
||||
} // namespace intrin128
|
||||
|
||||
TEST(hal_intrin256, uint8x32)
|
||||
{ DISPATCH_SIMD(test_hal_intrin_uint8); }
|
||||
|
||||
TEST(hal_intrin256, int8x32)
|
||||
{ DISPATCH_SIMD(test_hal_intrin_int8); }
|
||||
namespace intrin256 {
|
||||
|
||||
TEST(hal_intrin256, uint16x16)
|
||||
{ DISPATCH_SIMD(test_hal_intrin_uint16); }
|
||||
|
||||
TEST(hal_intrin256, int16x16)
|
||||
{ DISPATCH_SIMD(test_hal_intrin_int16); }
|
||||
// Not available due missing C++ backend for SIMD256
|
||||
//DEFINE_SIMD_TESTS(256, BASELINE)
|
||||
|
||||
TEST(hal_intrin256, uint32x8)
|
||||
{ DISPATCH_SIMD(test_hal_intrin_uint32); }
|
||||
//#if defined CV_CPU_DISPATCH_COMPILE_AVX
|
||||
//DEFINE_SIMD_TESTS(256, AVX)
|
||||
//#endif
|
||||
|
||||
TEST(hal_intrin256, int32x8)
|
||||
{ DISPATCH_SIMD(test_hal_intrin_int32); }
|
||||
#if defined CV_CPU_DISPATCH_COMPILE_AVX2 || defined CV_CPU_BASELINE_COMPILE_AVX2
|
||||
DEFINE_SIMD_TESTS(256, AVX2)
|
||||
#endif
|
||||
|
||||
TEST(hal_intrin256, uint64x4)
|
||||
{ DISPATCH_SIMD(test_hal_intrin_uint64); }
|
||||
|
||||
TEST(hal_intrin256, int64x4)
|
||||
{ DISPATCH_SIMD(test_hal_intrin_int64); }
|
||||
|
||||
TEST(hal_intrin256, float32x8)
|
||||
{ DISPATCH_SIMD(test_hal_intrin_float32); }
|
||||
|
||||
TEST(hal_intrin256, float64x4)
|
||||
{ DISPATCH_SIMD(test_hal_intrin_float64); }
|
||||
|
||||
TEST(hal_intrin256, float16x16)
|
||||
TEST(hal_intrin256, float16x16_FP16)
|
||||
{
|
||||
if (!CV_CPU_HAS_SUPPORT_FP16)
|
||||
throw SkipTestException("Unsupported hardware: FP16 is not available");
|
||||
DISPATCH_SIMD(test_hal_intrin_float16);
|
||||
//CV_CPU_CALL_FP16_(test_hal_intrin_float16, ());
|
||||
CV_CPU_CALL_AVX2_(test_hal_intrin_float16, ());
|
||||
throw SkipTestException("Unsupported hardware: FP16 is not available");
|
||||
}
|
||||
|
||||
|
||||
} // namespace intrin256
|
||||
|
||||
}} // namespace
|
||||
@@ -1,19 +0,0 @@
|
||||
// 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.
|
||||
#include "test_precomp.hpp"
|
||||
#include "test_intrin_utils.hpp"
|
||||
|
||||
namespace opencv_test { namespace hal {
|
||||
CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN
|
||||
|
||||
void test_hal_intrin_float16()
|
||||
{
|
||||
TheTest<v_float16>()
|
||||
.test_loadstore_fp16()
|
||||
.test_float_cvt_fp16()
|
||||
;
|
||||
}
|
||||
|
||||
CV_CPU_OPTIMIZATION_NAMESPACE_END
|
||||
}} // namespace
|
||||
@@ -1,296 +0,0 @@
|
||||
// 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.
|
||||
#include "test_precomp.hpp"
|
||||
#include "test_intrin_utils.hpp"
|
||||
|
||||
namespace opencv_test { namespace hal {
|
||||
CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN
|
||||
|
||||
void test_hal_intrin_uint8();
|
||||
void test_hal_intrin_int8();
|
||||
void test_hal_intrin_uint16();
|
||||
void test_hal_intrin_int16();
|
||||
void test_hal_intrin_uint32();
|
||||
void test_hal_intrin_int32();
|
||||
void test_hal_intrin_uint64();
|
||||
void test_hal_intrin_int64();
|
||||
void test_hal_intrin_float32();
|
||||
void test_hal_intrin_float64();
|
||||
|
||||
#ifndef CV_CPU_OPTIMIZATION_DECLARATIONS_ONLY
|
||||
|
||||
//============= 8-bit integer =====================================================================
|
||||
|
||||
void test_hal_intrin_uint8()
|
||||
{
|
||||
TheTest<v_uint8>()
|
||||
.test_loadstore()
|
||||
.test_interleave()
|
||||
.test_expand()
|
||||
.test_expand_q()
|
||||
.test_addsub()
|
||||
.test_addsub_wrap()
|
||||
.test_cmp()
|
||||
.test_logic()
|
||||
.test_min_max()
|
||||
.test_absdiff()
|
||||
.test_mask()
|
||||
.test_popcount()
|
||||
.test_pack<1>().test_pack<2>().test_pack<3>().test_pack<8>()
|
||||
.test_pack_u<1>().test_pack_u<2>().test_pack_u<3>().test_pack_u<8>()
|
||||
.test_unpack()
|
||||
.test_extract<0>().test_extract<1>().test_extract<8>().test_extract<15>()
|
||||
.test_rotate<0>().test_rotate<1>().test_rotate<8>().test_rotate<15>()
|
||||
;
|
||||
|
||||
#if CV_SIMD256
|
||||
TheTest<v_uint8>()
|
||||
.test_pack<9>().test_pack<10>().test_pack<13>().test_pack<15>()
|
||||
.test_pack_u<9>().test_pack_u<10>().test_pack_u<13>().test_pack_u<15>()
|
||||
.test_extract<16>().test_extract<17>().test_extract<23>().test_extract<31>()
|
||||
.test_rotate<16>().test_rotate<17>().test_rotate<23>().test_rotate<31>()
|
||||
;
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_hal_intrin_int8()
|
||||
{
|
||||
TheTest<v_int8>()
|
||||
.test_loadstore()
|
||||
.test_interleave()
|
||||
.test_expand()
|
||||
.test_expand_q()
|
||||
.test_addsub()
|
||||
.test_addsub_wrap()
|
||||
.test_cmp()
|
||||
.test_logic()
|
||||
.test_min_max()
|
||||
.test_absdiff()
|
||||
.test_abs()
|
||||
.test_mask()
|
||||
.test_popcount()
|
||||
.test_pack<1>().test_pack<2>().test_pack<3>().test_pack<8>()
|
||||
.test_unpack()
|
||||
.test_extract<0>().test_extract<1>().test_extract<8>().test_extract<15>()
|
||||
.test_rotate<0>().test_rotate<1>().test_rotate<8>().test_rotate<15>()
|
||||
;
|
||||
}
|
||||
|
||||
//============= 16-bit integer =====================================================================
|
||||
|
||||
void test_hal_intrin_uint16()
|
||||
{
|
||||
TheTest<v_uint16>()
|
||||
.test_loadstore()
|
||||
.test_interleave()
|
||||
.test_expand()
|
||||
.test_addsub()
|
||||
.test_addsub_wrap()
|
||||
.test_mul()
|
||||
.test_mul_expand()
|
||||
.test_cmp()
|
||||
.test_shift<1>()
|
||||
.test_shift<8>()
|
||||
.test_logic()
|
||||
.test_min_max()
|
||||
.test_absdiff()
|
||||
.test_reduce()
|
||||
.test_mask()
|
||||
.test_popcount()
|
||||
.test_pack<1>().test_pack<2>().test_pack<7>().test_pack<16>()
|
||||
.test_pack_u<1>().test_pack_u<2>().test_pack_u<7>().test_pack_u<16>()
|
||||
.test_unpack()
|
||||
.test_extract<0>().test_extract<1>().test_extract<4>().test_extract<7>()
|
||||
.test_rotate<0>().test_rotate<1>().test_rotate<4>().test_rotate<7>()
|
||||
;
|
||||
}
|
||||
|
||||
void test_hal_intrin_int16()
|
||||
{
|
||||
TheTest<v_int16>()
|
||||
.test_loadstore()
|
||||
.test_interleave()
|
||||
.test_expand()
|
||||
.test_addsub()
|
||||
.test_addsub_wrap()
|
||||
.test_mul()
|
||||
.test_mul_expand()
|
||||
.test_cmp()
|
||||
.test_shift<1>()
|
||||
.test_shift<8>()
|
||||
.test_dot_prod()
|
||||
.test_logic()
|
||||
.test_min_max()
|
||||
.test_absdiff()
|
||||
.test_abs()
|
||||
.test_reduce()
|
||||
.test_mask()
|
||||
.test_popcount()
|
||||
.test_pack<1>().test_pack<2>().test_pack<7>().test_pack<16>()
|
||||
.test_unpack()
|
||||
.test_extract<0>().test_extract<1>().test_extract<4>().test_extract<7>()
|
||||
.test_rotate<0>().test_rotate<1>().test_rotate<4>().test_rotate<7>()
|
||||
;
|
||||
}
|
||||
|
||||
//============= 32-bit integer =====================================================================
|
||||
|
||||
void test_hal_intrin_uint32()
|
||||
{
|
||||
TheTest<v_uint32>()
|
||||
.test_loadstore()
|
||||
.test_interleave()
|
||||
.test_expand()
|
||||
.test_addsub()
|
||||
.test_mul()
|
||||
.test_mul_expand()
|
||||
.test_cmp()
|
||||
.test_shift<1>()
|
||||
.test_shift<8>()
|
||||
.test_logic()
|
||||
.test_min_max()
|
||||
.test_absdiff()
|
||||
.test_reduce()
|
||||
.test_mask()
|
||||
.test_popcount()
|
||||
.test_pack<1>().test_pack<2>().test_pack<15>().test_pack<32>()
|
||||
.test_unpack()
|
||||
.test_extract<0>().test_extract<1>().test_extract<2>().test_extract<3>()
|
||||
.test_rotate<0>().test_rotate<1>().test_rotate<2>().test_rotate<3>()
|
||||
.test_transpose()
|
||||
;
|
||||
}
|
||||
|
||||
void test_hal_intrin_int32()
|
||||
{
|
||||
TheTest<v_int32>()
|
||||
.test_loadstore()
|
||||
.test_interleave()
|
||||
.test_expand()
|
||||
.test_addsub()
|
||||
.test_mul()
|
||||
.test_abs()
|
||||
.test_cmp()
|
||||
.test_popcount()
|
||||
.test_shift<1>().test_shift<8>()
|
||||
.test_logic()
|
||||
.test_min_max()
|
||||
.test_absdiff()
|
||||
.test_reduce()
|
||||
.test_mask()
|
||||
.test_pack<1>().test_pack<2>().test_pack<15>().test_pack<32>()
|
||||
.test_unpack()
|
||||
.test_extract<0>().test_extract<1>().test_extract<2>().test_extract<3>()
|
||||
.test_rotate<0>().test_rotate<1>().test_rotate<2>().test_rotate<3>()
|
||||
.test_float_cvt32()
|
||||
.test_float_cvt64()
|
||||
.test_transpose()
|
||||
;
|
||||
}
|
||||
|
||||
//============= 64-bit integer =====================================================================
|
||||
|
||||
void test_hal_intrin_uint64()
|
||||
{
|
||||
TheTest<v_uint64>()
|
||||
.test_loadstore()
|
||||
.test_addsub()
|
||||
.test_shift<1>().test_shift<8>()
|
||||
.test_logic()
|
||||
.test_extract<0>().test_extract<1>()
|
||||
.test_rotate<0>().test_rotate<1>()
|
||||
;
|
||||
}
|
||||
|
||||
void test_hal_intrin_int64()
|
||||
{
|
||||
TheTest<v_int64>()
|
||||
.test_loadstore()
|
||||
.test_addsub()
|
||||
.test_shift<1>().test_shift<8>()
|
||||
.test_logic()
|
||||
.test_extract<0>().test_extract<1>()
|
||||
.test_rotate<0>().test_rotate<1>()
|
||||
;
|
||||
}
|
||||
|
||||
//============= Floating point =====================================================================
|
||||
void test_hal_intrin_float32()
|
||||
{
|
||||
TheTest<v_float32>()
|
||||
.test_loadstore()
|
||||
.test_interleave()
|
||||
.test_interleave_2channel()
|
||||
.test_addsub()
|
||||
.test_mul()
|
||||
.test_div()
|
||||
.test_cmp()
|
||||
.test_sqrt_abs()
|
||||
.test_min_max()
|
||||
.test_float_absdiff()
|
||||
.test_reduce()
|
||||
.test_mask()
|
||||
.test_unpack()
|
||||
.test_float_math()
|
||||
.test_float_cvt64()
|
||||
.test_matmul()
|
||||
.test_transpose()
|
||||
.test_reduce_sum4()
|
||||
.test_extract<0>().test_extract<1>().test_extract<2>().test_extract<3>()
|
||||
.test_rotate<0>().test_rotate<1>().test_rotate<2>().test_rotate<3>()
|
||||
;
|
||||
|
||||
#if CV_SIMD256
|
||||
TheTest<v_float32>()
|
||||
.test_extract<4>().test_extract<5>().test_extract<6>().test_extract<7>()
|
||||
.test_rotate<4>().test_rotate<5>().test_rotate<6>().test_rotate<7>()
|
||||
;
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_hal_intrin_float64()
|
||||
{
|
||||
#if CV_SIMD_64F
|
||||
TheTest<v_float64>()
|
||||
.test_loadstore()
|
||||
.test_addsub()
|
||||
.test_mul()
|
||||
.test_div()
|
||||
.test_cmp()
|
||||
.test_sqrt_abs()
|
||||
.test_min_max()
|
||||
.test_float_absdiff()
|
||||
.test_mask()
|
||||
.test_unpack()
|
||||
.test_float_math()
|
||||
.test_float_cvt32()
|
||||
.test_extract<0>().test_extract<1>()
|
||||
.test_rotate<0>().test_rotate<1>()
|
||||
;
|
||||
|
||||
#if CV_SIMD256
|
||||
TheTest<v_float64>()
|
||||
.test_extract<2>().test_extract<3>()
|
||||
.test_rotate<2>().test_rotate<3>()
|
||||
;
|
||||
#endif //CV_SIMD256
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
#if CV_FP16 && CV_SIMD_WIDTH > 16
|
||||
void test_hal_intrin_float16()
|
||||
{
|
||||
TheTest<v_float16>()
|
||||
.test_loadstore_fp16()
|
||||
.test_float_cvt_fp16()
|
||||
;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //CV_CPU_OPTIMIZATION_DECLARATIONS_ONLY
|
||||
|
||||
CV_CPU_OPTIMIZATION_NAMESPACE_END
|
||||
|
||||
}} //namespace
|
||||
@@ -0,0 +1,22 @@
|
||||
// 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.
|
||||
#ifndef CV_CPU_OPTIMIZATION_DECLARATIONS_ONLY
|
||||
|
||||
#define CV__SIMD_FORCE_WIDTH 128
|
||||
#include "opencv2/core/hal/intrin.hpp"
|
||||
#undef CV__SIMD_FORCE_WIDTH
|
||||
|
||||
#if CV_SIMD_WIDTH != 16
|
||||
#error "Invalid build configuration"
|
||||
#endif
|
||||
|
||||
#endif // CV_CPU_OPTIMIZATION_DECLARATIONS_ONLY
|
||||
|
||||
namespace opencv_test { namespace hal { namespace intrin128 {
|
||||
CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN
|
||||
|
||||
#include "test_intrin_utils.hpp"
|
||||
|
||||
CV_CPU_OPTIMIZATION_NAMESPACE_END
|
||||
}}} //namespace
|
||||
@@ -0,0 +1,23 @@
|
||||
// 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.
|
||||
#if !defined CV_CPU_OPTIMIZATION_DECLARATIONS_ONLY && \
|
||||
!defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS // TODO? C++ fallback implementation for SIMD256
|
||||
|
||||
#define CV__SIMD_FORCE_WIDTH 256
|
||||
#include "opencv2/core/hal/intrin.hpp"
|
||||
#undef CV__SIMD_FORCE_WIDTH
|
||||
|
||||
#if CV_SIMD_WIDTH != 32
|
||||
#error "Invalid build configuration"
|
||||
#endif
|
||||
|
||||
#endif // CV_CPU_OPTIMIZATION_DECLARATIONS_ONLY
|
||||
|
||||
namespace opencv_test { namespace hal { namespace intrin256 {
|
||||
CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN
|
||||
|
||||
#include "test_intrin_utils.hpp"
|
||||
|
||||
CV_CPU_OPTIMIZATION_NAMESPACE_END
|
||||
}}} //namespace
|
||||
@@ -1,10 +1,22 @@
|
||||
// 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.
|
||||
#include "opencv2/core/hal/intrin.hpp"
|
||||
|
||||
namespace opencv_test { namespace hal {
|
||||
CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN
|
||||
// This file is not standalone.
|
||||
// It is included with these active namespaces:
|
||||
//namespace opencv_test { namespace hal { namespace intrinXXX {
|
||||
//CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN
|
||||
|
||||
void test_hal_intrin_uint8();
|
||||
void test_hal_intrin_int8();
|
||||
void test_hal_intrin_uint16();
|
||||
void test_hal_intrin_int16();
|
||||
void test_hal_intrin_uint32();
|
||||
void test_hal_intrin_int32();
|
||||
void test_hal_intrin_uint64();
|
||||
void test_hal_intrin_int64();
|
||||
void test_hal_intrin_float32();
|
||||
void test_hal_intrin_float64();
|
||||
|
||||
void test_hal_intrin_float16();
|
||||
|
||||
@@ -258,6 +270,7 @@ template<typename R> struct TheTest
|
||||
v_store(out.u.d, r_low);
|
||||
for (int i = 0; i < R::nlanes/2; ++i)
|
||||
{
|
||||
SCOPED_TRACE(cv::format("i=%d", i));
|
||||
EXPECT_EQ((LaneType)data.u[i], (LaneType)out.u[i]);
|
||||
}
|
||||
|
||||
@@ -266,6 +279,7 @@ template<typename R> struct TheTest
|
||||
v_store(out.u.d, r_low_align8byte);
|
||||
for (int i = 0; i < R::nlanes/2; ++i)
|
||||
{
|
||||
SCOPED_TRACE(cv::format("i=%d", i));
|
||||
EXPECT_EQ((LaneType)data.u[i + R::nlanes/2], (LaneType)out.u[i]);
|
||||
}
|
||||
|
||||
@@ -296,6 +310,7 @@ template<typename R> struct TheTest
|
||||
resV.fill((LaneType)8);
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
{
|
||||
SCOPED_TRACE(cv::format("i=%d", i));
|
||||
EXPECT_EQ((LaneType)0, resZ[i]);
|
||||
EXPECT_EQ((LaneType)8, resV[i]);
|
||||
}
|
||||
@@ -342,6 +357,7 @@ template<typename R> struct TheTest
|
||||
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
{
|
||||
SCOPED_TRACE(cv::format("i=%d", i));
|
||||
EXPECT_EQ(data1, Data<R>(a));
|
||||
EXPECT_EQ(data2, Data<R>(b));
|
||||
EXPECT_EQ(data3, Data<R>(c));
|
||||
@@ -374,6 +390,7 @@ template<typename R> struct TheTest
|
||||
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
{
|
||||
SCOPED_TRACE(cv::format("i=%d", i));
|
||||
EXPECT_EQ(data1, Data<R>(a));
|
||||
EXPECT_EQ(data2, Data<R>(b));
|
||||
}
|
||||
@@ -397,6 +414,7 @@ template<typename R> struct TheTest
|
||||
const int n = Rx2::nlanes;
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
SCOPED_TRACE(cv::format("i=%d", i));
|
||||
EXPECT_EQ(dataA[i], resB[i]);
|
||||
EXPECT_EQ(dataA[i], resC[i]);
|
||||
EXPECT_EQ(dataA[i + n], resD[i]);
|
||||
@@ -412,7 +430,10 @@ template<typename R> struct TheTest
|
||||
Data<Rx4> out = vx_load_expand_q(data.d);
|
||||
const int n = Rx4::nlanes;
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
SCOPED_TRACE(cv::format("i=%d", i));
|
||||
EXPECT_EQ(data[i], out[i]);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -426,6 +447,7 @@ template<typename R> struct TheTest
|
||||
Data<R> resC = a + b, resD = a - b;
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
{
|
||||
SCOPED_TRACE(cv::format("i=%d", i));
|
||||
EXPECT_EQ(saturate_cast<LaneType>(dataA[i] + dataB[i]), resC[i]);
|
||||
EXPECT_EQ(saturate_cast<LaneType>(dataA[i] - dataB[i]), resD[i]);
|
||||
}
|
||||
@@ -443,6 +465,7 @@ template<typename R> struct TheTest
|
||||
resD = v_sub_wrap(a, b);
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
{
|
||||
SCOPED_TRACE(cv::format("i=%d", i));
|
||||
EXPECT_EQ((LaneType)(dataA[i] + dataB[i]), resC[i]);
|
||||
EXPECT_EQ((LaneType)(dataA[i] - dataB[i]), resD[i]);
|
||||
}
|
||||
@@ -458,6 +481,7 @@ template<typename R> struct TheTest
|
||||
Data<R> resC = a * b;
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
{
|
||||
SCOPED_TRACE(cv::format("i=%d", i));
|
||||
EXPECT_EQ(dataA[i] * dataB[i], resC[i]);
|
||||
}
|
||||
|
||||
@@ -473,6 +497,7 @@ template<typename R> struct TheTest
|
||||
Data<R> resC = a / b;
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
{
|
||||
SCOPED_TRACE(cv::format("i=%d", i));
|
||||
EXPECT_EQ(dataA[i] / dataB[i], resC[i]);
|
||||
}
|
||||
|
||||
@@ -492,6 +517,7 @@ template<typename R> struct TheTest
|
||||
const int n = R::nlanes / 2;
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
SCOPED_TRACE(cv::format("i=%d", i));
|
||||
EXPECT_EQ((typename Rx2::lane_type)dataA[i] * dataB[i], resC[i]);
|
||||
EXPECT_EQ((typename Rx2::lane_type)dataA[i + n] * dataB[i + n], resD[i]);
|
||||
}
|
||||
@@ -511,6 +537,7 @@ template<typename R> struct TheTest
|
||||
|
||||
for (int i = 0; i < Ru::nlanes; ++i)
|
||||
{
|
||||
SCOPED_TRACE(cv::format("i=%d", i));
|
||||
EXPECT_EQ((u_type)std::abs(dataA[i] - dataB[i]), resC[i]);
|
||||
}
|
||||
|
||||
@@ -529,6 +556,7 @@ template<typename R> struct TheTest
|
||||
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
{
|
||||
SCOPED_TRACE(cv::format("i=%d", i));
|
||||
EXPECT_EQ(static_cast<LaneType>(dataA[i] << s), resB[i]);
|
||||
EXPECT_EQ(static_cast<LaneType>(dataA[i] << s), resC[i]);
|
||||
EXPECT_EQ(static_cast<LaneType>(dataA[i] >> s), resD[i]);
|
||||
@@ -553,6 +581,7 @@ template<typename R> struct TheTest
|
||||
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
{
|
||||
SCOPED_TRACE(cv::format("i=%d", i));
|
||||
EXPECT_EQ(dataA[i] == dataB[i], resC[i] != 0);
|
||||
EXPECT_EQ(dataA[i] != dataB[i], resD[i] != 0);
|
||||
EXPECT_EQ(dataA[i] > dataB[i], resE[i] != 0);
|
||||
@@ -583,6 +612,7 @@ template<typename R> struct TheTest
|
||||
const int n = R::nlanes / 2;
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
SCOPED_TRACE(cv::format("i=%d", i));
|
||||
EXPECT_EQ(dataA[i*2] * dataB[i*2] + dataA[i*2 + 1] * dataB[i*2 + 1], resD[i]);
|
||||
EXPECT_EQ(dataA[i*2] * dataB[i*2] + dataA[i*2 + 1] * dataB[i*2 + 1] + dataC[i], resE[i]);
|
||||
}
|
||||
@@ -597,6 +627,7 @@ template<typename R> struct TheTest
|
||||
Data<R> resC = a & b, resD = a | b, resE = a ^ b, resF = ~a;
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
{
|
||||
SCOPED_TRACE(cv::format("i=%d", i));
|
||||
EXPECT_EQ(dataA[i] & dataB[i], resC[i]);
|
||||
EXPECT_EQ(dataA[i] | dataB[i], resD[i]);
|
||||
EXPECT_EQ(dataA[i] ^ dataB[i], resE[i]);
|
||||
@@ -615,6 +646,7 @@ template<typename R> struct TheTest
|
||||
Data<R> resB = v_sqrt(a), resC = v_invsqrt(a), resE = v_abs(d);
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
{
|
||||
SCOPED_TRACE(cv::format("i=%d", i));
|
||||
EXPECT_COMPARE_EQ((float)std::sqrt(dataA[i]), (float)resB[i]);
|
||||
EXPECT_COMPARE_EQ(1/(float)std::sqrt(dataA[i]), (float)resC[i]);
|
||||
EXPECT_COMPARE_EQ((float)abs(dataA[i]), (float)resE[i]);
|
||||
@@ -632,6 +664,7 @@ template<typename R> struct TheTest
|
||||
Data<R> resC = v_min(a, b), resD = v_max(a, b);
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
{
|
||||
SCOPED_TRACE(cv::format("i=%d", i));
|
||||
EXPECT_EQ(std::min(dataA[i], dataB[i]), resC[i]);
|
||||
EXPECT_EQ(std::max(dataA[i], dataB[i]), resD[i]);
|
||||
}
|
||||
@@ -672,6 +705,7 @@ template<typename R> struct TheTest
|
||||
const u_type mask = std::numeric_limits<LaneType>::is_signed ? (u_type)(1 << (sizeof(u_type)*8 - 1)) : 0;
|
||||
for (int i = 0; i < Ru::nlanes; ++i)
|
||||
{
|
||||
SCOPED_TRACE(cv::format("i=%d", i));
|
||||
u_type uA = dataA[i] ^ mask;
|
||||
u_type uB = dataB[i] ^ mask;
|
||||
EXPECT_EQ(uA > uB ? uA - uB : uB - uA, resC[i]);
|
||||
@@ -691,6 +725,7 @@ template<typename R> struct TheTest
|
||||
Data<R> resC = v_absdiff(a, b);
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
{
|
||||
SCOPED_TRACE(cv::format("i=%d", i));
|
||||
EXPECT_EQ(dataA[i] > dataB[i] ? dataA[i] - dataB[i] : dataB[i] - dataA[i], resC[i]);
|
||||
}
|
||||
return *this;
|
||||
@@ -744,6 +779,7 @@ template<typename R> struct TheTest
|
||||
Data<R> resF = f;
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
{
|
||||
SCOPED_TRACE(cv::format("i=%d", i));
|
||||
int_type m2 = dataB.as_int(i);
|
||||
EXPECT_EQ((dataD.as_int(i) & m2) | (dataE.as_int(i) & ~m2), resF.as_int(i));
|
||||
}
|
||||
@@ -776,6 +812,7 @@ template<typename R> struct TheTest
|
||||
const w_type add = (w_type)1 << (s - 1);
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
SCOPED_TRACE(cv::format("i=%d", i));
|
||||
EXPECT_EQ(pack_saturate_cast<LaneType>(dataA[i]), resC[i]);
|
||||
EXPECT_EQ(pack_saturate_cast<LaneType>(dataB[i]), resC[i + n]);
|
||||
EXPECT_EQ(pack_saturate_cast<LaneType>((dataA[i] + add) >> s), resD[i]);
|
||||
@@ -816,6 +853,7 @@ template<typename R> struct TheTest
|
||||
const w_type add = (w_type)1 << (s - 1);
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
SCOPED_TRACE(cv::format("i=%d", i));
|
||||
EXPECT_EQ(pack_saturate_cast<LaneType>(dataA[i]), resC[i]);
|
||||
EXPECT_EQ(pack_saturate_cast<LaneType>(dataB[i]), resC[i + n]);
|
||||
EXPECT_EQ(pack_saturate_cast<LaneType>((dataA[i] + add) >> s), resD[i]);
|
||||
@@ -845,6 +883,7 @@ template<typename R> struct TheTest
|
||||
const int n = R::nlanes/2;
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
SCOPED_TRACE(cv::format("i=%d", i));
|
||||
EXPECT_EQ(dataA[i], resC[i*2]);
|
||||
EXPECT_EQ(dataB[i], resC[i*2+1]);
|
||||
EXPECT_EQ(dataA[i+n], resD[i*2]);
|
||||
@@ -876,6 +915,7 @@ template<typename R> struct TheTest
|
||||
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
{
|
||||
SCOPED_TRACE(cv::format("i=%d", i));
|
||||
if (i + s >= R::nlanes)
|
||||
EXPECT_EQ(dataB[i - R::nlanes + s], resC[i]);
|
||||
else
|
||||
@@ -901,6 +941,7 @@ template<typename R> struct TheTest
|
||||
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
{
|
||||
SCOPED_TRACE(cv::format("i=%d", i));
|
||||
if (i + s >= R::nlanes)
|
||||
{
|
||||
EXPECT_EQ((LaneType)0, resC[i]);
|
||||
@@ -940,6 +981,7 @@ template<typename R> struct TheTest
|
||||
|
||||
for (int i = 0; i < R::nlanes; ++i)
|
||||
{
|
||||
SCOPED_TRACE(cv::format("i=%d", i));
|
||||
EXPECT_EQ(cvRound(data1[i]), resB[i]);
|
||||
EXPECT_EQ((typename Ri::lane_type)data1[i], resC[i]);
|
||||
EXPECT_EQ(cvFloor(data1[i]), resD[i]);
|
||||
@@ -964,6 +1006,7 @@ template<typename R> struct TheTest
|
||||
int n = std::min<int>(Rt::nlanes, R::nlanes);
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
SCOPED_TRACE(cv::format("i=%d", i));
|
||||
EXPECT_EQ((typename Rt::lane_type)dataA[i], resB[i]);
|
||||
}
|
||||
return *this;
|
||||
@@ -983,10 +1026,12 @@ template<typename R> struct TheTest
|
||||
int n = std::min<int>(Rt::nlanes, R::nlanes);
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
SCOPED_TRACE(cv::format("i=%d", i));
|
||||
EXPECT_EQ((typename Rt::lane_type)dataA[i], resB[i]);
|
||||
}
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
SCOPED_TRACE(cv::format("i=%d", i));
|
||||
EXPECT_EQ((typename Rt::lane_type)dataA[i+n], resC[i]);
|
||||
}
|
||||
#endif
|
||||
@@ -1006,6 +1051,7 @@ template<typename R> struct TheTest
|
||||
{
|
||||
for (int j = i; j < i + 4; ++j)
|
||||
{
|
||||
SCOPED_TRACE(cv::format("i=%d j=%d", i, j));
|
||||
LaneType val = dataV[i] * dataA[j]
|
||||
+ dataV[i + 1] * dataB[j]
|
||||
+ dataV[i + 2] * dataC[j]
|
||||
@@ -1019,6 +1065,7 @@ template<typename R> struct TheTest
|
||||
{
|
||||
for (int j = i; j < i + 4; ++j)
|
||||
{
|
||||
SCOPED_TRACE(cv::format("i=%d j=%d", i, j));
|
||||
LaneType val = dataV[i] * dataA[j]
|
||||
+ dataV[i + 1] * dataB[j]
|
||||
+ dataV[i + 2] * dataC[j]
|
||||
@@ -1045,6 +1092,7 @@ template<typename R> struct TheTest
|
||||
{
|
||||
for (int j = 0; j < 4; ++j)
|
||||
{
|
||||
SCOPED_TRACE(cv::format("i=%d j=%d", i, j));
|
||||
EXPECT_EQ(dataA[i + j], res[j][i]);
|
||||
EXPECT_EQ(dataB[i + j], res[j][i + 1]);
|
||||
EXPECT_EQ(dataC[i + j], res[j][i + 2]);
|
||||
@@ -1066,6 +1114,7 @@ template<typename R> struct TheTest
|
||||
|
||||
for (int i = 0; i < R::nlanes; i += 4)
|
||||
{
|
||||
SCOPED_TRACE(cv::format("i=%d", i));
|
||||
EXPECT_COMPARE_EQ(dataA.sum(i, 4), res[i]);
|
||||
EXPECT_COMPARE_EQ(dataB.sum(i, 4), res[i + 1]);
|
||||
EXPECT_COMPARE_EQ(dataC.sum(i, 4), res[i + 2]);
|
||||
@@ -1121,7 +1170,304 @@ template<typename R> struct TheTest
|
||||
|
||||
};
|
||||
|
||||
|
||||
#if 1
|
||||
#define DUMP_ENTRY(type) printf("SIMD%d: %s\n", 8*(int)sizeof(v_uint8), CV__TRACE_FUNCTION);
|
||||
#endif
|
||||
|
||||
CV_CPU_OPTIMIZATION_NAMESPACE_END
|
||||
}} // namespace
|
||||
//============= 8-bit integer =====================================================================
|
||||
|
||||
void test_hal_intrin_uint8()
|
||||
{
|
||||
DUMP_ENTRY(v_uint8);
|
||||
TheTest<v_uint8>()
|
||||
.test_loadstore()
|
||||
.test_interleave()
|
||||
.test_expand()
|
||||
.test_expand_q()
|
||||
.test_addsub()
|
||||
.test_addsub_wrap()
|
||||
.test_cmp()
|
||||
.test_logic()
|
||||
.test_min_max()
|
||||
.test_absdiff()
|
||||
.test_mask()
|
||||
.test_popcount()
|
||||
.test_pack<1>().test_pack<2>().test_pack<3>().test_pack<8>()
|
||||
.test_pack_u<1>().test_pack_u<2>().test_pack_u<3>().test_pack_u<8>()
|
||||
.test_unpack()
|
||||
.test_extract<0>().test_extract<1>().test_extract<8>().test_extract<15>()
|
||||
.test_rotate<0>().test_rotate<1>().test_rotate<8>().test_rotate<15>()
|
||||
;
|
||||
|
||||
#if CV_SIMD_WIDTH == 32
|
||||
TheTest<v_uint8>()
|
||||
.test_pack<9>().test_pack<10>().test_pack<13>().test_pack<15>()
|
||||
.test_pack_u<9>().test_pack_u<10>().test_pack_u<13>().test_pack_u<15>()
|
||||
.test_extract<16>().test_extract<17>().test_extract<23>().test_extract<31>()
|
||||
.test_rotate<16>().test_rotate<17>().test_rotate<23>().test_rotate<31>()
|
||||
;
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_hal_intrin_int8()
|
||||
{
|
||||
DUMP_ENTRY(v_int8);
|
||||
TheTest<v_int8>()
|
||||
.test_loadstore()
|
||||
.test_interleave()
|
||||
.test_expand()
|
||||
.test_expand_q()
|
||||
.test_addsub()
|
||||
.test_addsub_wrap()
|
||||
.test_cmp()
|
||||
.test_logic()
|
||||
.test_min_max()
|
||||
.test_absdiff()
|
||||
.test_abs()
|
||||
.test_mask()
|
||||
.test_popcount()
|
||||
.test_pack<1>().test_pack<2>().test_pack<3>().test_pack<8>()
|
||||
.test_unpack()
|
||||
.test_extract<0>().test_extract<1>().test_extract<8>().test_extract<15>()
|
||||
.test_rotate<0>().test_rotate<1>().test_rotate<8>().test_rotate<15>()
|
||||
;
|
||||
}
|
||||
|
||||
//============= 16-bit integer =====================================================================
|
||||
|
||||
void test_hal_intrin_uint16()
|
||||
{
|
||||
DUMP_ENTRY(v_uint16);
|
||||
TheTest<v_uint16>()
|
||||
.test_loadstore()
|
||||
.test_interleave()
|
||||
.test_expand()
|
||||
.test_addsub()
|
||||
.test_addsub_wrap()
|
||||
.test_mul()
|
||||
.test_mul_expand()
|
||||
.test_cmp()
|
||||
.test_shift<1>()
|
||||
.test_shift<8>()
|
||||
.test_logic()
|
||||
.test_min_max()
|
||||
.test_absdiff()
|
||||
.test_reduce()
|
||||
.test_mask()
|
||||
.test_popcount()
|
||||
.test_pack<1>().test_pack<2>().test_pack<7>().test_pack<16>()
|
||||
.test_pack_u<1>().test_pack_u<2>().test_pack_u<7>().test_pack_u<16>()
|
||||
.test_unpack()
|
||||
.test_extract<0>().test_extract<1>().test_extract<4>().test_extract<7>()
|
||||
.test_rotate<0>().test_rotate<1>().test_rotate<4>().test_rotate<7>()
|
||||
;
|
||||
}
|
||||
|
||||
void test_hal_intrin_int16()
|
||||
{
|
||||
DUMP_ENTRY(v_int16);
|
||||
TheTest<v_int16>()
|
||||
.test_loadstore()
|
||||
.test_interleave()
|
||||
.test_expand()
|
||||
.test_addsub()
|
||||
.test_addsub_wrap()
|
||||
.test_mul()
|
||||
.test_mul_expand()
|
||||
.test_cmp()
|
||||
.test_shift<1>()
|
||||
.test_shift<8>()
|
||||
.test_dot_prod()
|
||||
.test_logic()
|
||||
.test_min_max()
|
||||
.test_absdiff()
|
||||
.test_abs()
|
||||
.test_reduce()
|
||||
.test_mask()
|
||||
.test_popcount()
|
||||
.test_pack<1>().test_pack<2>().test_pack<7>().test_pack<16>()
|
||||
.test_unpack()
|
||||
.test_extract<0>().test_extract<1>().test_extract<4>().test_extract<7>()
|
||||
.test_rotate<0>().test_rotate<1>().test_rotate<4>().test_rotate<7>()
|
||||
;
|
||||
}
|
||||
|
||||
//============= 32-bit integer =====================================================================
|
||||
|
||||
void test_hal_intrin_uint32()
|
||||
{
|
||||
DUMP_ENTRY(v_uint32);
|
||||
TheTest<v_uint32>()
|
||||
.test_loadstore()
|
||||
.test_interleave()
|
||||
.test_expand()
|
||||
.test_addsub()
|
||||
.test_mul()
|
||||
.test_mul_expand()
|
||||
.test_cmp()
|
||||
.test_shift<1>()
|
||||
.test_shift<8>()
|
||||
.test_logic()
|
||||
.test_min_max()
|
||||
.test_absdiff()
|
||||
.test_reduce()
|
||||
.test_mask()
|
||||
.test_popcount()
|
||||
.test_pack<1>().test_pack<2>().test_pack<15>().test_pack<32>()
|
||||
.test_unpack()
|
||||
.test_extract<0>().test_extract<1>().test_extract<2>().test_extract<3>()
|
||||
.test_rotate<0>().test_rotate<1>().test_rotate<2>().test_rotate<3>()
|
||||
.test_transpose()
|
||||
;
|
||||
}
|
||||
|
||||
void test_hal_intrin_int32()
|
||||
{
|
||||
DUMP_ENTRY(v_int32);
|
||||
TheTest<v_int32>()
|
||||
.test_loadstore()
|
||||
.test_interleave()
|
||||
.test_expand()
|
||||
.test_addsub()
|
||||
.test_mul()
|
||||
.test_abs()
|
||||
.test_cmp()
|
||||
.test_popcount()
|
||||
.test_shift<1>().test_shift<8>()
|
||||
.test_logic()
|
||||
.test_min_max()
|
||||
.test_absdiff()
|
||||
.test_reduce()
|
||||
.test_mask()
|
||||
.test_pack<1>().test_pack<2>().test_pack<15>().test_pack<32>()
|
||||
.test_unpack()
|
||||
.test_extract<0>().test_extract<1>().test_extract<2>().test_extract<3>()
|
||||
.test_rotate<0>().test_rotate<1>().test_rotate<2>().test_rotate<3>()
|
||||
.test_float_cvt32()
|
||||
.test_float_cvt64()
|
||||
.test_transpose()
|
||||
;
|
||||
}
|
||||
|
||||
//============= 64-bit integer =====================================================================
|
||||
|
||||
void test_hal_intrin_uint64()
|
||||
{
|
||||
DUMP_ENTRY(v_uint64);
|
||||
TheTest<v_uint64>()
|
||||
.test_loadstore()
|
||||
.test_addsub()
|
||||
.test_shift<1>().test_shift<8>()
|
||||
.test_logic()
|
||||
.test_extract<0>().test_extract<1>()
|
||||
.test_rotate<0>().test_rotate<1>()
|
||||
;
|
||||
}
|
||||
|
||||
void test_hal_intrin_int64()
|
||||
{
|
||||
DUMP_ENTRY(v_int64);
|
||||
TheTest<v_int64>()
|
||||
.test_loadstore()
|
||||
.test_addsub()
|
||||
.test_shift<1>().test_shift<8>()
|
||||
.test_logic()
|
||||
.test_extract<0>().test_extract<1>()
|
||||
.test_rotate<0>().test_rotate<1>()
|
||||
;
|
||||
}
|
||||
|
||||
//============= Floating point =====================================================================
|
||||
void test_hal_intrin_float32()
|
||||
{
|
||||
DUMP_ENTRY(v_float32);
|
||||
TheTest<v_float32>()
|
||||
.test_loadstore()
|
||||
.test_interleave()
|
||||
.test_interleave_2channel()
|
||||
.test_addsub()
|
||||
.test_mul()
|
||||
.test_div()
|
||||
.test_cmp()
|
||||
.test_sqrt_abs()
|
||||
.test_min_max()
|
||||
.test_float_absdiff()
|
||||
.test_reduce()
|
||||
.test_mask()
|
||||
.test_unpack()
|
||||
.test_float_math()
|
||||
.test_float_cvt64()
|
||||
.test_matmul()
|
||||
.test_transpose()
|
||||
.test_reduce_sum4()
|
||||
.test_extract<0>().test_extract<1>().test_extract<2>().test_extract<3>()
|
||||
.test_rotate<0>().test_rotate<1>().test_rotate<2>().test_rotate<3>()
|
||||
;
|
||||
|
||||
#if CV_SIMD_WIDTH == 32
|
||||
TheTest<v_float32>()
|
||||
.test_extract<4>().test_extract<5>().test_extract<6>().test_extract<7>()
|
||||
.test_rotate<4>().test_rotate<5>().test_rotate<6>().test_rotate<7>()
|
||||
;
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_hal_intrin_float64()
|
||||
{
|
||||
DUMP_ENTRY(v_float64);
|
||||
#if CV_SIMD_64F
|
||||
TheTest<v_float64>()
|
||||
.test_loadstore()
|
||||
.test_addsub()
|
||||
.test_mul()
|
||||
.test_div()
|
||||
.test_cmp()
|
||||
.test_sqrt_abs()
|
||||
.test_min_max()
|
||||
.test_float_absdiff()
|
||||
.test_mask()
|
||||
.test_unpack()
|
||||
.test_float_math()
|
||||
.test_float_cvt32()
|
||||
.test_extract<0>().test_extract<1>()
|
||||
.test_rotate<0>().test_rotate<1>()
|
||||
;
|
||||
|
||||
#if CV_SIMD_WIDTH == 32
|
||||
TheTest<v_float64>()
|
||||
.test_extract<2>().test_extract<3>()
|
||||
.test_rotate<2>().test_rotate<3>()
|
||||
;
|
||||
#endif //CV_SIMD256
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
#if CV_FP16
|
||||
void test_hal_intrin_float16()
|
||||
{
|
||||
DUMP_ENTRY(v_float16);
|
||||
#if CV_SIMD_WIDTH > 16
|
||||
TheTest<v_float16>()
|
||||
.test_loadstore_fp16()
|
||||
.test_float_cvt_fp16()
|
||||
;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/*#if defined(CV_CPU_DISPATCH_MODE_FP16) && CV_CPU_DISPATCH_MODE == FP16
|
||||
void test_hal_intrin_float16()
|
||||
{
|
||||
TheTest<v_float16>()
|
||||
.test_loadstore_fp16()
|
||||
.test_float_cvt_fp16()
|
||||
;
|
||||
}
|
||||
#endif*/
|
||||
|
||||
#endif //CV_CPU_OPTIMIZATION_DECLARATIONS_ONLY
|
||||
|
||||
//CV_CPU_OPTIMIZATION_NAMESPACE_END
|
||||
//}}} // namespace
|
||||
|
||||
@@ -1814,4 +1814,62 @@ BIGDATA_TEST(Mat, push_back_regression_4158) // memory usage: ~10.6 Gb
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TEST(Core_Merge, hang_12171)
|
||||
{
|
||||
Mat src1(4, 24, CV_8UC1, Scalar::all(1));
|
||||
Mat src2(4, 24, CV_8UC1, Scalar::all(2));
|
||||
Rect src_roi(0, 0, 23, 4);
|
||||
Mat src_channels[2] = { src1(src_roi), src2(src_roi) };
|
||||
Mat dst(4, 24, CV_8UC2, Scalar::all(5));
|
||||
Rect dst_roi(1, 0, 23, 4);
|
||||
cv::merge(src_channels, 2, dst(dst_roi));
|
||||
EXPECT_EQ(5, dst.ptr<uchar>()[0]);
|
||||
EXPECT_EQ(5, dst.ptr<uchar>()[1]);
|
||||
EXPECT_EQ(1, dst.ptr<uchar>()[2]);
|
||||
EXPECT_EQ(2, dst.ptr<uchar>()[3]);
|
||||
EXPECT_EQ(5, dst.ptr<uchar>(1)[0]);
|
||||
EXPECT_EQ(5, dst.ptr<uchar>(1)[1]);
|
||||
EXPECT_EQ(1, dst.ptr<uchar>(1)[2]);
|
||||
EXPECT_EQ(2, dst.ptr<uchar>(1)[3]);
|
||||
}
|
||||
|
||||
TEST(Core_Split, hang_12171)
|
||||
{
|
||||
Mat src(4, 24, CV_8UC2, Scalar(1,2,3,4));
|
||||
Rect src_roi(0, 0, 23, 4);
|
||||
Mat dst1(4, 24, CV_8UC1, Scalar::all(5));
|
||||
Mat dst2(4, 24, CV_8UC1, Scalar::all(10));
|
||||
Rect dst_roi(0, 0, 23, 4);
|
||||
Mat dst[2] = { dst1(dst_roi), dst2(dst_roi) };
|
||||
cv::split(src(src_roi), dst);
|
||||
EXPECT_EQ(1, dst1.ptr<uchar>()[0]);
|
||||
EXPECT_EQ(1, dst1.ptr<uchar>()[1]);
|
||||
EXPECT_EQ(2, dst2.ptr<uchar>()[0]);
|
||||
EXPECT_EQ(2, dst2.ptr<uchar>()[1]);
|
||||
EXPECT_EQ(1, dst1.ptr<uchar>(1)[0]);
|
||||
EXPECT_EQ(1, dst1.ptr<uchar>(1)[1]);
|
||||
EXPECT_EQ(2, dst2.ptr<uchar>(1)[0]);
|
||||
EXPECT_EQ(2, dst2.ptr<uchar>(1)[1]);
|
||||
}
|
||||
|
||||
TEST(Core_Split, crash_12171)
|
||||
{
|
||||
Mat src(4, 40, CV_8UC2, Scalar(1,2,3,4));
|
||||
Rect src_roi(0, 0, 39, 4);
|
||||
Mat dst1(4, 40, CV_8UC1, Scalar::all(5));
|
||||
Mat dst2(4, 40, CV_8UC1, Scalar::all(10));
|
||||
Rect dst_roi(0, 0, 39, 4);
|
||||
Mat dst[2] = { dst1(dst_roi), dst2(dst_roi) };
|
||||
cv::split(src(src_roi), dst);
|
||||
EXPECT_EQ(1, dst1.ptr<uchar>()[0]);
|
||||
EXPECT_EQ(1, dst1.ptr<uchar>()[1]);
|
||||
EXPECT_EQ(2, dst2.ptr<uchar>()[0]);
|
||||
EXPECT_EQ(2, dst2.ptr<uchar>()[1]);
|
||||
EXPECT_EQ(1, dst1.ptr<uchar>(1)[0]);
|
||||
EXPECT_EQ(1, dst1.ptr<uchar>(1)[1]);
|
||||
EXPECT_EQ(2, dst2.ptr<uchar>(1)[0]);
|
||||
EXPECT_EQ(2, dst2.ptr<uchar>(1)[1]);
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
|
||||
@@ -11,6 +11,5 @@
|
||||
#include "opencv2/core/cvdef.h"
|
||||
#include "opencv2/core/private.hpp"
|
||||
#include "opencv2/core/hal/hal.hpp"
|
||||
#include "opencv2/core/hal/intrin.hpp"
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user