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 --- tests/MemoryStrategyBenchmark/TestStrategy.cpp | 43 ++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 tests/MemoryStrategyBenchmark/TestStrategy.cpp (limited to 'tests/MemoryStrategyBenchmark/TestStrategy.cpp') diff --git a/tests/MemoryStrategyBenchmark/TestStrategy.cpp b/tests/MemoryStrategyBenchmark/TestStrategy.cpp new file mode 100644 index 0000000000..9e9194972a --- /dev/null +++ b/tests/MemoryStrategyBenchmark/TestStrategy.cpp @@ -0,0 +1,43 @@ +// +// Copyright © 2021 Arm Ltd and Contributors. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include "TestStrategy.hpp" + +namespace armnn +{ + + std::string TestStrategy::GetName() const + { + return m_Name; + } + + MemBlockStrategyType TestStrategy::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 TestStrategy::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