From 6f9af0a8b38a36208b79a446490be490422d71cf Mon Sep 17 00:00:00 2001 From: Michael Platings Date: Wed, 27 Nov 2024 15:08:07 +0000 Subject: [PATCH] Rename kleidicv_float_conversion_... functions --- CHANGELOG.md | 5 +++++ adapters/opencv/kleidicv_hal.cpp | 8 ++++---- benchmark/benchmark.cpp | 8 ++++---- .../kleidicv/conversions/float_conversion.h | 20 ++++++++----------- kleidicv/include/kleidicv/kleidicv.h | 12 +++++------ kleidicv/src/conversions/float_conv_api.cpp | 9 ++++----- kleidicv/src/conversions/float_conv_neon.cpp | 18 ++++++++--------- .../include/kleidicv_thread/kleidicv_thread.h | 12 ++++------- kleidicv_thread/src/kleidicv_thread.cpp | 8 ++++---- test/api/test_float_conv.cpp | 7 +++---- test/api/test_thread.cpp | 8 ++++---- 11 files changed, 54 insertions(+), 61 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d545ee12b..23ac56994 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,11 @@ This changelog aims to follow the guiding principles of - `KLEIDICV_ENABLE_SME2` defaults to off. This is because the ACLE SME specification has not yet been finalized. - In the OpenCV HAL, cvtColor for gray-RGBA & BGRA-RGBA are multithreaded. - Improved performance of 8-bit int to 32-bit float conversion. +- Renamed functions: + - kleidicv_float_conversion_f32_s8 to kleidicv_f32_to_s8 + - kleidicv_float_conversion_f32_u8 to kleidicv_f32_to_u8 + - kleidicv_float_conversion_s8_f32 to kleidicv_s8_to_f32 + - kleidicv_float_conversion_u8_f32 to kleidicv_u8_to_f32 ## 0.2.0 - 2024-09-30 diff --git a/adapters/opencv/kleidicv_hal.cpp b/adapters/opencv/kleidicv_hal.cpp index 915db0ada..450135886 100644 --- a/adapters/opencv/kleidicv_hal.cpp +++ b/adapters/opencv/kleidicv_hal.cpp @@ -1172,25 +1172,25 @@ int convertTo(const uchar *src_data, size_t src_step, int src_depth, if (scale == 1.0 && shift == 0.0) { // float32 to int8 if (src_depth == CV_32F && dst_depth == CV_8S) { - return convert_error(kleidicv_thread_float_conversion_f32_s8( + return convert_error(kleidicv_thread_f32_to_s8( reinterpret_cast(src_data), src_step, reinterpret_cast(dst_data), dst_step, width, height, mt)); } // float32 to uint8 if (src_depth == CV_32F && dst_depth == CV_8U) { - return convert_error(kleidicv_thread_float_conversion_f32_u8( + return convert_error(kleidicv_thread_f32_to_u8( reinterpret_cast(src_data), src_step, reinterpret_cast(dst_data), dst_step, width, height, mt)); } // int8 to float32 if (src_depth == CV_8S && dst_depth == CV_32F) { - return convert_error(kleidicv_thread_float_conversion_s8_f32( + return convert_error(kleidicv_thread_s8_to_f32( reinterpret_cast(src_data), src_step, reinterpret_cast(dst_data), dst_step, width, height, mt)); } // uint8 to float32 if (src_depth == CV_8U && dst_depth == CV_32F) { - return convert_error(kleidicv_thread_float_conversion_u8_f32( + return convert_error(kleidicv_thread_u8_to_f32( reinterpret_cast(src_data), src_step, reinterpret_cast(dst_data), dst_step, width, height, mt)); } diff --git a/benchmark/benchmark.cpp b/benchmark/benchmark.cpp index b4b4488dd..2cbaa4caf 100644 --- a/benchmark/benchmark.cpp +++ b/benchmark/benchmark.cpp @@ -102,10 +102,10 @@ BENCH_UNARY_OP(exp_f32, 1, float); } \ BENCHMARK(name) -BENCH_UNARY_OP_DIFFERENT_IO_TYPES(float_conversion_f32_s8, float, int8_t); -BENCH_UNARY_OP_DIFFERENT_IO_TYPES(float_conversion_f32_u8, float, uint8_t); -BENCH_UNARY_OP_DIFFERENT_IO_TYPES(float_conversion_s8_f32, int8_t, float); -BENCH_UNARY_OP_DIFFERENT_IO_TYPES(float_conversion_u8_f32, uint8_t, float); +BENCH_UNARY_OP_DIFFERENT_IO_TYPES(f32_to_s8, float, int8_t); +BENCH_UNARY_OP_DIFFERENT_IO_TYPES(f32_to_u8, float, uint8_t); +BENCH_UNARY_OP_DIFFERENT_IO_TYPES(s8_to_f32, int8_t, float); +BENCH_UNARY_OP_DIFFERENT_IO_TYPES(u8_to_f32, uint8_t, float); #define BENCH_UNARY_OP_DIFFERENT_CHANNEL_NUMBER(name, in_channels, \ out_channels, type) \ diff --git a/kleidicv/include/kleidicv/conversions/float_conversion.h b/kleidicv/include/kleidicv/conversions/float_conversion.h index 199a96b3a..8913cafec 100644 --- a/kleidicv/include/kleidicv/conversions/float_conversion.h +++ b/kleidicv/include/kleidicv/conversions/float_conversion.h @@ -10,21 +10,17 @@ namespace kleidicv { namespace neon { -kleidicv_error_t float_conversion_f32_s8(const float *src, size_t src_stride, - int8_t *dst, size_t dst_stride, - size_t width, size_t height); +kleidicv_error_t f32_to_s8(const float *src, size_t src_stride, int8_t *dst, + size_t dst_stride, size_t width, size_t height); -kleidicv_error_t float_conversion_f32_u8(const float *src, size_t src_stride, - uint8_t *dst, size_t dst_stride, - size_t width, size_t height); +kleidicv_error_t f32_to_u8(const float *src, size_t src_stride, uint8_t *dst, + size_t dst_stride, size_t width, size_t height); -kleidicv_error_t float_conversion_s8_f32(const int8_t *src, size_t src_stride, - float *dst, size_t dst_stride, - size_t width, size_t height); +kleidicv_error_t s8_to_f32(const int8_t *src, size_t src_stride, float *dst, + size_t dst_stride, size_t width, size_t height); -kleidicv_error_t float_conversion_u8_f32(const uint8_t *src, size_t src_stride, - float *dst, size_t dst_stride, - size_t width, size_t height); +kleidicv_error_t u8_to_f32(const uint8_t *src, size_t src_stride, float *dst, + size_t dst_stride, size_t width, size_t height); } // namespace neon } // namespace kleidicv diff --git a/kleidicv/include/kleidicv/kleidicv.h b/kleidicv/include/kleidicv/kleidicv.h index 9d8e609f0..26e6d0a52 100644 --- a/kleidicv/include/kleidicv/kleidicv.h +++ b/kleidicv/include/kleidicv/kleidicv.h @@ -1653,11 +1653,11 @@ KLEIDICV_API_DECLARATION(kleidicv_exp_f32, const float *src, size_t src_stride, /// @param width Number of elements in a row. /// @param height Number of rows in the data. /// -KLEIDICV_API_DECLARATION(kleidicv_float_conversion_f32_s8, const float *src, +KLEIDICV_API_DECLARATION(kleidicv_f32_to_s8, const float *src, size_t src_stride, int8_t *dst, size_t dst_stride, size_t width, size_t height); -/// @copydoc kleidicv_float_conversion_f32_s8 -KLEIDICV_API_DECLARATION(kleidicv_float_conversion_f32_u8, const float *src, +/// @copydoc kleidicv_f32_to_s8 +KLEIDICV_API_DECLARATION(kleidicv_f32_to_u8, const float *src, size_t src_stride, uint8_t *dst, size_t dst_stride, size_t width, size_t height); @@ -1683,11 +1683,11 @@ KLEIDICV_API_DECLARATION(kleidicv_float_conversion_f32_u8, const float *src, /// @param width Number of pixels in a row. /// @param height Number of rows in the data. /// -KLEIDICV_API_DECLARATION(kleidicv_float_conversion_s8_f32, const int8_t *src, +KLEIDICV_API_DECLARATION(kleidicv_s8_to_f32, const int8_t *src, size_t src_stride, float *dst, size_t dst_stride, size_t width, size_t height); -/// @copydoc kleidicv_float_conversion_s8_f32 -KLEIDICV_API_DECLARATION(kleidicv_float_conversion_u8_f32, const uint8_t *src, +/// @copydoc kleidicv_s8_to_f32 +KLEIDICV_API_DECLARATION(kleidicv_u8_to_f32, const uint8_t *src, size_t src_stride, float *dst, size_t dst_stride, size_t width, size_t height); diff --git a/kleidicv/src/conversions/float_conv_api.cpp b/kleidicv/src/conversions/float_conv_api.cpp index 06963f06e..c80538775 100644 --- a/kleidicv/src/conversions/float_conv_api.cpp +++ b/kleidicv/src/conversions/float_conv_api.cpp @@ -30,21 +30,20 @@ kleidicv_error_t float_conversion(const InputType* src, size_t src_stride, } // namespace kleidicv KLEIDICV_MULTIVERSION_C_API( - kleidicv_float_conversion_f32_s8, &kleidicv::neon::float_conversion_f32_s8, + kleidicv_f32_to_s8, &kleidicv::neon::f32_to_s8, KLEIDICV_SVE2_IMPL_IF((&kleidicv::sve2::float_conversion)), (&kleidicv::sme2::float_conversion)); KLEIDICV_MULTIVERSION_C_API( - kleidicv_float_conversion_f32_u8, &kleidicv::neon::float_conversion_f32_u8, + kleidicv_f32_to_u8, &kleidicv::neon::f32_to_u8, KLEIDICV_SVE2_IMPL_IF((&kleidicv::sve2::float_conversion)), (&kleidicv::sme2::float_conversion)); -KLEIDICV_MULTIVERSION_C_API(kleidicv_float_conversion_s8_f32, - &kleidicv::neon::float_conversion_s8_f32, +KLEIDICV_MULTIVERSION_C_API(kleidicv_s8_to_f32, &kleidicv::neon::s8_to_f32, (&kleidicv::sve2::float_conversion), (&kleidicv::sme2::float_conversion)); KLEIDICV_MULTIVERSION_C_API( - kleidicv_float_conversion_u8_f32, &kleidicv::neon::float_conversion_u8_f32, + kleidicv_u8_to_f32, &kleidicv::neon::u8_to_f32, (&kleidicv::sve2::float_conversion), (&kleidicv::sme2::float_conversion)); diff --git a/kleidicv/src/conversions/float_conv_neon.cpp b/kleidicv/src/conversions/float_conv_neon.cpp index 61a49716b..a50f6fbe5 100644 --- a/kleidicv/src/conversions/float_conv_neon.cpp +++ b/kleidicv/src/conversions/float_conv_neon.cpp @@ -86,21 +86,19 @@ kleidicv_error_t float_conversion(const InputType* src, size_t src_stride, return KLEIDICV_OK; } -kleidicv_error_t float_conversion_f32_s8(const float* src, size_t src_stride, - int8_t* dst, size_t dst_stride, - size_t width, size_t height) { +kleidicv_error_t f32_to_s8(const float* src, size_t src_stride, int8_t* dst, + size_t dst_stride, size_t width, size_t height) { return float_conversion(src, src_stride, dst, dst_stride, width, height); } -kleidicv_error_t float_conversion_f32_u8(const float* src, size_t src_stride, - uint8_t* dst, size_t dst_stride, - size_t width, size_t height) { +kleidicv_error_t f32_to_u8(const float* src, size_t src_stride, uint8_t* dst, + size_t dst_stride, size_t width, size_t height) { return float_conversion(src, src_stride, dst, dst_stride, width, height); } KLEIDICV_TARGET_FN_ATTRS kleidicv_error_t -float_conversion_s8_f32(const int8_t* src, size_t src_stride, float* dst, - size_t dst_stride, size_t width, size_t height) { +s8_to_f32(const int8_t* src, size_t src_stride, float* dst, size_t dst_stride, + size_t width, size_t height) { CHECK_POINTER_AND_STRIDE(src, src_stride, height); CHECK_POINTER_AND_STRIDE(dst, dst_stride, height); CHECK_IMAGE_SIZE(width, height); @@ -146,8 +144,8 @@ float_conversion_s8_f32(const int8_t* src, size_t src_stride, float* dst, } KLEIDICV_TARGET_FN_ATTRS kleidicv_error_t -float_conversion_u8_f32(const uint8_t* src, size_t src_stride, float* dst, - size_t dst_stride, size_t width, size_t height) { +u8_to_f32(const uint8_t* src, size_t src_stride, float* dst, size_t dst_stride, + size_t width, size_t height) { CHECK_POINTER_AND_STRIDE(src, src_stride, height); CHECK_POINTER_AND_STRIDE(dst, dst_stride, height); CHECK_IMAGE_SIZE(width, height); diff --git a/kleidicv_thread/include/kleidicv_thread/kleidicv_thread.h b/kleidicv_thread/include/kleidicv_thread/kleidicv_thread.h index 3753af477..f122f79bc 100644 --- a/kleidicv_thread/include/kleidicv_thread/kleidicv_thread.h +++ b/kleidicv_thread/include/kleidicv_thread/kleidicv_thread.h @@ -68,14 +68,10 @@ KLEIDICV_THREAD_UNARY_OP(kleidicv_thread_rgb_to_yuv_u8, uint8_t, uint8_t); KLEIDICV_THREAD_UNARY_OP(kleidicv_thread_bgra_to_yuv_u8, uint8_t, uint8_t); KLEIDICV_THREAD_UNARY_OP(kleidicv_thread_rgba_to_yuv_u8, uint8_t, uint8_t); KLEIDICV_THREAD_UNARY_OP(kleidicv_thread_exp_f32, float, float); -KLEIDICV_THREAD_UNARY_OP(kleidicv_thread_float_conversion_f32_s8, float, - int8_t); -KLEIDICV_THREAD_UNARY_OP(kleidicv_thread_float_conversion_f32_u8, float, - uint8_t); -KLEIDICV_THREAD_UNARY_OP(kleidicv_thread_float_conversion_s8_f32, int8_t, - float); -KLEIDICV_THREAD_UNARY_OP(kleidicv_thread_float_conversion_u8_f32, uint8_t, - float); +KLEIDICV_THREAD_UNARY_OP(kleidicv_thread_f32_to_s8, float, int8_t); +KLEIDICV_THREAD_UNARY_OP(kleidicv_thread_f32_to_u8, float, uint8_t); +KLEIDICV_THREAD_UNARY_OP(kleidicv_thread_s8_to_f32, int8_t, float); +KLEIDICV_THREAD_UNARY_OP(kleidicv_thread_u8_to_f32, uint8_t, float); /// Internal - not part of the public API and its direct use is not supported. /// diff --git a/kleidicv_thread/src/kleidicv_thread.cpp b/kleidicv_thread/src/kleidicv_thread.cpp index 0e273aa42..f5d5f1822 100644 --- a/kleidicv_thread/src/kleidicv_thread.cpp +++ b/kleidicv_thread/src/kleidicv_thread.cpp @@ -121,10 +121,10 @@ KLEIDICV_THREAD_UNARY_OP_IMPL(rgb_to_yuv_u8, uint8_t, uint8_t); KLEIDICV_THREAD_UNARY_OP_IMPL(bgra_to_yuv_u8, uint8_t, uint8_t); KLEIDICV_THREAD_UNARY_OP_IMPL(rgba_to_yuv_u8, uint8_t, uint8_t); KLEIDICV_THREAD_UNARY_OP_IMPL(exp_f32, float, float); -KLEIDICV_THREAD_UNARY_OP_IMPL(float_conversion_f32_s8, float, int8_t); -KLEIDICV_THREAD_UNARY_OP_IMPL(float_conversion_f32_u8, float, uint8_t); -KLEIDICV_THREAD_UNARY_OP_IMPL(float_conversion_s8_f32, int8_t, float); -KLEIDICV_THREAD_UNARY_OP_IMPL(float_conversion_u8_f32, uint8_t, float); +KLEIDICV_THREAD_UNARY_OP_IMPL(f32_to_s8, float, int8_t); +KLEIDICV_THREAD_UNARY_OP_IMPL(f32_to_u8, float, uint8_t); +KLEIDICV_THREAD_UNARY_OP_IMPL(s8_to_f32, int8_t, float); +KLEIDICV_THREAD_UNARY_OP_IMPL(u8_to_f32, uint8_t, float); kleidicv_error_t kleidicv_thread_threshold_binary_u8( const uint8_t *src, size_t src_stride, uint8_t *dst, size_t dst_stride, diff --git a/test/api/test_float_conv.cpp b/test/api/test_float_conv.cpp index ae7e2906e..2e422313a 100644 --- a/test/api/test_float_conv.cpp +++ b/test/api/test_float_conv.cpp @@ -11,10 +11,9 @@ #include "kleidicv/kleidicv.h" #include "test_config.h" -#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) +#define KLEIDICV_FLOAT_CONVERSION(itype, itype_name, otype, otype_name) \ + KLEIDICV_API_DIFFERENT_IO_TYPES( \ + float_conversion, kleidicv_##itype_name##_to_##otype_name, itype, otype) KLEIDICV_FLOAT_CONVERSION(float, f32, int8_t, s8); KLEIDICV_FLOAT_CONVERSION(float, f32, uint8_t, u8); diff --git a/test/api/test_thread.cpp b/test/api/test_thread.cpp index e4cb0b6e3..662a8d83d 100644 --- a/test/api/test_thread.cpp +++ b/test/api/test_thread.cpp @@ -344,10 +344,10 @@ TEST_UNARY_OP(threshold_binary_u8, uint8_t, uint8_t, 1, 1, 100, 200); TEST_UNARY_OP(scale_u8, uint8_t, uint8_t, 1, 1, 0.5F, 3.5F); TEST_UNARY_OP(scale_f32, float, float, 1, 1, 0.123F, 45.6789F); TEST_UNARY_OP(exp_f32, float, float, 1, 1); -TEST_UNARY_OP(float_conversion_f32_s8, float, int8_t, 1, 1); -TEST_UNARY_OP(float_conversion_f32_u8, float, uint8_t, 1, 1); -TEST_UNARY_OP(float_conversion_s8_f32, int8_t, float, 1, 1); -TEST_UNARY_OP(float_conversion_u8_f32, uint8_t, float, 1, 1); +TEST_UNARY_OP(f32_to_s8, float, int8_t, 1, 1); +TEST_UNARY_OP(f32_to_u8, float, uint8_t, 1, 1); +TEST_UNARY_OP(s8_to_f32, int8_t, float, 1, 1); +TEST_UNARY_OP(u8_to_f32, uint8_t, float, 1, 1); TEST_BINARY_OP(saturating_add_s8, int8_t, 1, 1); TEST_BINARY_OP(saturating_add_u8, uint8_t, 1, 1); -- GitLab