From 473cb01e84cef6cab057e9492bfa3b68f708e5d7 Mon Sep 17 00:00:00 2001 From: Michalis Spyrou Date: Tue, 23 Feb 2021 11:48:12 +0000 Subject: Remove Compute Vision CL support Resolves COMPMID-4151 Change-Id: I46f541efe8c4087f27794d2e158b6c1547d459ba Signed-off-by: Michalis Spyrou Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5160 Comments-Addressed: Arm Jenkins Tested-by: Arm Jenkins Reviewed-by: Michele Di Giorgio --- src/runtime/CL/functions/CLAbsoluteDifference.cpp | 42 --- src/runtime/CL/functions/CLAccumulate.cpp | 66 ----- src/runtime/CL/functions/CLBox3x3.cpp | 45 ---- src/runtime/CL/functions/CLCannyEdge.cpp | 214 ---------------- src/runtime/CL/functions/CLChannelCombine.cpp | 54 ---- src/runtime/CL/functions/CLChannelExtract.cpp | 54 ---- src/runtime/CL/functions/CLColorConvert.cpp | 78 ------ src/runtime/CL/functions/CLConvolution.cpp | 144 ----------- src/runtime/CL/functions/CLDerivative.cpp | 45 ---- src/runtime/CL/functions/CLDilate.cpp | 45 ---- src/runtime/CL/functions/CLEqualizeHistogram.cpp | 124 --------- src/runtime/CL/functions/CLErode.cpp | 45 ---- src/runtime/CL/functions/CLFastCorners.cpp | 141 ----------- src/runtime/CL/functions/CLGaussian3x3.cpp | 45 ---- src/runtime/CL/functions/CLGaussian5x5.cpp | 81 ------ src/runtime/CL/functions/CLGaussianPyramid.cpp | 214 ---------------- src/runtime/CL/functions/CLHOGDescriptor.cpp | 124 --------- src/runtime/CL/functions/CLHOGDetector.cpp | 77 ------ src/runtime/CL/functions/CLHOGGradient.cpp | 93 ------- src/runtime/CL/functions/CLHOGMultiDetection.cpp | 282 --------------------- src/runtime/CL/functions/CLHarrisCorners.cpp | 198 --------------- src/runtime/CL/functions/CLHistogram.cpp | 50 ---- src/runtime/CL/functions/CLIntegralImage.cpp | 54 ---- src/runtime/CL/functions/CLLaplacianPyramid.cpp | 112 -------- .../CL/functions/CLLaplacianReconstruct.cpp | 108 -------- src/runtime/CL/functions/CLMagnitude.cpp | 42 --- src/runtime/CL/functions/CLMeanStdDev.cpp | 177 ------------- src/runtime/CL/functions/CLMedian3x3.cpp | 45 ---- src/runtime/CL/functions/CLMinMaxLocation.cpp | 108 -------- src/runtime/CL/functions/CLNonLinearFilter.cpp | 46 ---- .../CL/functions/CLNonMaximaSuppression3x3.cpp | 52 ---- src/runtime/CL/functions/CLOpticalFlow.cpp | 184 -------------- src/runtime/CL/functions/CLPhase.cpp | 42 --- src/runtime/CL/functions/CLScharr3x3.cpp | 45 ---- src/runtime/CL/functions/CLSobel3x3.cpp | 47 ---- src/runtime/CL/functions/CLSobel5x5.cpp | 101 -------- src/runtime/CL/functions/CLSobel7x7.cpp | 101 -------- src/runtime/CL/functions/CLTableLookup.cpp | 42 --- src/runtime/CL/functions/CLThreshold.cpp | 43 ---- src/runtime/CL/functions/CLWarpAffine.cpp | 46 ---- src/runtime/CL/functions/CLWarpPerspective.cpp | 46 ---- 41 files changed, 3702 deletions(-) delete mode 100644 src/runtime/CL/functions/CLAbsoluteDifference.cpp delete mode 100644 src/runtime/CL/functions/CLAccumulate.cpp delete mode 100644 src/runtime/CL/functions/CLBox3x3.cpp delete mode 100644 src/runtime/CL/functions/CLCannyEdge.cpp delete mode 100644 src/runtime/CL/functions/CLChannelCombine.cpp delete mode 100644 src/runtime/CL/functions/CLChannelExtract.cpp delete mode 100644 src/runtime/CL/functions/CLColorConvert.cpp delete mode 100644 src/runtime/CL/functions/CLConvolution.cpp delete mode 100644 src/runtime/CL/functions/CLDerivative.cpp delete mode 100644 src/runtime/CL/functions/CLDilate.cpp delete mode 100644 src/runtime/CL/functions/CLEqualizeHistogram.cpp delete mode 100644 src/runtime/CL/functions/CLErode.cpp delete mode 100644 src/runtime/CL/functions/CLFastCorners.cpp delete mode 100644 src/runtime/CL/functions/CLGaussian3x3.cpp delete mode 100644 src/runtime/CL/functions/CLGaussian5x5.cpp delete mode 100644 src/runtime/CL/functions/CLGaussianPyramid.cpp delete mode 100644 src/runtime/CL/functions/CLHOGDescriptor.cpp delete mode 100644 src/runtime/CL/functions/CLHOGDetector.cpp delete mode 100644 src/runtime/CL/functions/CLHOGGradient.cpp delete mode 100644 src/runtime/CL/functions/CLHOGMultiDetection.cpp delete mode 100644 src/runtime/CL/functions/CLHarrisCorners.cpp delete mode 100644 src/runtime/CL/functions/CLHistogram.cpp delete mode 100644 src/runtime/CL/functions/CLIntegralImage.cpp delete mode 100644 src/runtime/CL/functions/CLLaplacianPyramid.cpp delete mode 100644 src/runtime/CL/functions/CLLaplacianReconstruct.cpp delete mode 100644 src/runtime/CL/functions/CLMagnitude.cpp delete mode 100644 src/runtime/CL/functions/CLMeanStdDev.cpp delete mode 100644 src/runtime/CL/functions/CLMedian3x3.cpp delete mode 100644 src/runtime/CL/functions/CLMinMaxLocation.cpp delete mode 100644 src/runtime/CL/functions/CLNonLinearFilter.cpp delete mode 100644 src/runtime/CL/functions/CLNonMaximaSuppression3x3.cpp delete mode 100644 src/runtime/CL/functions/CLOpticalFlow.cpp delete mode 100644 src/runtime/CL/functions/CLPhase.cpp delete mode 100644 src/runtime/CL/functions/CLScharr3x3.cpp delete mode 100644 src/runtime/CL/functions/CLSobel3x3.cpp delete mode 100644 src/runtime/CL/functions/CLSobel5x5.cpp delete mode 100644 src/runtime/CL/functions/CLSobel7x7.cpp delete mode 100644 src/runtime/CL/functions/CLTableLookup.cpp delete mode 100644 src/runtime/CL/functions/CLThreshold.cpp delete mode 100644 src/runtime/CL/functions/CLWarpAffine.cpp delete mode 100644 src/runtime/CL/functions/CLWarpPerspective.cpp (limited to 'src/runtime/CL/functions') diff --git a/src/runtime/CL/functions/CLAbsoluteDifference.cpp b/src/runtime/CL/functions/CLAbsoluteDifference.cpp deleted file mode 100644 index ff5b0a864d..0000000000 --- a/src/runtime/CL/functions/CLAbsoluteDifference.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLAbsoluteDifference.h" - -#include "src/core/CL/kernels/CLAbsoluteDifferenceKernel.h" - -#include - -using namespace arm_compute; - -void CLAbsoluteDifference::configure(const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output) -{ - configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output); -} - -void CLAbsoluteDifference::configure(const CLCompileContext &compile_context, const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output) -{ - auto k = std::make_unique(); - k->configure(compile_context, input1, input2, output); - _kernel = std::move(k); -} diff --git a/src/runtime/CL/functions/CLAccumulate.cpp b/src/runtime/CL/functions/CLAccumulate.cpp deleted file mode 100644 index 44020fd816..0000000000 --- a/src/runtime/CL/functions/CLAccumulate.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLAccumulate.h" - -#include "src/core/CL/kernels/CLAccumulateKernel.h" - -#include - -using namespace arm_compute; - -void CLAccumulate::configure(const ICLTensor *input, ICLTensor *accum) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, accum); -} - -void CLAccumulate::configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *accum) -{ - auto k = std::make_unique(); - k->configure(compile_context, input, accum); - _kernel = std::move(k); -} - -void CLAccumulateWeighted::configure(const ICLTensor *input, float alpha, ICLTensor *accum) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, alpha, accum); -} - -void CLAccumulateWeighted::configure(const CLCompileContext &compile_context, const ICLTensor *input, float alpha, ICLTensor *accum) -{ - auto k = std::make_unique(); - k->configure(compile_context, input, alpha, accum); - _kernel = std::move(k); -} - -void CLAccumulateSquared::configure(const ICLTensor *input, uint32_t shift, ICLTensor *accum) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, shift, accum); -} - -void CLAccumulateSquared::configure(const CLCompileContext &compile_context, const ICLTensor *input, uint32_t shift, ICLTensor *accum) -{ - auto k = std::make_unique(); - k->configure(compile_context, input, shift, accum); - _kernel = std::move(k); -} diff --git a/src/runtime/CL/functions/CLBox3x3.cpp b/src/runtime/CL/functions/CLBox3x3.cpp deleted file mode 100644 index 09e24d1bc0..0000000000 --- a/src/runtime/CL/functions/CLBox3x3.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLBox3x3.h" - -#include "arm_compute/core/PixelValue.h" -#include "src/core/CL/kernels/CLBox3x3Kernel.h" -#include "src/core/CL/kernels/CLFillBorderKernel.h" - -#include - -using namespace arm_compute; - -void CLBox3x3::configure(ICLTensor *input, ICLTensor *output, BorderMode border_mode, uint8_t constant_border_value) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, output, border_mode, constant_border_value); -} - -void CLBox3x3::configure(const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *output, BorderMode border_mode, uint8_t constant_border_value) -{ - auto k = std::make_unique(); - k->configure(compile_context, input, output, border_mode == BorderMode::UNDEFINED); - _kernel = std::move(k); - _border_handler->configure(compile_context, input, BorderSize(1), border_mode, PixelValue(constant_border_value)); -} diff --git a/src/runtime/CL/functions/CLCannyEdge.cpp b/src/runtime/CL/functions/CLCannyEdge.cpp deleted file mode 100644 index 7e99a1bbb3..0000000000 --- a/src/runtime/CL/functions/CLCannyEdge.cpp +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Copyright (c) 2017-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLCannyEdge.h" - -#include "arm_compute/core/CL/ICLTensor.h" -#include "arm_compute/core/CL/OpenCL.h" -#include "arm_compute/core/Error.h" -#include "arm_compute/core/Validate.h" -#include "arm_compute/runtime/CL/CLScheduler.h" -#include "arm_compute/runtime/CL/functions/CLSobel3x3.h" -#include "arm_compute/runtime/CL/functions/CLSobel5x5.h" -#include "arm_compute/runtime/CL/functions/CLSobel7x7.h" -#include "src/core/CL/kernels/CLCannyEdgeKernel.h" -#include "src/core/CL/kernels/CLFillBorderKernel.h" -#include "src/core/CL/kernels/CLSobel5x5Kernel.h" -#include "src/core/CL/kernels/CLSobel7x7Kernel.h" - -using namespace arm_compute; - -CLCannyEdge::CLCannyEdge(std::shared_ptr memory_manager) // NOLINT - : _memory_group(std::move(memory_manager)), - _sobel(), - _gradient(std::make_unique()), - _border_mag_gradient(std::make_unique()), - _non_max_suppr(std::make_unique()), - _edge_trace(std::make_unique()), - _gx(), - _gy(), - _mag(), - _phase(), - _nonmax(), - _visited(), - _recorded(), - _l1_list_counter(), - _l1_stack(), - _output(nullptr) -{ -} - -CLCannyEdge::~CLCannyEdge() = default; - -void CLCannyEdge::configure(ICLTensor *input, ICLTensor *output, int32_t upper_thr, int32_t lower_thr, int32_t gradient_size, int32_t norm_type, BorderMode border_mode, - uint8_t constant_border_value) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, output, upper_thr, lower_thr, gradient_size, norm_type, border_mode, constant_border_value); -} - -void CLCannyEdge::configure(const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *output, int32_t upper_thr, int32_t lower_thr, int32_t gradient_size, int32_t norm_type, - BorderMode border_mode, - uint8_t constant_border_value) -{ - ARM_COMPUTE_ERROR_ON_NULLPTR(input, output); - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8); - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(output, 1, DataType::U8); - ARM_COMPUTE_ERROR_ON((1 != norm_type) && (2 != norm_type)); - ARM_COMPUTE_ERROR_ON((gradient_size != 3) && (gradient_size != 5) && (gradient_size != 7)); - ARM_COMPUTE_ERROR_ON((lower_thr < 0) || (lower_thr >= upper_thr)); - - _output = output; - - const unsigned int L1_hysteresis_stack_size = 8; - const TensorShape shape = input->info()->tensor_shape(); - - TensorInfo gradient_info; - TensorInfo info; - - // Initialize images - if(gradient_size < 7) - { - gradient_info.init(shape, 1, arm_compute::DataType::S16); - info.init(shape, 1, arm_compute::DataType::U16); - } - else - { - gradient_info.init(shape, 1, arm_compute::DataType::S32); - info.init(shape, 1, arm_compute::DataType::U32); - } - - _gx.allocator()->init(gradient_info); - _gy.allocator()->init(gradient_info); - _mag.allocator()->init(info); - _nonmax.allocator()->init(info); - - TensorInfo info_u8(shape, 1, arm_compute::DataType::U8); - _phase.allocator()->init(info_u8); - _l1_list_counter.allocator()->init(info_u8); - - TensorInfo info_u32(shape, 1, arm_compute::DataType::U32); - _visited.allocator()->init(info_u32); - _recorded.allocator()->init(info_u32); - - TensorShape shape_l1_stack = input->info()->tensor_shape(); - shape_l1_stack.set(0, input->info()->dimension(0) * L1_hysteresis_stack_size); - TensorInfo info_s32(shape_l1_stack, 1, arm_compute::DataType::S32); - _l1_stack.allocator()->init(info_s32); - - // Manage intermediate buffers - _memory_group.manage(&_gx); - _memory_group.manage(&_gy); - - // Configure/Init sobelNxN - if(gradient_size == 3) - { - auto k = std::make_unique(); - k->configure(compile_context, input, &_gx, &_gy, border_mode, constant_border_value); - _sobel = std::move(k); - } - else if(gradient_size == 5) - { - auto k = std::make_unique(); - k->configure(compile_context, input, &_gx, &_gy, border_mode, constant_border_value); - _sobel = std::move(k); - } - else if(gradient_size == 7) - { - auto k = std::make_unique(); - k->configure(compile_context, input, &_gx, &_gy, border_mode, constant_border_value); - _sobel = std::move(k); - } - else - { - ARM_COMPUTE_ERROR_VAR("Gradient size %d not supported", gradient_size); - } - - // Manage intermediate buffers - _memory_group.manage(&_mag); - _memory_group.manage(&_phase); - - // Configure gradient - _gradient->configure(compile_context, &_gx, &_gy, &_mag, &_phase, norm_type); - - // Allocate intermediate buffers - _gx.allocator()->allocate(); - _gy.allocator()->allocate(); - - // Manage intermediate buffers - _memory_group.manage(&_nonmax); - - // Configure non-maxima suppression - _non_max_suppr->configure(compile_context, &_mag, &_phase, &_nonmax, lower_thr, border_mode == BorderMode::UNDEFINED); - - // Allocate intermediate buffers - _phase.allocator()->allocate(); - - // Fill border around magnitude image as non-maxima suppression will access - // it. If border mode is undefined filling the border is a nop. - _border_mag_gradient->configure(compile_context, &_mag, _non_max_suppr->border_size(), border_mode, constant_border_value); - - // Allocate intermediate buffers - _mag.allocator()->allocate(); - - // Manage intermediate buffers - _memory_group.manage(&_visited); - _memory_group.manage(&_recorded); - _memory_group.manage(&_l1_stack); - _memory_group.manage(&_l1_list_counter); - - // Configure edge tracing - _edge_trace->configure(compile_context, &_nonmax, output, upper_thr, lower_thr, &_visited, &_recorded, &_l1_stack, &_l1_list_counter); - - // Allocate intermediate buffers - _visited.allocator()->allocate(); - _recorded.allocator()->allocate(); - _l1_stack.allocator()->allocate(); - _l1_list_counter.allocator()->allocate(); - _nonmax.allocator()->allocate(); -} - -void CLCannyEdge::run() -{ - MemoryGroupResourceScope scope_mg(_memory_group); - - // Run sobel - _sobel->run(); - - // Run phase and magnitude calculation - CLScheduler::get().enqueue(*_gradient, false); - - // Fill border before non-maxima suppression. Nop for border mode undefined. - CLScheduler::get().enqueue(*_border_mag_gradient, false); - - // Run non max suppresion - _nonmax.clear(CLScheduler::get().queue()); - CLScheduler::get().enqueue(*_non_max_suppr, false); - - // Clear temporary structures and run edge trace - _output->clear(CLScheduler::get().queue()); - _visited.clear(CLScheduler::get().queue()); - _recorded.clear(CLScheduler::get().queue()); - _l1_list_counter.clear(CLScheduler::get().queue()); - _l1_stack.clear(CLScheduler::get().queue()); - CLScheduler::get().enqueue(*_edge_trace, true); -} diff --git a/src/runtime/CL/functions/CLChannelCombine.cpp b/src/runtime/CL/functions/CLChannelCombine.cpp deleted file mode 100644 index 543de9c653..0000000000 --- a/src/runtime/CL/functions/CLChannelCombine.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLChannelCombine.h" - -#include "src/core/CL/kernels/CLChannelCombineKernel.h" - -#include - -using namespace arm_compute; - -void CLChannelCombine::configure(const ICLTensor *plane0, const ICLTensor *plane1, const ICLTensor *plane2, const ICLTensor *plane3, ICLTensor *output) -{ - configure(CLKernelLibrary::get().get_compile_context(), plane0, plane1, plane2, plane3, output); -} - -void CLChannelCombine::configure(const CLCompileContext &compile_context, const ICLTensor *plane0, const ICLTensor *plane1, const ICLTensor *plane2, const ICLTensor *plane3, ICLTensor *output) -{ - auto k = std::make_unique(); - k->configure(compile_context, plane0, plane1, plane2, plane3, output); - _kernel = std::move(k); -} - -void CLChannelCombine::configure(const ICLImage *plane0, const ICLImage *plane1, const ICLImage *plane2, ICLMultiImage *output) -{ - configure(CLKernelLibrary::get().get_compile_context(), plane0, plane1, plane2, output); -} - -void CLChannelCombine::configure(const CLCompileContext &compile_context, const ICLImage *plane0, const ICLImage *plane1, const ICLImage *plane2, ICLMultiImage *output) -{ - auto k = std::make_unique(); - k->configure(compile_context, plane0, plane1, plane2, output); - _kernel = std::move(k); -} diff --git a/src/runtime/CL/functions/CLChannelExtract.cpp b/src/runtime/CL/functions/CLChannelExtract.cpp deleted file mode 100644 index 645fc051cb..0000000000 --- a/src/runtime/CL/functions/CLChannelExtract.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLChannelExtract.h" - -#include "src/core/CL/kernels/CLChannelExtractKernel.h" - -#include - -using namespace arm_compute; - -void CLChannelExtract::configure(const ICLTensor *input, Channel channel, ICLTensor *output) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, channel, output); -} - -void CLChannelExtract::configure(const CLCompileContext &compile_context, const ICLTensor *input, Channel channel, ICLTensor *output) -{ - auto k = std::make_unique(); - k->configure(compile_context, input, channel, output); - _kernel = std::move(k); -} - -void CLChannelExtract::configure(const ICLMultiImage *input, Channel channel, ICLImage *output) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, channel, output); -} - -void CLChannelExtract::configure(const CLCompileContext &compile_context, const ICLMultiImage *input, Channel channel, ICLImage *output) -{ - auto k = std::make_unique(); - k->configure(compile_context, input, channel, output); - _kernel = std::move(k); -} diff --git a/src/runtime/CL/functions/CLColorConvert.cpp b/src/runtime/CL/functions/CLColorConvert.cpp deleted file mode 100644 index 9aeeb65dc4..0000000000 --- a/src/runtime/CL/functions/CLColorConvert.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLColorConvert.h" - -#include "src/core/CL/kernels/CLColorConvertKernel.h" - -#include - -using namespace arm_compute; - -void CLColorConvert::configure(const ICLTensor *input, ICLTensor *output) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, output); -} - -void CLColorConvert::configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output) -{ - auto k = std::make_unique(); - k->configure(compile_context, input, output); - _kernel = std::move(k); -} - -void CLColorConvert::configure(const ICLImage *input, ICLMultiImage *output) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, output); -} - -void CLColorConvert::configure(const CLCompileContext &compile_context, const ICLImage *input, ICLMultiImage *output) -{ - auto k = std::make_unique(); - k->configure(compile_context, input, output); - _kernel = std::move(k); -} - -void CLColorConvert::configure(const ICLMultiImage *input, ICLImage *output) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, output); -} - -void CLColorConvert::configure(const CLCompileContext &compile_context, const ICLMultiImage *input, ICLImage *output) -{ - auto k = std::make_unique(); - k->configure(compile_context, input, output); - _kernel = std::move(k); -} - -void CLColorConvert::configure(const ICLMultiImage *input, ICLMultiImage *output) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, output); -} - -void CLColorConvert::configure(const CLCompileContext &compile_context, const ICLMultiImage *input, ICLMultiImage *output) -{ - auto k = std::make_unique(); - k->configure(compile_context, input, output); - _kernel = std::move(k); -} diff --git a/src/runtime/CL/functions/CLConvolution.cpp b/src/runtime/CL/functions/CLConvolution.cpp deleted file mode 100644 index ffc7cda034..0000000000 --- a/src/runtime/CL/functions/CLConvolution.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright (c) 2016-2021 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLConvolution.h" - -#include "arm_compute/core/CL/ICLTensor.h" -#include "arm_compute/core/Error.h" -#include "arm_compute/core/PixelValue.h" -#include "arm_compute/core/TensorInfo.h" -#include "arm_compute/core/Utils.h" -#include "arm_compute/core/Validate.h" -#include "arm_compute/runtime/CL/CLScheduler.h" -#include "arm_compute/runtime/ITensorAllocator.h" -#include "src/core/CL/kernels/CLConvolutionKernel.h" -#include "src/core/CL/kernels/CLFillBorderKernel.h" - -#include - -using namespace arm_compute; - -void CLConvolution3x3::configure(ICLTensor *input, ICLTensor *output, const int16_t *conv, uint32_t scale, BorderMode border_mode, uint8_t constant_border_value) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, output, conv, scale, border_mode, constant_border_value); -} - -void CLConvolution3x3::configure(const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *output, const int16_t *conv, uint32_t scale, BorderMode border_mode, - uint8_t constant_border_value) -{ - auto k = std::make_unique(); - k->configure(compile_context, input, output, conv, scale, border_mode == BorderMode::UNDEFINED); - _kernel = std::move(k); - _border_handler->configure(compile_context, input, _kernel->border_size(), border_mode, PixelValue(constant_border_value)); -} - -template -CLConvolutionSquare::CLConvolutionSquare(std::shared_ptr memory_manager) - : _memory_group(std::move(memory_manager)), _tmp(), _is_separable(false), _kernel_hor(std::make_unique>()), - _kernel_vert(std::make_unique>()), _kernel(std::make_unique>()), _border_handler(std::make_unique()) -{ -} - -template -CLConvolutionSquare::~CLConvolutionSquare() = default; - -template -void CLConvolutionSquare::configure(ICLTensor *input, ICLTensor *output, const int16_t *conv, uint32_t scale, BorderMode border_mode, - uint8_t constant_border_value) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, output, conv, scale, border_mode, constant_border_value); -} - -template -void CLConvolutionSquare::configure(const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *output, const int16_t *conv, uint32_t scale, BorderMode border_mode, - uint8_t constant_border_value) -{ - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8); - ARM_COMPUTE_ERROR_ON(conv == nullptr); - std::array conv_col{ 0 }; - std::array conv_row{ 0 }; - _is_separable = separate_matrix(conv, conv_col.data(), conv_row.data(), matrix_size); - - if(_is_separable) - { - std::pair type_pair = data_type_for_convolution(conv_col.data(), conv_row.data(), matrix_size); - _tmp.allocator()->init(TensorInfo(input->info()->tensor_shape(), 1, type_pair.first)); - - // Manage intermediate buffers - _memory_group.manage(&_tmp); - - if(scale == 0) - { - scale = calculate_matrix_scale(conv, matrix_size); - } - - _kernel_hor->configure(compile_context, input, &_tmp, conv_row.data(), border_mode == BorderMode::UNDEFINED); - _kernel_vert->configure(compile_context, &_tmp, output, conv_col.data(), scale, border_mode == BorderMode::UNDEFINED, type_pair.second); - _border_handler->configure(compile_context, input, _kernel_hor->border_size(), border_mode, PixelValue(constant_border_value)); - - // Allocate intermediate buffer - _tmp.allocator()->allocate(); - } - else - { - _kernel->configure(compile_context, input, output, conv, scale, border_mode == BorderMode::UNDEFINED); - _border_handler->configure(compile_context, input, _kernel->border_size(), border_mode, PixelValue(constant_border_value)); - } -} - -template -void CLConvolutionSquare::run() -{ - CLScheduler::get().enqueue(*_border_handler); - - if(_is_separable) - { - MemoryGroupResourceScope scope_mg(_memory_group); - - CLScheduler::get().enqueue(*_kernel_hor, false); - CLScheduler::get().enqueue(*_kernel_vert); - } - else - { - CLScheduler::get().enqueue(*_kernel); - } -} - -template class arm_compute::CLConvolutionSquare<5>; -template class arm_compute::CLConvolutionSquare<7>; -template class arm_compute::CLConvolutionSquare<9>; - -void CLConvolutionRectangle::configure(ICLTensor *input, ICLTensor *output, const int16_t *conv, uint32_t rows, uint32_t cols, uint32_t scale, BorderMode border_mode, uint8_t constant_border_value) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, output, conv, rows, cols, scale, border_mode, constant_border_value); -} - -void CLConvolutionRectangle::configure(const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *output, const int16_t *conv, uint32_t rows, uint32_t cols, uint32_t scale, - BorderMode border_mode, uint8_t constant_border_value) -{ - border_mode = (border_mode == BorderMode::UNDEFINED) ? BorderMode::CONSTANT : border_mode; - auto k = std::make_unique(); - k->configure(compile_context, input, output, conv, rows, cols, scale, false); - _kernel = std::move(k); - _border_handler->configure(compile_context, input, _kernel->border_size(), border_mode, PixelValue(constant_border_value)); -} diff --git a/src/runtime/CL/functions/CLDerivative.cpp b/src/runtime/CL/functions/CLDerivative.cpp deleted file mode 100644 index 2e3ecf7700..0000000000 --- a/src/runtime/CL/functions/CLDerivative.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLDerivative.h" - -#include "arm_compute/core/PixelValue.h" -#include "src/core/CL/kernels/CLDerivativeKernel.h" -#include "src/core/CL/kernels/CLFillBorderKernel.h" - -#include - -using namespace arm_compute; - -void CLDerivative::configure(ICLTensor *input, ICLTensor *output_x, ICLTensor *output_y, BorderMode border_mode, uint8_t constant_border_value) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, output_x, output_y, border_mode, constant_border_value); -} - -void CLDerivative::configure(const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *output_x, ICLTensor *output_y, BorderMode border_mode, uint8_t constant_border_value) -{ - auto k = std::make_unique(); - k->configure(compile_context, input, output_x, output_y, border_mode == BorderMode::UNDEFINED); - _kernel = std::move(k); - _border_handler->configure(compile_context, input, BorderSize(1), border_mode, PixelValue(constant_border_value)); -} diff --git a/src/runtime/CL/functions/CLDilate.cpp b/src/runtime/CL/functions/CLDilate.cpp deleted file mode 100644 index 92c5cc7ab1..0000000000 --- a/src/runtime/CL/functions/CLDilate.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLDilate.h" - -#include "arm_compute/core/PixelValue.h" -#include "src/core/CL/kernels/CLDilateKernel.h" -#include "src/core/CL/kernels/CLFillBorderKernel.h" - -#include - -using namespace arm_compute; - -void CLDilate::configure(ICLTensor *input, ICLTensor *output, BorderMode border_mode, uint8_t constant_border_value) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, output, border_mode, constant_border_value); -} - -void CLDilate::configure(const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *output, BorderMode border_mode, uint8_t constant_border_value) -{ - auto k = std::make_unique(); - k->configure(compile_context, input, output, border_mode == BorderMode::UNDEFINED); - _kernel = std::move(k); - _border_handler->configure(compile_context, input, BorderSize(1), border_mode, PixelValue(constant_border_value)); -} diff --git a/src/runtime/CL/functions/CLEqualizeHistogram.cpp b/src/runtime/CL/functions/CLEqualizeHistogram.cpp deleted file mode 100644 index 11607cf71d..0000000000 --- a/src/runtime/CL/functions/CLEqualizeHistogram.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLEqualizeHistogram.h" - -#include "arm_compute/core/CL/ICLDistribution1D.h" -#include "arm_compute/core/CL/ICLLut.h" -#include "arm_compute/core/CL/OpenCL.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLScheduler.h" -#include "src/core/CL/kernels/CLHistogramKernel.h" -#include "src/core/CL/kernels/CLTableLookupKernel.h" - -#include -#include -#include -#include - -using namespace arm_compute; - -namespace -{ -void calculate_cum_dist_and_lut(CLDistribution1D &dist, CLDistribution1D &cum_dist, CLLut &lut) -{ - dist.map(true); - cum_dist.map(true); - lut.map(true); - - const uint32_t *dist_ptr = dist.buffer(); - uint32_t *cum_dist_ptr = cum_dist.buffer(); - uint8_t *lut_ptr = lut.buffer(); - - ARM_COMPUTE_ERROR_ON(dist_ptr == nullptr); - ARM_COMPUTE_ERROR_ON(cum_dist_ptr == nullptr); - ARM_COMPUTE_ERROR_ON(lut_ptr == nullptr); - - // Calculate cumulative distribution - std::partial_sum(dist_ptr, dist_ptr + 256, cum_dist_ptr); - - // Get the number of pixels that have the lowest value in the input image - const uint32_t num_lowest_pixels = *std::find_if(dist_ptr, dist_ptr + 256, [](const uint32_t &v) - { - return v > 0; - }); - const size_t image_size = cum_dist_ptr[255]; - - if(image_size == num_lowest_pixels) - { - std::iota(lut_ptr, lut_ptr + 256, 0); - } - else - { - const float diff = image_size - num_lowest_pixels; - - for(size_t i = 0; i < 256; ++i) - { - lut_ptr[i] = lround((cum_dist_ptr[i] - num_lowest_pixels) / diff * 255.f); - } - } - - dist.unmap(); - cum_dist.unmap(); - lut.unmap(); -} -} // namespace - -CLEqualizeHistogram::CLEqualizeHistogram() - : _histogram_kernel(std::make_unique()), - _border_histogram_kernel(std::make_unique()), - _map_histogram_kernel(std::make_unique()), - _hist(nr_bins, 0, max_range), - _cum_dist(nr_bins, 0, max_range), - _cd_lut(nr_bins, DataType::U8) -{ -} - -CLEqualizeHistogram::~CLEqualizeHistogram() = default; - -void CLEqualizeHistogram::configure(const ICLImage *input, ICLImage *output) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, output); -} - -void CLEqualizeHistogram::configure(const CLCompileContext &compile_context, const ICLImage *input, ICLImage *output) -{ - _histogram_kernel->configure(compile_context, input, &_hist); - _border_histogram_kernel->configure(compile_context, input, &_hist); - _map_histogram_kernel->configure(compile_context, input, &_cd_lut, output); -} - -void CLEqualizeHistogram::run() -{ - // Calculate histogram of input. - CLScheduler::get().enqueue(*_histogram_kernel, false); - - // Calculate remaining pixels when image is not multiple of the elements of histogram kernel - CLScheduler::get().enqueue(*_border_histogram_kernel, false); - - // Calculate cumulative distribution of histogram and create LUT. - calculate_cum_dist_and_lut(_hist, _cum_dist, _cd_lut); - - // Map input to output using created LUT. - CLScheduler::get().enqueue(*_map_histogram_kernel); -} diff --git a/src/runtime/CL/functions/CLErode.cpp b/src/runtime/CL/functions/CLErode.cpp deleted file mode 100644 index 29551fc6bd..0000000000 --- a/src/runtime/CL/functions/CLErode.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLErode.h" - -#include "arm_compute/core/PixelValue.h" -#include "src/core/CL/kernels/CLErodeKernel.h" -#include "src/core/CL/kernels/CLFillBorderKernel.h" - -#include - -using namespace arm_compute; - -void CLErode::configure(ICLTensor *input, ICLTensor *output, BorderMode border_mode, uint8_t constant_border_value) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, output, border_mode, constant_border_value); -} - -void CLErode::configure(const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *output, BorderMode border_mode, uint8_t constant_border_value) -{ - auto k = std::make_unique(); - k->configure(compile_context, input, output, border_mode == BorderMode::UNDEFINED); - _kernel = std::move(k); - _border_handler->configure(compile_context, input, BorderSize(1), border_mode, PixelValue(constant_border_value)); -} diff --git a/src/runtime/CL/functions/CLFastCorners.cpp b/src/runtime/CL/functions/CLFastCorners.cpp deleted file mode 100644 index a3a62d6d5e..0000000000 --- a/src/runtime/CL/functions/CLFastCorners.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLFastCorners.h" - -#include "arm_compute/core/CL/OpenCL.h" -#include "arm_compute/core/Error.h" -#include "arm_compute/core/TensorInfo.h" -#include "arm_compute/core/Validate.h" -#include "arm_compute/runtime/CL/CLScheduler.h" -#include "arm_compute/runtime/ITensorAllocator.h" -#include "src/core/CL/kernels/CLFastCornersKernel.h" -#include "src/core/CL/kernels/CLFillBorderKernel.h" - -#include -#include - -using namespace arm_compute; - -CLFastCorners::CLFastCorners(std::shared_ptr memory_manager) - : _memory_group(std::move(memory_manager)), - _fast_corners_kernel(std::make_unique()), - _suppr_func(), - _copy_array_kernel(std::make_unique()), - _output(), - _suppr(), - _win(), - _non_max(false), - _num_corners(nullptr), - _num_buffer(), - _corners(nullptr), - _constant_border_value(0) -{ -} - -CLFastCorners::~CLFastCorners() = default; - -void CLFastCorners::configure(const ICLImage *input, float threshold, bool nonmax_suppression, ICLKeyPointArray *corners, - unsigned int *num_corners, BorderMode border_mode, uint8_t constant_border_value) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, threshold, nonmax_suppression, corners, num_corners, border_mode, constant_border_value); -} - -void CLFastCorners::configure(const CLCompileContext &compile_context, const ICLImage *input, float threshold, bool nonmax_suppression, ICLKeyPointArray *corners, - unsigned int *num_corners, BorderMode border_mode, uint8_t constant_border_value) -{ - ARM_COMPUTE_ERROR_ON_TENSOR_NOT_2D(input); - ARM_COMPUTE_ERROR_ON(BorderMode::UNDEFINED != border_mode); - ARM_COMPUTE_ERROR_ON(nullptr == corners); - ARM_COMPUTE_ERROR_ON(threshold < 1 && threshold > 255); - - TensorInfo tensor_info(input->info()->tensor_shape(), 1, DataType::U8); - _output.allocator()->init(tensor_info); - - _non_max = nonmax_suppression; - _num_corners = num_corners; - _corners = corners; - _num_buffer = cl::Buffer(CLScheduler::get().context(), CL_MEM_ALLOC_HOST_PTR | CL_MEM_READ_WRITE, sizeof(unsigned int)); - _constant_border_value = constant_border_value; - - const bool update_number = (nullptr != _num_corners); - - _memory_group.manage(&_output); - _fast_corners_kernel->configure(compile_context, input, &_output, threshold, nonmax_suppression, border_mode); - - if(!_non_max) - { - _copy_array_kernel->configure(compile_context, &_output, update_number, _corners, &_num_buffer); - } - else - { - _suppr.allocator()->init(tensor_info); - _memory_group.manage(&_suppr); - - _suppr_func.configure(compile_context, &_output, &_suppr, border_mode); - _copy_array_kernel->configure(compile_context, &_suppr, update_number, _corners, &_num_buffer); - - _suppr.allocator()->allocate(); - } - - // Allocate intermediate tensors - _output.allocator()->allocate(); -} - -void CLFastCorners::run() -{ - cl::CommandQueue q = CLScheduler::get().queue(); - - MemoryGroupResourceScope scope_mg(_memory_group); - - if(_non_max) - { - ARM_COMPUTE_ERROR_ON_MSG(_output.cl_buffer().get() == nullptr, "Unconfigured function"); - const auto out_buffer = static_cast(q.enqueueMapBuffer(_output.cl_buffer(), CL_TRUE, CL_MAP_WRITE, 0, _output.info()->total_size())); - memset(out_buffer, 0, _output.info()->total_size()); - q.enqueueUnmapMemObject(_output.cl_buffer(), out_buffer); - } - - CLScheduler::get().enqueue(*_fast_corners_kernel, false); - - if(_non_max) - { - _suppr_func.run(); - } - - CLScheduler::get().enqueue(*_copy_array_kernel, false); - - unsigned int get_num_corners = 0; - q.enqueueReadBuffer(_num_buffer, CL_TRUE, 0, sizeof(unsigned int), &get_num_corners); - - size_t corner_size = std::min(static_cast(get_num_corners), _corners->max_num_values()); - - _corners->resize(corner_size); - - if(_num_corners != nullptr) - { - *_num_corners = get_num_corners; - } - - q.flush(); -} diff --git a/src/runtime/CL/functions/CLGaussian3x3.cpp b/src/runtime/CL/functions/CLGaussian3x3.cpp deleted file mode 100644 index 8eeade2f47..0000000000 --- a/src/runtime/CL/functions/CLGaussian3x3.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLGaussian3x3.h" - -#include "arm_compute/core/PixelValue.h" -#include "src/core/CL/kernels/CLFillBorderKernel.h" -#include "src/core/CL/kernels/CLGaussian3x3Kernel.h" - -#include - -using namespace arm_compute; - -void CLGaussian3x3::configure(ICLTensor *input, ICLTensor *output, BorderMode border_mode, uint8_t constant_border_value) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, output, border_mode, constant_border_value); -} - -void CLGaussian3x3::configure(const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *output, BorderMode border_mode, uint8_t constant_border_value) -{ - auto k = std::make_unique(); - k->configure(compile_context, input, output, border_mode == BorderMode::UNDEFINED); - _kernel = std::move(k); - _border_handler->configure(compile_context, input, _kernel->border_size(), border_mode, PixelValue(constant_border_value)); -} diff --git a/src/runtime/CL/functions/CLGaussian5x5.cpp b/src/runtime/CL/functions/CLGaussian5x5.cpp deleted file mode 100644 index ee72fcbe11..0000000000 --- a/src/runtime/CL/functions/CLGaussian5x5.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLGaussian5x5.h" - -#include "arm_compute/core/CL/ICLTensor.h" -#include "arm_compute/core/PixelValue.h" -#include "arm_compute/core/TensorInfo.h" -#include "arm_compute/core/Validate.h" -#include "arm_compute/runtime/CL/CLScheduler.h" -#include "arm_compute/runtime/ITensorAllocator.h" -#include "src/core/CL/kernels/CLFillBorderKernel.h" -#include "src/core/CL/kernels/CLGaussian5x5Kernel.h" - -#include - -using namespace arm_compute; - -CLGaussian5x5::CLGaussian5x5(std::shared_ptr memory_manager) - : _memory_group(std::move(memory_manager)), - _kernel_hor(std::make_unique()), - _kernel_vert(std::make_unique()), - _border_handler(std::make_unique()), - _tmp() -{ -} - -CLGaussian5x5::~CLGaussian5x5() = default; - -void CLGaussian5x5::configure(ICLTensor *input, ICLTensor *output, BorderMode border_mode, uint8_t constant_border_value) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, output, border_mode, constant_border_value); -} - -void CLGaussian5x5::configure(const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *output, BorderMode border_mode, uint8_t constant_border_value) -{ - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8); - - _tmp.allocator()->init(TensorInfo(input->info()->tensor_shape(), 1, DataType::U16)); - - // Manage intermediate buffers - _memory_group.manage(&_tmp); - - // Configure kernels - _kernel_hor->configure(compile_context, input, &_tmp, border_mode == BorderMode::UNDEFINED); - _kernel_vert->configure(compile_context, &_tmp, output, border_mode == BorderMode::UNDEFINED); - _border_handler->configure(compile_context, input, _kernel_hor->border_size(), border_mode, PixelValue(constant_border_value)); - - // Allocate intermediate buffers - _tmp.allocator()->allocate(); -} - -void CLGaussian5x5::run() -{ - CLScheduler::get().enqueue(*_border_handler, false); - - MemoryGroupResourceScope scope_mg(_memory_group); - - CLScheduler::get().enqueue(*_kernel_hor, false); - CLScheduler::get().enqueue(*_kernel_vert); -} diff --git a/src/runtime/CL/functions/CLGaussianPyramid.cpp b/src/runtime/CL/functions/CLGaussianPyramid.cpp deleted file mode 100644 index 9fe35f6f0e..0000000000 --- a/src/runtime/CL/functions/CLGaussianPyramid.cpp +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Copyright (c) 2017-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLGaussianPyramid.h" - -#include "arm_compute/core/CL/ICLTensor.h" -#include "arm_compute/core/Error.h" -#include "arm_compute/core/PixelValue.h" -#include "arm_compute/core/TensorInfo.h" -#include "arm_compute/core/Validate.h" -#include "arm_compute/core/Window.h" -#include "arm_compute/runtime/CL/CLPyramid.h" -#include "arm_compute/runtime/CL/CLScheduler.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLGaussian5x5.h" -#include "src/core/CL/kernels/CLFillBorderKernel.h" -#include "src/core/CL/kernels/CLGaussian5x5Kernel.h" -#include "src/core/CL/kernels/CLGaussianPyramidKernel.h" -#include "src/core/CL/kernels/CLScaleKernel.h" - -#include - -using namespace arm_compute; - -CLGaussianPyramid::CLGaussianPyramid() - : _input(nullptr), _pyramid(nullptr), _tmp() -{ -} - -CLGaussianPyramid::~CLGaussianPyramid() = default; - -CLGaussianPyramidHalf::CLGaussianPyramidHalf() // NOLINT - : _horizontal_border_handler(), - _vertical_border_handler(), - _horizontal_reduction(), - _vertical_reduction() -{ -} - -CLGaussianPyramidHalf::~CLGaussianPyramidHalf() = default; - -void CLGaussianPyramidHalf::configure(ICLTensor *input, CLPyramid *pyramid, BorderMode border_mode, uint8_t constant_border_value) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, pyramid, border_mode, constant_border_value); -} - -void CLGaussianPyramidHalf::configure(const CLCompileContext &compile_context, ICLTensor *input, CLPyramid *pyramid, BorderMode border_mode, uint8_t constant_border_value) -{ - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8); - ARM_COMPUTE_ERROR_ON(pyramid == nullptr); - ARM_COMPUTE_ERROR_ON(input->info()->num_dimensions() != pyramid->get_pyramid_level(0)->info()->num_dimensions()); - ARM_COMPUTE_ERROR_ON(input->info()->dimension(0) != pyramid->info()->width()); - ARM_COMPUTE_ERROR_ON(input->info()->dimension(1) != pyramid->info()->height()); - ARM_COMPUTE_ERROR_ON(SCALE_PYRAMID_HALF != pyramid->info()->scale()); - - // Constant value to use for vertical fill border when the border mode is CONSTANT - const uint16_t pixel_value_u16 = static_cast(constant_border_value) * 2 + static_cast(constant_border_value) * 8 + static_cast(constant_border_value) * 6; - - /* Get number of pyramid levels */ - const size_t num_levels = pyramid->info()->num_levels(); - - _input = input; - _pyramid = pyramid; - - if(num_levels > 1) - { - _horizontal_border_handler.reserve(num_levels - 1); - _vertical_border_handler.reserve(num_levels - 1); - _horizontal_reduction.reserve(num_levels - 1); - _vertical_reduction.reserve(num_levels - 1); - - // Apply half scale to the X dimension of the tensor shape - TensorShape tensor_shape = pyramid->info()->tensor_shape(); - tensor_shape.set(0, (pyramid->info()->width() + 1) * SCALE_PYRAMID_HALF); - - PyramidInfo pyramid_info(num_levels - 1, SCALE_PYRAMID_HALF, tensor_shape, Format::U16); - _tmp.init(pyramid_info); - - for(size_t i = 0; i < num_levels - 1; ++i) - { - /* Configure horizontal kernel */ - _horizontal_reduction.emplace_back(std::make_unique()); - _horizontal_reduction.back()->configure(compile_context, _pyramid->get_pyramid_level(i), _tmp.get_pyramid_level(i)); - - /* Configure vertical kernel */ - _vertical_reduction.emplace_back(std::make_unique()); - _vertical_reduction.back()->configure(compile_context, _tmp.get_pyramid_level(i), _pyramid->get_pyramid_level(i + 1)); - - /* Configure border */ - _horizontal_border_handler.emplace_back(std::make_unique()); - _horizontal_border_handler.back()->configure(compile_context, _pyramid->get_pyramid_level(i), _horizontal_reduction.back()->border_size(), border_mode, PixelValue(constant_border_value)); - - /* Configure border */ - _vertical_border_handler.emplace_back(std::make_unique()); - _vertical_border_handler.back()->configure(compile_context, _tmp.get_pyramid_level(i), _vertical_reduction.back()->border_size(), border_mode, PixelValue(pixel_value_u16)); - } - _tmp.allocate(); - } -} - -void CLGaussianPyramidHalf::run() -{ - ARM_COMPUTE_ERROR_ON_MSG(_pyramid == nullptr, "Unconfigured function"); - - /* Get number of pyramid levels */ - const size_t num_levels = _pyramid->info()->num_levels(); - - /* The first level of the pyramid has the input image */ - _pyramid->get_pyramid_level(0)->map(CLScheduler::get().queue(), true /* blocking */); - _input->map(CLScheduler::get().queue(), true /* blocking */); - _pyramid->get_pyramid_level(0)->copy_from(*_input); - - _input->unmap(CLScheduler::get().queue()); - _pyramid->get_pyramid_level(0)->unmap(CLScheduler::get().queue()); - - for(unsigned int i = 0; i < num_levels - 1; ++i) - { - CLScheduler::get().enqueue(*_horizontal_border_handler[i], false); - CLScheduler::get().enqueue(*_horizontal_reduction[i], false); - CLScheduler::get().enqueue(*_vertical_border_handler[i], false); - CLScheduler::get().enqueue(*_vertical_reduction[i], false); - } -} - -CLGaussianPyramidOrb::CLGaussianPyramidOrb() // NOLINT - : _gauss5x5(), - _scale_nearest() -{ -} - -void CLGaussianPyramidOrb::configure(ICLTensor *input, CLPyramid *pyramid, BorderMode border_mode, uint8_t constant_border_value) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, pyramid, border_mode, constant_border_value); -} - -void CLGaussianPyramidOrb::configure(const CLCompileContext &compile_context, ICLTensor *input, CLPyramid *pyramid, BorderMode border_mode, uint8_t constant_border_value) -{ - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8); - ARM_COMPUTE_ERROR_ON(nullptr == pyramid); - ARM_COMPUTE_ERROR_ON(input->info()->num_dimensions() != pyramid->get_pyramid_level(0)->info()->num_dimensions()); - ARM_COMPUTE_ERROR_ON(input->info()->dimension(0) != pyramid->info()->width()); - ARM_COMPUTE_ERROR_ON(input->info()->dimension(1) != pyramid->info()->height()); - ARM_COMPUTE_ERROR_ON(SCALE_PYRAMID_ORB != pyramid->info()->scale()); - - /* Get number of pyramid levels */ - const size_t num_levels = pyramid->info()->num_levels(); - - _input = input; - _pyramid = pyramid; - - if(num_levels > 1) - { - _gauss5x5.resize(num_levels - 1); - _scale_nearest.reserve(num_levels - 1); - - PyramidInfo pyramid_info(num_levels - 1, SCALE_PYRAMID_ORB, pyramid->info()->tensor_shape(), Format::U8); - - _tmp.init(pyramid_info); - - for(size_t i = 0; i < num_levels - 1; ++i) - { - /* Configure gaussian 5x5 */ - _gauss5x5[i].configure(compile_context, _pyramid->get_pyramid_level(i), _tmp.get_pyramid_level(i), border_mode, constant_border_value); - - /* Configure scale image kernel */ - _scale_nearest.emplace_back(std::make_unique()); - _scale_nearest.back()->configure(compile_context, _tmp.get_pyramid_level(i), _pyramid->get_pyramid_level(i + 1), ScaleKernelInfo{ InterpolationPolicy::NEAREST_NEIGHBOR, border_mode, PixelValue(), SamplingPolicy::CENTER }); - } - - _tmp.allocate(); - } -} - -void CLGaussianPyramidOrb::run() -{ - ARM_COMPUTE_ERROR_ON_MSG(_pyramid == nullptr, "Unconfigured function"); - - /* Get number of pyramid levels */ - const size_t num_levels = _pyramid->info()->num_levels(); - - /* The first level of the pyramid has the input image */ - _pyramid->get_pyramid_level(0)->map(CLScheduler::get().queue(), true /* blocking */); - _input->map(CLScheduler::get().queue(), true /* blocking */); - _pyramid->get_pyramid_level(0)->copy_from(*_input); - _input->unmap(CLScheduler::get().queue()); - _pyramid->get_pyramid_level(0)->unmap(CLScheduler::get().queue()); - - for(unsigned int i = 0; i < num_levels - 1; ++i) - { - _gauss5x5[i].run(); - CLScheduler::get().enqueue(*_scale_nearest[i]); - } -} diff --git a/src/runtime/CL/functions/CLHOGDescriptor.cpp b/src/runtime/CL/functions/CLHOGDescriptor.cpp deleted file mode 100644 index 8d9ea17d66..0000000000 --- a/src/runtime/CL/functions/CLHOGDescriptor.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2017-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLHOGDescriptor.h" - -#include "arm_compute/core/Error.h" -#include "arm_compute/core/HOGInfo.h" -#include "arm_compute/core/Size2D.h" -#include "arm_compute/core/Validate.h" -#include "arm_compute/runtime/CL/CLScheduler.h" -#include "src/core/CL/kernels/CLFillBorderKernel.h" -#include "src/core/CL/kernels/CLHOGDescriptorKernel.h" -#include "src/core/CL/kernels/CLMagnitudePhaseKernel.h" - -using namespace arm_compute; - -CLHOGDescriptor::CLHOGDescriptor(std::shared_ptr memory_manager) - : _memory_group(std::move(memory_manager)), - _gradient(), - _orient_bin(std::make_unique()), - _block_norm(std::make_unique()), - _mag(), - _phase(), - _hog_space() -{ -} - -CLHOGDescriptor::~CLHOGDescriptor() = default; - -void CLHOGDescriptor::configure(ICLTensor *input, ICLTensor *output, const IHOG *hog, BorderMode border_mode, uint8_t constant_border_value) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, output, hog, border_mode, constant_border_value); -} - -void CLHOGDescriptor::configure(const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *output, const IHOG *hog, BorderMode border_mode, uint8_t constant_border_value) -{ - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8); - ARM_COMPUTE_ERROR_ON(nullptr == output); - ARM_COMPUTE_ERROR_ON(nullptr == hog); - - const HOGInfo *hog_info = hog->info(); - const size_t width = input->info()->dimension(Window::DimX); - const size_t height = input->info()->dimension(Window::DimY); - const size_t num_bins = hog_info->num_bins(); - - Size2D cell_size = hog_info->cell_size(); - - // Calculate number of cells along the x and y directions for the hog_space - const size_t num_cells_x = width / cell_size.width; - const size_t num_cells_y = height / cell_size.height; - - // TensorShape of the input image - const TensorShape &shape_img = input->info()->tensor_shape(); - - // TensorShape of the hog space - TensorShape shape_hog_space = input->info()->tensor_shape(); - shape_hog_space.set(Window::DimX, num_cells_x); - shape_hog_space.set(Window::DimY, num_cells_y); - - // Intitialize tensors for magnitude, phase and hog space - TensorInfo info_mag(shape_img, Format::S16); - _mag.allocator()->init(info_mag); - - TensorInfo info_phase(shape_img, Format::U8); - _phase.allocator()->init(info_phase); - - TensorInfo info_space(shape_hog_space, num_bins, DataType::F32); - _hog_space.allocator()->init(info_space); - - // Manage intermediate buffers - _memory_group.manage(&_mag); - _memory_group.manage(&_phase); - - // Initialise gradient kernel - _gradient.configure(compile_context, input, &_mag, &_phase, hog_info->phase_type(), border_mode, constant_border_value); - - // Manage intermediate buffers - _memory_group.manage(&_hog_space); - - // Initialise orientation binning kernel - _orient_bin->configure(compile_context, &_mag, &_phase, &_hog_space, hog->info()); - - // Initialize HOG norm kernel - _block_norm->configure(compile_context, &_hog_space, output, hog->info()); - - // Allocate intermediate tensors - _mag.allocator()->allocate(); - _phase.allocator()->allocate(); - _hog_space.allocator()->allocate(); -} - -void CLHOGDescriptor::run() -{ - MemoryGroupResourceScope scope_mg(_memory_group); - - // Run gradient - _gradient.run(); - - // Run orientation binning - CLScheduler::get().enqueue(*_orient_bin, false); - - // Run block normalization - CLScheduler::get().enqueue(*_block_norm); -} \ No newline at end of file diff --git a/src/runtime/CL/functions/CLHOGDetector.cpp b/src/runtime/CL/functions/CLHOGDetector.cpp deleted file mode 100644 index 365021c723..0000000000 --- a/src/runtime/CL/functions/CLHOGDetector.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2017-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLHOGDetector.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/runtime/CL/CLScheduler.h" -#include "src/core/CL/kernels/CLHOGDetectorKernel.h" - -#include - -using namespace arm_compute; - -CLHOGDetector::CLHOGDetector() - : _hog_detector_kernel(std::make_unique()), _detection_windows(nullptr), _num_detection_windows() -{ -} - -CLHOGDetector::~CLHOGDetector() = default; - -void CLHOGDetector::configure(const ICLTensor *input, const ICLHOG *hog, ICLDetectionWindowArray *detection_windows, const Size2D &detection_window_stride, float threshold, size_t idx_class) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, hog, detection_windows, detection_window_stride, threshold, idx_class); -} - -void CLHOGDetector::configure(const CLCompileContext &compile_context, const ICLTensor *input, const ICLHOG *hog, ICLDetectionWindowArray *detection_windows, const Size2D &detection_window_stride, - float threshold, size_t idx_class) -{ - _detection_windows = detection_windows; - - // Allocate buffer for storing the number of detected objects - _num_detection_windows = cl::Buffer(CLScheduler::get().context(), CL_MEM_ALLOC_HOST_PTR | CL_MEM_READ_WRITE, sizeof(unsigned int)); - - // Configure HOGDetectorKernel - _hog_detector_kernel->configure(compile_context, input, hog, detection_windows, &_num_detection_windows, detection_window_stride, threshold, idx_class); -} - -void CLHOGDetector::run() -{ - cl::CommandQueue q = CLScheduler::get().queue(); - - // Reset number of detections - const unsigned int init_num_detection_windows = _detection_windows->num_values(); - q.enqueueWriteBuffer(_num_detection_windows, CL_FALSE, 0, sizeof(unsigned int), &init_num_detection_windows); - - // Run CLHOGDetectorKernel - CLScheduler::get().enqueue(*_hog_detector_kernel); - - // Read number of detections - unsigned int num_detection_windows = 0; - q.enqueueReadBuffer(_num_detection_windows, CL_TRUE, 0, sizeof(unsigned int), &num_detection_windows); - - // Update the number of values stored in _detection_windows - _detection_windows->resize(static_cast(num_detection_windows)); - - q.flush(); -} \ No newline at end of file diff --git a/src/runtime/CL/functions/CLHOGGradient.cpp b/src/runtime/CL/functions/CLHOGGradient.cpp deleted file mode 100644 index f3aa527417..0000000000 --- a/src/runtime/CL/functions/CLHOGGradient.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2017-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLHOGGradient.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Validate.h" -#include "arm_compute/runtime/CL/CLScheduler.h" -#include "src/core/CL/kernels/CLFillBorderKernel.h" -#include "src/core/CL/kernels/CLMagnitudePhaseKernel.h" - -using namespace arm_compute; - -CLHOGGradient::CLHOGGradient(std::shared_ptr memory_manager) - : _memory_group(std::move(memory_manager)), - _derivative(), - _mag_phase(std::make_unique()), - _gx(), - _gy() -{ -} - -void CLHOGGradient::configure(ICLTensor *input, ICLTensor *output_magnitude, ICLTensor *output_phase, PhaseType phase_type, BorderMode border_mode, uint8_t constant_border_value) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, output_magnitude, output_phase, phase_type, border_mode, constant_border_value); -} - -void CLHOGGradient::configure(const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *output_magnitude, ICLTensor *output_phase, PhaseType phase_type, BorderMode border_mode, - uint8_t constant_border_value) -{ - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8); - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(output_magnitude, 1, DataType::S16); - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(output_phase, 1, DataType::U8); - - const TensorShape &shape_img = input->info()->tensor_shape(); - - // Allocate image memory - TensorInfo info(shape_img, Format::S16); - _gx.allocator()->init(info); - _gy.allocator()->init(info); - - // Manage intermediate buffers - _memory_group.manage(&_gx); - _memory_group.manage(&_gy); - - // Initialise derivate kernel - _derivative.configure(compile_context, input, &_gx, &_gy, border_mode, constant_border_value); - - // Initialise magnitude/phase kernel - if(PhaseType::UNSIGNED == phase_type) - { - _mag_phase->configure(compile_context, &_gx, &_gy, output_magnitude, output_phase, MagnitudeType::L2NORM, PhaseType::UNSIGNED); - } - else - { - _mag_phase->configure(compile_context, &_gx, &_gy, output_magnitude, output_phase, MagnitudeType::L2NORM, PhaseType::SIGNED); - } - - // Allocate intermediate tensors - _gx.allocator()->allocate(); - _gy.allocator()->allocate(); -} - -void CLHOGGradient::run() -{ - MemoryGroupResourceScope scope_mg(_memory_group); - - // Run derivative - _derivative.run(); - - // Run magnitude/phase kernel - CLScheduler::get().enqueue(*_mag_phase); -} \ No newline at end of file diff --git a/src/runtime/CL/functions/CLHOGMultiDetection.cpp b/src/runtime/CL/functions/CLHOGMultiDetection.cpp deleted file mode 100644 index 2464e6cf9f..0000000000 --- a/src/runtime/CL/functions/CLHOGMultiDetection.cpp +++ /dev/null @@ -1,282 +0,0 @@ -/* - * Copyright (c) 2017-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLHOGMultiDetection.h" - -#include "arm_compute/core/CL/OpenCL.h" -#include "arm_compute/core/Error.h" -#include "arm_compute/core/TensorInfo.h" -#include "arm_compute/runtime/CL/CLArray.h" -#include "arm_compute/runtime/CL/CLScheduler.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/Scheduler.h" -#include "src/core/CL/kernels/CLFillBorderKernel.h" -#include "src/core/CL/kernels/CLHOGDescriptorKernel.h" -#include "src/core/CL/kernels/CLHOGDetectorKernel.h" -#include "src/core/CL/kernels/CLMagnitudePhaseKernel.h" - -using namespace arm_compute; - -CLHOGMultiDetection::CLHOGMultiDetection(std::shared_ptr memory_manager) // NOLINT - : _memory_group(std::move(memory_manager)), - _gradient_kernel(), - _orient_bin_kernel(), - _block_norm_kernel(), - _hog_detect_kernel(), - _non_maxima_kernel(), - _hog_space(), - _hog_norm_space(), - _detection_windows(), - _mag(), - _phase(), - _non_maxima_suppression(false), - _num_orient_bin_kernel(0), - _num_block_norm_kernel(0), - _num_hog_detect_kernel(0) -{ -} - -CLHOGMultiDetection::~CLHOGMultiDetection() = default; - -void CLHOGMultiDetection::configure(ICLTensor *input, const ICLMultiHOG *multi_hog, ICLDetectionWindowArray *detection_windows, ICLSize2DArray *detection_window_strides, BorderMode border_mode, - uint8_t constant_border_value, float threshold, bool non_maxima_suppression, float min_distance) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, multi_hog, detection_windows, detection_window_strides, border_mode, constant_border_value, threshold, non_maxima_suppression, - min_distance); -} - -void CLHOGMultiDetection::configure(const CLCompileContext &compile_context, ICLTensor *input, const ICLMultiHOG *multi_hog, ICLDetectionWindowArray *detection_windows, - ICLSize2DArray *detection_window_strides, BorderMode border_mode, - uint8_t constant_border_value, float threshold, bool non_maxima_suppression, float min_distance) -{ - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8); - ARM_COMPUTE_ERROR_ON_INVALID_MULTI_HOG(multi_hog); - ARM_COMPUTE_ERROR_ON(nullptr == detection_windows); - ARM_COMPUTE_ERROR_ON(detection_window_strides->num_values() != multi_hog->num_models()); - - const size_t width = input->info()->dimension(Window::DimX); - const size_t height = input->info()->dimension(Window::DimY); - const TensorShape &shape_img = input->info()->tensor_shape(); - const size_t num_models = multi_hog->num_models(); - PhaseType phase_type = multi_hog->model(0)->info()->phase_type(); - - size_t prev_num_bins = multi_hog->model(0)->info()->num_bins(); - Size2D prev_cell_size = multi_hog->model(0)->info()->cell_size(); - Size2D prev_block_size = multi_hog->model(0)->info()->block_size(); - Size2D prev_block_stride = multi_hog->model(0)->info()->block_stride(); - - /* Check if CLHOGOrientationBinningKernel and CLHOGBlockNormalizationKernel kernels can be skipped for a specific HOG data-object - * - * 1) CLHOGOrientationBinningKernel and CLHOGBlockNormalizationKernel are skipped if the cell size and the number of bins don't change. - * Since "multi_hog" is sorted,it is enough to check the HOG descriptors at level "ith" and level "(i-1)th - * 2) CLHOGBlockNormalizationKernel is skipped if the cell size, the number of bins and block size do not change. - * Since "multi_hog" is sorted,it is enough to check the HOG descriptors at level "ith" and level "(i-1)th - * - * @note Since the orientation binning and block normalization kernels can be skipped, we need to keep track of the input to process for each kernel - * with "input_orient_bin", "input_hog_detect" and "input_block_norm" - */ - std::vector input_orient_bin; - std::vector input_hog_detect; - std::vector> input_block_norm; - - input_orient_bin.push_back(0); - input_hog_detect.push_back(0); - input_block_norm.emplace_back(0, 0); - - for(size_t i = 1; i < num_models; ++i) - { - size_t cur_num_bins = multi_hog->model(i)->info()->num_bins(); - Size2D cur_cell_size = multi_hog->model(i)->info()->cell_size(); - Size2D cur_block_size = multi_hog->model(i)->info()->block_size(); - Size2D cur_block_stride = multi_hog->model(i)->info()->block_stride(); - - if((cur_num_bins != prev_num_bins) || (cur_cell_size.width != prev_cell_size.width) || (cur_cell_size.height != prev_cell_size.height)) - { - prev_num_bins = cur_num_bins; - prev_cell_size = cur_cell_size; - prev_block_size = cur_block_size; - prev_block_stride = cur_block_stride; - - // Compute orientation binning and block normalization kernels. Update input to process - input_orient_bin.push_back(i); - input_block_norm.emplace_back(i, input_orient_bin.size() - 1); - } - else if((cur_block_size.width != prev_block_size.width) || (cur_block_size.height != prev_block_size.height) || (cur_block_stride.width != prev_block_stride.width) - || (cur_block_stride.height != prev_block_stride.height)) - { - prev_block_size = cur_block_size; - prev_block_stride = cur_block_stride; - - // Compute block normalization kernel. Update input to process - input_block_norm.emplace_back(i, input_orient_bin.size() - 1); - } - - // Update input to process for hog detector kernel - input_hog_detect.push_back(input_block_norm.size() - 1); - } - - _detection_windows = detection_windows; - _non_maxima_suppression = non_maxima_suppression; - _num_orient_bin_kernel = input_orient_bin.size(); // Number of CLHOGOrientationBinningKernel kernels to compute - _num_block_norm_kernel = input_block_norm.size(); // Number of CLHOGBlockNormalizationKernel kernels to compute - _num_hog_detect_kernel = input_hog_detect.size(); // Number of CLHOGDetector functions to compute - - _orient_bin_kernel.reserve(_num_orient_bin_kernel); - _block_norm_kernel.reserve(_num_block_norm_kernel); - _hog_detect_kernel.resize(_num_hog_detect_kernel); - _hog_space.resize(_num_orient_bin_kernel); - _hog_norm_space.resize(_num_block_norm_kernel); - - // Allocate tensors for magnitude and phase - TensorInfo info_mag(shape_img, Format::S16); - _mag.allocator()->init(info_mag); - - TensorInfo info_phase(shape_img, Format::U8); - _phase.allocator()->init(info_phase); - - // Manage intermediate buffers - _memory_group.manage(&_mag); - _memory_group.manage(&_phase); - - // Initialise gradient kernel - _gradient_kernel.configure(compile_context, input, &_mag, &_phase, phase_type, border_mode, constant_border_value); - - // Configure NETensor for the HOG space and orientation binning kernel - for(size_t i = 0; i < _num_orient_bin_kernel; ++i) - { - const size_t idx_multi_hog = input_orient_bin[i]; - - // Get the corresponding cell size and number of bins - const Size2D &cell = multi_hog->model(idx_multi_hog)->info()->cell_size(); - const size_t num_bins = multi_hog->model(idx_multi_hog)->info()->num_bins(); - - // Calculate number of cells along the x and y directions for the hog_space - const size_t num_cells_x = width / cell.width; - const size_t num_cells_y = height / cell.height; - - // TensorShape of hog space - TensorShape shape_hog_space = input->info()->tensor_shape(); - shape_hog_space.set(Window::DimX, num_cells_x); - shape_hog_space.set(Window::DimY, num_cells_y); - - // Allocate HOG space - TensorInfo info_space(shape_hog_space, num_bins, DataType::F32); - _hog_space[i].allocator()->init(info_space); - - // Manage intermediate buffers - _memory_group.manage(&_hog_space[i]); - - // Initialise orientation binning kernel - _orient_bin_kernel.emplace_back(std::make_unique()); - _orient_bin_kernel.back()->configure(compile_context, &_mag, &_phase, &_hog_space[i], multi_hog->model(idx_multi_hog)->info()); - } - - // Allocate intermediate tensors - _mag.allocator()->allocate(); - _phase.allocator()->allocate(); - - // Configure CLTensor for the normalized HOG space and block normalization kernel - for(size_t i = 0; i < _num_block_norm_kernel; ++i) - { - const size_t idx_multi_hog = input_block_norm[i].first; - const size_t idx_orient_bin = input_block_norm[i].second; - - // Allocate normalized HOG space - TensorInfo tensor_info(*(multi_hog->model(idx_multi_hog)->info()), width, height); - _hog_norm_space[i].allocator()->init(tensor_info); - - // Manage intermediate buffers - _memory_group.manage(&_hog_norm_space[i]); - - // Initialize block normalization kernel - _block_norm_kernel.emplace_back(std::make_unique()); - _block_norm_kernel.back()->configure(compile_context, &_hog_space[idx_orient_bin], &_hog_norm_space[i], multi_hog->model(idx_multi_hog)->info()); - } - - // Allocate intermediate tensors - for(size_t i = 0; i < _num_orient_bin_kernel; ++i) - { - _hog_space[i].allocator()->allocate(); - } - - detection_window_strides->map(CLScheduler::get().queue(), true); - - // Configure HOG detector kernel - for(size_t i = 0; i < _num_hog_detect_kernel; ++i) - { - const size_t idx_block_norm = input_hog_detect[i]; - - _hog_detect_kernel[i].configure(compile_context, &_hog_norm_space[idx_block_norm], multi_hog->cl_model(i), detection_windows, detection_window_strides->at(i), threshold, i); - } - - detection_window_strides->unmap(CLScheduler::get().queue()); - - // Configure non maxima suppression kernel - _non_maxima_kernel.configure(_detection_windows, min_distance); - - // Allocate intermediate tensors - for(size_t i = 0; i < _num_block_norm_kernel; ++i) - { - _hog_norm_space[i].allocator()->allocate(); - } -} - -void CLHOGMultiDetection::run() -{ - ARM_COMPUTE_ERROR_ON_MSG(_detection_windows == nullptr, "Unconfigured function"); - - MemoryGroupResourceScope scope_mg(_memory_group); - - // Reset detection window - _detection_windows->clear(); - - // Run gradient - _gradient_kernel.run(); - - // Run orientation binning kernel - for(size_t i = 0; i < _num_orient_bin_kernel; ++i) - { - CLScheduler::get().enqueue(*_orient_bin_kernel[i], false); - } - - // Run block normalization kernel - for(size_t i = 0; i < _num_block_norm_kernel; ++i) - { - CLScheduler::get().enqueue(*_block_norm_kernel[i], false); - } - - // Run HOG detector kernel - for(size_t i = 0; i < _num_hog_detect_kernel; ++i) - { - _hog_detect_kernel[i].run(); - } - - // Run non-maxima suppression kernel if enabled - if(_non_maxima_suppression) - { - // Map detection windows array before computing non maxima suppression - _detection_windows->map(CLScheduler::get().queue(), true); - Scheduler::get().schedule(&_non_maxima_kernel, Window::DimY); - _detection_windows->unmap(CLScheduler::get().queue()); - } -} diff --git a/src/runtime/CL/functions/CLHarrisCorners.cpp b/src/runtime/CL/functions/CLHarrisCorners.cpp deleted file mode 100644 index 37f428c677..0000000000 --- a/src/runtime/CL/functions/CLHarrisCorners.cpp +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLHarrisCorners.h" - -#include "arm_compute/core/CL/OpenCL.h" -#include "arm_compute/core/Error.h" -#include "arm_compute/core/TensorInfo.h" -#include "arm_compute/core/Validate.h" -#include "arm_compute/runtime/CL/CLScheduler.h" -#include "arm_compute/runtime/CL/functions/CLSobel3x3.h" -#include "arm_compute/runtime/CL/functions/CLSobel5x5.h" -#include "arm_compute/runtime/CL/functions/CLSobel7x7.h" -#include "arm_compute/runtime/ITensorAllocator.h" -#include "arm_compute/runtime/Scheduler.h" -#include "src/core/CL/kernels/CLFillBorderKernel.h" -#include "src/core/CL/kernels/CLHarrisCornersKernel.h" -#include "src/core/CL/kernels/CLSobel5x5Kernel.h" -#include "src/core/CL/kernels/CLSobel7x7Kernel.h" - -#include -#include - -using namespace arm_compute; - -CLHarrisCorners::CLHarrisCorners(std::shared_ptr memory_manager) // NOLINT - : _memory_group(std::move(memory_manager)), - _sobel(nullptr), - _harris_score(std::make_unique()), - _non_max_suppr(), - _candidates(), - _sort_euclidean(), - _border_gx(std::make_unique()), - _border_gy(std::make_unique()), - _gx(), - _gy(), - _score(), - _nonmax(), - _corners_list(), - _num_corner_candidates(0), - _corners(nullptr) -{ -} - -CLHarrisCorners::~CLHarrisCorners() = default; - -void CLHarrisCorners::configure(ICLImage *input, float threshold, float min_dist, - float sensitivity, int32_t gradient_size, int32_t block_size, ICLKeyPointArray *corners, - BorderMode border_mode, uint8_t constant_border_value, bool use_fp16) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, threshold, min_dist, sensitivity, gradient_size, block_size, corners, border_mode, constant_border_value, use_fp16); -} - -void CLHarrisCorners::configure(const CLCompileContext &compile_context, ICLImage *input, float threshold, float min_dist, - float sensitivity, int32_t gradient_size, int32_t block_size, ICLKeyPointArray *corners, - BorderMode border_mode, uint8_t constant_border_value, bool use_fp16) -{ - ARM_COMPUTE_UNUSED(use_fp16); //TODO(COMPMID-772): Add half float support - ARM_COMPUTE_ERROR_ON_TENSOR_NOT_2D(input); - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8); - ARM_COMPUTE_ERROR_ON(!(block_size == 3 || block_size == 5 || block_size == 7)); - ARM_COMPUTE_ERROR_ON(nullptr == corners); - - _corners = corners; - - const TensorShape shape = input->info()->tensor_shape(); - const DataType dt = (gradient_size < 7) ? DataType::S16 : DataType::S32; - TensorInfo tensor_info(shape, 1, dt); - - _gx.allocator()->init(tensor_info); - _gy.allocator()->init(tensor_info); - - TensorInfo info_f32(shape, 1, DataType::F32); - _score.allocator()->init(info_f32); - _nonmax.allocator()->init(info_f32); - - _corners_list.resize(shape.x() * shape.y()); - - // Manage intermediate buffers - _memory_group.manage(&_gx); - _memory_group.manage(&_gy); - - /* Set/init Sobel kernel accordingly with gradient_size */ - switch(gradient_size) - { - case 3: - { - auto k = std::make_unique(); - k->configure(compile_context, input, &_gx, &_gy, border_mode, constant_border_value); - _sobel = std::move(k); - break; - } - case 5: - { - auto k = std::make_unique(); - k->configure(compile_context, input, &_gx, &_gy, border_mode, constant_border_value); - _sobel = std::move(k); - break; - } - case 7: - { - auto k = std::make_unique(); - k->configure(compile_context, input, &_gx, &_gy, border_mode, constant_border_value); - _sobel = std::move(k); - break; - } - default: - ARM_COMPUTE_ERROR("Gradient size not implemented"); - } - - // Normalization factor - const float norm_factor = 1.0f / (255.0f * pow(4.0f, gradient_size / 2) * block_size); - const float pow4_normalization_factor = pow(norm_factor, 4); - - // Manage intermediate buffers - _memory_group.manage(&_score); - - // Set/init Harris Score kernel accordingly with block_size - _harris_score->configure(compile_context, &_gx, &_gy, &_score, block_size, pow4_normalization_factor, threshold, sensitivity, border_mode == BorderMode::UNDEFINED); - - // Configure border filling using harris score kernel's block size - _border_gx->configure(compile_context, &_gx, _harris_score->border_size(), border_mode, PixelValue(constant_border_value)); - _border_gy->configure(compile_context, &_gy, _harris_score->border_size(), border_mode, PixelValue(constant_border_value)); - - // Allocate intermediate buffers - _gx.allocator()->allocate(); - _gy.allocator()->allocate(); - - // Manage intermediate buffers - _memory_group.manage(&_nonmax); - - // Init non-maxima suppression function - _non_max_suppr.configure(compile_context, &_score, &_nonmax, border_mode); - - // Allocate intermediate buffers - _score.allocator()->allocate(); - - // Init corner candidates kernel - _candidates.configure(&_nonmax, _corners_list.data(), &_num_corner_candidates); - - // Allocate intermediate buffers - _nonmax.allocator()->allocate(); - - // Init euclidean distance - _sort_euclidean.configure(_corners_list.data(), _corners, &_num_corner_candidates, min_dist); -} - -void CLHarrisCorners::run() -{ - ARM_COMPUTE_ERROR_ON_MSG(_sobel == nullptr, "Unconfigured function"); - - MemoryGroupResourceScope scope_mg(_memory_group); - - // Init to 0 number of corner candidates - _num_corner_candidates = 0; - - // Run Sobel kernel - _sobel->run(); - - // Fill border before harris score kernel - CLScheduler::get().enqueue(*_border_gx, false); - CLScheduler::get().enqueue(*_border_gy, false); - - // Run harris score kernel - CLScheduler::get().enqueue(*_harris_score, false); - - // Run non-maxima suppression - _non_max_suppr.run(); - - // Run corner candidate kernel - _nonmax.map(true); - Scheduler::get().schedule(&_candidates, Window::DimY); - _nonmax.unmap(); - - _corners->map(CLScheduler::get().queue(), true); - Scheduler::get().schedule(&_sort_euclidean, Window::DimY); - _corners->unmap(CLScheduler::get().queue()); -} diff --git a/src/runtime/CL/functions/CLHistogram.cpp b/src/runtime/CL/functions/CLHistogram.cpp deleted file mode 100644 index f278cf0dc2..0000000000 --- a/src/runtime/CL/functions/CLHistogram.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLHistogram.h" - -#include "arm_compute/runtime/CL/CLScheduler.h" - -using namespace arm_compute; - -CLHistogram::CLHistogram() - : _kernel(), _kernel_border() -{ -} - -void CLHistogram::configure(const ICLImage *input, ICLDistribution1D *output) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, output); -} - -void CLHistogram::configure(const CLCompileContext &compile_context, const ICLImage *input, ICLDistribution1D *output) -{ - _kernel.configure(compile_context, input, output); - _kernel_border.configure(compile_context, input, output); -} - -void CLHistogram::run() -{ - CLScheduler::get().enqueue(_kernel, false); - CLScheduler::get().enqueue(_kernel_border); -} diff --git a/src/runtime/CL/functions/CLIntegralImage.cpp b/src/runtime/CL/functions/CLIntegralImage.cpp deleted file mode 100644 index 56a151a085..0000000000 --- a/src/runtime/CL/functions/CLIntegralImage.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLIntegralImage.h" - -#include "arm_compute/runtime/CL/CLScheduler.h" -#include "src/core/CL/kernels/CLIntegralImageKernel.h" - -using namespace arm_compute; - -CLIntegralImage::CLIntegralImage() - : _integral_hor(std::make_unique()), - _integral_vert(std::make_unique()) -{ -} - -CLIntegralImage::~CLIntegralImage() = default; - -void CLIntegralImage::configure(const ICLTensor *input, ICLTensor *output) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, output); -} - -void CLIntegralImage::configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output) -{ - _integral_hor->configure(compile_context, input, output); - _integral_vert->configure(compile_context, output); -} - -void CLIntegralImage::run() -{ - CLScheduler::get().enqueue(*_integral_hor, false); - CLScheduler::get().enqueue(*_integral_vert); -} diff --git a/src/runtime/CL/functions/CLLaplacianPyramid.cpp b/src/runtime/CL/functions/CLLaplacianPyramid.cpp deleted file mode 100644 index 1ad19e56ea..0000000000 --- a/src/runtime/CL/functions/CLLaplacianPyramid.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2017-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLLaplacianPyramid.h" - -#include "arm_compute/core/Error.h" -#include "arm_compute/core/IPyramid.h" -#include "arm_compute/core/TensorInfo.h" -#include "arm_compute/core/Validate.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/functions/CLDepthConvertLayer.h" -#include "arm_compute/runtime/CL/functions/CLElementwiseOperations.h" -#include "arm_compute/runtime/CL/functions/CLGaussian5x5.h" -#include "arm_compute/runtime/CL/functions/CLGaussianPyramid.h" -#include "src/core/CL/kernels/CLFillBorderKernel.h" -#include "src/core/CL/kernels/CLGaussian5x5Kernel.h" -#include "src/core/CL/kernels/CLGaussianPyramidKernel.h" - -using namespace arm_compute; - -CLLaplacianPyramid::CLLaplacianPyramid() // NOLINT - : _num_levels(0), - _gaussian_pyr_function(), - _convf(), - _subf(), - _depth_function(), - _gauss_pyr(), - _conv_pyr() -{ -} - -void CLLaplacianPyramid::configure(ICLTensor *input, CLPyramid *pyramid, ICLTensor *output, BorderMode border_mode, uint8_t constant_border_value) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, pyramid, output, border_mode, constant_border_value); -} - -void CLLaplacianPyramid::configure(const CLCompileContext &compile_context, ICLTensor *input, CLPyramid *pyramid, ICLTensor *output, BorderMode border_mode, uint8_t constant_border_value) -{ - ARM_COMPUTE_ERROR_ON(nullptr == pyramid); - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8); - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(output, 1, DataType::S16); - ARM_COMPUTE_ERROR_ON(0 == pyramid->info()->num_levels()); - ARM_COMPUTE_ERROR_ON(input->info()->dimension(0) != pyramid->info()->width()); - ARM_COMPUTE_ERROR_ON(input->info()->dimension(1) != pyramid->info()->height()); - ARM_COMPUTE_ERROR_ON(output->info()->dimension(0) != pyramid->get_pyramid_level(pyramid->info()->num_levels() - 1)->info()->dimension(0)); - ARM_COMPUTE_ERROR_ON(output->info()->dimension(1) != pyramid->get_pyramid_level(pyramid->info()->num_levels() - 1)->info()->dimension(1)); - - _num_levels = pyramid->info()->num_levels(); - - // Create and initialize the gaussian pyramid and the convoluted pyramid - PyramidInfo pyramid_info; - pyramid_info.init(_num_levels, 0.5f, pyramid->info()->tensor_shape(), arm_compute::Format::U8); - - _gauss_pyr.init(pyramid_info); - _conv_pyr.init(pyramid_info); - - // Create Gaussian Pyramid function - _gaussian_pyr_function.configure(compile_context, input, &_gauss_pyr, border_mode, constant_border_value); - - _convf.resize(_num_levels); - _subf.resize(_num_levels); - - for(unsigned int i = 0; i < _num_levels; ++i) - { - _convf[i].configure(compile_context, _gauss_pyr.get_pyramid_level(i), _conv_pyr.get_pyramid_level(i), border_mode, constant_border_value); - _subf[i].configure(compile_context, _gauss_pyr.get_pyramid_level(i), _conv_pyr.get_pyramid_level(i), pyramid->get_pyramid_level(i), ConvertPolicy::WRAP); - } - - _depth_function.configure(compile_context, _conv_pyr.get_pyramid_level(_num_levels - 1), output, ConvertPolicy::WRAP, 0); - - _gauss_pyr.allocate(); - _conv_pyr.allocate(); -} - -void CLLaplacianPyramid::run() -{ - ARM_COMPUTE_ERROR_ON_MSG(0 == _num_levels, "Unconfigured function"); - - _gaussian_pyr_function.run(); // compute gaussian pyramid - - for(unsigned int i = 0; i < _num_levels; ++i) - { - _convf[i].run(); // convolute gaussian pyramid - } - - for(unsigned int i = 0; i < _num_levels; ++i) - { - _subf[i].run(); // compute laplacian image - } - - _depth_function.run(); -} diff --git a/src/runtime/CL/functions/CLLaplacianReconstruct.cpp b/src/runtime/CL/functions/CLLaplacianReconstruct.cpp deleted file mode 100644 index d7fd81754b..0000000000 --- a/src/runtime/CL/functions/CLLaplacianReconstruct.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2017-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLLaplacianReconstruct.h" - -#include "arm_compute/core/CL/CLKernelLibrary.h" -#include "arm_compute/core/Error.h" -#include "arm_compute/core/IPyramid.h" -#include "arm_compute/core/ITensor.h" -#include "arm_compute/core/TensorInfo.h" -#include "arm_compute/core/Validate.h" -#include "src/core/CL/kernels/CLFillBorderKernel.h" - -#include - -using namespace arm_compute; - -CLLaplacianReconstruct::CLLaplacianReconstruct() // NOLINT - : _tmp_pyr(), - _addf(), - _scalef(), - _depthf() -{ -} - -void CLLaplacianReconstruct::configure(const CLPyramid *pyramid, ICLTensor *input, ICLTensor *output, BorderMode border_mode, uint8_t constant_border_value) -{ - configure(CLKernelLibrary::get().get_compile_context(), pyramid, input, output, border_mode, constant_border_value); -} - -void CLLaplacianReconstruct::configure(const CLCompileContext &compile_context, const CLPyramid *pyramid, ICLTensor *input, ICLTensor *output, BorderMode border_mode, uint8_t constant_border_value) -{ - ARM_COMPUTE_ERROR_ON(nullptr == pyramid); - ARM_COMPUTE_ERROR_ON(input == output); - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::S16); - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(output, 1, DataType::U8); - ARM_COMPUTE_ERROR_ON(input->info()->num_dimensions() != pyramid->get_pyramid_level(0)->info()->num_dimensions()); - ARM_COMPUTE_ERROR_ON(output->info()->num_dimensions() != pyramid->get_pyramid_level(0)->info()->num_dimensions()); - ARM_COMPUTE_ERROR_ON(output->info()->dimension(0) != pyramid->get_pyramid_level(0)->info()->dimension(0)); - ARM_COMPUTE_ERROR_ON(output->info()->dimension(1) != pyramid->get_pyramid_level(0)->info()->dimension(1)); - ARM_COMPUTE_ERROR_ON(input->info()->dimension(0) != pyramid->get_pyramid_level(pyramid->info()->num_levels() - 1)->info()->dimension(0)); - ARM_COMPUTE_ERROR_ON(input->info()->dimension(1) != pyramid->get_pyramid_level(pyramid->info()->num_levels() - 1)->info()->dimension(1)); - - const size_t num_levels = pyramid->info()->num_levels(); - - // Create and initialize the tmp pyramid: I(n-2) = upsample( input + Laplace(n-1) ) - PyramidInfo pyramid_info; - pyramid_info.init(num_levels, 0.5f, output->info()->tensor_shape(), arm_compute::Format::S16); - _tmp_pyr.init(pyramid_info); - - // Allocate add and scale functions. Level 0 does not need to be scaled. - _addf.resize(num_levels); - _scalef.resize(num_levels - 1); - - const size_t last_level = num_levels - 1; - - _addf[last_level].configure(compile_context, input, pyramid->get_pyramid_level(last_level), _tmp_pyr.get_pyramid_level(last_level), ConvertPolicy::SATURATE); - - // Scale levels n-1 to 1, and add levels n-2 to 0 - for(size_t l = 0; l < last_level; ++l) - { - _scalef[l].configure(compile_context, _tmp_pyr.get_pyramid_level(l + 1), _tmp_pyr.get_pyramid_level(l), ScaleKernelInfo{ arm_compute::InterpolationPolicy::NEAREST_NEIGHBOR, border_mode, constant_border_value }); - _addf[l].configure(compile_context, _tmp_pyr.get_pyramid_level(l), pyramid->get_pyramid_level(l), _tmp_pyr.get_pyramid_level(l), ConvertPolicy::SATURATE); - } - - // Convert level 0 from S16 to U8 - _depthf.configure(compile_context, _tmp_pyr.get_pyramid_level(0), output, ConvertPolicy::SATURATE, 0); - - _tmp_pyr.allocate(); -} - -void CLLaplacianReconstruct::run() -{ - ARM_COMPUTE_ERROR_ON_MSG(_addf.empty(), "Unconfigured function"); - - const size_t last_level = _tmp_pyr.info()->num_levels() - 1; - - _addf[last_level].run(); - - // Run l = [last_level - 1, 0] - for(size_t l = last_level; l-- > 0;) - { - _scalef[l].run(); - _addf[l].run(); - } - - _depthf.run(); -} diff --git a/src/runtime/CL/functions/CLMagnitude.cpp b/src/runtime/CL/functions/CLMagnitude.cpp deleted file mode 100644 index 0599a11fa1..0000000000 --- a/src/runtime/CL/functions/CLMagnitude.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLMagnitude.h" - -#include "src/core/CL/kernels/CLMagnitudePhaseKernel.h" - -#include - -using namespace arm_compute; - -void CLMagnitude::configure(const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output, MagnitudeType mag_type) -{ - configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, mag_type); -} - -void CLMagnitude::configure(const CLCompileContext &compile_context, const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output, MagnitudeType mag_type) -{ - auto k = std::make_unique(); - k->configure(compile_context, input1, input2, output, nullptr, mag_type); - _kernel = std::move(k); -} diff --git a/src/runtime/CL/functions/CLMeanStdDev.cpp b/src/runtime/CL/functions/CLMeanStdDev.cpp deleted file mode 100644 index d8cd41d45f..0000000000 --- a/src/runtime/CL/functions/CLMeanStdDev.cpp +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/TensorInfo.h" - -#include "arm_compute/runtime/CL/CLScheduler.h" -#include "arm_compute/runtime/CL/functions/CLMeanStdDev.h" -#include "src/core/CL/kernels/CLFillBorderKernel.h" -#include "src/core/CL/kernels/CLMeanStdDevKernel.h" -#include "src/core/CL/kernels/CLReductionOperationKernel.h" - -using namespace arm_compute; - -CLMeanStdDev::CLMeanStdDev(std::shared_ptr memory_manager) // NOLINT - : _memory_group(std::move(memory_manager)), - _data_type(), - _num_pixels(), - _run_stddev(), - _reduction_operation_mean(), - _reduction_operation_stddev(), - _reduction_output_mean(), - _reduction_output_stddev(), - _mean(nullptr), - _stddev(nullptr), - _mean_stddev_kernel(std::make_unique()), - _fill_border_kernel(std::make_unique()), - _global_sum(), - _global_sum_squared() -{ -} - -CLMeanStdDev::~CLMeanStdDev() = default; - -Status CLMeanStdDev::validate(ITensorInfo *input, float *mean, float *stddev) -{ - ARM_COMPUTE_RETURN_ERROR_ON_TENSOR_NOT_2D(input); - if(is_data_type_float(input->data_type())) - { - ARM_COMPUTE_UNUSED(mean); - ARM_COMPUTE_UNUSED(stddev); - - TensorShape output_shape = TensorShape{ 1, input->dimension(1) }; - TensorInfo output_shape_info = TensorInfo(output_shape, 1, DataType::U8); - return CLReductionOperation::validate(input, &output_shape_info, 0, ReductionOperation::SUM); - } - else - { - return CLMeanStdDevKernel::validate(input, mean, nullptr, stddev, nullptr); - } -} - -void CLMeanStdDev::configure(ICLImage *input, float *mean, float *stddev) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, mean, stddev); -} - -void CLMeanStdDev::configure(const CLCompileContext &compile_context, ICLImage *input, float *mean, float *stddev) -{ - // In the case of F16/F32 we call reduction operation for calculating CLMeanStdDev - _data_type = input->info()->data_type(); - - if(is_data_type_float(_data_type)) - { - _num_pixels = input->info()->dimension(0) * input->info()->dimension(1); - - _memory_group.manage(&_reduction_output_mean); - _reduction_operation_mean.configure(compile_context, input, &_reduction_output_mean, 0, ReductionOperation::SUM); - _reduction_output_mean.allocator()->allocate(); - _mean = mean; - - if(stddev != nullptr) - { - _memory_group.manage(&_reduction_output_stddev); - _reduction_operation_stddev.configure(compile_context, input, &_reduction_output_stddev, 0, ReductionOperation::SUM_SQUARE); - _reduction_output_stddev.allocator()->allocate(); - _stddev = stddev; - _run_stddev = true; - } - } - else - { - _global_sum = cl::Buffer(CLScheduler::get().context(), CL_MEM_ALLOC_HOST_PTR | CL_MEM_READ_WRITE, sizeof(cl_ulong)); - - if(stddev != nullptr) - { - _global_sum_squared = cl::Buffer(CLScheduler::get().context(), CL_MEM_ALLOC_HOST_PTR | CL_MEM_READ_WRITE, sizeof(cl_ulong)); - } - - _mean_stddev_kernel->configure(compile_context, input, mean, &_global_sum, stddev, &_global_sum_squared); - _fill_border_kernel->configure(compile_context, input, _mean_stddev_kernel->border_size(), BorderMode::CONSTANT, PixelValue(static_cast(0))); - } -} - -template -void CLMeanStdDev::run_float() -{ - MemoryGroupResourceScope scope_mg(_memory_group); - - // Perform reduction on x-axis - _reduction_operation_mean.run(); - if(_run_stddev) - { - _reduction_operation_stddev.run(); - _reduction_output_stddev.map(true); - } - - _reduction_output_mean.map(true); - - auto mean = static_cast(0); - - // Calculate final result for mean - for(unsigned int i = 0; i < _reduction_output_mean.info()->dimension(1); ++i) - { - mean += *reinterpret_cast(_reduction_output_mean.buffer() + _reduction_output_mean.info()->offset_element_in_bytes(Coordinates(0, i))); - } - - mean /= _num_pixels; - *_mean = mean; - - if(_run_stddev) - { - auto stddev = static_cast(0); - // Calculate final result for stddev - for(unsigned int i = 0; i < _reduction_output_stddev.info()->dimension(1); ++i) - { - stddev += *reinterpret_cast(_reduction_output_stddev.buffer() + _reduction_output_stddev.info()->offset_element_in_bytes(Coordinates(0, i))); - } - *_stddev = std::sqrt((stddev / _num_pixels) - (mean * mean)); - - _reduction_output_stddev.unmap(); - } - _reduction_output_mean.unmap(); -} - -void CLMeanStdDev::run_int() -{ - CLScheduler::get().enqueue(*_fill_border_kernel); - CLScheduler::get().enqueue(*_mean_stddev_kernel); -} - -void CLMeanStdDev::run() -{ - switch(_data_type) - { - case DataType::F16: - run_float(); - break; - case DataType::F32: - run_float(); - break; - case DataType::U8: - run_int(); - break; - default: - ARM_COMPUTE_ERROR_ON("Not supported"); - } -} diff --git a/src/runtime/CL/functions/CLMedian3x3.cpp b/src/runtime/CL/functions/CLMedian3x3.cpp deleted file mode 100644 index b32063a8fe..0000000000 --- a/src/runtime/CL/functions/CLMedian3x3.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLMedian3x3.h" - -#include "arm_compute/core/PixelValue.h" -#include "src/core/CL/kernels/CLFillBorderKernel.h" -#include "src/core/CL/kernels/CLMedian3x3Kernel.h" - -#include - -using namespace arm_compute; - -void CLMedian3x3::configure(ICLTensor *input, ICLTensor *output, BorderMode border_mode, uint8_t constant_border_value) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, output, border_mode, constant_border_value); -} - -void CLMedian3x3::configure(const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *output, BorderMode border_mode, uint8_t constant_border_value) -{ - auto k = std::make_unique(); - k->configure(compile_context, input, output, border_mode == BorderMode::UNDEFINED); - _kernel = std::move(k); - _border_handler->configure(compile_context, input, _kernel->border_size(), border_mode, PixelValue(constant_border_value)); -} diff --git a/src/runtime/CL/functions/CLMinMaxLocation.cpp b/src/runtime/CL/functions/CLMinMaxLocation.cpp deleted file mode 100644 index ace6a1cb21..0000000000 --- a/src/runtime/CL/functions/CLMinMaxLocation.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2017-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLMinMaxLocation.h" -#include "arm_compute/core/CL/CLHelpers.h" -#include "src/core/CL/kernels/CLMinMaxLocationKernel.h" - -namespace arm_compute -{ -CLMinMaxLocation::CLMinMaxLocation() - : _min_max_kernel(std::make_unique()), - _min_max_loc_kernel(std::make_unique()), - _min_max_vals(), - _min_max_count_vals(), - _min(nullptr), - _max(nullptr), - _min_count(nullptr), - _max_count(nullptr), - _min_loc(nullptr), - _max_loc(nullptr) -{ -} - -CLMinMaxLocation::~CLMinMaxLocation() = default; - -void CLMinMaxLocation::configure(const ICLImage *input, void *min, void *max, CLCoordinates2DArray *min_loc, CLCoordinates2DArray *max_loc, uint32_t *min_count, uint32_t *max_count) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, min, max, min_loc, max_loc, min_count, max_count); -} - -void CLMinMaxLocation::configure(const CLCompileContext &compile_context, const ICLImage *input, void *min, void *max, CLCoordinates2DArray *min_loc, CLCoordinates2DArray *max_loc, - uint32_t *min_count, - uint32_t *max_count) -{ - ARM_COMPUTE_ERROR_ON(nullptr == min); - ARM_COMPUTE_ERROR_ON(nullptr == max); - - _min_max_vals = cl::Buffer(CLScheduler::get().context(), CL_MEM_ALLOC_HOST_PTR | CL_MEM_READ_WRITE, 2 * sizeof(int32_t)); - _min_max_count_vals = cl::Buffer(CLScheduler::get().context(), CL_MEM_ALLOC_HOST_PTR | CL_MEM_READ_WRITE, 2 * sizeof(uint32_t)); - _min = min; - _max = max; - _min_count = min_count; - _max_count = max_count; - _min_loc = min_loc; - _max_loc = max_loc; - - _min_max_kernel->configure(compile_context, input, &_min_max_vals); - _min_max_loc_kernel->configure(compile_context, input, &_min_max_vals, &_min_max_count_vals, _min_loc, _max_loc); -} - -void CLMinMaxLocation::run() -{ - cl::CommandQueue q = CLScheduler::get().queue(); - - CLScheduler::get().enqueue(*_min_max_kernel, false); - CLScheduler::get().enqueue(*_min_max_loc_kernel, false); - - // Update min and max - q.enqueueReadBuffer(_min_max_vals, CL_FALSE, 0 * sizeof(int32_t), sizeof(int32_t), static_cast(_min)); - q.enqueueReadBuffer(_min_max_vals, CL_FALSE, 1 * sizeof(int32_t), sizeof(int32_t), static_cast(_max)); - - // Update min and max count - if(_min_count != nullptr) - { - q.enqueueReadBuffer(_min_max_count_vals, CL_FALSE, 0 * sizeof(uint32_t), sizeof(uint32_t), _min_count); - } - if(_max_count != nullptr) - { - q.enqueueReadBuffer(_min_max_count_vals, CL_FALSE, 1 * sizeof(uint32_t), sizeof(uint32_t), _max_count); - } - - // Update min/max point arrays (Makes the kernel blocking) - if(_min_loc != nullptr) - { - unsigned int min_count = 0; - q.enqueueReadBuffer(_min_max_count_vals, CL_TRUE, 0 * sizeof(uint32_t), sizeof(uint32_t), &min_count); - size_t min_corner_size = std::min(static_cast(min_count), _min_loc->max_num_values()); - _min_loc->resize(min_corner_size); - } - if(_max_loc != nullptr) - { - unsigned int max_count = 0; - q.enqueueReadBuffer(_min_max_count_vals, CL_TRUE, 1 * sizeof(uint32_t), sizeof(uint32_t), &max_count); - size_t max_corner_size = std::min(static_cast(max_count), _max_loc->max_num_values()); - _max_loc->resize(max_corner_size); - } -} -} // namespace arm_compute diff --git a/src/runtime/CL/functions/CLNonLinearFilter.cpp b/src/runtime/CL/functions/CLNonLinearFilter.cpp deleted file mode 100644 index ec88f879b7..0000000000 --- a/src/runtime/CL/functions/CLNonLinearFilter.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2017-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLNonLinearFilter.h" - -#include "src/core/CL/kernels/CLFillBorderKernel.h" -#include "src/core/CL/kernels/CLNonLinearFilterKernel.h" - -#include - -using namespace arm_compute; - -void CLNonLinearFilter::configure(ICLTensor *input, ICLTensor *output, NonLinearFilterFunction function, unsigned int mask_size, MatrixPattern pattern, const uint8_t *mask, - BorderMode border_mode, uint8_t constant_border_value) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, output, function, mask_size, pattern, mask, border_mode, constant_border_value); -} - -void CLNonLinearFilter::configure(const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *output, NonLinearFilterFunction function, unsigned int mask_size, MatrixPattern pattern, - const uint8_t *mask, BorderMode border_mode, uint8_t constant_border_value) -{ - auto k = std::make_unique(); - k->configure(compile_context, input, output, function, mask_size, pattern, mask, border_mode == BorderMode::UNDEFINED); - _kernel = std::move(k); - _border_handler->configure(compile_context, input, _kernel->border_size(), border_mode, PixelValue(constant_border_value)); -} diff --git a/src/runtime/CL/functions/CLNonMaximaSuppression3x3.cpp b/src/runtime/CL/functions/CLNonMaximaSuppression3x3.cpp deleted file mode 100644 index 5906ea5a4b..0000000000 --- a/src/runtime/CL/functions/CLNonMaximaSuppression3x3.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLNonMaximaSuppression3x3.h" - -#include "src/core/CL/kernels/CLFillBorderKernel.h" -#include "src/core/CL/kernels/CLNonMaximaSuppression3x3Kernel.h" - -#include - -using namespace arm_compute; - -void CLNonMaximaSuppression3x3::configure(ICLTensor *input, ICLTensor *output, BorderMode border_mode) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, output, border_mode); -} - -void CLNonMaximaSuppression3x3::configure(const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *output, BorderMode border_mode) -{ - auto k = std::make_unique(); - k->configure(compile_context, input, output, border_mode == BorderMode::UNDEFINED); - _kernel = std::move(k); - - if(border_mode != BorderMode::UNDEFINED) - { - _border_handler->configure(compile_context, input, _kernel->border_size(), BorderMode::CONSTANT); - } - else - { - _border_handler->configure(compile_context, input, _kernel->border_size(), BorderMode::UNDEFINED); - } -} diff --git a/src/runtime/CL/functions/CLOpticalFlow.cpp b/src/runtime/CL/functions/CLOpticalFlow.cpp deleted file mode 100644 index 76e0ac5f0b..0000000000 --- a/src/runtime/CL/functions/CLOpticalFlow.cpp +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright (c) 2017-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLOpticalFlow.h" - -#include "arm_compute/core/CL/ICLTensor.h" -#include "arm_compute/core/Error.h" -#include "arm_compute/core/TensorInfo.h" -#include "arm_compute/core/Window.h" -#include "arm_compute/runtime/CL/CLPyramid.h" -#include "arm_compute/runtime/CL/CLScheduler.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLScharr3x3.h" -#include "src/core/CL/kernels/CLFillBorderKernel.h" -#include "src/core/CL/kernels/CLLKTrackerKernel.h" - -using namespace arm_compute; - -CLOpticalFlow::CLOpticalFlow(std::shared_ptr memory_manager) // NOLINT - : _memory_group(std::move(memory_manager)), - _tracker_init_kernel(), - _tracker_stage0_kernel(), - _tracker_stage1_kernel(), - _tracker_finalize_kernel(std::make_unique()), - _func_scharr(), - _scharr_gx(), - _scharr_gy(), - _old_points(nullptr), - _new_points_estimates(nullptr), - _new_points(nullptr), - _old_points_internal(), - _new_points_internal(), - _coefficient_table(), - _old_values(), - _num_levels(0) -{ -} - -CLOpticalFlow::~CLOpticalFlow() = default; - -void CLOpticalFlow::configure(const CLPyramid *old_pyramid, const CLPyramid *new_pyramid, - const ICLKeyPointArray *old_points, const ICLKeyPointArray *new_points_estimates, ICLKeyPointArray *new_points, - Termination termination, float epsilon, size_t num_iterations, size_t window_dimension, bool use_initial_estimate, - BorderMode border_mode, uint8_t constant_border_value) -{ - configure(CLKernelLibrary::get().get_compile_context(), old_pyramid, new_pyramid, old_points, new_points_estimates, new_points, termination, epsilon, num_iterations, window_dimension, - use_initial_estimate, border_mode, constant_border_value); -} - -void CLOpticalFlow::configure(const CLCompileContext &compile_context, const CLPyramid *old_pyramid, const CLPyramid *new_pyramid, - const ICLKeyPointArray *old_points, const ICLKeyPointArray *new_points_estimates, ICLKeyPointArray *new_points, - Termination termination, float epsilon, size_t num_iterations, size_t window_dimension, bool use_initial_estimate, - BorderMode border_mode, uint8_t constant_border_value) -{ - ARM_COMPUTE_ERROR_ON(nullptr == old_pyramid); - ARM_COMPUTE_ERROR_ON(nullptr == new_pyramid); - ARM_COMPUTE_ERROR_ON(nullptr == old_points); - ARM_COMPUTE_ERROR_ON(nullptr == new_points_estimates); - ARM_COMPUTE_ERROR_ON(nullptr == new_points); - ARM_COMPUTE_ERROR_ON(old_pyramid->info()->num_levels() != new_pyramid->info()->num_levels()); - ARM_COMPUTE_ERROR_ON(0 == old_pyramid->info()->num_levels()); - ARM_COMPUTE_ERROR_ON(old_pyramid->info()->width() != new_pyramid->info()->width()); - ARM_COMPUTE_ERROR_ON(old_pyramid->info()->height() != new_pyramid->info()->height()); - ARM_COMPUTE_ERROR_ON(use_initial_estimate && old_points->num_values() != new_points_estimates->num_values()); - - // Set member variables - _old_points = old_points; - _new_points_estimates = new_points_estimates; - _new_points = new_points; - _num_levels = old_pyramid->info()->num_levels(); - - const float pyr_scale = old_pyramid->info()->scale(); - const int list_length = old_points->num_values(); - const int old_values_list_length = list_length * window_dimension * window_dimension; - - // Create kernels and tensors - _tracker_init_kernel.reserve(_num_levels); - _tracker_stage0_kernel.reserve(_num_levels); - _tracker_stage1_kernel.reserve(_num_levels); - _func_scharr.resize(_num_levels); - _scharr_gx.resize(_num_levels); - _scharr_gy.resize(_num_levels); - - // Create internal keypoint arrays - _old_points_internal = std::make_unique(list_length); - _old_points_internal->resize(list_length); - _new_points_internal = std::make_unique(list_length); - _new_points_internal->resize(list_length); - _coefficient_table = std::make_unique(list_length); - _coefficient_table->resize(list_length); - _old_values = std::make_unique(old_values_list_length); - _old_values->resize(old_values_list_length); - _new_points->resize(list_length); - - for(size_t i = 0; i < _num_levels; ++i) - { - // Get images from the ith level of old and right pyramid - ICLImage *old_ith_input = old_pyramid->get_pyramid_level(i); - ICLImage *new_ith_input = new_pyramid->get_pyramid_level(i); - - // Get width and height of images - const unsigned int width_ith = old_ith_input->info()->dimension(0); - const unsigned int height_ith = new_ith_input->info()->dimension(1); - - // Initialize Scharr tensors - TensorInfo tensor_info(TensorShape(width_ith, height_ith), 1, DataType::S16); - _scharr_gx[i].allocator()->init(tensor_info); - _scharr_gy[i].allocator()->init(tensor_info); - - // Manage intermediate buffers - _memory_group.manage(&_scharr_gx[i]); - _memory_group.manage(&_scharr_gy[i]); - - // Init Scharr kernel - _func_scharr[i].configure(compile_context, old_ith_input, &_scharr_gx[i], &_scharr_gy[i], border_mode, constant_border_value); - - // Init Lucas-Kanade init kernel - _tracker_init_kernel.emplace_back(std::make_unique()); - _tracker_init_kernel.back()->configure(compile_context, old_points, new_points_estimates, _old_points_internal.get(), _new_points_internal.get(), use_initial_estimate, i, _num_levels, pyr_scale); - - // Init Lucas-Kanade stage0 kernel - _tracker_stage0_kernel.emplace_back(std::make_unique()); - _tracker_stage0_kernel.back()->configure(compile_context, old_ith_input, &_scharr_gx[i], &_scharr_gy[i], - _old_points_internal.get(), _new_points_internal.get(), _coefficient_table.get(), _old_values.get(), - window_dimension, i); - - // Init Lucas-Kanade stage1 kernel - _tracker_stage1_kernel.emplace_back(std::make_unique()); - _tracker_stage1_kernel.back()->configure(compile_context, new_ith_input, _new_points_internal.get(), _coefficient_table.get(), _old_values.get(), - termination, epsilon, num_iterations, window_dimension, i); - - // Allocate intermediate buffers - _scharr_gx[i].allocator()->allocate(); - _scharr_gy[i].allocator()->allocate(); - } - - // Finalize Lucas-Kanade - _tracker_finalize_kernel->configure(compile_context, _new_points_internal.get(), new_points); -} - -void CLOpticalFlow::run() -{ - ARM_COMPUTE_ERROR_ON_MSG(_num_levels == 0, "Unconfigured function"); - - MemoryGroupResourceScope scope_mg(_memory_group); - - for(unsigned int level = _num_levels; level > 0; --level) - { - // Run Scharr kernel - _func_scharr[level - 1].run(); - - // Run Lucas-Kanade init kernel - CLScheduler::get().enqueue(*_tracker_init_kernel[level - 1]); - - // Run Lucas-Kanade stage0 kernel - CLScheduler::get().enqueue(*_tracker_stage0_kernel[level - 1]); - - // Run Lucas-Kanade stage1 kernel - CLScheduler::get().enqueue(*_tracker_stage1_kernel[level - 1]); - } - - CLScheduler::get().enqueue(*_tracker_finalize_kernel, true); -} diff --git a/src/runtime/CL/functions/CLPhase.cpp b/src/runtime/CL/functions/CLPhase.cpp deleted file mode 100644 index b2ff5d05ca..0000000000 --- a/src/runtime/CL/functions/CLPhase.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLPhase.h" - -#include "src/core/CL/kernels/CLMagnitudePhaseKernel.h" - -#include - -using namespace arm_compute; - -void CLPhase::configure(const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output, PhaseType phase_type) -{ - configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, phase_type); -} - -void CLPhase::configure(const CLCompileContext &compile_context, const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output, PhaseType phase_type) -{ - auto k = std::make_unique(); - k->configure(compile_context, input1, input2, nullptr, output, MagnitudeType::L1NORM, phase_type); - _kernel = std::move(k); -} diff --git a/src/runtime/CL/functions/CLScharr3x3.cpp b/src/runtime/CL/functions/CLScharr3x3.cpp deleted file mode 100644 index 563ec19266..0000000000 --- a/src/runtime/CL/functions/CLScharr3x3.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLScharr3x3.h" - -#include "arm_compute/core/PixelValue.h" -#include "src/core/CL/kernels/CLFillBorderKernel.h" -#include "src/core/CL/kernels/CLScharr3x3Kernel.h" - -#include - -using namespace arm_compute; - -void CLScharr3x3::configure(ICLTensor *input, ICLTensor *output_x, ICLTensor *output_y, BorderMode border_mode, uint8_t constant_border_value) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, output_x, output_y, border_mode, constant_border_value); -} - -void CLScharr3x3::configure(const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *output_x, ICLTensor *output_y, BorderMode border_mode, uint8_t constant_border_value) -{ - auto k = std::make_unique(); - k->configure(compile_context, input, output_x, output_y, border_mode == BorderMode::UNDEFINED); - _kernel = std::move(k); - _border_handler->configure(compile_context, input, _kernel->border_size(), border_mode, PixelValue(constant_border_value)); -} diff --git a/src/runtime/CL/functions/CLSobel3x3.cpp b/src/runtime/CL/functions/CLSobel3x3.cpp deleted file mode 100644 index 6724c12a72..0000000000 --- a/src/runtime/CL/functions/CLSobel3x3.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLSobel3x3.h" - -#include "arm_compute/core/PixelValue.h" -#include "src/core/CL/kernels/CLFillBorderKernel.h" -#include "src/core/CL/kernels/CLSobel3x3Kernel.h" - -#include - -using namespace arm_compute; - -CLSobel3x3::~CLSobel3x3() = default; - -void CLSobel3x3::configure(ICLTensor *input, ICLTensor *output_x, ICLTensor *output_y, BorderMode border_mode, uint8_t constant_border_value) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, output_x, output_y, border_mode, constant_border_value); -} - -void CLSobel3x3::configure(const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *output_x, ICLTensor *output_y, BorderMode border_mode, uint8_t constant_border_value) -{ - auto k = std::make_unique(); - k->configure(compile_context, input, output_x, output_y, border_mode == BorderMode::UNDEFINED); - _kernel = std::move(k); - _border_handler->configure(compile_context, input, _kernel->border_size(), border_mode, PixelValue(constant_border_value)); -} diff --git a/src/runtime/CL/functions/CLSobel5x5.cpp b/src/runtime/CL/functions/CLSobel5x5.cpp deleted file mode 100644 index 98f215794c..0000000000 --- a/src/runtime/CL/functions/CLSobel5x5.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLSobel5x5.h" - -#include "arm_compute/core/CL/ICLTensor.h" -#include "arm_compute/core/PixelValue.h" -#include "arm_compute/core/TensorInfo.h" -#include "arm_compute/core/Validate.h" -#include "arm_compute/runtime/CL/CLScheduler.h" -#include "arm_compute/runtime/ITensorAllocator.h" -#include "src/core/CL/kernels/CLFillBorderKernel.h" -#include "src/core/CL/kernels/CLSobel5x5Kernel.h" - -using namespace arm_compute; - -CLSobel5x5::CLSobel5x5(std::shared_ptr memory_manager) - : _memory_group(std::move(memory_manager)), - _sobel_hor(std::make_unique()), - _sobel_vert(std::make_unique()), - _border_handler(std::make_unique()), - _tmp_x(), - _tmp_y() -{ -} - -CLSobel5x5::~CLSobel5x5() = default; - -void CLSobel5x5::configure(ICLTensor *input, ICLTensor *output_x, ICLTensor *output_y, BorderMode border_mode, uint8_t constant_border_value) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, output_x, output_y, border_mode, constant_border_value); -} - -void CLSobel5x5::configure(const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *output_x, ICLTensor *output_y, BorderMode border_mode, uint8_t constant_border_value) -{ - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8); - - const bool run_sobel_x = output_x != nullptr; - const bool run_sobel_y = output_y != nullptr; - - TensorInfo tensor_info(input->info()->tensor_shape(), 1, DataType::S16); - - if(run_sobel_x && run_sobel_y) - { - _tmp_x.allocator()->init(tensor_info); - _tmp_y.allocator()->init(tensor_info); - _memory_group.manage(&_tmp_x); - _memory_group.manage(&_tmp_y); - _sobel_hor->configure(compile_context, input, &_tmp_x, &_tmp_y, border_mode == BorderMode::UNDEFINED); - _sobel_vert->configure(compile_context, &_tmp_x, &_tmp_y, output_x, output_y, border_mode == BorderMode::UNDEFINED); - _tmp_x.allocator()->allocate(); - _tmp_y.allocator()->allocate(); - } - else if(run_sobel_x) - { - _tmp_x.allocator()->init(tensor_info); - _memory_group.manage(&_tmp_x); - _sobel_hor->configure(compile_context, input, &_tmp_x, nullptr, border_mode == BorderMode::UNDEFINED); - _sobel_vert->configure(compile_context, &_tmp_x, nullptr, output_x, nullptr, border_mode == BorderMode::UNDEFINED); - _tmp_x.allocator()->allocate(); - } - else if(run_sobel_y) - { - _tmp_y.allocator()->init(tensor_info); - _memory_group.manage(&_tmp_y); - _sobel_hor->configure(compile_context, input, nullptr, &_tmp_y, border_mode == BorderMode::UNDEFINED); - _sobel_vert->configure(compile_context, nullptr, &_tmp_y, nullptr, output_y, border_mode == BorderMode::UNDEFINED); - _tmp_y.allocator()->allocate(); - } - _border_handler->configure(compile_context, input, _sobel_hor->border_size(), border_mode, PixelValue(constant_border_value)); -} - -void CLSobel5x5::run() -{ - CLScheduler::get().enqueue(*_border_handler, false); - - MemoryGroupResourceScope scope_mg(_memory_group); - - CLScheduler::get().enqueue(*_sobel_hor, false); - CLScheduler::get().enqueue(*_sobel_vert); -} diff --git a/src/runtime/CL/functions/CLSobel7x7.cpp b/src/runtime/CL/functions/CLSobel7x7.cpp deleted file mode 100644 index a3d63f98dd..0000000000 --- a/src/runtime/CL/functions/CLSobel7x7.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLSobel7x7.h" - -#include "arm_compute/core/CL/ICLTensor.h" -#include "arm_compute/core/PixelValue.h" -#include "arm_compute/core/TensorInfo.h" -#include "arm_compute/core/Validate.h" -#include "arm_compute/runtime/CL/CLScheduler.h" -#include "arm_compute/runtime/ITensorAllocator.h" -#include "src/core/CL/kernels/CLFillBorderKernel.h" -#include "src/core/CL/kernels/CLSobel7x7Kernel.h" - -using namespace arm_compute; - -CLSobel7x7::CLSobel7x7(std::shared_ptr memory_manager) - : _memory_group(std::move(memory_manager)), - _sobel_hor(std::make_unique()), - _sobel_vert(std::make_unique()), - _border_handler(std::make_unique()), - _tmp_x(), - _tmp_y() -{ -} - -CLSobel7x7::~CLSobel7x7() = default; - -void CLSobel7x7::configure(ICLTensor *input, ICLTensor *output_x, ICLTensor *output_y, BorderMode border_mode, uint8_t constant_border_value) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, output_x, output_y, border_mode, constant_border_value); -} - -void CLSobel7x7::configure(const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *output_x, ICLTensor *output_y, BorderMode border_mode, uint8_t constant_border_value) -{ - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8); - - const bool run_sobel_x = output_x != nullptr; - const bool run_sobel_y = output_y != nullptr; - - TensorInfo tensor_info(input->info()->tensor_shape(), 1, DataType::S32); - - if(run_sobel_x && run_sobel_y) - { - _tmp_x.allocator()->init(tensor_info); - _tmp_y.allocator()->init(tensor_info); - _memory_group.manage(&_tmp_x); - _memory_group.manage(&_tmp_y); - _sobel_hor->configure(compile_context, input, &_tmp_x, &_tmp_y, border_mode == BorderMode::UNDEFINED); - _sobel_vert->configure(compile_context, &_tmp_x, &_tmp_y, output_x, output_y, border_mode == BorderMode::UNDEFINED); - _tmp_x.allocator()->allocate(); - _tmp_y.allocator()->allocate(); - } - else if(run_sobel_x) - { - _tmp_x.allocator()->init(tensor_info); - _memory_group.manage(&_tmp_x); - _sobel_hor->configure(compile_context, input, &_tmp_x, nullptr, border_mode == BorderMode::UNDEFINED); - _sobel_vert->configure(compile_context, &_tmp_x, nullptr, output_x, nullptr, border_mode == BorderMode::UNDEFINED); - _tmp_x.allocator()->allocate(); - } - else if(run_sobel_y) - { - _tmp_y.allocator()->init(tensor_info); - _memory_group.manage(&_tmp_y); - _sobel_hor->configure(compile_context, input, nullptr, &_tmp_y, border_mode == BorderMode::UNDEFINED); - _sobel_vert->configure(compile_context, nullptr, &_tmp_y, nullptr, output_y, border_mode == BorderMode::UNDEFINED); - _tmp_y.allocator()->allocate(); - } - _border_handler->configure(compile_context, input, _sobel_hor->border_size(), border_mode, PixelValue(constant_border_value)); -} - -void CLSobel7x7::run() -{ - CLScheduler::get().enqueue(*_border_handler, false); - - MemoryGroupResourceScope scope_mg(_memory_group); - - CLScheduler::get().enqueue(*_sobel_hor, false); - CLScheduler::get().enqueue(*_sobel_vert); -} diff --git a/src/runtime/CL/functions/CLTableLookup.cpp b/src/runtime/CL/functions/CLTableLookup.cpp deleted file mode 100644 index a4671f51bd..0000000000 --- a/src/runtime/CL/functions/CLTableLookup.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLTableLookup.h" - -#include "src/core/CL/kernels/CLTableLookupKernel.h" - -#include - -using namespace arm_compute; - -void CLTableLookup::configure(const ICLTensor *input, const ICLLut *lut, ICLTensor *output) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, lut, output); -} - -void CLTableLookup::configure(const CLCompileContext &compile_context, const ICLTensor *input, const ICLLut *lut, ICLTensor *output) -{ - auto k = std::make_unique(); - k->configure(compile_context, input, lut, output); - _kernel = std::move(k); -} diff --git a/src/runtime/CL/functions/CLThreshold.cpp b/src/runtime/CL/functions/CLThreshold.cpp deleted file mode 100644 index 70bc3b9365..0000000000 --- a/src/runtime/CL/functions/CLThreshold.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2016-2021 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLThreshold.h" - -#include "src/core/CL/kernels/CLThresholdKernel.h" - -#include - -namespace arm_compute -{ -void CLThreshold::configure(const ICLTensor *input, ICLTensor *output, const ThresholdKernelInfo &info) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, output, info); -} - -void CLThreshold::configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output, const ThresholdKernelInfo &info) -{ - auto k = std::make_unique(); - k->configure(compile_context, input, output, info); - _kernel = std::move(k); -} -} // namespace arm_compute diff --git a/src/runtime/CL/functions/CLWarpAffine.cpp b/src/runtime/CL/functions/CLWarpAffine.cpp deleted file mode 100644 index 9a22446cf6..0000000000 --- a/src/runtime/CL/functions/CLWarpAffine.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLWarpAffine.h" - -#include "arm_compute/core/PixelValue.h" -#include "src/core/CL/kernels/CLFillBorderKernel.h" -#include "src/core/CL/kernels/CLWarpAffineKernel.h" - -#include - -using namespace arm_compute; - -void CLWarpAffine::configure(ICLTensor *input, ICLTensor *output, const std::array &matrix, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, output, matrix, policy, border_mode, constant_border_value); -} - -void CLWarpAffine::configure(const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *output, const std::array &matrix, InterpolationPolicy policy, BorderMode border_mode, - uint8_t constant_border_value) -{ - auto k = std::make_unique(); - k->configure(compile_context, input, output, matrix, policy); - _kernel = std::move(k); - _border_handler->configure(compile_context, input, _kernel->border_size(), border_mode, PixelValue(constant_border_value)); -} diff --git a/src/runtime/CL/functions/CLWarpPerspective.cpp b/src/runtime/CL/functions/CLWarpPerspective.cpp deleted file mode 100644 index 0ec6b42e75..0000000000 --- a/src/runtime/CL/functions/CLWarpPerspective.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLWarpPerspective.h" - -#include "arm_compute/core/PixelValue.h" -#include "src/core/CL/kernels/CLFillBorderKernel.h" -#include "src/core/CL/kernels/CLWarpPerspectiveKernel.h" - -#include - -using namespace arm_compute; - -void CLWarpPerspective::configure(ICLTensor *input, ICLTensor *output, const std::array &matrix, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, output, matrix, policy, border_mode, constant_border_value); -} - -void CLWarpPerspective::configure(const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *output, const std::array &matrix, InterpolationPolicy policy, BorderMode border_mode, - uint8_t constant_border_value) -{ - auto k = std::make_unique(); - k->configure(compile_context, input, output, matrix, policy); - _kernel = std::move(k); - _border_handler->configure(compile_context, input, _kernel->border_size(), border_mode, PixelValue(constant_border_value)); -} -- cgit v1.2.1