From 9326aabf60f6ea4e62fe5913a20da887805c334b Mon Sep 17 00:00:00 2001 From: Matteo Martincigh Date: Thu, 15 Nov 2018 10:54:54 +0000 Subject: Adedd load/unload warm-up before the memory lek test to put the runtime into a stable test (memory-wise) This prevents false-positives when running the tests on Master Change-Id: I4348378f3689cb3ec98686a93315d2b88bb7bcc7 --- src/armnn/test/RuntimeTests.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/armnn/test/RuntimeTests.cpp b/src/armnn/test/RuntimeTests.cpp index 08e3190414..998808c508 100644 --- a/src/armnn/test/RuntimeTests.cpp +++ b/src/armnn/test/RuntimeTests.cpp @@ -126,27 +126,27 @@ BOOST_AUTO_TEST_CASE(RuntimeMemoryLeak) armnn::Runtime runtime(options); armnn::RuntimeLoadedNetworksReserve(&runtime); - // Checks for leaks before we load the network and record them so that we can see the delta after unloading. - VALGRIND_DO_QUICK_LEAK_CHECK; - VALGRIND_COUNT_LEAKS(leakedBefore, dubious, reachableBefore, suppressed); - - // Builds a mock-network and load it into the runtime. { - unsigned int inputShape[] = {1, 7, 1, 1}; - armnn::TensorInfo inputTensorInfo(4, inputShape, armnn::DataType::Float32); + std::vector backends = {armnn::Compute::CpuRef}; std::unique_ptr mockNetwork1 = std::make_unique(); mockNetwork1->AddInputLayer(0, "test layer"); - - std::vector backends = {armnn::Compute::CpuRef}; + // Warm-up load/unload pair to put the runtime in a stable state (memory-wise). runtime.LoadNetwork(networkIdentifier1, Optimize(*mockNetwork1, backends, runtime.GetDeviceSpec())); - } + runtime.UnloadNetwork(networkIdentifier1); + + // Checks for leaks before we load the network and record them so that we can see the delta after unloading. + VALGRIND_DO_QUICK_LEAK_CHECK; + VALGRIND_COUNT_LEAKS(leakedBefore, dubious, reachableBefore, suppressed); - runtime.UnloadNetwork(networkIdentifier1); + // The actual test. + runtime.LoadNetwork(networkIdentifier1, Optimize(*mockNetwork1, backends, runtime.GetDeviceSpec())); + runtime.UnloadNetwork(networkIdentifier1); - VALGRIND_DO_ADDED_LEAK_CHECK; - VALGRIND_COUNT_LEAKS(leakedAfter, dubious, reachableAfter, suppressed); + VALGRIND_DO_ADDED_LEAK_CHECK; + VALGRIND_COUNT_LEAKS(leakedAfter, dubious, reachableAfter, suppressed); + } // If we're not running under Valgrind, these vars will have been initialised to 0, so this will always pass. BOOST_TEST(leakedBefore == leakedAfter); -- cgit v1.2.1