From 7bfd38a721360183f3392f9ab35db18a0dd7fef8 Mon Sep 17 00:00:00 2001 From: Nikhil Raj Date: Fri, 19 Aug 2022 15:23:36 +0100 Subject: Update Doxygen for 22.08 Release Signed-off-by: Nikhil Raj Change-Id: I4789fe868e0492839be1482e5cee3642ed90d756 --- ...mory_optimizer_strategy_tests_8cpp_source.xhtml | 135 +++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 22.08/_custom_memory_optimizer_strategy_tests_8cpp_source.xhtml (limited to '22.08/_custom_memory_optimizer_strategy_tests_8cpp_source.xhtml') diff --git a/22.08/_custom_memory_optimizer_strategy_tests_8cpp_source.xhtml b/22.08/_custom_memory_optimizer_strategy_tests_8cpp_source.xhtml new file mode 100644 index 0000000000..0bf486a8e1 --- /dev/null +++ b/22.08/_custom_memory_optimizer_strategy_tests_8cpp_source.xhtml @@ -0,0 +1,135 @@ + + + + + + + + + + + + + +ArmNN: src/backends/backendsCommon/test/CustomMemoryOptimizerStrategyTests.cpp Source File + + + + + + + + + + + + + + + + +
+
+ + + + ArmNN + + + +
+
+  22.08 +
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+
+
CustomMemoryOptimizerStrategyTests.cpp
+
+
+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 
6 #include <armnn/IRuntime.hpp>
7 #include <armnn/Utils.hpp>
9 
11 
12 #if defined(ARMNNREF_ENABLED)
13 #include <reference/RefBackend.hpp>
14 #endif
15 
16 #if defined(ARMCOMPUTENEON_ENABLED)
17 #include <neon/NeonBackend.hpp>
18 #endif
19 
20 #include <doctest/doctest.h>
21 
22 
23 // Sample implementation of IMemoryOptimizerStrategy..
24 class SampleMemoryOptimizerStrategy : public armnn::IMemoryOptimizerStrategy
25 {
26 public:
27  SampleMemoryOptimizerStrategy() = default;
28 
29  std::string GetName() const
30  {
31  return std::string("SampleMemoryOptimizerStrategy");
32  }
33 
35  {
37  }
38 
39  std::vector<armnn::MemBin> Optimize(std::vector<armnn::MemBlock>& memBlocks)
40  {
41  std::vector<armnn::MemBin> memBins;
42  memBins.reserve(memBlocks.size());
43  return memBins;
44  }
45 };
46 
47 TEST_SUITE("CustomMemoryOptimizerStrategyTests")
48 {
49 
50 // Only run this test if CpuRef is enabled
51 #if defined(ARMNNREF_ENABLED)
52 TEST_CASE("RefCustomMemoryOptimizerStrategyTest")
53 {
54  using namespace armnn;
55 
56  // Create ArmNN runtime
57  IRuntime::CreationOptions options; // default options
58  auto customMemoryOptimizerStrategy = std::make_shared<SampleMemoryOptimizerStrategy>();
59  options.m_MemoryOptimizerStrategyMap = {{"CpuRef", std::move(customMemoryOptimizerStrategy)}};
60  IRuntimePtr run = IRuntime::Create(options);
61 
62  CHECK(!BackendRegistryInstance().GetMemoryOptimizerStrategies().empty());
63  CHECK(BackendRegistryInstance().GetMemoryOptimizerStrategies().size() == 1);
64  CHECK(BackendRegistryInstance().GetMemoryOptimizerStrategies().at(RefBackend::GetIdStatic()));
65  auto optimizerStrategy = BackendRegistryInstance().GetMemoryOptimizerStrategies().at(RefBackend::GetIdStatic());
66  CHECK(optimizerStrategy->GetName() == std::string("SampleMemoryOptimizerStrategy"));
67 
68  // De-register the memory optimizer
70  CHECK(BackendRegistryInstance().GetMemoryOptimizerStrategies().empty());
71 
72 }
73 
74 TEST_CASE("CpuRefSetMemoryOptimizerStrategyTest")
75 {
76  using namespace armnn;
77 
78  // Create ArmNN runtime
79  IRuntime::CreationOptions options; // default options
80  options.m_BackendOptions.emplace_back(
81  BackendOptions{"CpuRef",
82  {
83  {"MemoryOptimizerStrategy", "ConstantMemoryStrategy"}
84  }
85  });
86 
87  IRuntimePtr run = IRuntime::Create(options);
88 
89  // ConstantMemoryStrategy should be registered for CpuRef
90  CHECK(!BackendRegistryInstance().GetMemoryOptimizerStrategies().empty());
91  CHECK(BackendRegistryInstance().GetMemoryOptimizerStrategies().size() == 1);
92  CHECK(BackendRegistryInstance().GetMemoryOptimizerStrategies().at(RefBackend::GetIdStatic()));
93  auto optimizerStrategy = BackendRegistryInstance().GetMemoryOptimizerStrategies().at(RefBackend::GetIdStatic());
94  CHECK(optimizerStrategy->GetName() == std::string("ConstantMemoryStrategy"));
96 }
97 
98 #endif
99 
100 // Only run this test if CpuAcc is enabled
101 #if defined(ARMCOMPUTENEON_ENABLED)
102 
103 TEST_CASE("CpuAccSetMemoryOptimizerStrategyTest")
104 {
105  using namespace armnn;
106 
107  // Create ArmNN runtime
108  IRuntime::CreationOptions options; // default options
109  options.m_BackendOptions.emplace_back(
110  BackendOptions{"CpuAcc",
111  {
112  {"MemoryOptimizerStrategy", "NotExistMemoryOptimizerStrategy"}
113  }
114  });
115 
116  IRuntimePtr run = IRuntime::Create(options);
117 
118  // No MemoryOptimizerStrategy should be registered..
119  CHECK(armnn::BackendRegistryInstance().GetMemoryOptimizerStrategies().empty());
121 }
122 
123 #endif
124 
125 } // test suite CustomMemoryOptimizerStrategyTests
TEST_SUITE("TestConstTensorLayerVisitor")
+ + + +
MemoryOptimizerStrategiesMapRef GetMemoryOptimizerStrategies()
+
std::unique_ptr< IRuntime, void(*)(IRuntime *runtime)> IRuntimePtr
Definition: IRuntime.hpp:33
+ +
BackendRegistry & BackendRegistryInstance()
+
std::map< BackendId, std::shared_ptr< IMemoryOptimizerStrategy > > m_MemoryOptimizerStrategyMap
A map to define a custom memory optimizer strategy for specific backend Ids.
Definition: IRuntime.hpp:122
+
Copyright (c) 2021 ARM Limited and Contributors.
+ +
std::vector< BackendOptions > m_BackendOptions
Pass backend specific options.
Definition: IRuntime.hpp:189
+ +
virtual MemBlockStrategyType GetMemBlockStrategyType() const =0
+ +
void DeregisterMemoryOptimizerStrategy(const BackendId &id)
+ + +
Struct for the users to pass backend specific options.
+
MemBlockStrategyType
Definition: Types.hpp:239
+
virtual std::vector< MemBin > Optimize(std::vector< MemBlock > &memBlocks)=0
+
virtual std::string GetName() const =0
+
+
+ + + + -- cgit v1.2.1