diff options
author | Derek Lamberti <derek.lamberti@arm.com> | 2019-11-26 16:38:31 +0000 |
---|---|---|
committer | Derek Lamberti <derek.lamberti@arm.com> | 2019-12-05 15:35:51 +0000 |
commit | 08446976e3b6ce0e02f22b391b37aacaad181e1a (patch) | |
tree | b57106c6a3e28662adb2592ac3e850a8f19b6ec7 /src/armnnUtils | |
parent | a3b31f010004ed397ec04325edf7020984847f21 (diff) | |
download | armnn-08446976e3b6ce0e02f22b391b37aacaad181e1a.tar.gz |
Replace boost logging with simple logger
!referencetests:214319
* Reduces arm nn binary size ~15%
* Also fixed test logging black hole issues
Change-Id: Iba27db304d9a8088fa46aeb0b52225d93bb56bc8
Signed-off-by: Derek Lamberti <derek.lamberti@arm.com>
Diffstat (limited to 'src/armnnUtils')
-rw-r--r-- | src/armnnUtils/Logging.cpp | 99 | ||||
-rw-r--r-- | src/armnnUtils/Logging.hpp | 21 | ||||
-rw-r--r-- | src/armnnUtils/ModelAccuracyChecker.cpp | 8 |
3 files changed, 5 insertions, 123 deletions
diff --git a/src/armnnUtils/Logging.cpp b/src/armnnUtils/Logging.cpp deleted file mode 100644 index 10f32dcbef..0000000000 --- a/src/armnnUtils/Logging.cpp +++ /dev/null @@ -1,99 +0,0 @@ -// -// Copyright © 2017 Arm Ltd. All rights reserved. -// SPDX-License-Identifier: MIT -// -#include "Logging.hpp" - -#include <string> -#include <iostream> - -#if defined(_MSC_VER) -#include <Windows.h> -#endif - -#if defined(__ANDROID__) -#include <android/log.h> -#endif - -#include <boost/make_shared.hpp> -#include <boost/log/core.hpp> -#include <boost/log/sinks.hpp> -#include <boost/log/sinks/debug_output_backend.hpp> -#include <boost/log/sinks/basic_sink_backend.hpp> -#include <boost/log/sinks/text_ostream_backend.hpp> -#include <boost/log/utility/setup/console.hpp> - -namespace armnnUtils -{ - -struct DebugOutputSink : boost::log::sinks::basic_formatted_sink_backend<char, boost::log::sinks::concurrent_feeding> -{ - void consume(boost::log::record_view const& rec, std::string const& formatted_message) - { -#if defined(_MSC_VER) - OutputDebugString(formatted_message.c_str()); - OutputDebugString("\n"); -#endif -#if defined(__ANDROID__) - __android_log_write(ANDROID_LOG_DEBUG, "armnn", formatted_message.c_str()); -#endif - } -}; - -void ConfigureLogging(boost::log::core* core, bool printToStandardOutput, bool printToDebugOutput, - armnn::LogSeverity severity) -{ - // Even if we remove all the sinks, Boost will fallback to the 'default sink' and still print stuff to - // stdout, so we have to explicitly disable logging in this case. - core->set_logging_enabled(printToStandardOutput || printToDebugOutput); - - // Sets up severity filter. - boost::log::trivial::severity_level boostSeverity; - switch (severity) - { - case armnn::LogSeverity::Trace: - boostSeverity = boost::log::trivial::trace; - break; - case armnn::LogSeverity::Debug: - boostSeverity = boost::log::trivial::debug; - break; - case armnn::LogSeverity::Info: - boostSeverity = boost::log::trivial::info; - break; - case armnn::LogSeverity::Warning: - boostSeverity = boost::log::trivial::warning; - break; - case armnn::LogSeverity::Error: - boostSeverity = boost::log::trivial::error; - break; - case armnn::LogSeverity::Fatal: - boostSeverity = boost::log::trivial::fatal; - break; - default: - BOOST_ASSERT_MSG(false, "Invalid severity"); - } - core->set_filter(boost::log::trivial::severity >= boostSeverity); - - core->remove_all_sinks(); - if (printToStandardOutput) - { - typedef boost::log::sinks::basic_text_ostream_backend<char> backend_t; - boost::shared_ptr<backend_t> backend = boost::make_shared<backend_t>(); - - boost::shared_ptr<std::basic_ostream<char>> stream(&std::cout, boost::null_deleter()); - backend->add_stream(stream); - - typedef boost::log::sinks::synchronous_sink<backend_t> sink_t; - boost::shared_ptr<sink_t> standardOutputSink = boost::make_shared<sink_t>(backend); - - core->add_sink(standardOutputSink); - } - if (printToDebugOutput) - { - typedef boost::log::sinks::synchronous_sink<DebugOutputSink> sink_t; - boost::shared_ptr<sink_t> debugOutputSink(new sink_t()); - core->add_sink(debugOutputSink); - } -} - -} diff --git a/src/armnnUtils/Logging.hpp b/src/armnnUtils/Logging.hpp deleted file mode 100644 index db60d389f6..0000000000 --- a/src/armnnUtils/Logging.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// -// Copyright © 2017 Arm Ltd. All rights reserved. -// SPDX-License-Identifier: MIT -// -#pragma once - - -#include "armnn/Utils.hpp" - -#include <boost/log/trivial.hpp> - -namespace armnnUtils -{ - -// Configures logging for the given Boost Log Core object. -void ConfigureLogging(boost::log::core* core, - bool printToStandardOutput, - bool printToDebugOutput, - armnn::LogSeverity severity); - -}
\ No newline at end of file diff --git a/src/armnnUtils/ModelAccuracyChecker.cpp b/src/armnnUtils/ModelAccuracyChecker.cpp index 81942dc2be..818cb17a65 100644 --- a/src/armnnUtils/ModelAccuracyChecker.cpp +++ b/src/armnnUtils/ModelAccuracyChecker.cpp @@ -4,8 +4,10 @@ // #include "ModelAccuracyChecker.hpp" + +#include <armnn/Logging.hpp> + #include <boost/filesystem.hpp> -#include <boost/log/trivial.hpp> #include <map> #include <vector> @@ -22,8 +24,8 @@ float ModelAccuracyChecker::GetAccuracy(unsigned int k) { if (k > 10) { - BOOST_LOG_TRIVIAL(warning) << "Accuracy Tool only supports a maximum of Top 10 Accuracy. " - "Printing Top 10 Accuracy result!"; + ARMNN_LOG(warning) << "Accuracy Tool only supports a maximum of Top 10 Accuracy. " + "Printing Top 10 Accuracy result!"; k = 10; } unsigned int total = 0; |