From 7c75e336fbeeec052a1cb90c68d1caece332c176 Mon Sep 17 00:00:00 2001 From: Declan-ARM Date: Tue, 12 Mar 2024 16:40:25 +0000 Subject: IVGCVSW-7853 Assert audit and removal * src/armnn * src/armnn/layers Signed-off-by: Declan-ARM Change-Id: Ic78cbbb59e90fbb15f893205a358c45264243721 --- src/armnn/Profiling.cpp | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'src/armnn/Profiling.cpp') diff --git a/src/armnn/Profiling.cpp b/src/armnn/Profiling.cpp index db2962ecad..78afb05611 100644 --- a/src/armnn/Profiling.cpp +++ b/src/armnn/Profiling.cpp @@ -1,5 +1,5 @@ // -// Copyright © 2017 Arm Ltd. All rights reserved. +// Copyright © 2017,2024 Arm Ltd. All rights reserved. // SPDX-License-Identifier: MIT // #include "Profiling.hpp" @@ -43,7 +43,7 @@ constexpr bool g_WriteReportToStdOutOnProfilerDestruction = false; Measurement FindMeasurement(const std::string& name, const Event* event) { - ARMNN_ASSERT(event != nullptr); + ARMNN_THROW_INVALIDARG_MSG_IF_FALSE(event, "event should not be null."); // Search though the measurements. for (const auto& measurement : event->GetMeasurements()) @@ -61,7 +61,7 @@ Measurement FindMeasurement(const std::string& name, const Event* event) std::vector FindKernelMeasurements(const Event* event) { - ARMNN_ASSERT(event != nullptr); + ARMNN_THROW_INVALIDARG_MSG_IF_FALSE(event, "event should not be null."); std::vector measurements; @@ -230,13 +230,24 @@ void ProfilerImpl::EndEvent(Event* event) { event->Stop(); - ARMNN_ASSERT(!m_Parents.empty()); - ARMNN_ASSERT(event == m_Parents.top()); + if (!!m_Parents.empty()) + { + throw armnn::Exception("m_Parents must not be empty."); + } + + if (event != m_Parents.top()) + { + throw armnn::Exception("event must match the top of m_Parents."); + } + m_Parents.pop(); Event* parent = m_Parents.empty() ? nullptr : m_Parents.top(); - IgnoreUnused(parent); - ARMNN_ASSERT(event->GetParentEvent() == parent); + + if (event->GetParentEvent() != parent) + { + throw armnn::Exception("parent events must match."); + } #if ARMNN_STREAMLINE_ENABLED ANNOTATE_CHANNEL_END(uint32_t(m_Parents.size())); @@ -305,7 +316,7 @@ void ExtractJsonObjects(unsigned int inferenceIndex, JsonChildObject& parentObject, std::map> descendantsMap) { - ARMNN_ASSERT(parentEvent); + ARMNN_THROW_INVALIDARG_MSG_IF_FALSE(parentEvent, "parentEvent must not be null."); // If profiling GUID is entered, process it if (parentEvent->GetProfilingGuid().has_value()) @@ -339,7 +350,10 @@ void ExtractJsonObjects(unsigned int inferenceIndex, measurementObject.SetUnit(instrumentMeasurements[measurementIndex].m_Unit); measurementObject.SetType(JsonObjectType::Measurement); - ARMNN_ASSERT(parentObject.NumChildren() == childIdx); + if (parentObject.NumChildren() != childIdx) + { + throw armnn::Exception("parentObject must have the same number of children as childIdx."); + } parentObject.AddChild(measurementObject); } else -- cgit v1.2.1