aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/NEON/functions/NEPoolingLayer.cpp
diff options
context:
space:
mode:
authorMichele Di Giorgio <michele.digiorgio@arm.com>2021-05-11 17:41:32 +0100
committerMichele Di Giorgio <michele.digiorgio@arm.com>2021-05-17 09:33:02 +0000
commit0c19cbd5800e830fa67cdd3b725efe796b211899 (patch)
tree450f5e33d482207d77355aa094d27e148588f42e /src/runtime/NEON/functions/NEPoolingLayer.cpp
parent538a076aae14dbc1940c52057e135f8a1872aa11 (diff)
downloadComputeLibrary-0c19cbd5800e830fa67cdd3b725efe796b211899.tar.gz
Move memory management out of CpuPooling
Change-Id: Idae4fc687942f61a1f63f23c9e5538df28888d93 Signed-off-by: Michele Di Giorgio <michele.digiorgio@arm.com> Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5632 Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/runtime/NEON/functions/NEPoolingLayer.cpp')
-rw-r--r--src/runtime/NEON/functions/NEPoolingLayer.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/runtime/NEON/functions/NEPoolingLayer.cpp b/src/runtime/NEON/functions/NEPoolingLayer.cpp
index dd7a3a337e..1570cdeedc 100644
--- a/src/runtime/NEON/functions/NEPoolingLayer.cpp
+++ b/src/runtime/NEON/functions/NEPoolingLayer.cpp
@@ -23,7 +23,9 @@
*/
#include "arm_compute/runtime/NEON/functions/NEPoolingLayer.h"
+#include "arm_compute/core/TensorInfo.h"
#include "arm_compute/core/Validate.h"
+#include "arm_compute/runtime/Tensor.h"
#include "src/runtime/cpu/operators/CpuPooling.h"
namespace arm_compute
@@ -33,16 +35,15 @@ struct NEPoolingLayer::Impl
ITensor *src{ nullptr };
ITensor *dst{ nullptr };
ITensor *indices{ nullptr };
- std::shared_ptr<IMemoryManager> memory_manager{ nullptr };
+ Tensor workspace{ nullptr };
std::unique_ptr<cpu::CpuPooling> op{ nullptr };
};
NEPoolingLayer::~NEPoolingLayer() = default;
NEPoolingLayer::NEPoolingLayer(std::shared_ptr<IMemoryManager> memory_manager)
- : _impl(std::make_unique<Impl>())
+ : _memory_group(memory_manager), _impl(std::make_unique<Impl>())
{
- _impl->memory_manager = std::move(memory_manager);
}
void NEPoolingLayer::configure(ITensor *input, ITensor *output, const PoolingLayerInfo &pool_info, ITensor *indices)
@@ -50,8 +51,17 @@ void NEPoolingLayer::configure(ITensor *input, ITensor *output, const PoolingLay
_impl->src = input;
_impl->dst = output;
_impl->indices = indices;
- _impl->op = std::make_unique<cpu::CpuPooling>(_impl->memory_manager);
+ _impl->op = std::make_unique<cpu::CpuPooling>();
_impl->op->configure(input->info(), output->info(), pool_info, (indices) ? indices->info() : nullptr);
+
+ // Allocate workspace based on kernel's memory requirements
+ const experimental::MemoryRequirements mem_req = _impl->op->workspace();
+ if(!mem_req.empty())
+ {
+ _impl->workspace.allocator()->init(TensorInfo(TensorShape{ (mem_req[0].size + mem_req[0].alignment) }, 1, DataType::S8), mem_req[0].alignment);
+ _memory_group.manage(&_impl->workspace);
+ _impl->workspace.allocator()->allocate();
+ }
}
Status NEPoolingLayer::validate(const ITensorInfo *input, const ITensorInfo *output, const PoolingLayerInfo &pool_info, const ITensorInfo *indices)
@@ -65,6 +75,7 @@ void NEPoolingLayer::run()
pack.add_tensor(TensorType::ACL_SRC, _impl->src);
pack.add_tensor(TensorType::ACL_DST_0, _impl->dst);
pack.add_tensor(TensorType::ACL_DST_1, _impl->indices);
+ pack.add_tensor(TensorType::ACL_INT_0, &_impl->workspace);
_impl->op->run(pack);
}
} // namespace arm_compute