From 2048b68cf7caf14e03ceaf84d841bda7bbda8c75 Mon Sep 17 00:00:00 2001 From: Colm Donelan Date: Tue, 15 Feb 2022 14:59:08 +0000 Subject: IVGCVSW-6783 Re-ordering DumpJsonProfilingIfRequired in ArmnnPreparedModel * In the destructor of ArmnnPreparedModel, DumpJsonProfilingIfRequired was being called with a potentially null profiler. Signed-off-by: Colm Donelan Change-Id: Id0d3a2403878fedc4e05dc498edb48d574232c71 --- ArmnnPreparedModel.cpp | 9 ++++++--- ArmnnPreparedModel_1_2.cpp | 9 ++++++--- ArmnnPreparedModel_1_3.cpp | 9 ++++++--- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/ArmnnPreparedModel.cpp b/ArmnnPreparedModel.cpp index 563abd44..38f1bc20 100644 --- a/ArmnnPreparedModel.cpp +++ b/ArmnnPreparedModel.cpp @@ -154,6 +154,12 @@ ArmnnPreparedModel::~ArmnnPreparedModel() { // Get a hold of the profiler used by this model. std::shared_ptr profiler = m_Runtime->GetProfiler(m_NetworkId); + if (profiler && m_GpuProfilingEnabled) + { + // Dump the profiling info to a file if required. + DumpJsonProfilingIfRequired(m_GpuProfilingEnabled, m_RequestInputsAndOutputsDumpDir, m_NetworkId, + profiler.get()); + } // Unload the network associated with this model. m_Runtime->UnloadNetwork(m_NetworkId); @@ -163,9 +169,6 @@ ArmnnPreparedModel::~ArmnnPreparedModel() { m_Threadpool->UnloadMemHandles(m_NetworkId); } - - // Dump the profiling info to a file if required. - DumpJsonProfilingIfRequired(m_GpuProfilingEnabled, m_RequestInputsAndOutputsDumpDir, m_NetworkId, profiler.get()); } template diff --git a/ArmnnPreparedModel_1_2.cpp b/ArmnnPreparedModel_1_2.cpp index 29055a70..7f35e60f 100644 --- a/ArmnnPreparedModel_1_2.cpp +++ b/ArmnnPreparedModel_1_2.cpp @@ -230,6 +230,12 @@ ArmnnPreparedModel_1_2::~ArmnnPreparedModel_1_2() { // Get a hold of the profiler used by this model. std::shared_ptr profiler = m_Runtime->GetProfiler(m_NetworkId); + if (profiler && m_GpuProfilingEnabled) + { + // Dump the profiling info to a file if required. + DumpJsonProfilingIfRequired(m_GpuProfilingEnabled, m_RequestInputsAndOutputsDumpDir, m_NetworkId, + profiler.get()); + } // Unload the network associated with this model. m_Runtime->UnloadNetwork(m_NetworkId); @@ -239,9 +245,6 @@ ArmnnPreparedModel_1_2::~ArmnnPreparedModel_1_2() { m_Threadpool->UnloadMemHandles(m_NetworkId); } - - // Dump the profiling info to a file if required. - DumpJsonProfilingIfRequired(m_GpuProfilingEnabled, m_RequestInputsAndOutputsDumpDir, m_NetworkId, profiler.get()); } template diff --git a/ArmnnPreparedModel_1_3.cpp b/ArmnnPreparedModel_1_3.cpp index abd135e8..36575b86 100644 --- a/ArmnnPreparedModel_1_3.cpp +++ b/ArmnnPreparedModel_1_3.cpp @@ -254,6 +254,12 @@ ArmnnPreparedModel_1_3::~ArmnnPreparedModel_1_3() { // Get a hold of the profiler used by this model. std::shared_ptr profiler = m_Runtime->GetProfiler(m_NetworkId); + if (profiler && m_GpuProfilingEnabled) + { + // Dump the profiling info to a file if required. + DumpJsonProfilingIfRequired(m_GpuProfilingEnabled, m_RequestInputsAndOutputsDumpDir, m_NetworkId, + profiler.get()); + } // Unload the network associated with this model. m_Runtime->UnloadNetwork(m_NetworkId); @@ -263,9 +269,6 @@ ArmnnPreparedModel_1_3::~ArmnnPreparedModel_1_3() { m_Threadpool->UnloadMemHandles(m_NetworkId); } - - // Dump the profiling info to a file if required. - DumpJsonProfilingIfRequired(m_GpuProfilingEnabled, m_RequestInputsAndOutputsDumpDir, m_NetworkId, profiler.get()); } template -- cgit v1.2.1