From 658039bc4e06be34272eccf559a516a6b52f75f5 Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Fri, 15 Sep 2017 16:30:50 +0100 Subject: COMPMID-534: Add MemoryManager support in NEON functions Adds support for: -NECannyEdge -NEConvolution -NEDirectConvolution -NEGEMM -NEGEMMLowp -NEGaussian5x5 -NEHOGDescriptor -NEHOGGradient -NEL2Normalize -NELocallyConnectedLayer -NENormalizationLayer -NEScale -NESobel5x5 -NESobel7x7 Change-Id: I68e05aa6054372fa873a882633a15fb97882c00d Reviewed-on: http://mpd-gerrit.cambridge.arm.com/87926 Reviewed-by: Pablo Tello Tested-by: Kaizen --- src/runtime/NEON/functions/NEHOGMultiDetection.cpp | 37 ++++++++++++++++------ 1 file changed, 27 insertions(+), 10 deletions(-) (limited to 'src/runtime/NEON/functions/NEHOGMultiDetection.cpp') diff --git a/src/runtime/NEON/functions/NEHOGMultiDetection.cpp b/src/runtime/NEON/functions/NEHOGMultiDetection.cpp index 1a038a2f62..8c834e2a93 100644 --- a/src/runtime/NEON/functions/NEHOGMultiDetection.cpp +++ b/src/runtime/NEON/functions/NEHOGMultiDetection.cpp @@ -32,8 +32,9 @@ using namespace arm_compute; -NEHOGMultiDetection::NEHOGMultiDetection() // NOLINT - : _gradient_kernel(), +NEHOGMultiDetection::NEHOGMultiDetection(std::shared_ptr memory_manager) // NOLINT + : _memory_group(std::move(memory_manager)), + _gradient_kernel(), _orient_bin_kernel(), _block_norm_kernel(), _hog_detect_kernel(), @@ -139,6 +140,10 @@ void NEHOGMultiDetection::configure(ITensor *input, const IMultiHOG *multi_hog, 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); @@ -164,10 +169,17 @@ void NEHOGMultiDetection::configure(ITensor *input, const IMultiHOG *multi_hog, 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 NETensor for the normalized HOG space and block normalization kernel for(size_t i = 0; i < _num_block_norm_kernel; ++i) { @@ -178,10 +190,19 @@ void NEHOGMultiDetection::configure(ITensor *input, const IMultiHOG *multi_hog, 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(); + } + // Configure HOG detector kernel for(size_t i = 0; i < _num_hog_detect_kernel; ++i) { @@ -194,14 +215,6 @@ void NEHOGMultiDetection::configure(ITensor *input, const IMultiHOG *multi_hog, _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(); @@ -212,6 +225,8 @@ void NEHOGMultiDetection::run() { ARM_COMPUTE_ERROR_ON_MSG(_detection_windows == nullptr, "Unconfigured function"); + _memory_group.acquire(); + // Reset detection window _detection_windows->clear(); @@ -241,4 +256,6 @@ void NEHOGMultiDetection::run() { NEScheduler::get().schedule(_non_maxima_kernel.get(), Window::DimY); } + + _memory_group.release(); } -- cgit v1.2.1