From b3be45759bdd0749ae3a16fe470820f0d9830ea9 Mon Sep 17 00:00:00 2001 From: Sang-Hoon Park Date: Tue, 18 May 2021 10:46:00 +0100 Subject: Implement memory injection in CpuDirectGemmConv2d The following operators are now stateless by implementing memory injection. - CpuDirectGemmConv2d - CpuGemmAssemblyDispatch A test case is added to test if CpuDirectGemmConv2d can run on different group of tensors with a single configure. Resolves: COMPMID-4506 Change-Id: I48f44ed41236ca7e18da2de07bdbacc9007a3c5e Signed-off-by: Sang-Hoon Park Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5718 Comments-Addressed: Arm Jenkins Tested-by: Arm Jenkins Reviewed-by: Pablo Marquez Tello --- src/runtime/NEON/functions/NEGEMMConv2d.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/runtime/NEON/functions/NEGEMMConv2d.cpp') diff --git a/src/runtime/NEON/functions/NEGEMMConv2d.cpp b/src/runtime/NEON/functions/NEGEMMConv2d.cpp index 94ceb6d27c..790543a34a 100644 --- a/src/runtime/NEON/functions/NEGEMMConv2d.cpp +++ b/src/runtime/NEON/functions/NEGEMMConv2d.cpp @@ -26,24 +26,37 @@ #include "arm_compute/core/utils/misc/ShapeCalculator.h" #include "arm_compute/core/utils/quantization/AsymmHelpers.h" #include "arm_compute/runtime/NEON/NEScheduler.h" +#include "src/core/helpers/MemoryHelpers.h" #include "src/runtime/cpu/operators/CpuGemmDirectConv2d.h" #include namespace arm_compute { -using OperatorType = cpu::CpuGemmDirectConv2d; +using OperatorType = cpu::CpuGemmDirectConv2d; +using WorkspaceDataType = WorkspaceData; struct NEGEMMConv2d::Impl { ITensorPack tensors{}; + MemoryGroup mg{}; std::unique_ptr op{ nullptr }; + WorkspaceDataType ws{}; + + void allocate_and_add_workspace() + { + if(op) + { + ws = manage_workspace(op->workspace(), mg, tensors); + } + } }; NEGEMMConv2d::NEGEMMConv2d(const std::shared_ptr &memory_manager) : _impl(std::make_unique()) { - _impl->op = std::make_unique(memory_manager); + _impl->op = std::make_unique(); + _impl->mg = MemoryGroup(memory_manager); } NEGEMMConv2d::~NEGEMMConv2d() = default; @@ -55,7 +68,9 @@ void NEGEMMConv2d::configure(ITensor *input, const ITensor *weights, const ITens _impl->tensors.add_const_tensor(TensorType::ACL_SRC_2, biases); _impl->tensors.add_tensor(TensorType::ACL_DST, output); - _impl->op->configure(input->info(), weights->info(), biases->info(), output->info(), info); + _impl->op->configure(input->info(), weights->info(), ((biases) ? biases->info() : nullptr), output->info(), info); + + _impl->allocate_and_add_workspace(); } Status NEGEMMConv2d::validate(const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *output, const Conv2dInfo &info) -- cgit v1.2.1