diff options
author | Felix Thomasmathibalan <felixjohnny.thomasmathibalan@arm.com> | 2023-09-27 17:46:17 +0100 |
---|---|---|
committer | felixjohnny.thomasmathibalan <felixjohnny.thomasmathibalan@arm.com> | 2023-09-28 12:08:05 +0000 |
commit | afd38f0c617d6f89b2b4532c6c44f116617e2b6f (patch) | |
tree | 03bc7d5a762099989b16a656fa8d397b490ed70e /src/cpu/kernels/crop/generic/neon | |
parent | bdcb4c148ee2fdeaaddf4cf1e57bbb0de02bb894 (diff) | |
download | ComputeLibrary-afd38f0c617d6f89b2b4532c6c44f116617e2b6f.tar.gz |
Apply clang-format on repository
Code is formatted as per a revised clang format configuration
file(not part of this delivery). Version 14.0.6 is used.
Exclusion List:
- files with .cl extension
- files that are not strictly C/C++ (e.g. Android.bp, Sconscript ...)
And the following directories
- compute_kernel_writer/validation/
- tests/
- include/
- src/core/NEON/kernels/convolution/
- src/core/NEON/kernels/arm_gemm/
- src/core/NEON/kernels/arm_conv/
- data/
There will be a follow up for formatting of .cl files and the
files under tests/ and compute_kernel_writer/validation/.
Signed-off-by: Felix Thomasmathibalan <felixjohnny.thomasmathibalan@arm.com>
Change-Id: Ib7eb1fcf4e7537b9feaefcfc15098a804a3fde0a
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/10391
Benchmark: Arm Jenkins <bsgcomp@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Gunes Bayir <gunes.bayir@arm.com>
Diffstat (limited to 'src/cpu/kernels/crop/generic/neon')
-rw-r--r-- | src/cpu/kernels/crop/generic/neon/crop_helper.h | 4 | ||||
-rw-r--r-- | src/cpu/kernels/crop/generic/neon/fp16.cpp | 17 | ||||
-rw-r--r-- | src/cpu/kernels/crop/generic/neon/fp32.cpp | 17 | ||||
-rw-r--r-- | src/cpu/kernels/crop/generic/neon/impl.h | 49 | ||||
-rw-r--r-- | src/cpu/kernels/crop/generic/neon/integer.cpp | 92 |
5 files changed, 124 insertions, 55 deletions
diff --git a/src/cpu/kernels/crop/generic/neon/crop_helper.h b/src/cpu/kernels/crop/generic/neon/crop_helper.h index 1fe8e11e98..8fb7ad2087 100644 --- a/src/cpu/kernels/crop/generic/neon/crop_helper.h +++ b/src/cpu/kernels/crop/generic/neon/crop_helper.h @@ -80,7 +80,7 @@ inline float32x4_t load_as_f32(uint8_t *ptr) { return vcvtq_f32_u32(vmovl_u16(vget_low_u16(vmovl_u8(wrapper::vload(ptr))))); } -} +} // namespace cpu } // namespace arm_compute -#endif //SRC_CORE_NEON_KERNELS_CROP_CROP_HELPER_H
\ No newline at end of file +#endif //SRC_CORE_NEON_KERNELS_CROP_CROP_HELPER_H diff --git a/src/cpu/kernels/crop/generic/neon/fp16.cpp b/src/cpu/kernels/crop/generic/neon/fp16.cpp index 218ebba191..3739c9d4e0 100644 --- a/src/cpu/kernels/crop/generic/neon/fp16.cpp +++ b/src/cpu/kernels/crop/generic/neon/fp16.cpp @@ -29,12 +29,19 @@ namespace arm_compute { namespace cpu { -void fp16_in_bounds_crop_window(const ITensor *input, const ITensor *output, float *output_ptr, Coordinates input_offset, - int32_t window_step_x, int32_t output_width_start, int32_t output_width_limit, bool input_has_single_channel, bool is_width_flipped) +void fp16_in_bounds_crop_window(const ITensor *input, + const ITensor *output, + float *output_ptr, + Coordinates input_offset, + int32_t window_step_x, + int32_t output_width_start, + int32_t output_width_limit, + bool input_has_single_channel, + bool is_width_flipped) { - return in_bounds_crop_window<float16_t>(input, output, output_ptr, input_offset, - window_step_x, output_width_start, output_width_limit, input_has_single_channel, is_width_flipped); -} + return in_bounds_crop_window<float16_t>(input, output, output_ptr, input_offset, window_step_x, output_width_start, + output_width_limit, input_has_single_channel, is_width_flipped); } +} // namespace cpu } // namespace arm_compute #endif /* defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) && defined(ENABLE_FP16_KERNELS) */ diff --git a/src/cpu/kernels/crop/generic/neon/fp32.cpp b/src/cpu/kernels/crop/generic/neon/fp32.cpp index 16d0218fce..f665c3652c 100644 --- a/src/cpu/kernels/crop/generic/neon/fp32.cpp +++ b/src/cpu/kernels/crop/generic/neon/fp32.cpp @@ -28,11 +28,18 @@ namespace arm_compute { namespace cpu { -void fp32_in_bounds_crop_window(const ITensor *input, const ITensor *output, float *output_ptr, Coordinates input_offset, - int32_t window_step_x, int32_t output_width_start, int32_t output_width_limit, bool input_has_single_channel, bool is_width_flipped) +void fp32_in_bounds_crop_window(const ITensor *input, + const ITensor *output, + float *output_ptr, + Coordinates input_offset, + int32_t window_step_x, + int32_t output_width_start, + int32_t output_width_limit, + bool input_has_single_channel, + bool is_width_flipped) { - return in_bounds_crop_window<float32_t>(input, output, output_ptr, input_offset, - window_step_x, output_width_start, output_width_limit, input_has_single_channel, is_width_flipped); -} + return in_bounds_crop_window<float32_t>(input, output, output_ptr, input_offset, window_step_x, output_width_start, + output_width_limit, input_has_single_channel, is_width_flipped); } +} // namespace cpu } // namespace arm_compute diff --git a/src/cpu/kernels/crop/generic/neon/impl.h b/src/cpu/kernels/crop/generic/neon/impl.h index a59588be45..b90ba9ddbf 100644 --- a/src/cpu/kernels/crop/generic/neon/impl.h +++ b/src/cpu/kernels/crop/generic/neon/impl.h @@ -26,8 +26,9 @@ #include "arm_compute/core/Helpers.h" #include "arm_compute/core/TensorInfo.h" -#include "src/core/NEON/wrapper/wrapper.h" + #include "src/core/common/Registrars.h" +#include "src/core/NEON/wrapper/wrapper.h" #include "src/cpu/kernels/crop/generic/neon/crop_helper.h" namespace arm_compute @@ -35,19 +36,26 @@ namespace arm_compute namespace cpu { template <typename T> -void in_bounds_crop_window(const ITensor *input, const ITensor *output, float *output_ptr, Coordinates input_offset, - int32_t window_step_x, int32_t output_width_start, int32_t output_width_limit, bool input_has_single_channel, bool is_width_flipped) +void in_bounds_crop_window(const ITensor *input, + const ITensor *output, + float *output_ptr, + Coordinates input_offset, + int32_t window_step_x, + int32_t output_width_start, + int32_t output_width_limit, + bool input_has_single_channel, + bool is_width_flipped) { // Reverse elements if width flipped. - if(is_width_flipped) + if (is_width_flipped) { // Collapse first dimension if possible. - if(input_has_single_channel) + if (input_has_single_channel) { int32_t x = output_width_start; Coordinates negative_offset(input_offset); negative_offset.set(1, negative_offset[1] - window_step_x + 1); - for(; x <= output_width_limit - window_step_x; x += window_step_x, negative_offset[1] -= window_step_x) + for (; x <= output_width_limit - window_step_x; x += window_step_x, negative_offset[1] -= window_step_x) { auto in = load_as_f32(reinterpret_cast<T *>(input->ptr_to_element(negative_offset))); @@ -57,25 +65,27 @@ void in_bounds_crop_window(const ITensor *input, const ITensor *output, float *o wrapper::vstore(output_ptr + x, in); } input_offset[1] = negative_offset[1] + window_step_x - 1; - for(; x < output_width_limit; ++x, --input_offset[1]) + for (; x < output_width_limit; ++x, --input_offset[1]) { *(output_ptr + x) = static_cast<float>(*reinterpret_cast<T *>(input->ptr_to_element(input_offset))); } } else { - for(int32_t x = output_width_start; x < output_width_limit; ++x, --input_offset[1]) + for (int32_t x = output_width_start; x < output_width_limit; ++x, --input_offset[1]) { input_offset.set(0, 0); int32_t c = 0; - for(; c <= static_cast<int32_t>(input->info()->dimension(0)) - window_step_x; c += window_step_x, input_offset[0] += window_step_x) + for (; c <= static_cast<int32_t>(input->info()->dimension(0)) - window_step_x; + c += window_step_x, input_offset[0] += window_step_x) { auto in = load_as_f32(reinterpret_cast<T *>(input->ptr_to_element(input_offset))); wrapper::vstore(output_ptr + x * output->info()->dimension(0) + c, in); } - for(; c < static_cast<int32_t>(input->info()->dimension(0)); ++c, ++input_offset[0]) + for (; c < static_cast<int32_t>(input->info()->dimension(0)); ++c, ++input_offset[0]) { - *(output_ptr + x * output->info()->dimension(0) + c) = static_cast<float>(*reinterpret_cast<T *>(input->ptr_to_element(input_offset))); + *(output_ptr + x * output->info()->dimension(0) + c) = + static_cast<float>(*reinterpret_cast<T *>(input->ptr_to_element(input_offset))); } } } @@ -83,25 +93,28 @@ void in_bounds_crop_window(const ITensor *input, const ITensor *output, float *o else { // Use memcpy if the elements don't need converting to float. - if(std::is_same<T, float>::value) + if (std::is_same<T, float>::value) { memcpy(static_cast<void *>(output_ptr + output_width_start * output->info()->dimension(0)), reinterpret_cast<const void *>(input->ptr_to_element(input_offset)), - (output_width_limit - output_width_start) * output->info()->dimension(0) * output->info()->element_size()); + (output_width_limit - output_width_start) * output->info()->dimension(0) * + output->info()->element_size()); } else { - int32_t x = 0; - int32_t limit = (output_width_limit - output_width_start) * static_cast<int32_t>(output->info()->dimension(0)); + int32_t x = 0; + int32_t limit = + (output_width_limit - output_width_start) * static_cast<int32_t>(output->info()->dimension(0)); float *output_start_ptr = output_ptr + output_width_start * output->info()->dimension(0); - for(; x <= limit - window_step_x; x += window_step_x, input_offset[0] += window_step_x) + for (; x <= limit - window_step_x; x += window_step_x, input_offset[0] += window_step_x) { auto in = load_as_f32(reinterpret_cast<T *>(input->ptr_to_element(input_offset))); wrapper::vstore(output_start_ptr + x, in); } - for(; x < limit; ++x, ++input_offset[0]) + for (; x < limit; ++x, ++input_offset[0]) { - *(output_start_ptr + x) = static_cast<float>(*reinterpret_cast<T *>(input->ptr_to_element(input_offset))); + *(output_start_ptr + x) = + static_cast<float>(*reinterpret_cast<T *>(input->ptr_to_element(input_offset))); } } } diff --git a/src/cpu/kernels/crop/generic/neon/integer.cpp b/src/cpu/kernels/crop/generic/neon/integer.cpp index ebf2c1fbd3..602434f54f 100644 --- a/src/cpu/kernels/crop/generic/neon/integer.cpp +++ b/src/cpu/kernels/crop/generic/neon/integer.cpp @@ -29,46 +29,88 @@ namespace arm_compute { namespace cpu { -void u8_in_bounds_crop_window(const ITensor *input, const ITensor *output, float *output_ptr, Coordinates input_offset, - int32_t window_step_x, int32_t output_width_start, int32_t output_width_limit, bool input_has_single_channel, bool is_width_flipped) +void u8_in_bounds_crop_window(const ITensor *input, + const ITensor *output, + float *output_ptr, + Coordinates input_offset, + int32_t window_step_x, + int32_t output_width_start, + int32_t output_width_limit, + bool input_has_single_channel, + bool is_width_flipped) { - return in_bounds_crop_window<uint8_t>(input, output, output_ptr, input_offset, - window_step_x, output_width_start, output_width_limit, input_has_single_channel, is_width_flipped); + return in_bounds_crop_window<uint8_t>(input, output, output_ptr, input_offset, window_step_x, output_width_start, + output_width_limit, input_has_single_channel, is_width_flipped); } -void u16_in_bounds_crop_window(const ITensor *input, const ITensor *output, float *output_ptr, Coordinates input_offset, - int32_t window_step_x, int32_t output_width_start, int32_t output_width_limit, bool input_has_single_channel, bool is_width_flipped) +void u16_in_bounds_crop_window(const ITensor *input, + const ITensor *output, + float *output_ptr, + Coordinates input_offset, + int32_t window_step_x, + int32_t output_width_start, + int32_t output_width_limit, + bool input_has_single_channel, + bool is_width_flipped) { - return in_bounds_crop_window<uint16_t>(input, output, output_ptr, input_offset, - window_step_x, output_width_start, output_width_limit, input_has_single_channel, is_width_flipped); + return in_bounds_crop_window<uint16_t>(input, output, output_ptr, input_offset, window_step_x, output_width_start, + output_width_limit, input_has_single_channel, is_width_flipped); } -void u32_in_bounds_crop_window(const ITensor *input, const ITensor *output, float *output_ptr, Coordinates input_offset, - int32_t window_step_x, int32_t output_width_start, int32_t output_width_limit, bool input_has_single_channel, bool is_width_flipped) +void u32_in_bounds_crop_window(const ITensor *input, + const ITensor *output, + float *output_ptr, + Coordinates input_offset, + int32_t window_step_x, + int32_t output_width_start, + int32_t output_width_limit, + bool input_has_single_channel, + bool is_width_flipped) { - return in_bounds_crop_window<uint32_t>(input, output, output_ptr, input_offset, - window_step_x, output_width_start, output_width_limit, input_has_single_channel, is_width_flipped); + return in_bounds_crop_window<uint32_t>(input, output, output_ptr, input_offset, window_step_x, output_width_start, + output_width_limit, input_has_single_channel, is_width_flipped); } -void s8_in_bounds_crop_window(const ITensor *input, const ITensor *output, float *output_ptr, Coordinates input_offset, - int32_t window_step_x, int32_t output_width_start, int32_t output_width_limit, bool input_has_single_channel, bool is_width_flipped) +void s8_in_bounds_crop_window(const ITensor *input, + const ITensor *output, + float *output_ptr, + Coordinates input_offset, + int32_t window_step_x, + int32_t output_width_start, + int32_t output_width_limit, + bool input_has_single_channel, + bool is_width_flipped) { - return in_bounds_crop_window<int8_t>(input, output, output_ptr, input_offset, - window_step_x, output_width_start, output_width_limit, input_has_single_channel, is_width_flipped); + return in_bounds_crop_window<int8_t>(input, output, output_ptr, input_offset, window_step_x, output_width_start, + output_width_limit, input_has_single_channel, is_width_flipped); } -void s16_in_bounds_crop_window(const ITensor *input, const ITensor *output, float *output_ptr, Coordinates input_offset, - int32_t window_step_x, int32_t output_width_start, int32_t output_width_limit, bool input_has_single_channel, bool is_width_flipped) +void s16_in_bounds_crop_window(const ITensor *input, + const ITensor *output, + float *output_ptr, + Coordinates input_offset, + int32_t window_step_x, + int32_t output_width_start, + int32_t output_width_limit, + bool input_has_single_channel, + bool is_width_flipped) { - return in_bounds_crop_window<int16_t>(input, output, output_ptr, input_offset, - window_step_x, output_width_start, output_width_limit, input_has_single_channel, is_width_flipped); + return in_bounds_crop_window<int16_t>(input, output, output_ptr, input_offset, window_step_x, output_width_start, + output_width_limit, input_has_single_channel, is_width_flipped); } -void s32_in_bounds_crop_window(const ITensor *input, const ITensor *output, float *output_ptr, Coordinates input_offset, - int32_t window_step_x, int32_t output_width_start, int32_t output_width_limit, bool input_has_single_channel, bool is_width_flipped) +void s32_in_bounds_crop_window(const ITensor *input, + const ITensor *output, + float *output_ptr, + Coordinates input_offset, + int32_t window_step_x, + int32_t output_width_start, + int32_t output_width_limit, + bool input_has_single_channel, + bool is_width_flipped) { - return in_bounds_crop_window<int32_t>(input, output, output_ptr, input_offset, - window_step_x, output_width_start, output_width_limit, input_has_single_channel, is_width_flipped); -} + return in_bounds_crop_window<int32_t>(input, output, output_ptr, input_offset, window_step_x, output_width_start, + output_width_limit, input_has_single_channel, is_width_flipped); } +} // namespace cpu } // namespace arm_compute |