diff --git a/adapters/opencv/kleidicv_hal.cpp b/adapters/opencv/kleidicv_hal.cpp index 7c98dd0fea0ed255a623bca1f0aaa378be6c07dc..cea5dd4afd00a70a0b2765d6527e8a31861e2081 100644 --- a/adapters/opencv/kleidicv_hal.cpp +++ b/adapters/opencv/kleidicv_hal.cpp @@ -677,7 +677,6 @@ int convertTo(const uchar *src_data, size_t src_step, int src_depth, reinterpret_cast(dst_data), dst_step, width, height, static_cast(scale), static_cast(shift))); } - return CV_HAL_ERROR_NOT_IMPLEMENTED; } // type conversion only diff --git a/conformity/opencv/test_float_conv.cpp b/conformity/opencv/test_float_conv.cpp index 6b3abfe68b0020af794f69397d5e98e0977f0b7b..73baa077410ee3704f686d2e8eaafb2c46fbc27f 100644 --- a/conformity/opencv/test_float_conv.cpp +++ b/conformity/opencv/test_float_conv.cpp @@ -6,30 +6,30 @@ #include -float floatval_(uint32_t v) { +float floatval(uint32_t v) { static_assert(sizeof(float) == 4); return *reinterpret_cast(&v); } -float quietNaN = floatval_(0x7FC00000); -float signalingNaN = floatval_(0x7FA00000); -float posInfinity = floatval_(0x7F800000); -float negInfinity = floatval_(0xFF800000); +float quietNaN = floatval(0x7FC00000); +float signalingNaN = floatval(0x7FA00000); +float posInfinity = floatval(0x7F800000); +float negInfinity = floatval(0xFF800000); -float minusNaN = floatval_(0xFF800001); -float plusNaN = floatval_(0x7F800001); -float plusZero = floatval_(0x00000000); -float minusZero = floatval_(0x80000000); +float minusNaN = floatval(0xFF800001); +float plusNaN = floatval(0x7F800001); +float plusZero = floatval(0x00000000); +float minusZero = floatval(0x80000000); -float oneNaN = floatval_(0x7FC00001); -float zeroDivZero = floatval_(0xFFC00000); -float floatMin = floatval_(0x00800000); -float floatMax = floatval_(0x7F7FFFFF); +float oneNaN = floatval(0x7FC00001); +float zeroDivZero = floatval(0xFFC00000); +float floatMin = floatval(0x00800000); +float floatMax = floatval(0x7F7FFFFF); -float posSubnormalMin = floatval_(0x00000001); -float posSubnormalMax = floatval_(0x007FFFFF); -float negSubnormalMin = floatval_(0x80000001); -float negSubnormalMax = floatval_(0x807FFFFF); +float posSubnormalMin = floatval(0x00000001); +float posSubnormalMax = floatval(0x007FFFFF); +float negSubnormalMin = floatval(0x80000001); +float negSubnormalMax = floatval(0x807FFFFF); template cv::Mat exec_float32_to_int8(cv::Mat& input) { @@ -95,53 +95,45 @@ bool test_int8_to_float32_random(int index, return false; } -static constexpr int custom_data_height = 8; -static constexpr int custom_data_width = 4; - -static float custom_data_float[custom_data_height * custom_data_width] = { - // clang-format off - quietNaN, signalingNaN, posInfinity, negInfinity, - minusNaN, plusNaN, plusZero, minusZero, - oneNaN, zeroDivZero, floatMin, floatMax, - posSubnormalMin, posSubnormalMax, negSubnormalMin, negSubnormalMax, - 1111.11, -1112.22, 113.33, 114.44, - 111.51, 112.62, 113.73, 114.84, - 126.66, 127.11, 128.66, 129.11, - 11.5, 12.5, -11.5, -12.5, - // clang-format on +static constexpr int custom_data_float_height = 8; +static constexpr int custom_data_float_width = 4; + +static float + custom_data_float[custom_data_float_height * custom_data_float_width] = { + // clang-format off + quietNaN, signalingNaN, posInfinity, negInfinity, + minusNaN, plusNaN, plusZero, minusZero, + oneNaN, zeroDivZero, floatMin, floatMax, + posSubnormalMin, posSubnormalMax, negSubnormalMin, negSubnormalMax, + 1111.11, -1112.22, 113.33, 114.44, + 111.51, 112.62, 113.73, 114.84, + 126.66, 127.11, 128.66, 129.11, + 11.5, 12.5, -11.5, -12.5, + // clang-format on }; -static int8_t custom_data_int8[custom_data_height * custom_data_width] = { - // clang-format off - -128, -128, 126, 127, - -128, -128, -128, -128, - -128, -128, -128, 126, - -127, -127, -127, 125, - 126, 127, 113, 114, - 112, 113, 114, 115, - 12, 12, 12, 12, - 11, 11, 11, 11, - // clang-format on +static constexpr int custom_data_int8_height = 1; +static constexpr int custom_data_int8_width = 7; + +static int8_t + custom_data_int8[custom_data_int8_height * custom_data_int8_width] = { + // clang-format off + -128, -127, -1, 0, 1, 126, 127 + // clang-format on }; -static uint8_t custom_data_uint8[custom_data_height * custom_data_width] = { - // clang-format off - 0, 0, 254, 255, - 0, 0, 0, 0, - 0, 0, 0, 254, - 1, 1, 1, 253, - 254, 255, 113, 114, - 112, 113, 114, 115, - 12, 12, 12, 12, - 11, 11, 11, 11, - // clang-format on +static uint8_t + custom_data_uint8[custom_data_int8_height * custom_data_int8_width] = { + // clang-format off + 0, 1, 126, 127, 128, 254, 255 + // clang-format on }; template bool test_float32_to_int8_custom(int index, RecreatedMessageQueue& request_queue, RecreatedMessageQueue& reply_queue) { - cv::Mat input(custom_data_height, custom_data_width, CV_32FC1, + cv::Mat input(custom_data_float_height, custom_data_float_width, CV_32FC1, custom_data_float); cv::Mat actual = exec_float32_to_int8(input); @@ -149,8 +141,8 @@ bool test_float32_to_int8_custom(int index, get_expected_from_subordinate(index, request_queue, reply_queue, input); if (are_matrices_different(0, actual, expected)) { - fail_print_matrices(custom_data_height, custom_data_width, input, actual, - expected); + fail_print_matrices(custom_data_float_height, custom_data_float_width, + input, actual, expected); return true; } @@ -161,7 +153,7 @@ template bool test_int8_to_float32_custom(int index, RecreatedMessageQueue& request_queue, RecreatedMessageQueue& reply_queue) { - cv::Mat input(custom_data_height, custom_data_width, + cv::Mat input(custom_data_int8_height, custom_data_int8_width, Signed ? CV_8SC1 : CV_8UC1, Signed ? static_cast(custom_data_int8) : static_cast(custom_data_uint8)); @@ -171,8 +163,8 @@ bool test_int8_to_float32_custom(int index, get_expected_from_subordinate(index, request_queue, reply_queue, input); if (are_matrices_different(0, actual, expected)) { - fail_print_matrices(custom_data_height, custom_data_width, input, actual, - expected); + fail_print_matrices(custom_data_int8_height, custom_data_int8_width, input, + actual, expected); return true; } @@ -180,7 +172,7 @@ bool test_int8_to_float32_custom(int index, } #endif -std::vector& float_conversion_tests_singleton() { +std::vector& float_conversion_tests_get() { // clang-format off static std::vector tests = { TEST("Float32 to Signed Int8, fill, 1 channel", (test_float32_to_int8_random), exec_float32_to_int8), @@ -206,8 +198,8 @@ std::vector& float_conversion_tests_singleton() { TEST("Unsigned Int8 to Float32, fill, 3 channel", (test_int8_to_float32_random), exec_int8_to_float32), TEST("Unsigned Int8 to Float32, fill, 4 channel", (test_int8_to_float32_random), exec_int8_to_float32), - TEST("Signed Int8 Float32, custom (special)", test_int8_to_float32_custom, exec_int8_to_float32), - TEST("Unigned Int8 Float32, custom (special)", test_int8_to_float32_custom, exec_int8_to_float32), + TEST("Signed Int8 Float32, custom", test_int8_to_float32_custom, exec_int8_to_float32), + TEST("Unigned Int8 Float32, custom", test_int8_to_float32_custom, exec_int8_to_float32), }; // clang-format on return tests; diff --git a/conformity/opencv/test_float_conv.h b/conformity/opencv/test_float_conv.h index 1b98d9820666b185ba337b9ee87ce0b090566eb7..9e4c40be6f28f9d49e2ca3e525ce3fd6c395b094 100644 --- a/conformity/opencv/test_float_conv.h +++ b/conformity/opencv/test_float_conv.h @@ -9,6 +9,6 @@ #include "tests.h" -std::vector& float_conversion_tests_singleton(); +std::vector& float_conversion_tests_get(); #endif // KLEIDICV_OPENCV_CONFORMITY_TEST_FLOAT_CONV_H_ diff --git a/conformity/opencv/test_gaussian_blur.cpp b/conformity/opencv/test_gaussian_blur.cpp index 27ae51e2d6952b11cc07799d1a9215bc6e3b875a..87dd565dc9342224c33d44d309fd5a5dbf0ed25f 100644 --- a/conformity/opencv/test_gaussian_blur.cpp +++ b/conformity/opencv/test_gaussian_blur.cpp @@ -40,7 +40,7 @@ bool test_gaussian_blur(int index, RecreatedMessageQueue& request_queue, } #endif -std::vector& gaussian_blur_tests_singleton() { +std::vector& gaussian_blur_tests_get() { // clang-format off static std::vector tests = { TEST("Gaussian blur 3x3, BORDER_REFLECT_101, 1 channel", (test_gaussian_blur<3, cv::BORDER_REFLECT_101, 1>), (exec_gaussian_blur<3, cv::BORDER_REFLECT_101>)), diff --git a/conformity/opencv/test_gaussian_blur.h b/conformity/opencv/test_gaussian_blur.h index 0756ca4fd3d702c793cc5b071972da29f3ea5331..ddc045ed244b066c772ef147cf6b8e7d5fd3b96f 100644 --- a/conformity/opencv/test_gaussian_blur.h +++ b/conformity/opencv/test_gaussian_blur.h @@ -9,6 +9,6 @@ #include "tests.h" -std::vector& gaussian_blur_tests_singleton(); +std::vector& gaussian_blur_tests_get(); #endif // KLEIDICV_OPENCV_CONFORMITY_TEST_GAUSSIAN_BLUR_H_ diff --git a/conformity/opencv/test_sobel.cpp b/conformity/opencv/test_sobel.cpp index a87143aa0aa62e41a01cc0224fd9defbafe809f2..473e153a651526b259a2c64889bf46bd233f205a 100644 --- a/conformity/opencv/test_sobel.cpp +++ b/conformity/opencv/test_sobel.cpp @@ -43,7 +43,7 @@ bool test_sobel(int index, RecreatedMessageQueue& request_queue, } #endif -std::vector& sobel_tests_singleton() { +std::vector& sobel_tests_get() { // clang-format off static std::vector tests = { TEST("Sobel Vertical, 1 channel", (test_sobel), exec_sobel), diff --git a/conformity/opencv/test_sobel.h b/conformity/opencv/test_sobel.h index 6c2bb8b45b89b2ff002d51530cae153f3600a295..131fb38500338ca7451e044e76a7ecb421a55072 100644 --- a/conformity/opencv/test_sobel.h +++ b/conformity/opencv/test_sobel.h @@ -9,6 +9,6 @@ #include "tests.h" -std::vector& sobel_tests_singleton(); +std::vector& sobel_tests_get(); #endif // KLEIDICV_OPENCV_CONFORMITY_TEST_SOBEL_H_ diff --git a/conformity/opencv/tests.cpp b/conformity/opencv/tests.cpp index 596282bfbd15c69fb601fb58be07353db4988544..0fe97db16ad4c84388d2c4efebc79ec400332504 100644 --- a/conformity/opencv/tests.cpp +++ b/conformity/opencv/tests.cpp @@ -14,6 +14,22 @@ #include "test_gaussian_blur.h" #include "test_sobel.h" +static std::vector merge_tests( + std::initializer_list& (*)()> test_groups) { + std::vector all_tests; + for (auto getter : test_groups) { + std::vector& group = getter(); + all_tests.insert(all_tests.cend(), group.cbegin(), group.cend()); + } + return all_tests; +} + +std::vector all_tests = merge_tests({ + sobel_tests_get, + gaussian_blur_tests_get, + float_conversion_tests_get, +}); + #if MANAGER void fail_print_matrices(size_t height, size_t width, cv::Mat& input, cv::Mat& manager_result, cv::Mat& subord_result) { @@ -42,23 +58,6 @@ cv::Mat get_expected_from_subordinate(int index, } #endif -template -static std::vector merge_tests( - std::initializer_list& (*)()> test_groups) { - std::vector all_tests; - for (auto singleton : test_groups) { - std::vector& group = singleton(); - all_tests.insert(all_tests.cend(), group.cbegin(), group.cend()); - } - return all_tests; -} - -std::vector all_tests = merge_tests({ - sobel_tests_singleton, - gaussian_blur_tests_singleton, - float_conversion_tests_singleton, -}); - #if MANAGER int run_tests(RecreatedMessageQueue& request_queue, RecreatedMessageQueue& reply_queue) { diff --git a/kleidicv/include/kleidicv/kleidicv.h b/kleidicv/include/kleidicv/kleidicv.h index f08c492f938cd4bef54e93555728ddd444ef6c8d..19297bd0e36e6d02bcacce9b05e9c34508447f1b 100644 --- a/kleidicv/include/kleidicv/kleidicv.h +++ b/kleidicv/include/kleidicv/kleidicv.h @@ -1255,7 +1255,7 @@ KLEIDICV_API_DECLARATION(kleidicv_scale_u8, const uint8_t *src, /// /// Each resulting element is saturated, i.e. it is the smallest/largest /// number of the type of the element if the `src` data type cannot be -/// represented as the `dst` type. In case of special values, such as the +/// represented as the `dst` type. In case of some special values, such as the /// different variations of `NaN`, the result is `0`. Source and destination /// data length is `width` * `height`. Number of elements is limited to @ref /// KLEIDICV_MAX_IMAGE_PIXELS. @@ -1284,8 +1284,8 @@ KLEIDICV_API_DECLARATION(kleidicv_float_conversion_f32_u8, const float *src, /// /// Each resulting element is saturated, i.e. it is the smallest/largest /// number of the type of the element if the `src` data type cannot be -/// represented as the `dst` type. Source and destination data length is `width` -/// * `height`. Number of elements is limited to @ref +/// represented as the `dst` type. Source and destination data length is +/// `width` * `height`. Number of elements is limited to @ref /// KLEIDICV_MAX_IMAGE_PIXELS. /// /// @param src Pointer to the source data. Must be non-null. diff --git a/kleidicv/src/conversions/float_conv_sc.h b/kleidicv/src/conversions/float_conv_sc.h index fb2b4e85b259cc21903205e60f388f378a9790c6..e04884112471ca2a8ec77d6ad4f7d1613cba9399 100644 --- a/kleidicv/src/conversions/float_conv_sc.h +++ b/kleidicv/src/conversions/float_conv_sc.h @@ -90,7 +90,7 @@ class float_conversion_operation { return svcvt_u32_f32_x(pg, src); } -}; // end of class float_conversion_operation +}; // end of class float_conversion_operation template class float_conversion_operation { @@ -142,7 +142,7 @@ class float_conversion_operation { svuint32_t src_vector = svld1ub_u32(pg, src); return svcvt_f32_u32_x(pg, src_vector); } -}; +}; // end of class float_conversion_operation template static kleidicv_error_t float_conversion_sc( diff --git a/test/api/test_float_conv.cpp b/test/api/test_float_conv.cpp index 41b60bf49aff614b9b01be9e6409b204ed00fa67..49fdde174d3ba4ce27968e291bcdc324ac655434 100644 --- a/test/api/test_float_conv.cpp +++ b/test/api/test_float_conv.cpp @@ -11,15 +11,15 @@ #include "kleidicv/kleidicv.h" #include "test_config.h" -#define KLEIDICV_float_conversion(I, input_type_name, O, output_type_name) \ - KLEIDICV_DIFF_IO_API( \ - float_conversion, \ - kleidicv_float_conversion_##input_type_name##_##output_type_name, I, O) +#define KLEIDICV_FLOAT_CONVERSION(itype, itype_name, otype, otype_name) \ + KLEIDICV_API_DIFFERENT_IO_TYPES( \ + float_conversion, kleidicv_float_conversion_##itype_name##_##otype_name, \ + itype, otype) -KLEIDICV_float_conversion(float, f32, int8_t, s8); -KLEIDICV_float_conversion(float, f32, uint8_t, u8); -KLEIDICV_float_conversion(int8_t, s8, float, f32); -KLEIDICV_float_conversion(uint8_t, u8, float, f32); +KLEIDICV_FLOAT_CONVERSION(float, f32, int8_t, s8); +KLEIDICV_FLOAT_CONVERSION(float, f32, uint8_t, u8); +KLEIDICV_FLOAT_CONVERSION(int8_t, s8, float, f32); +KLEIDICV_FLOAT_CONVERSION(uint8_t, u8, float, f32); template class FloatConversionTest final { @@ -75,7 +75,7 @@ class FloatConversionTest final { static constexpr uint32_t negSubnormalMin = 0x80000001; static constexpr uint32_t negSubnormalMax = 0x807FFFFF; - static constexpr float _floatval(uint32_t v) { + static constexpr float floatval(uint32_t v) { static_assert(sizeof(float) == 4); KLEIDICV_NO_STRICT_ALIASING_BEGIN return *reinterpret_cast(&v); @@ -88,27 +88,27 @@ class FloatConversionTest final { const Elements& get_custom_elements() { static const Elements kTestElements = { // clang-format off - 4, 8, - {{ - { _floatval(quietNaN), _floatval(signalingNaN), _floatval(posInfinity), _floatval(negInfinity) }, - { _floatval(minusNaN), _floatval(plusNaN), _floatval(plusZero), _floatval(minusZero) }, - { _floatval(oneNaN), _floatval(zeroDivZero), _floatval(floatMin), _floatval(floatMax) }, - { _floatval(posSubnormalMin), _floatval(posSubnormalMax), _floatval(negSubnormalMin), _floatval(negSubnormalMax) }, - { 1111.11, -1112.22, 113.33, 114.44 }, - { 111.51, 112.62, 113.73, 114.84 }, - { 126.66, 127.11, 128.66, 129.11 }, - { 11.5, 12.5, -11.5, -12.5 } - }}, - {{ - { 0, 0, 127, -128 }, - { 0, 0, 0, 0 }, - { 0, 0, 0, 127 }, - { 0, 0, 0, 0 }, - { 127, -128, 113, 114 }, - { 112, 113, 114, 115 }, - { 127, 127, 127, 127 }, - { 12, 12, -12, -12 } - }} + 4, 8, + {{ + { floatval(quietNaN), floatval(signalingNaN), floatval(posInfinity), floatval(negInfinity) }, + { floatval(minusNaN), floatval(plusNaN), floatval(plusZero), floatval(minusZero) }, + { floatval(oneNaN), floatval(zeroDivZero), floatval(floatMin), floatval(floatMax) }, + { floatval(posSubnormalMin), floatval(posSubnormalMax), floatval(negSubnormalMin), floatval(negSubnormalMax) }, + { 1111.11, -1112.22, 113.33, 114.44 }, + { 111.51, 112.62, 113.73, 114.84 }, + { 126.66, 127.11, 128.66, 129.11 }, + { 11.5, 12.5, -11.5, -12.5 } + }}, + {{ + { 0, 0, 127, -128 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 127 }, + { 0, 0, 0, 0 }, + { 127, -128, 113, 114 }, + { 112, 113, 114, 115 }, + { 127, 127, 127, 127 }, + { 12, 12, -12, -12 } + }} // clang-format on }; return kTestElements; @@ -120,61 +120,54 @@ class FloatConversionTest final { const Elements& get_custom_elements() { static const Elements kTestElements = { // clang-format off - 4, 8, - {{ - { _floatval(quietNaN), _floatval(signalingNaN), _floatval(posInfinity), _floatval(negInfinity) }, - { _floatval(minusNaN), _floatval(plusNaN), _floatval(plusZero), _floatval(minusZero) }, - { _floatval(oneNaN), _floatval(zeroDivZero), _floatval(floatMin), _floatval(floatMax) }, - { _floatval(posSubnormalMin), _floatval(posSubnormalMax), _floatval(negSubnormalMin), _floatval(negSubnormalMax) }, - { 1111.11, -1112.22, 113.33, 114.44 }, - { 111.51, 112.62, 113.73, 114.84 }, - { 126.66, 127.11, 128.66, 129.11 }, - { 11.5, 12.5, -11.5, -12.5 } - }}, - {{ - { 0, 0, 255, 0 }, - { 0, 0, 0, 0 }, - { 0, 0, 0, 255 }, - { 0, 0, 0, 0 }, - { 255, 0, 113, 114 }, - { 112, 113, 114, 115 }, - { 127, 127, 129, 129 }, - { 12, 12, 0, 0 } - }} + 4, 8, + {{ + { floatval(quietNaN), floatval(signalingNaN), floatval(posInfinity), floatval(negInfinity) }, + { floatval(minusNaN), floatval(plusNaN), floatval(plusZero), floatval(minusZero) }, + { floatval(oneNaN), floatval(zeroDivZero), floatval(floatMin), floatval(floatMax) }, + { floatval(posSubnormalMin), floatval(posSubnormalMax), floatval(negSubnormalMin), floatval(negSubnormalMax) }, + { 1111.11, -1112.22, 113.33, 114.44 }, + { 111.51, 112.62, 113.73, 114.84 }, + { 126.66, 127.11, 128.66, 129.11 }, + { 11.5, 12.5, -11.5, -12.5 } + }}, + {{ + { 0, 0, 255, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 255 }, + { 0, 0, 0, 0 }, + { 255, 0, 113, 114 }, + { 112, 113, 114, 115 }, + { 127, 127, 129, 129 }, + { 12, 12, 0, 0 } + }} // clang-format on }; return kTestElements; } template , bool> = true, std::enable_if_t, bool> = true> const Elements& get_custom_elements() { static const Elements kTestElements = { // clang-format off - 4, 6, - {{ - { min(), min(), max() - 1, max() }, - { min(), min(), min(), min() }, - { min(), min(), min(), max() - 1 }, - { max() - 1, max(), 113, 114 }, - { 112, 113, 114, 115 }, - { 12, 12, 12, 12 } - }}, - {{ - { min(), min(), max() - 1.0, max() }, - { min(), min(), min(), min() }, - { min(), min(), min(), max() - 1.0 }, - { max() - 1.0, max(), 113.0, 114.0 }, - { 112.0, 113.0, 114.0, 115.0 }, - { 12.0, 12.0, 12.0, 12.0 } - }} + 5, 1, + {{ + { min(), min() + 1, 0, max() - 1, max() } + }}, + {{ + { static_cast(min()), static_cast(min()) + 1.0, 0, + static_cast(max()) - 1.0, static_cast(max()) } + }} // clang-format on }; return kTestElements; } template , bool> = true> + std::enable_if_t, bool> = true, + std::enable_if_t, bool> = true> const Values& get_values() { static const Values kTestValues = { // clang-format off @@ -185,6 +178,7 @@ class FloatConversionTest final { } template , bool> = true, std::enable_if_t, bool> = true> const Values& get_values() { static const Values kTestValues = { @@ -241,36 +235,22 @@ class FloatConversionTest final { return height; } - template , bool> = true, - std::enable_if_t, bool> = true> - std::tuple, test::Array2D, test::Array2D> - get_linear_arrays(size_t width, size_t height) { - test::Array2D source(width, height, 1, 1); - test::Array2D expected(width, height, 1, 1); - test::Array2D actual(width, height, 1, 1); - - test::GenerateLinearSeries generator(min()); - - source.fill(generator); - - calculate_expected(source, expected); - - return {source, expected, actual}; - } - - template , bool> = true, - std::enable_if_t, bool> = true> + template std::tuple, test::Array2D, test::Array2D> get_linear_arrays(size_t width, size_t height) { test::Array2D source(width, height, 1, 1); test::Array2D expected(width, height, 1, 1); test::Array2D actual(width, height, 1, 1); - test::GenerateLinearSeries generator(min()); - - source.fill(generator); + if constexpr (std::is_same_v && std::is_integral_v) { + test::GenerateLinearSeries generator(min()); + source.fill(generator); + } else if constexpr (std::is_integral_v && std::is_same_v) { + test::GenerateLinearSeries generator(min()); + source.fill(generator); + } else { + static_assert(sizeof(I) == 0 && sizeof(O) == 0, "should never happen"); + } calculate_expected(source, expected); @@ -279,30 +259,16 @@ class FloatConversionTest final { public: // minimum_size set by caller to trigger the 'big' conversion path. - template , bool> = true, - std::enable_if_t, bool> = true> + template void test_linear(size_t width, size_t minimum_size = 1) { - size_t height = get_linear_height(width, minimum_size); - - auto arrays = get_linear_arrays(width, height); - - test::Array2D& source = std::get<0>(arrays); - test::Array2D& expected = std::get<1>(arrays); - test::Array2D& actual = std::get<2>(arrays); - - ASSERT_EQ(KLEIDICV_OK, (float_conversion()( - source.data(), source.stride(), actual.data(), - actual.stride(), width, height))); - - EXPECT_EQ_ARRAY2D(expected, actual); - } - - template , bool> = true, - std::enable_if_t, bool> = true> - void test_linear(size_t width, size_t minimum_size = 1) { - size_t height = get_linear_height(width, minimum_size); + size_t height = 0; + if constexpr (std::is_same_v && std::is_integral_v) { + height = get_linear_height(width, minimum_size); + } else if constexpr (std::is_integral_v && std::is_same_v) { + height = get_linear_height(width, minimum_size); + } else { + static_assert(sizeof(I) == 0 && sizeof(O) == 0, "should never happen"); + } auto arrays = get_linear_arrays(width, height); @@ -340,14 +306,12 @@ class FloatConversionTest final { void test_sizes(const size_t width, const size_t height) { auto values_list = get_values(); - test::Array2D source(width, height, 1, 1); + test::Array2D source(width, height, 1, 1); test::Array2D expected(width, height, 1, 1); - test::Array2D actual(width, height, 1, 1); source.fill(values_list.source); - expected.fill(values_list.expected); actual.fill(0); diff --git a/test/framework/utils.h b/test/framework/utils.h index 5eefe1fd87cd617773571bf5601beac7866688db..9ee2ea6210022b031f1ed55996d5537d5fe5526c 100644 --- a/test/framework/utils.h +++ b/test/framework/utils.h @@ -24,7 +24,7 @@ return impl; \ } -#define KLEIDICV_DIFF_IO_API(name, impl, itype, otype) \ +#define KLEIDICV_API_DIFFERENT_IO_TYPES(name, impl, itype, otype) \ template , bool> = true, \ std::enable_if_t, bool> = true> \