From f760c939d45c9e59fc10db8db220d30ecc65adf0 Mon Sep 17 00:00:00 2001 From: Colm Donelan Date: Mon, 25 Mar 2024 17:54:04 +0000 Subject: MLCE-1245 Fixing runtime memory handling in delegate and ArmNN executor. Neither the armnn_delegate nor the ArmNNExecutor unloaded their network before being destructed. This was leaking significant memory. Signed-off-by: Colm Donelan Change-Id: I61db2e6cbbff4ec4771e86ac71eab90c02389c9e --- tests/ExecuteNetwork/ArmNNExecutor.cpp | 7 ++++++- tests/ExecuteNetwork/ArmNNExecutor.hpp | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/ExecuteNetwork/ArmNNExecutor.cpp b/tests/ExecuteNetwork/ArmNNExecutor.cpp index 58655c1814..121d3fab15 100644 --- a/tests/ExecuteNetwork/ArmNNExecutor.cpp +++ b/tests/ExecuteNetwork/ArmNNExecutor.cpp @@ -1,5 +1,5 @@ // -// Copyright © 2022-2023 Arm Ltd and Contributors. All rights reserved. +// Copyright © 2022-2024 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // @@ -89,6 +89,11 @@ ArmNNExecutor::ArmNNExecutor(const ExecuteNetworkParams& params, armnn::IRuntime } } +ArmNNExecutor::~ArmNNExecutor() +{ + m_Runtime->UnloadNetwork(m_NetworkId); +} + void ArmNNExecutor::ExecuteAsync() { #if !defined(ARMNN_DISABLE_THREADS) diff --git a/tests/ExecuteNetwork/ArmNNExecutor.hpp b/tests/ExecuteNetwork/ArmNNExecutor.hpp index b0b29deffd..cbc8607137 100644 --- a/tests/ExecuteNetwork/ArmNNExecutor.hpp +++ b/tests/ExecuteNetwork/ArmNNExecutor.hpp @@ -38,13 +38,18 @@ class ArmNNExecutor : public IExecutor { public: ArmNNExecutor(const ExecuteNetworkParams& params, armnn::IRuntime::CreationOptions runtimeOptions); + ~ArmNNExecutor(); + ArmNNExecutor(const ArmNNExecutor&) = delete; // No copy constructor. + ArmNNExecutor & operator=(const ArmNNExecutor&) = delete; // No Copy operator. std::vector Execute() override; void PrintNetworkInfo() override; void CompareAndPrintResult(std::vector otherOutput) override; private: - + ArmNNExecutor(ArmNNExecutor&&); // No move constructor. + ArmNNExecutor& operator=(ArmNNExecutor&&); // No move operator. + /** * Returns a pointer to the armnn::IRuntime* this will be shared by all ArmNNExecutors. */ -- cgit v1.2.1