From 8a94e7cec7b09a417a278425e2b56e7af5bf45d9 Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Fri, 15 Sep 2017 19:06:47 +0100 Subject: COMPMID-534: Add MemoryManager support in OpenCL functions Adds support for: -CLConvolution -CLGEMM -CLGEMMLowp -CLHOGDescriptor -CLHOGGradient -CLHOGMultiDetection -CLL2Normalize -CLLocallyConnectedLayer -CLOpticalFlow -CLReductionOperation Change-Id: Ib13354d274ccf32ae933f3fbbad3ac3896cfd3bd Reviewed-on: http://mpd-gerrit.cambridge.arm.com/87938 Tested-by: Kaizen Reviewed-by: Pablo Tello --- src/runtime/CL/functions/CLHOGMultiDetection.cpp | 37 +++++++++++++++++------- 1 file changed, 27 insertions(+), 10 deletions(-) (limited to 'src/runtime/CL/functions/CLHOGMultiDetection.cpp') diff --git a/src/runtime/CL/functions/CLHOGMultiDetection.cpp b/src/runtime/CL/functions/CLHOGMultiDetection.cpp index 9eed355710..8012c2f60a 100644 --- a/src/runtime/CL/functions/CLHOGMultiDetection.cpp +++ b/src/runtime/CL/functions/CLHOGMultiDetection.cpp @@ -34,8 +34,9 @@ using namespace arm_compute; -CLHOGMultiDetection::CLHOGMultiDetection() // NOLINT - : _gradient_kernel(), +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(), @@ -141,6 +142,10 @@ void CLHOGMultiDetection::configure(ICLTensor *input, const ICLMultiHOG *multi_h 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(input, &_mag, &_phase, phase_type, border_mode, constant_border_value); @@ -166,10 +171,17 @@ void CLHOGMultiDetection::configure(ICLTensor *input, const ICLMultiHOG *multi_h 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.get() + i); + // Initialise orientation binning kernel _orient_bin_kernel[i].configure(&_mag, &_phase, _hog_space.get() + 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) { @@ -180,10 +192,19 @@ void CLHOGMultiDetection::configure(ICLTensor *input, const ICLMultiHOG *multi_h 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.get() + i); + // Initialize block normalization kernel _block_norm_kernel[i].configure(_hog_space.get() + idx_orient_bin, _hog_norm_space.get() + 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 @@ -200,14 +221,6 @@ void CLHOGMultiDetection::configure(ICLTensor *input, const ICLMultiHOG *multi_h _non_maxima_kernel->configure(_detection_windows, min_distance); // Allocate intermediate tensors - _mag.allocator()->allocate(); - _phase.allocator()->allocate(); - - for(size_t i = 0; i < _num_orient_bin_kernel; ++i) - { - _hog_space[i].allocator()->allocate(); - } - for(size_t i = 0; i < _num_block_norm_kernel; ++i) { _hog_norm_space[i].allocator()->allocate(); @@ -218,6 +231,8 @@ void CLHOGMultiDetection::run() { ARM_COMPUTE_ERROR_ON_MSG(_detection_windows == nullptr, "Unconfigured function"); + _memory_group.acquire(); + // Reset detection window _detection_windows->clear(); @@ -250,4 +265,6 @@ void CLHOGMultiDetection::run() Scheduler::get().schedule(_non_maxima_kernel.get(), Window::DimY); _detection_windows->unmap(CLScheduler::get().queue()); } + + _memory_group.release(); } -- cgit v1.2.1