From e1fdd2866b0f403b5e80994890d62c2c038c16c9 Mon Sep 17 00:00:00 2001 From: Jim Flynn Date: Tue, 26 Oct 2021 21:26:10 +0100 Subject: IVGCVSW-6470 Create MemoryStrategyBenchmark * Refactor the strategy library to be more generic * Shorten the names of the current strategies * Change validatorStrat to throw exceptions Change-Id: I0d9c9ef609b2d8675e5788610d1accac6767c660 Signed-off-by: Finn Williams Signed-off-by: Jim Flynn --- .../strategies/ConstantMemoryStrategy.cpp | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/backends/backendsCommon/memoryOptimizerStrategyLibrary/strategies/ConstantMemoryStrategy.cpp (limited to 'src/backends/backendsCommon/memoryOptimizerStrategyLibrary/strategies/ConstantMemoryStrategy.cpp') diff --git a/src/backends/backendsCommon/memoryOptimizerStrategyLibrary/strategies/ConstantMemoryStrategy.cpp b/src/backends/backendsCommon/memoryOptimizerStrategyLibrary/strategies/ConstantMemoryStrategy.cpp new file mode 100644 index 0000000000..55f7f89f4b --- /dev/null +++ b/src/backends/backendsCommon/memoryOptimizerStrategyLibrary/strategies/ConstantMemoryStrategy.cpp @@ -0,0 +1,43 @@ +// +// Copyright © 2021 Arm Ltd and Contributors. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include "ConstantMemoryStrategy.hpp" + +namespace armnn +{ + +std::string ConstantMemoryStrategy::GetName() const +{ + return m_Name; +} + +MemBlockStrategyType ConstantMemoryStrategy::GetMemBlockStrategyType() const +{ + return m_MemBlockStrategyType; +} + +// A IMemoryOptimizerStrategy must ensure that +// 1: All MemBlocks have been assigned to a MemBin +// 2: No MemBlock is assigned to multiple MemBins +// 3: No two Memblocks in a MemBin overlap in both the X and Y axis +std::vector ConstantMemoryStrategy::Optimize(std::vector& memBlocks) +{ + std::vector memBins; + memBins.reserve(memBlocks.size()); + + for (auto& memBlock : memBlocks) + { + MemBin memBin; + memBin.m_MemSize = memBlock.m_MemSize; + memBin.m_MemBlocks.reserve(1); + memBlock.m_Offset = 0; + memBin.m_MemBlocks.push_back(memBlock); + memBins.push_back(memBin); + } + + return memBins; +} + +} // namespace armnn \ No newline at end of file -- cgit v1.2.1