1 //
2 // Copyright © 2021 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "ConstantMemoryStrategy.hpp"
7 
8 namespace armnn
9 {
10 
GetName() const11 std::string ConstantMemoryStrategy::GetName() const
12 {
13     return m_Name;
14 }
15 
GetMemBlockStrategyType() const16 MemBlockStrategyType ConstantMemoryStrategy::GetMemBlockStrategyType() const
17 {
18     return m_MemBlockStrategyType;
19 }
20 
21 // A IMemoryOptimizerStrategy must ensure that
22 // 1: All MemBlocks have been assigned to a MemBin
23 // 2: No MemBlock is assigned to multiple MemBins
24 // 3: No two Memblocks in a MemBin overlap in both the X and Y axis
Optimize(std::vector<MemBlock> & memBlocks)25 std::vector<MemBin> ConstantMemoryStrategy::Optimize(std::vector<MemBlock>& memBlocks)
26 {
27     std::vector<MemBin> memBins;
28     memBins.reserve(memBlocks.size());
29 
30     for (auto& memBlock : memBlocks)
31     {
32         MemBin memBin;
33         memBin.m_MemSize = memBlock.m_MemSize;
34         memBin.m_MemBlocks.reserve(1);
35         memBlock.m_Offset = 0;
36         memBin.m_MemBlocks.push_back(memBlock);
37         memBins.push_back(memBin);
38     }
39 
40     return memBins;
41 }
42 
43 } // namespace armnn