diff options
author | Jim Flynn <jim.flynn@arm.com> | 2021-10-26 21:26:10 +0100 |
---|---|---|
committer | Jim Flynn <jim.flynn@arm.com> | 2021-10-26 21:27:22 +0100 |
commit | e1fdd2866b0f403b5e80994890d62c2c038c16c9 (patch) | |
tree | d7398443532cbafde7c6824015397e6bac6dd502 /tests/MemoryStrategyBenchmark/TestStrategy.cpp | |
parent | ca5883951ab51191eb19502459f0936fc96e14f1 (diff) | |
download | armnn-e1fdd2866b0f403b5e80994890d62c2c038c16c9.tar.gz |
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 <finwil01@e127804.cambridge.arm.com>
Signed-off-by: Jim Flynn <jim.flynn@arm.com>
Diffstat (limited to 'tests/MemoryStrategyBenchmark/TestStrategy.cpp')
-rw-r--r-- | tests/MemoryStrategyBenchmark/TestStrategy.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
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<MemBin> TestStrategy::Optimize(std::vector<MemBlock>& memBlocks) + { + std::vector<MemBin> 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 |