ArmNN
 20.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 <boost/test/unit_test.hpp>
14 
15 BOOST_AUTO_TEST_SUITE(NeonRuntime)
16 
17 BOOST_AUTO_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  BOOST_CHECK(optNet);
34 
35  // Load it into the runtime. It should success.
36  armnn::NetworkId netId;
37  BOOST_TEST(runtime->LoadNetwork(netId, std::move(optNet)) == armnn::Status::Success);
38 }
39 
40 #ifdef ARMNN_LEAK_CHECKING_ENABLED
41 BOOST_AUTO_TEST_CASE(RuntimeMemoryLeaksCpuAcc)
42 {
43  BOOST_TEST(ARMNN_LEAK_CHECKER_IS_ACTIVE());
45  armnn::Runtime 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  BOOST_TEST(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  BOOST_TEST(ARMNN_NO_LEAKS_IN_SCOPE());
63  BOOST_TEST(ARMNN_BYTES_LEAKED_IN_SCOPE() == 0);
64  BOOST_TEST(ARMNN_OBJECTS_LEAKED_IN_SCOPE() == 0);
65  }
66 }
67 #endif
68 
69 BOOST_AUTO_TEST_CASE(ProfilingPostOptimisationStructureCpuAcc)
70 {
72 }
73 
#define ARMNN_SCOPED_LEAK_CHECKER(TAG)
BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
static IRuntimePtr Create(const CreationOptions &options)
Definition: Runtime.cpp:32
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:61
void VerifyPostOptimisationStructureTestImpl(armnn::BackendId backendId)
std::unique_ptr< IRuntime, void(*)(IRuntime *runtime)> IRuntimePtr
Definition: IRuntime.hpp:24
int NetworkId
Definition: IRuntime.hpp:19
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
#define ARMNN_LEAK_CHECKER_IS_ACTIVE()
#define ARMNN_OBJECTS_LEAKED_IN_SCOPE()
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:890
std::unique_ptr< IOptimizedNetwork, void(*)(IOptimizedNetwork *network)> IOptimizedNetworkPtr
Definition: INetwork.hpp:566
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(RuntimeValidateCpuAccDeviceSupportLayerNoFallback)
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:101
virtual int Connect(IInputSlot &destination)=0
armnn::Runtime::CreationOptions::ExternalProfilingOptions options
#define ARMNN_BYTES_LEAKED_IN_SCOPE()
static INetworkPtr Create()
Definition: Network.cpp:49
void RuntimeLoadedNetworksReserve(armnn::Runtime *runtime)