ArmNN
 24.02
MemoryOptimizerStrategyLibrary.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2021 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 #pragma once
6 
9 
13 
14 #include <map>
15 
16 namespace armnn
17 {
18 namespace
19 {
20 
21 static std::map<std::string, std::unique_ptr<IMemoryOptimizerStrategyFactory>>& GetStrategyFactories()
22 {
23  static std::map<std::string, std::unique_ptr<IMemoryOptimizerStrategyFactory>> strategies;
24 
25  if (strategies.size() == 0)
26  {
27  strategies["ConstantMemoryStrategy"] = std::make_unique<StrategyFactory<ConstantMemoryStrategy>>();
28  strategies["SingleAxisPriorityList"] = std::make_unique<StrategyFactory<SingleAxisPriorityList>>();
29  strategies["StrategyValidator"] = std::make_unique<StrategyFactory<StrategyValidator>>();
30  }
31  return strategies;
32 }
33 
34 } // anonymous namespace
35 
36 inline std::unique_ptr<IMemoryOptimizerStrategy> GetMemoryOptimizerStrategy(const std::string& strategyName)
37 {
38  const auto& strategyFactoryMap = GetStrategyFactories();
39  auto strategyFactory = strategyFactoryMap.find(strategyName);
40  if (strategyFactory != GetStrategyFactories().end())
41  {
42  return strategyFactory->second->CreateMemoryOptimizerStrategy();
43  }
44  return nullptr;
45 }
46 
47 inline const std::vector<std::string> GetMemoryOptimizerStrategyNames()
48 {
49  const auto& strategyFactoryMap = GetStrategyFactories();
50  std::vector<std::string> strategyNames;
51  for (const auto& strategyFactory : strategyFactoryMap)
52  {
53  strategyNames.emplace_back(strategyFactory.first);
54  }
55  return strategyNames;
56 }
57 } // namespace armnn
StrategyValidator.hpp
MemoryOptimizerStrategyFactory.hpp
IMemoryOptimizerStrategy.hpp
armnn::GetMemoryOptimizerStrategy
std::unique_ptr< IMemoryOptimizerStrategy > GetMemoryOptimizerStrategy(const std::string &strategyName)
Definition: MemoryOptimizerStrategyLibrary.hpp:36
SingleAxisPriorityList.hpp
ConstantMemoryStrategy.hpp
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
armnn::GetMemoryOptimizerStrategyNames
const std::vector< std::string > GetMemoryOptimizerStrategyNames()
Definition: MemoryOptimizerStrategyLibrary.hpp:47