2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
6 #include <test/RuntimeTests.hpp>
8 #include <LeakChecking.hpp>
10 #include <backendsCommon/test/RuntimeTestImpl.hpp>
12 #include <boost/test/unit_test.hpp>
14 BOOST_AUTO_TEST_SUITE(NeonRuntime)
16 BOOST_AUTO_TEST_CASE(RuntimeValidateCpuAccDeviceSupportLayerNoFallback)
18 // build up the structure of the network
19 armnn::INetworkPtr net(armnn::INetwork::Create());
21 armnn::IConnectableLayer* input = net->AddInputLayer(0);
22 armnn::IConnectableLayer* output = net->AddOutputLayer(0);
24 input->GetOutputSlot(0).Connect(output->GetInputSlot(0));
25 input->GetOutputSlot(0).SetTensorInfo(armnn::TensorInfo({ 1, 1, 4, 4 }, armnn::DataType::Float32));
27 armnn::IRuntime::CreationOptions options;
28 armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options));
30 std::vector<armnn::BackendId> backends = { armnn::Compute::CpuAcc };
31 armnn::IOptimizedNetworkPtr optNet = armnn::Optimize(*net, backends, runtime->GetDeviceSpec());
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);
39 #ifdef ARMNN_LEAK_CHECKING_ENABLED
40 BOOST_AUTO_TEST_CASE(RuntimeMemoryLeaksCpuAcc)
42 BOOST_TEST(ARMNN_LEAK_CHECKER_IS_ACTIVE());
43 armnn::IRuntime::CreationOptions options;
44 armnn::Runtime runtime(options);
45 armnn::RuntimeLoadedNetworksReserve(&runtime);
47 std::vector<armnn::BackendId> backends = {armnn::Compute::CpuAcc};
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);
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);
68 BOOST_AUTO_TEST_SUITE_END()