diff options
author | Sang-Hoon Park <sang-hoon.park@arm.com> | 2021-05-18 10:46:00 +0100 |
---|---|---|
committer | Pablo Marquez Tello <pablo.tello@arm.com> | 2021-05-27 16:33:44 +0000 |
commit | b3be45759bdd0749ae3a16fe470820f0d9830ea9 (patch) | |
tree | 10bb8c1c0a049a23c00781c64e993f1b197c0d05 /src/runtime/NEON/functions/NEGEMMConv2d.cpp | |
parent | bc91297c865808ed2c321febc405179f63195ff8 (diff) | |
download | ComputeLibrary-b3be45759bdd0749ae3a16fe470820f0d9830ea9.tar.gz |
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 <sang-hoon.park@arm.com>
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5718
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Pablo Marquez Tello <pablo.tello@arm.com>
Diffstat (limited to 'src/runtime/NEON/functions/NEGEMMConv2d.cpp')
-rw-r--r-- | src/runtime/NEON/functions/NEGEMMConv2d.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
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 <set> namespace arm_compute { -using OperatorType = cpu::CpuGemmDirectConv2d; +using OperatorType = cpu::CpuGemmDirectConv2d; +using WorkspaceDataType = WorkspaceData<Tensor>; struct NEGEMMConv2d::Impl { ITensorPack tensors{}; + MemoryGroup mg{}; std::unique_ptr<OperatorType> op{ nullptr }; + WorkspaceDataType ws{}; + + void allocate_and_add_workspace() + { + if(op) + { + ws = manage_workspace<Tensor>(op->workspace(), mg, tensors); + } + } }; NEGEMMConv2d::NEGEMMConv2d(const std::shared_ptr<IMemoryManager> &memory_manager) : _impl(std::make_unique<Impl>()) { - _impl->op = std::make_unique<OperatorType>(memory_manager); + _impl->op = std::make_unique<OperatorType>(); + _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) |