From 4a0844db1ba4889153071c4023071f23860de817 Mon Sep 17 00:00:00 2001 From: Sadik Armagan Date: Wed, 26 Jan 2022 09:57:05 +0000 Subject: IVGCVSW-6739 'Issues on Logging API' * Enabled using same instance of SimpleLogger * Removed some trailing new lines on some log messages Signed-off-by: Sadik Armagan Change-Id: I4b917c0ca5011afc9b39dad50715290ba15a1246 --- include/armnn/Logging.hpp | 6 +----- src/armnn/Logging.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++++++- src/armnn/Runtime.cpp | 28 +++++++++++++------------- tests/InferenceModel.hpp | 6 +++--- 4 files changed, 67 insertions(+), 23 deletions(-) diff --git a/include/armnn/Logging.hpp b/include/armnn/Logging.hpp index d18072a22d..6336e96d8c 100644 --- a/include/armnn/Logging.hpp +++ b/include/armnn/Logging.hpp @@ -156,11 +156,7 @@ public: { } - static SimpleLogger& Get() - { - static SimpleLogger logger; - return logger; - } + static SimpleLogger& Get(); void Enable(bool enable = true) { diff --git a/src/armnn/Logging.cpp b/src/armnn/Logging.cpp index 0cdcdc58ea..73879e644d 100644 --- a/src/armnn/Logging.cpp +++ b/src/armnn/Logging.cpp @@ -21,6 +21,55 @@ namespace armnn { +template +SimpleLogger& SimpleLogger::Get() +{ + static SimpleLogger logger; + return logger; +} + +template<> +SimpleLogger& SimpleLogger::Get() +{ + static SimpleLogger logger; + return logger; +} + +template<> +SimpleLogger& SimpleLogger::Get() +{ + static SimpleLogger logger; + return logger; +} + +template<> +SimpleLogger& SimpleLogger::Get() +{ + static SimpleLogger logger; + return logger; +} + +template<> +SimpleLogger& SimpleLogger::Get() +{ + static SimpleLogger logger; + return logger; +} + +template<> +SimpleLogger& SimpleLogger::Get() +{ + static SimpleLogger logger; + return logger; +} + +template<> +SimpleLogger& SimpleLogger::Get() +{ + static SimpleLogger logger; + return logger; +} + void SetLogFilter(LogSeverity level) { SimpleLogger::Get().Enable(false); @@ -149,5 +198,4 @@ void SetAllLoggingSinks(bool standardOut, bool debugOut, bool coloured) SetLoggingSinks(standardOut, debugOut, coloured); } - } //namespace armnn diff --git a/src/armnn/Runtime.cpp b/src/armnn/Runtime.cpp index 1ccfb4687a..2752e7209c 100644 --- a/src/armnn/Runtime.cpp +++ b/src/armnn/Runtime.cpp @@ -293,7 +293,7 @@ RuntimeImpl::RuntimeImpl(const IRuntime::CreationOptions& options) m_ProfilingService(*this) { const auto start_time = armnn::GetTimeNow(); - ARMNN_LOG(info) << "ArmNN v" << ARMNN_VERSION << "\n"; + ARMNN_LOG(info) << "ArmNN v" << ARMNN_VERSION; if ( options.m_ProfilingOptions.m_TimelineEnabled && !options.m_ProfilingOptions.m_EnableProfiling ) { throw RuntimeException( @@ -337,7 +337,7 @@ RuntimeImpl::RuntimeImpl(const IRuntime::CreationOptions& options) // backend should not be registered ARMNN_LOG(warning) << "Backend " << id - << " is not registered as does not support protected content allocation \n"; + << " is not registered as does not support protected content allocation."; continue; } // The user is responsible to provide a custom memory allocator which allows to allocate @@ -431,7 +431,7 @@ RuntimeImpl::RuntimeImpl(const IRuntime::CreationOptions& options) if (!strategy) { ARMNN_LOG(warning) << "MemoryOptimizerStrategy: " << memoryOptimizerStrategyName - << " was not found \n"; + << " was not found."; } else { @@ -450,7 +450,7 @@ RuntimeImpl::RuntimeImpl(const IRuntime::CreationOptions& options) ARMNN_LOG(warning) << "Backend " << id << " does not have multi-axis packing capability and cannot support" - << "MemoryOptimizerStrategy: " << memoryOptimizerStrategyName << "\n"; + << "MemoryOptimizerStrategy: " << memoryOptimizerStrategyName << "."; } } } @@ -497,7 +497,7 @@ RuntimeImpl::RuntimeImpl(const IRuntime::CreationOptions& options) m_DeviceSpec.AddSupportedBackends(supportedBackends); ARMNN_LOG(info) << "Initialization time: " << std::setprecision(2) - << std::fixed << armnn::GetTimeDuration(start_time).count() << " ms\n"; + << std::fixed << armnn::GetTimeDuration(start_time).count() << " ms."; } RuntimeImpl::~RuntimeImpl() @@ -547,7 +547,7 @@ RuntimeImpl::~RuntimeImpl() BackendRegistryInstance().SetProfilingService(armnn::EmptyOptional()); ARMNN_LOG(info) << "Shutdown time: " << std::setprecision(2) - << std::fixed << armnn::GetTimeDuration(startTime).count() << " ms\n"; + << std::fixed << armnn::GetTimeDuration(startTime).count() << " ms."; } LoadedNetwork* RuntimeImpl::GetLoadedNetworkPtr(NetworkId networkId) const @@ -595,12 +595,12 @@ Status RuntimeImpl::EnqueueWorkload(NetworkId networkId, if (!loadedNetwork) { - ARMNN_LOG(error) << "A Network with an id of " << networkId << " does not exist.\n"; + ARMNN_LOG(error) << "A Network with an id of " << networkId << " does not exist."; return Status::Failure; } if (loadedNetwork->IsAsyncEnabled()) { - ARMNN_LOG(error) << "Network " << networkId << " is async enabled.\n"; + ARMNN_LOG(error) << "Network " << networkId << " is async enabled."; return Status::Failure; } ProfilerManager::GetInstance().RegisterProfiler(loadedNetwork->GetProfiler().get()); @@ -620,7 +620,7 @@ Status RuntimeImpl::EnqueueWorkload(NetworkId networkId, auto status = loadedNetwork->EnqueueWorkload(inputTensors, outputTensors); ARMNN_LOG(info) << "Execution time: " << std::setprecision(2) - << std::fixed << armnn::GetTimeDuration(startTime).count() << " ms\n"; + << std::fixed << armnn::GetTimeDuration(startTime).count() << " ms."; return status; } @@ -638,12 +638,12 @@ Status RuntimeImpl::Execute(IWorkingMemHandle& iWorkingMemHandle, if (!loadedNetwork) { - ARMNN_LOG(error) << "A Network with an id of " << networkId << " does not exist.\n"; + ARMNN_LOG(error) << "A Network with an id of " << networkId << " does not exist."; return Status::Failure; } if (!loadedNetwork->IsAsyncEnabled()) { - ARMNN_LOG(error) << "Attempting execute " << networkId << " when it is not async enabled.\n"; + ARMNN_LOG(error) << "Attempting execute " << networkId << " when it is not async enabled."; return Status::Failure; } ProfilerManager::GetInstance().RegisterProfiler(loadedNetwork->GetProfiler().get()); @@ -657,7 +657,7 @@ Status RuntimeImpl::Execute(IWorkingMemHandle& iWorkingMemHandle, preImportedOutputs); ARMNN_LOG(info) << "Execution time: " << std::setprecision(2) - << std::fixed << armnn::GetTimeDuration(startTime).count() << " ms\n"; + << std::fixed << armnn::GetTimeDuration(startTime).count() << " ms."; return status; } @@ -670,12 +670,12 @@ std::unique_ptr RuntimeImpl::CreateWorkingMemHandle(NetworkId if (!loadedNetwork) { - ARMNN_LOG(error) << "A Network with an id of " << networkId << " does not exist.\n"; + ARMNN_LOG(error) << "A Network with an id of " << networkId << " does not exist."; return nullptr; } if (!loadedNetwork->IsAsyncEnabled()) { - ARMNN_LOG(error) << "Network " << networkId << " is not async enabled.\n"; + ARMNN_LOG(error) << "Network " << networkId << " is not async enabled."; return nullptr; } ProfilerManager::GetInstance().RegisterProfiler(loadedNetwork->GetProfiler().get()); diff --git a/tests/InferenceModel.hpp b/tests/InferenceModel.hpp index 13f7d74e8d..bddaf557fd 100644 --- a/tests/InferenceModel.hpp +++ b/tests/InferenceModel.hpp @@ -471,7 +471,7 @@ public: armnn::INetworkPtr network = CreateNetworkImpl::Create(params, m_InputBindings, m_OutputBindings); ARMNN_LOG(info) << "Network parsing time: " << std::setprecision(2) - << std::fixed << armnn::GetTimeDuration(parsing_start_time).count() << " ms\n"; + << std::fixed << armnn::GetTimeDuration(parsing_start_time).count() << " ms."; ARMNN_SCOPED_HEAP_PROFILING("Optimizing"); @@ -503,7 +503,7 @@ public: optNet = armnn::Optimize(*network, params.m_ComputeDevices, m_Runtime->GetDeviceSpec(), options); ARMNN_LOG(info) << "Optimization time: " << std::setprecision(2) - << std::fixed << armnn::GetTimeDuration(optimization_start_time).count() << " ms\n"; + << std::fixed << armnn::GetTimeDuration(optimization_start_time).count() << " ms."; if (!optNet) { @@ -535,7 +535,7 @@ public: ret = m_Runtime->LoadNetwork(m_NetworkIdentifier, std::move(optNet), errorMessage, networkProperties); ARMNN_LOG(info) << "Network loading time: " << std::setprecision(2) - << std::fixed << armnn::GetTimeDuration(loading_start_time).count() << " ms\n"; + << std::fixed << armnn::GetTimeDuration(loading_start_time).count() << " ms."; if (params.m_AsyncEnabled && params.m_ThreadPoolSize > 0) { -- cgit v1.2.1