IVGCVSW-1946: Remove armnn/src from the include paths
[platform/upstream/armnn.git] / src / backends / neon / test / NeonRuntimeTests.cpp
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
12 #include <boost/test/unit_test.hpp>
13
14 BOOST_AUTO_TEST_SUITE(NeonRuntime)
15
16 BOOST_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
40 BOOST_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
68 BOOST_AUTO_TEST_SUITE_END()