ArmNN
 22.02
NeonRuntimeTests.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include <test/RuntimeTests.hpp>
7 
8 #include <LeakChecking.hpp>
9 
12 
13 #include <doctest/doctest.h>
14 
15 TEST_SUITE("NeonRuntime")
16 {
17 TEST_CASE("RuntimeValidateCpuAccDeviceSupportLayerNoFallback")
18 {
19  // build up the structure of the network
21 
22  armnn::IConnectableLayer* input = net->AddInputLayer(0);
23  armnn::IConnectableLayer* output = net->AddOutputLayer(0);
24 
25  input->GetOutputSlot(0).Connect(output->GetInputSlot(0));
27 
30 
31  std::vector<armnn::BackendId> backends = { armnn::Compute::CpuAcc };
32  armnn::IOptimizedNetworkPtr optNet = armnn::Optimize(*net, backends, runtime->GetDeviceSpec());
33  CHECK(optNet);
34 
35  // Load it into the runtime. It should success.
36  armnn::NetworkId netId;
37  CHECK(runtime->LoadNetwork(netId, std::move(optNet)) == armnn::Status::Success);
38 }
39 
40 #ifdef ARMNN_LEAK_CHECKING_ENABLED
41 TEST_CASE("RuntimeMemoryLeaksCpuAcc")
42 {
45  armnn::RuntimeImpl runtime(options);
47 
48  std::vector<armnn::BackendId> backends = {armnn::Compute::CpuAcc};
49  {
50  // Do a warmup of this so we make sure that all one-time
51  // initialization happens before we do the leak checking.
52  CreateAndDropDummyNetwork(backends, runtime);
53  }
54 
55  {
56  ARMNN_SCOPED_LEAK_CHECKER("LoadAndUnloadNetworkCpuAcc");
57  CHECK(ARMNN_NO_LEAKS_IN_SCOPE());
58  // In the second run we check for all remaining memory
59  // in use after the network was unloaded. If there is any
60  // then it will be treated as a memory leak.
61  CreateAndDropDummyNetwork(backends, runtime);
62  CHECK(ARMNN_NO_LEAKS_IN_SCOPE());
63  CHECK(ARMNN_BYTES_LEAKED_IN_SCOPE() == 0);
64  CHECK(ARMNN_OBJECTS_LEAKED_IN_SCOPE() == 0);
65  }
66 }
67 #endif
68 
69 TEST_CASE("ProfilingPostOptimisationStructureCpuAcc")
70 {
72 }
73 
74 }
#define ARMNN_SCOPED_LEAK_CHECKER(TAG)
static IRuntimePtr Create(const CreationOptions &options)
Definition: Runtime.cpp:40
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:66
void VerifyPostOptimisationStructureTestImpl(armnn::BackendId backendId)
std::unique_ptr< IRuntime, void(*)(IRuntime *runtime)> IRuntimePtr
Definition: IRuntime.hpp:31
TEST_SUITE("NeonRuntime")
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
#define ARMNN_LEAK_CHECKER_IS_ACTIVE()
#define ARMNN_OBJECTS_LEAKED_IN_SCOPE()
void RuntimeLoadedNetworksReserve(armnn::RuntimeImpl *runtime)
IOptimizedNetworkPtr Optimize(const INetwork &network, const std::vector< BackendId > &backendPreferences, const IDeviceSpec &deviceSpec, const OptimizerOptions &options=OptimizerOptions(), Optional< std::vector< std::string > &> messages=EmptyOptional())
Create an optimized version of the network.
Definition: Network.cpp:1680
int NetworkId
Definition: IRuntime.hpp:25
std::unique_ptr< IOptimizedNetwork, void(*)(IOptimizedNetwork *network)> IOptimizedNetworkPtr
Definition: INetwork.hpp:242
CPU Execution: NEON: ArmCompute.
#define ARMNN_NO_LEAKS_IN_SCOPE()
virtual const IInputSlot & GetInputSlot(unsigned int index) const =0
Get a const input slot handle by slot index.
virtual const IOutputSlot & GetOutputSlot(unsigned int index) const =0
Get the const output slot handle by slot index.
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:241
virtual int Connect(IInputSlot &destination)=0
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:492
#define ARMNN_BYTES_LEAKED_IN_SCOPE()