blob: ee5666d5cd5076dfa9c698312127484810c7aa0f [file] [log] [blame]
Aron Virginas-Tarc26ba752018-10-22 13:32:01 +01001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
Aron Virginas-Tarc9cc8042018-11-01 16:15:57 +00006#include <test/RuntimeTests.hpp>
Aron Virginas-Tarc26ba752018-10-22 13:32:01 +01007
Aron Virginas-Tarc9cc8042018-11-01 16:15:57 +00008#include <LeakChecking.hpp>
Aron Virginas-Tarc26ba752018-10-22 13:32:01 +01009
Aron Virginas-Tarc9cc8042018-11-01 16:15:57 +000010#include <backendsCommon/test/RuntimeTestImpl.hpp>
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +000011#include <test/ProfilingTestUtils.hpp>
Aron Virginas-Tarc26ba752018-10-22 13:32:01 +010012
Sadik Armagan1625efc2021-06-10 18:24:34 +010013#include <doctest/doctest.h>
Aron Virginas-Tarc26ba752018-10-22 13:32:01 +010014
Sadik Armagan1625efc2021-06-10 18:24:34 +010015TEST_SUITE("NeonRuntime")
16{
17TEST_CASE("RuntimeValidateCpuAccDeviceSupportLayerNoFallback")
Aron Virginas-Tarc26ba752018-10-22 13:32:01 +010018{
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());
Sadik Armagan1625efc2021-06-10 18:24:34 +010033 CHECK(optNet);
Aron Virginas-Tarc26ba752018-10-22 13:32:01 +010034
35 // Load it into the runtime. It should success.
36 armnn::NetworkId netId;
Sadik Armagan1625efc2021-06-10 18:24:34 +010037 CHECK(runtime->LoadNetwork(netId, std::move(optNet)) == armnn::Status::Success);
Aron Virginas-Tarc26ba752018-10-22 13:32:01 +010038}
39
40#ifdef ARMNN_LEAK_CHECKING_ENABLED
Sadik Armagan1625efc2021-06-10 18:24:34 +010041TEST_CASE("RuntimeMemoryLeaksCpuAcc")
Aron Virginas-Tarc26ba752018-10-22 13:32:01 +010042{
Sadik Armagan1625efc2021-06-10 18:24:34 +010043 CHECK(ARMNN_LEAK_CHECKER_IS_ACTIVE());
Aron Virginas-Tarc26ba752018-10-22 13:32:01 +010044 armnn::IRuntime::CreationOptions options;
Kevin Mayd92a6e42021-02-04 10:27:41 +000045 armnn::RuntimeImpl runtime(options);
Aron Virginas-Tarc26ba752018-10-22 13:32:01 +010046 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");
Sadik Armagan1625efc2021-06-10 18:24:34 +010057 CHECK(ARMNN_NO_LEAKS_IN_SCOPE());
Aron Virginas-Tarc26ba752018-10-22 13:32:01 +010058 // 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);
Sadik Armagan1625efc2021-06-10 18:24:34 +010062 CHECK(ARMNN_NO_LEAKS_IN_SCOPE());
63 CHECK(ARMNN_BYTES_LEAKED_IN_SCOPE() == 0);
64 CHECK(ARMNN_OBJECTS_LEAKED_IN_SCOPE() == 0);
Aron Virginas-Tarc26ba752018-10-22 13:32:01 +010065 }
66}
67#endif
68
Sadik Armagan1625efc2021-06-10 18:24:34 +010069TEST_CASE("ProfilingPostOptimisationStructureCpuAcc")
Narumol Prangnawaratdf31cfe2019-11-22 11:26:06 +000070{
71 VerifyPostOptimisationStructureTestImpl(armnn::Compute::CpuAcc);
72}
73
Sadik Armagan1625efc2021-06-10 18:24:34 +010074}