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 10 #include <backendsCommon/test/RuntimeTestImpl.hpp> 11 #include <test/ProfilingTestUtils.hpp> 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 20 armnn::INetworkPtr net(armnn::INetwork::Create()); 21 22 armnn::IConnectableLayer* input = net->AddInputLayer(0); 23 armnn::IConnectableLayer* output = net->AddOutputLayer(0); 24 25 input->GetOutputSlot(0).Connect(output->GetInputSlot(0)); 26 input->GetOutputSlot(0).SetTensorInfo(armnn::TensorInfo({ 1, 1, 4, 4 }, armnn::DataType::Float32)); 27 28 armnn::IRuntime::CreationOptions options; 29 armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options)); 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 { 43 CHECK(ARMNN_LEAK_CHECKER_IS_ACTIVE()); 44 armnn::IRuntime::CreationOptions options; 45 armnn::RuntimeImpl runtime(options); 46 armnn::RuntimeLoadedNetworksReserve(&runtime); 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 { 71 VerifyPostOptimisationStructureTestImpl(armnn::Compute::CpuAcc); 72 } 73 74 }