blob: 129cd1afe3c5e29a892f92f169db32b31df82e9d [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>
Aron Virginas-Tarc26ba752018-10-22 13:32:01 +010011
12#include <boost/test/unit_test.hpp>
13
14BOOST_AUTO_TEST_SUITE(NeonRuntime)
15
16BOOST_AUTO_TEST_CASE(RuntimeValidateCpuAccDeviceSupportLayerNoFallback)
17{
18 // build up the structure of the network
19 armnn::INetworkPtr net(armnn::INetwork::Create());
20
21 armnn::IConnectableLayer* input = net->AddInputLayer(0);
22 armnn::IConnectableLayer* output = net->AddOutputLayer(0);
23
24 input->GetOutputSlot(0).Connect(output->GetInputSlot(0));
25 input->GetOutputSlot(0).SetTensorInfo(armnn::TensorInfo({ 1, 1, 4, 4 }, armnn::DataType::Float32));
26
27 armnn::IRuntime::CreationOptions options;
28 armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options));
29
30 std::vector<armnn::BackendId> backends = { armnn::Compute::CpuAcc };
31 armnn::IOptimizedNetworkPtr optNet = armnn::Optimize(*net, backends, runtime->GetDeviceSpec());
32 BOOST_CHECK(optNet);
33
34 // Load it into the runtime. It should success.
35 armnn::NetworkId netId;
36 BOOST_TEST(runtime->LoadNetwork(netId, std::move(optNet)) == armnn::Status::Success);
37}
38
39#ifdef ARMNN_LEAK_CHECKING_ENABLED
40BOOST_AUTO_TEST_CASE(RuntimeMemoryLeaksCpuAcc)
41{
42 BOOST_TEST(ARMNN_LEAK_CHECKER_IS_ACTIVE());
43 armnn::IRuntime::CreationOptions options;
44 armnn::Runtime runtime(options);
45 armnn::RuntimeLoadedNetworksReserve(&runtime);
46
47 std::vector<armnn::BackendId> backends = {armnn::Compute::CpuAcc};
48 {
49 // Do a warmup of this so we make sure that all one-time
50 // initialization happens before we do the leak checking.
51 CreateAndDropDummyNetwork(backends, runtime);
52 }
53
54 {
55 ARMNN_SCOPED_LEAK_CHECKER("LoadAndUnloadNetworkCpuAcc");
56 BOOST_TEST(ARMNN_NO_LEAKS_IN_SCOPE());
57 // In the second run we check for all remaining memory
58 // in use after the network was unloaded. If there is any
59 // then it will be treated as a memory leak.
60 CreateAndDropDummyNetwork(backends, runtime);
61 BOOST_TEST(ARMNN_NO_LEAKS_IN_SCOPE());
62 BOOST_TEST(ARMNN_BYTES_LEAKED_IN_SCOPE() == 0);
63 BOOST_TEST(ARMNN_OBJECTS_LEAKED_IN_SCOPE() == 0);
64 }
65}
66#endif
67
68BOOST_AUTO_TEST_SUITE_END()