From 8dc332721ffce54c750f1a259690cc36c2b126b5 Mon Sep 17 00:00:00 2001 From: HAN Liutong Date: Wed, 17 Aug 2022 14:39:23 +0000 Subject: [PATCH] Add testcases for interleave_p&q and enable others testcases. --- modules/core/test/test_intrin_utils.hpp | 120 +++++++++++++++++------- 1 file changed, 87 insertions(+), 33 deletions(-) diff --git a/modules/core/test/test_intrin_utils.hpp b/modules/core/test/test_intrin_utils.hpp index 4af3998c3e..cb6ac5d901 100644 --- a/modules/core/test/test_intrin_utils.hpp +++ b/modules/core/test/test_intrin_utils.hpp @@ -503,6 +503,38 @@ template struct TheTest return *this; } + TheTest & test_interleave_pq() + { + Data dataA; + R a = dataA; + Data resP = v_interleave_pairs(a); + Data resQ = v_interleave_quads(a); + for (int i = 0; i < VTraits::vlanes()/4; ++i) + { + SCOPED_TRACE(cv::format("i=%d", i)); + EXPECT_EQ(resP[4*i], dataA[4*i ]); + EXPECT_EQ(resP[4*i + 1], dataA[4*i+2]); + EXPECT_EQ(resP[4*i + 2], dataA[4*i+1]); + EXPECT_EQ(resP[4*i + 3], dataA[4*i+3]); + } + for (int i = 0; i < VTraits::vlanes(); ++i) + { + printf("%d%s", (int)resQ[i], i == VTraits::vlanes()-1 ? "\n" : " "); + } + for (int i = 0; i < VTraits::vlanes()/8; ++i) + { + SCOPED_TRACE(cv::format("i=%d", i)); + EXPECT_EQ(resQ[8*i], dataA[8*i ]); + EXPECT_EQ(resQ[8*i + 1], dataA[8*i+4]); + EXPECT_EQ(resQ[8*i + 2], dataA[8*i+1]); + EXPECT_EQ(resQ[8*i + 3], dataA[8*i+5]); + EXPECT_EQ(resQ[8*i + 4], dataA[8*i+2]); + EXPECT_EQ(resQ[8*i + 5], dataA[8*i+6]); + EXPECT_EQ(resQ[8*i + 6], dataA[8*i+3]); + EXPECT_EQ(resQ[8*i + 7], dataA[8*i+7]); + } + return *this; + } // float32x4 only TheTest & test_interleave_2channel() @@ -1577,19 +1609,27 @@ template struct TheTest v_transpose4x4(a, b, c, d, e, f, g, h); - Data res[4] = {e, f, g, h}; - // for (int i = 0; i < VTraits::vlanes(); i += 4) - // { - int i = 0; - 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]); - EXPECT_EQ(dataD[i + j], res[j][i + 3]); - } - // } + // Data res[4] = {e, f, g, h}; // Generates incorrect data in certain RVV case. + Data res0 = e, res1 = f, res2 = g, res3 = h; + EXPECT_EQ(dataA[0], res0[0]); + EXPECT_EQ(dataB[0], res0[1]); + EXPECT_EQ(dataC[0], res0[2]); + EXPECT_EQ(dataD[0], res0[3]); + + EXPECT_EQ(dataA[1], res1[0]); + EXPECT_EQ(dataB[1], res1[1]); + EXPECT_EQ(dataC[1], res1[2]); + EXPECT_EQ(dataD[1], res1[3]); + + EXPECT_EQ(dataA[2], res2[0]); + EXPECT_EQ(dataB[2], res2[1]); + EXPECT_EQ(dataC[2], res2[2]); + EXPECT_EQ(dataD[2], res2[3]); + + EXPECT_EQ(dataA[3], res3[0]); + EXPECT_EQ(dataB[3], res3[1]); + EXPECT_EQ(dataC[3], res3[2]); + EXPECT_EQ(dataD[3], res3[3]); return *this; } @@ -1741,6 +1781,7 @@ void test_hal_intrin_uint8() // typedef v_uint8 R; TheTest() .test_loadstore() + .test_interleave_pq() .test_expand() .test_expand_q() .test_addsub() @@ -1755,6 +1796,8 @@ void test_hal_intrin_uint8() .test_rotate<0>().test_rotate<1>().test_rotate<8>().test_rotate<15>() .test_extract_n<0>().test_extract_n<1>() .test_extract_highest() + .test_unpack() + .test_reverse() #if 0 // not implemented in rvv backend yet. .test_interleave() .test_cmp() @@ -1764,8 +1807,6 @@ void test_hal_intrin_uint8() .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_pack_b() - .test_unpack() - .test_reverse() .test_popcount() #endif ; @@ -1777,6 +1818,7 @@ void test_hal_intrin_int8() // typedef v_int8 R; TheTest() .test_loadstore() + .test_interleave_pq() .test_expand() .test_expand_q() .test_addsub() @@ -1793,6 +1835,8 @@ void test_hal_intrin_int8() .test_rotate<0>().test_rotate<1>().test_rotate<8>().test_rotate<15>() .test_extract_n<0>().test_extract_n<1>() .test_extract_highest() + .test_unpack() + .test_reverse() #if 0 .test_interleave() .test_cmp() @@ -1800,8 +1844,6 @@ void test_hal_intrin_int8() .test_reduce() .test_reduce_sad() .test_pack<1>().test_pack<2>().test_pack<3>().test_pack<8>() - .test_unpack() - .test_reverse() .test_popcount() #endif ; @@ -1815,6 +1857,7 @@ void test_hal_intrin_uint16() // typedef v_uint16 R; TheTest() .test_loadstore() + .test_interleave_pq() .test_expand() .test_addsub() .test_arithm_wrap() @@ -1831,6 +1874,8 @@ void test_hal_intrin_uint16() .test_rotate<0>().test_rotate<1>().test_rotate<4>().test_rotate<7>() .test_extract_n<0>().test_extract_n<1>() .test_extract_highest() + .test_unpack() + .test_reverse() #if 0 .test_interleave() .test_cmp() @@ -1839,8 +1884,6 @@ void test_hal_intrin_uint16() .test_reduce_sad() .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_reverse() .test_popcount() #endif ; @@ -1852,6 +1895,7 @@ void test_hal_intrin_int16() // typedef v_int16 R; TheTest() .test_loadstore() + .test_interleave_pq() .test_expand() .test_addsub() .test_arithm_wrap() @@ -1870,6 +1914,8 @@ void test_hal_intrin_int16() .test_rotate<0>().test_rotate<1>().test_rotate<4>().test_rotate<7>() .test_extract_n<0>().test_extract_n<1>() .test_extract_highest() + .test_unpack() + .test_reverse() #if 0 .test_interleave() @@ -1879,8 +1925,6 @@ void test_hal_intrin_int16() .test_reduce() .test_reduce_sad() .test_pack<1>().test_pack<2>().test_pack<7>().test_pack<16>() - .test_unpack() - .test_reverse() .test_popcount() #endif ; @@ -1894,6 +1938,7 @@ void test_hal_intrin_uint32() // typedef v_uint32 R; TheTest() .test_loadstore() + .test_interleave_pq() .test_expand() .test_addsub() .test_mul() @@ -1910,15 +1955,15 @@ void test_hal_intrin_uint32() .test_broadcast_element<0>().test_broadcast_element<1>() .test_extract_highest() .test_broadcast_highest() + .test_unpack() + .test_transpose() + .test_reverse() #if 0 .test_interleave() .test_cmp() .test_reduce() .test_reduce_sad() .test_pack<1>().test_pack<2>().test_pack<15>().test_pack<32>() - .test_unpack() - .test_reverse() - .test_transpose() .test_popcount() #endif ; @@ -1930,6 +1975,7 @@ void test_hal_intrin_int32() // typedef v_int32 R; TheTest() .test_loadstore() + .test_interleave_pq() .test_expand() .test_addsub() .test_mul() @@ -1946,6 +1992,9 @@ void test_hal_intrin_int32() .test_broadcast_element<0>().test_broadcast_element<1>() .test_extract_highest() .test_broadcast_highest() + .test_unpack() + .test_transpose() + .test_reverse() #if 0 .test_interleave() .test_cmp() @@ -1953,11 +2002,8 @@ void test_hal_intrin_int32() .test_reduce() .test_reduce_sad() .test_pack<1>().test_pack<2>().test_pack<15>().test_pack<32>() - .test_unpack() - .test_reverse() .test_float_cvt32() .test_float_cvt64() - .test_transpose() .test_popcount() #endif ; @@ -1978,12 +2024,12 @@ void test_hal_intrin_uint64() .test_rotate<0>().test_rotate<1>() .test_extract_n<0>().test_extract_n<1>() .test_extract_highest() + .test_reverse() ; #if 0 #if CV_SIMD_64F .test_cmp64() #endif - .test_reverse() #endif } @@ -2001,12 +2047,12 @@ void test_hal_intrin_int64() .test_extract_n<0>().test_extract_n<1>() .test_extract_highest() .test_cvt64_double() + .test_reverse() ; #if 0 #if CV_SIMD_64F .test_cmp64() #endif - .test_reverse() #endif } @@ -2017,6 +2063,7 @@ void test_hal_intrin_float32() // typedef v_float32 R; TheTest() .test_loadstore() + .test_interleave_pq() .test_addsub() .test_abs() .test_mul() @@ -2031,18 +2078,18 @@ void test_hal_intrin_float32() .test_broadcast_element<0>().test_broadcast_element<1>() .test_extract_highest() .test_broadcast_highest() + .test_unpack() + .test_transpose() + .test_reverse() #if 0 .test_interleave() .test_interleave_2channel() .test_cmp() .test_reduce() .test_reduce_sad() - .test_unpack() .test_float_math() .test_float_cvt64() .test_matmul() - .test_transpose() - .test_reverse() .test_reduce_sum4() #endif ; @@ -2067,12 +2114,12 @@ void test_hal_intrin_float64() .test_rotate<0>().test_rotate<1>() .test_extract_n<0>().test_extract_n<1>() .test_extract_highest() + .test_reverse() #if 0 .test_cmp() .test_unpack() .test_float_cvt32() .test_float_math() - .test_reverse() #endif ; @@ -2091,6 +2138,7 @@ void test_hal_intrin_uint8() TheTest() .test_loadstore() .test_interleave() + .test_interleave_pq() .test_expand() .test_expand_q() .test_addsub() @@ -2132,6 +2180,7 @@ void test_hal_intrin_int8() TheTest() .test_loadstore() .test_interleave() + .test_interleave_pq() .test_expand() .test_expand_q() .test_addsub() @@ -2169,6 +2218,7 @@ void test_hal_intrin_uint16() TheTest() .test_loadstore() .test_interleave() + .test_interleave_pq() .test_expand() .test_addsub() .test_arithm_wrap() @@ -2205,6 +2255,7 @@ void test_hal_intrin_int16() TheTest() .test_loadstore() .test_interleave() + .test_interleave_pq() .test_expand() .test_addsub() .test_arithm_wrap() @@ -2245,6 +2296,7 @@ void test_hal_intrin_uint32() TheTest() .test_loadstore() .test_interleave() + // .test_interleave_pq() //not implemented in AVX .test_expand() .test_addsub() .test_mul() @@ -2279,6 +2331,7 @@ void test_hal_intrin_int32() TheTest() .test_loadstore() .test_interleave() + // .test_interleave_pq() //not implemented in AVX .test_expand() .test_addsub() .test_mul() @@ -2363,6 +2416,7 @@ void test_hal_intrin_float32() .test_loadstore() .test_interleave() .test_interleave_2channel() + // .test_interleave_pq() //not implemented in AVX .test_addsub() .test_mul() .test_div()