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 --- delegate/classic/src/armnn_delegate.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'delegate') diff --git a/delegate/classic/src/armnn_delegate.cpp b/delegate/classic/src/armnn_delegate.cpp index 52621ee6c1..ed63215a48 100644 --- a/delegate/classic/src/armnn_delegate.cpp +++ b/delegate/classic/src/armnn_delegate.cpp @@ -95,12 +95,12 @@ TfLiteStatus DoPrepare(TfLiteContext* tfLiteContext, TfLiteDelegate* tfLiteDeleg tfLiteContext, parameters, static_cast<::armnnDelegate::Delegate*>(parameters->delegate->data_))); }, // ArmnnSubgraph Free - .free = [](TfLiteContext* tfLiteContext, void* buffer) -> void { - armnn::IgnoreUnused(tfLiteContext); + .free = [](TfLiteContext*, void* buffer) -> void { if (buffer != nullptr) { delete static_cast(buffer); } + }, // ArmnnSubgraph Prepare .prepare = [](TfLiteContext* tfLiteContext, TfLiteNode* tfLiteNode) -> TfLiteStatus { @@ -276,6 +276,8 @@ const std::string Delegate::GetVersion() ArmnnSubgraph::~ArmnnSubgraph() { + // We're finished with the network. + m_Runtime->UnloadNetwork(m_NetworkId); // The delegate holds its own Arm NN runtime so this is our last chance to print internal profiling data. std::shared_ptr profiler = m_Runtime->GetProfiler(m_NetworkId); if (profiler && profiler->IsProfilingEnabled()) -- cgit v1.2.1