diff options
Diffstat (limited to 'src')
30 files changed, 151 insertions, 234 deletions
diff --git a/src/armnn/Descriptors.cpp b/src/armnn/Descriptors.cpp index 381d040683..95f9b5dd2b 100644 --- a/src/armnn/Descriptors.cpp +++ b/src/armnn/Descriptors.cpp @@ -3,13 +3,13 @@ // SPDX-License-Identifier: MIT // #include "armnn/Descriptors.hpp" +#include "armnn/Logging.hpp" #include <algorithm> #include <array> #include <vector> #include <boost/format.hpp> -#include <boost/log/trivial.hpp> #include <boost/numeric/conversion/cast.hpp> namespace armnn @@ -160,13 +160,13 @@ Status OriginsDescriptor::SetViewOriginCoord(uint32_t view, uint32_t coord, uint { if (view >= m_NumViews) { - BOOST_LOG_TRIVIAL(error) << "OriginsDescriptor::SetViewOriginCoord: view argument:" << view << + ARMNN_LOG(error) << "OriginsDescriptor::SetViewOriginCoord: view argument:" << view << " is out of range"; return Status::Failure; } if (coord >= m_NumDimensions) { - BOOST_LOG_TRIVIAL(error) << "OriginsDescriptor::SetViewOriginCoord: coord argument:" << coord << + ARMNN_LOG(error) << "OriginsDescriptor::SetViewOriginCoord: coord argument:" << coord << " is out of range"; return Status::Failure; } @@ -308,19 +308,19 @@ Status ViewsDescriptor::SetViewSize(uint32_t view, uint32_t coord, uint32_t valu { if (!m_ViewSizes) { - BOOST_LOG_TRIVIAL(error) << "ViewsDescriptor::SetViewSize: invalid view sizes"; + ARMNN_LOG(error) << "ViewsDescriptor::SetViewSize: invalid view sizes"; return Status::Failure; } if (view >= GetNumViews()) { - BOOST_LOG_TRIVIAL(error) << "ViewsDescriptor::SetViewSize: view argument:" << view << + ARMNN_LOG(error) << "ViewsDescriptor::SetViewSize: view argument:" << view << " is out of range"; return Status::Failure; } if (coord >= GetNumDimensions()) { - BOOST_LOG_TRIVIAL(error) << "ViewsDescriptor::SetViewSize: coord argument:" << coord << + ARMNN_LOG(error) << "ViewsDescriptor::SetViewSize: coord argument:" << coord << " is out of range"; return Status::Failure; } diff --git a/src/armnn/Graph.cpp b/src/armnn/Graph.cpp index 4e02be3531..fe6a7c8afa 100644 --- a/src/armnn/Graph.cpp +++ b/src/armnn/Graph.cpp @@ -14,7 +14,6 @@ #include <armnn/TypesUtils.hpp> #include <boost/polymorphic_cast.hpp> -#include <boost/log/trivial.hpp> #include <boost/assert.hpp> #include <boost/format.hpp> @@ -62,18 +61,18 @@ Status Graph::Print() const { if (m_Layers.empty()) { - BOOST_LOG_TRIVIAL(info) << "\n Graph is empty.\n"; + ARMNN_LOG(info) << "\n Graph is empty.\n"; return Status::Success; } - BOOST_LOG_TRIVIAL(info) << "\n"; - BOOST_LOG_TRIVIAL(info) << "Walking Pattern: \n"; + ARMNN_LOG(info) << "\n"; + ARMNN_LOG(info) << "Walking Pattern: \n"; for (auto&& it : TopologicalSort()) { - BOOST_LOG_TRIVIAL(info) << it->GetName() << ":" << GetLayerTypeAsCString(it->GetType()) + ARMNN_LOG(info) << it->GetName() << ":" << GetLayerTypeAsCString(it->GetType()) << ":" << it->GetBackendId().Get(); } - BOOST_LOG_TRIVIAL(info) << "\n\n"; + ARMNN_LOG(info) << "\n\n"; return Status::Success; } diff --git a/src/armnn/Layer.cpp b/src/armnn/Layer.cpp index 1efe7e412f..8350ea83c1 100644 --- a/src/armnn/Layer.cpp +++ b/src/armnn/Layer.cpp @@ -11,7 +11,6 @@ #include <boost/cast.hpp> #include <boost/format.hpp> -#include <boost/log/trivial.hpp> #include <numeric> diff --git a/src/armnn/LoadedNetwork.cpp b/src/armnn/LoadedNetwork.cpp index 16ec42308c..86cd9ede23 100644 --- a/src/armnn/LoadedNetwork.cpp +++ b/src/armnn/LoadedNetwork.cpp @@ -23,7 +23,6 @@ #include <boost/polymorphic_cast.hpp> #include <boost/assert.hpp> #include <boost/format.hpp> -#include <boost/log/trivial.hpp> namespace armnn { @@ -90,7 +89,7 @@ std::unique_ptr<LoadedNetwork> LoadedNetwork::MakeLoadedNetwork(std::unique_ptr< auto Fail = [&](const std::exception& error) -> std::unique_ptr<LoadedNetwork> { errorMessage = ToErrorMessage("An error occurred when preparing the network workloads: ", error); - BOOST_LOG_TRIVIAL(error) << errorMessage; + ARMNN_LOG(error) << errorMessage; return std::unique_ptr<LoadedNetwork>(); }; @@ -418,7 +417,7 @@ Status LoadedNetwork::EnqueueWorkload(const InputTensors& inputTensors, // Walk graph to determine the order of execution. if (graph.GetNumLayers() < 2) { - BOOST_LOG_TRIVIAL(warning) << "IRuntime::EnqueueWorkload()::Less than two nodes in graph"; + ARMNN_LOG(warning) << "IRuntime::EnqueueWorkload()::Less than two nodes in graph"; return Status::Failure; } @@ -679,7 +678,7 @@ bool LoadedNetwork::Execute(std::unique_ptr<TimelineUtilityMethods>& timelineUti auto Fail = [&](const std::exception& error) { - BOOST_LOG_TRIVIAL(error) << "An error occurred attempting to execute a workload: " << error.what(); + ARMNN_LOG(error) << "An error occurred attempting to execute a workload: " << error.what(); success = false; }; diff --git a/src/armnn/Network.cpp b/src/armnn/Network.cpp index 53e28c344a..c764e2a059 100644 --- a/src/armnn/Network.cpp +++ b/src/armnn/Network.cpp @@ -33,7 +33,6 @@ #include <boost/assert.hpp> #include <boost/format.hpp> -#include <boost/log/trivial.hpp> #include <boost/numeric/conversion/converter_policies.hpp> #include <boost/cast.hpp> @@ -76,7 +75,7 @@ void ReportError(const std::string& errorMessage, { std::stringstream fullErrorMessage; fullErrorMessage << "ERROR: " << errorMessage; - BOOST_LOG_TRIVIAL(warning) << fullErrorMessage.str(); + ARMNN_LOG(warning) << fullErrorMessage.str(); if (errorMessages) { errorMessages.value().push_back(fullErrorMessage.str()); @@ -88,7 +87,7 @@ void ReportWarning(const std::string& warningMessage, { std::stringstream fullWarningMessage; fullWarningMessage << "WARNING: " << warningMessage; - BOOST_LOG_TRIVIAL(warning) << fullWarningMessage.str(); + ARMNN_LOG(warning) << fullWarningMessage.str(); if (warningMessages) { warningMessages.value().push_back(fullWarningMessage.str()); @@ -120,7 +119,7 @@ bool CheckScaleSetOnQuantizedType(Layer* layer, Optional<std::vector<std::string ss << "Quantization parameters for Softmax layer (Scale: " << info.GetQuantizationScale() << " and Offset: " << info.GetQuantizationOffset() << ") are incorrect and have been updated to Scale: 0.00390625 and Offset: 0"; - BOOST_LOG_TRIVIAL(warning) << ss.str(); + ARMNN_LOG(warning) << ss.str(); info.SetQuantizationScale((1.0f /256.0f)); info.SetQuantizationOffset(0); outputSlot.SetTensorInfo(info); diff --git a/src/armnn/Runtime.cpp b/src/armnn/Runtime.cpp index 4dd5a22320..192817e69d 100644 --- a/src/armnn/Runtime.cpp +++ b/src/armnn/Runtime.cpp @@ -14,7 +14,6 @@ #include <iostream> -#include <boost/log/trivial.hpp> #include <boost/polymorphic_cast.hpp> using namespace armnn; @@ -106,8 +105,8 @@ Status Runtime::UnloadNetwork(NetworkId networkId) if (!unloadOk) { - BOOST_LOG_TRIVIAL(warning) << "Runtime::UnloadNetwork(): failed to unload " - "network with ID:" << networkId << " because BeforeUnloadNetwork failed"; + ARMNN_LOG(warning) << "Runtime::UnloadNetwork(): failed to unload " + "network with ID:" << networkId << " because BeforeUnloadNetwork failed"; return Status::Failure; } @@ -116,7 +115,7 @@ Status Runtime::UnloadNetwork(NetworkId networkId) if (m_LoadedNetworks.erase(networkId) == 0) { - BOOST_LOG_TRIVIAL(warning) << "WARNING: Runtime::UnloadNetwork(): " << networkId << " not found!"; + ARMNN_LOG(warning) << "WARNING: Runtime::UnloadNetwork(): " << networkId << " not found!"; return Status::Failure; } } @@ -126,7 +125,7 @@ Status Runtime::UnloadNetwork(NetworkId networkId) context.second->AfterUnloadNetwork(networkId); } - BOOST_LOG_TRIVIAL(debug) << "Runtime::UnloadNetwork(): Unloaded network with ID: " << networkId; + ARMNN_LOG(debug) << "Runtime::UnloadNetwork(): Unloaded network with ID: " << networkId; return Status::Success; } @@ -146,7 +145,7 @@ Runtime::Runtime(const CreationOptions& options) : m_NetworkIdCounter(0) , m_DeviceSpec{BackendRegistryInstance().GetBackendIds()} { - BOOST_LOG_TRIVIAL(info) << "ArmNN v" << ARMNN_VERSION << "\n"; + ARMNN_LOG(info) << "ArmNN v" << ARMNN_VERSION << "\n"; // pass configuration info to the profiling service armnn::profiling::ProfilingService::Instance().ConfigureProfilingService(options.m_ProfilingOptions); diff --git a/src/armnn/Tensor.cpp b/src/armnn/Tensor.cpp index dad9722aeb..171e02ad13 100644 --- a/src/armnn/Tensor.cpp +++ b/src/armnn/Tensor.cpp @@ -9,7 +9,6 @@ #include "armnn/TypesUtils.hpp" #include <boost/assert.hpp> -#include <boost/log/trivial.hpp> #include <boost/numeric/conversion/cast.hpp> #include <sstream> diff --git a/src/armnn/Utils.cpp b/src/armnn/Utils.cpp index b59999e848..fbf11c9588 100644 --- a/src/armnn/Utils.cpp +++ b/src/armnn/Utils.cpp @@ -2,17 +2,15 @@ // Copyright © 2017 Arm Ltd. All rights reserved. // SPDX-License-Identifier: MIT // +#include "armnn/Logging.hpp" #include "armnn/Utils.hpp" -#include "Logging.hpp" - -#include <boost/log/core.hpp> namespace armnn { void ConfigureLogging(bool printToStandardOutput, bool printToDebugOutput, LogSeverity severity) { - using armnnUtils::ConfigureLogging; - ConfigureLogging(boost::log::core::get().get(), printToStandardOutput, printToDebugOutput, severity); + SetAllLoggingSinks(printToStandardOutput, printToDebugOutput, false); + SetLogFilter(severity); } // Defaults to logging completely disabled. diff --git a/src/armnn/test/ModelAccuracyCheckerTest.cpp b/src/armnn/test/ModelAccuracyCheckerTest.cpp index e1618512eb..8bbe3d9f41 100644 --- a/src/armnn/test/ModelAccuracyCheckerTest.cpp +++ b/src/armnn/test/ModelAccuracyCheckerTest.cpp @@ -8,7 +8,6 @@ #include <boost/test/unit_test.hpp> #include <boost/filesystem.hpp> -#include <boost/log/core/core.hpp> #include <boost/optional.hpp> #include <boost/variant.hpp> #include <iostream> diff --git a/src/armnn/test/UnitTests.cpp b/src/armnn/test/UnitTests.cpp index c08b705506..7d171a8d88 100644 --- a/src/armnn/test/UnitTests.cpp +++ b/src/armnn/test/UnitTests.cpp @@ -6,6 +6,9 @@ #include <boost/test/unit_test.hpp> #include "UnitTests.hpp" +#include <armnn/Logging.hpp> + +#include <boost/algorithm/string.hpp> struct ConfigureLoggingFixture { @@ -57,4 +60,55 @@ private: BOOST_GLOBAL_FIXTURE(SetupDebugOutput); -#endif // defined(_MSC_VER)
\ No newline at end of file +#endif // defined(_MSC_VER) + + +BOOST_AUTO_TEST_SUITE(LoggerSuite) + +BOOST_AUTO_TEST_CASE(LoggerTest) +{ + std::stringstream ss; + + { + struct StreamRedirector + { + public: + StreamRedirector(std::ostream& stream, std::streambuf* newStreamBuffer) + : m_Stream(stream) + , m_BackupBuffer(m_Stream.rdbuf(newStreamBuffer)) + {} + ~StreamRedirector() { m_Stream.rdbuf(m_BackupBuffer); } + + private: + std::ostream& m_Stream; + std::streambuf* m_BackupBuffer; + }; + + + StreamRedirector redirect(std::cout, ss.rdbuf()); + + using namespace armnn; + SetLogFilter(LogSeverity::Trace); + SetAllLoggingSinks(true, false, false); + + + ARMNN_LOG(trace) << "My trace message; " << -2; + ARMNN_LOG(debug) << "My debug message; " << -1; + ARMNN_LOG(info) << "My info message; " << 0; + ARMNN_LOG(warning) << "My warning message; " << 1; + ARMNN_LOG(error) << "My error message; " << 2; + ARMNN_LOG(fatal) << "My fatal message; " << 3; + + SetLogFilter(LogSeverity::Fatal); + + } + + BOOST_CHECK(boost::contains(ss.str(), "Trace: My trace message; -2")); + BOOST_CHECK(boost::contains(ss.str(), "Debug: My debug message; -1")); + BOOST_CHECK(boost::contains(ss.str(), "Info: My info message; 0")); + BOOST_CHECK(boost::contains(ss.str(), "Warning: My warning message; 1")); + BOOST_CHECK(boost::contains(ss.str(), "Error: My error message; 2")); + BOOST_CHECK(boost::contains(ss.str(), "Fatal: My fatal message; 3")); +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/src/armnn/test/UnitTests.hpp b/src/armnn/test/UnitTests.hpp index dc97f90ba9..60d191f97d 100644 --- a/src/armnn/test/UnitTests.hpp +++ b/src/armnn/test/UnitTests.hpp @@ -4,7 +4,7 @@ // #pragma once -#include <Logging.hpp> +#include <armnn/Logging.hpp> #include <armnn/Utils.hpp> #include <reference/RefWorkloadFactory.hpp> #include <backendsCommon/test/LayerTests.hpp> @@ -16,7 +16,6 @@ inline void ConfigureLoggingTest() { // Configures logging for both the ARMNN library and this test program. armnn::ConfigureLogging(true, true, armnn::LogSeverity::Fatal); - armnnUtils::ConfigureLogging(boost::log::core::get().get(), true, true, armnn::LogSeverity::Fatal); } // The following macros require the caller to have defined FactoryType, with one of the following using statements: diff --git a/src/armnnCaffeParser/CaffeParser.cpp b/src/armnnCaffeParser/CaffeParser.cpp index cf2e140b68..ce5c5bd4f5 100644 --- a/src/armnnCaffeParser/CaffeParser.cpp +++ b/src/armnnCaffeParser/CaffeParser.cpp @@ -16,7 +16,6 @@ #include <boost/numeric/conversion/cast.hpp> #include <boost/assert.hpp> #include <boost/format.hpp> -#include <boost/log/trivial.hpp> // Caffe #include "caffe/proto/caffe.pb.h" diff --git a/src/armnnConverter/ArmnnConverter.cpp b/src/armnnConverter/ArmnnConverter.cpp index 04cbb5dba2..28e94a07c5 100644 --- a/src/armnnConverter/ArmnnConverter.cpp +++ b/src/armnnConverter/ArmnnConverter.cpp @@ -20,7 +20,6 @@ #include <armnnTfLiteParser/ITfLiteParser.hpp> #endif -#include <Logging.hpp> #include <HeapProfiling.hpp> #include <boost/format.hpp> @@ -52,7 +51,7 @@ armnn::TensorShape ParseTensorShape(std::istream& stream) } catch (const std::exception& e) { - BOOST_LOG_TRIVIAL(error) << "An error occurred when splitting tokens: " << e.what(); + ARMNN_LOG(error) << "An error occurred when splitting tokens: " << e.what(); continue; } for (const std::string& token : tokens) @@ -65,7 +64,7 @@ armnn::TensorShape ParseTensorShape(std::istream& stream) } catch (const std::exception&) { - BOOST_LOG_TRIVIAL(error) << "'" << token << "' is not a valid number. It has been ignored."; + ARMNN_LOG(error) << "'" << token << "' is not a valid number. It has been ignored."; } } } @@ -192,7 +191,7 @@ int ParseCommandLineArgs(int argc, const char* argv[], } else { - BOOST_LOG_TRIVIAL(fatal) << "Unknown model format: '" << modelFormat << "'. Please include 'binary' or 'text'"; + ARMNN_LOG(fatal) << "Unknown model format: '" << modelFormat << "'. Please include 'binary' or 'text'"; return EXIT_FAILURE; } @@ -364,12 +363,12 @@ int main(int argc, const char* argv[]) && !defined(ARMNN_ONNX_PARSER) \ && !defined(ARMNN_TF_PARSER) \ && !defined(ARMNN_TF_LITE_PARSER)) - BOOST_LOG_TRIVIAL(fatal) << "Not built with any of the supported parsers, Caffe, Onnx, Tensorflow, or TfLite."; + ARMNN_LOG(fatal) << "Not built with any of the supported parsers, Caffe, Onnx, Tensorflow, or TfLite."; return EXIT_FAILURE; #endif #if !defined(ARMNN_SERIALIZER) - BOOST_LOG_TRIVIAL(fatal) << "Not built with Serializer support."; + ARMNN_LOG(fatal) << "Not built with Serializer support."; return EXIT_FAILURE; #endif @@ -380,7 +379,6 @@ int main(int argc, const char* argv[]) #endif armnn::ConfigureLogging(true, true, level); - armnnUtils::ConfigureLogging(boost::log::core::get().get(), true, true, level); std::string modelFormat; std::string modelPath; @@ -414,7 +412,7 @@ int main(int argc, const char* argv[]) } catch (const armnn::InvalidArgumentException& e) { - BOOST_LOG_TRIVIAL(fatal) << "Cannot create tensor shape: " << e.what(); + ARMNN_LOG(fatal) << "Cannot create tensor shape: " << e.what(); return EXIT_FAILURE; } } @@ -427,11 +425,11 @@ int main(int argc, const char* argv[]) #if defined(ARMNN_CAFFE_PARSER) if (!converter.CreateNetwork<armnnCaffeParser::ICaffeParser>()) { - BOOST_LOG_TRIVIAL(fatal) << "Failed to load model from file"; + ARMNN_LOG(fatal) << "Failed to load model from file"; return EXIT_FAILURE; } #else - BOOST_LOG_TRIVIAL(fatal) << "Not built with Caffe parser support."; + ARMNN_LOG(fatal) << "Not built with Caffe parser support."; return EXIT_FAILURE; #endif } @@ -440,11 +438,11 @@ int main(int argc, const char* argv[]) #if defined(ARMNN_ONNX_PARSER) if (!converter.CreateNetwork<armnnOnnxParser::IOnnxParser>()) { - BOOST_LOG_TRIVIAL(fatal) << "Failed to load model from file"; + ARMNN_LOG(fatal) << "Failed to load model from file"; return EXIT_FAILURE; } #else - BOOST_LOG_TRIVIAL(fatal) << "Not built with Onnx parser support."; + ARMNN_LOG(fatal) << "Not built with Onnx parser support."; return EXIT_FAILURE; #endif } @@ -453,11 +451,11 @@ int main(int argc, const char* argv[]) #if defined(ARMNN_TF_PARSER) if (!converter.CreateNetwork<armnnTfParser::ITfParser>()) { - BOOST_LOG_TRIVIAL(fatal) << "Failed to load model from file"; + ARMNN_LOG(fatal) << "Failed to load model from file"; return EXIT_FAILURE; } #else - BOOST_LOG_TRIVIAL(fatal) << "Not built with Tensorflow parser support."; + ARMNN_LOG(fatal) << "Not built with Tensorflow parser support."; return EXIT_FAILURE; #endif } @@ -466,30 +464,30 @@ int main(int argc, const char* argv[]) #if defined(ARMNN_TF_LITE_PARSER) if (!isModelBinary) { - BOOST_LOG_TRIVIAL(fatal) << "Unknown model format: '" << modelFormat << "'. Only 'binary' format supported \ + ARMNN_LOG(fatal) << "Unknown model format: '" << modelFormat << "'. Only 'binary' format supported \ for tflite files"; return EXIT_FAILURE; } if (!converter.CreateNetwork<armnnTfLiteParser::ITfLiteParser>()) { - BOOST_LOG_TRIVIAL(fatal) << "Failed to load model from file"; + ARMNN_LOG(fatal) << "Failed to load model from file"; return EXIT_FAILURE; } #else - BOOST_LOG_TRIVIAL(fatal) << "Not built with TfLite parser support."; + ARMNN_LOG(fatal) << "Not built with TfLite parser support."; return EXIT_FAILURE; #endif } else { - BOOST_LOG_TRIVIAL(fatal) << "Unknown model format: '" << modelFormat << "'"; + ARMNN_LOG(fatal) << "Unknown model format: '" << modelFormat << "'"; return EXIT_FAILURE; } if (!converter.Serialize()) { - BOOST_LOG_TRIVIAL(fatal) << "Failed to serialize model"; + ARMNN_LOG(fatal) << "Failed to serialize model"; return EXIT_FAILURE; } diff --git a/src/armnnDeserializer/Deserializer.cpp b/src/armnnDeserializer/Deserializer.cpp index 3e6d5aa298..e01ed47740 100644 --- a/src/armnnDeserializer/Deserializer.cpp +++ b/src/armnnDeserializer/Deserializer.cpp @@ -18,7 +18,6 @@ #include <boost/core/ignore_unused.hpp> #include <boost/assert.hpp> #include <boost/format.hpp> -#include <boost/log/trivial.hpp> #include <boost/format.hpp> #include <boost/numeric/conversion/cast.hpp> #include <boost/polymorphic_cast.hpp> diff --git a/src/armnnTfLiteParser/TfLiteParser.cpp b/src/armnnTfLiteParser/TfLiteParser.cpp index 6122f5e967..f06e244223 100644 --- a/src/armnnTfLiteParser/TfLiteParser.cpp +++ b/src/armnnTfLiteParser/TfLiteParser.cpp @@ -7,6 +7,7 @@ #include <armnn/ArmNN.hpp> #include <armnn/Exceptions.hpp> +#include <armnn/Logging.hpp> #include <armnn/TypesUtils.hpp> #include <boost/filesystem.hpp> @@ -24,8 +25,6 @@ #include <boost/core/ignore_unused.hpp> #include <boost/assert.hpp> #include <boost/format.hpp> -#include <boost/log/trivial.hpp> -#include <boost/format.hpp> #include <boost/numeric/conversion/cast.hpp> #include <fstream> @@ -607,7 +606,7 @@ INetworkPtr TfLiteParser::CreateNetworkFromModel() errorString << "Failed to parse operator #" << operatorIndex << " within subgraph #" << subgraphIndex << " error: " << e.what(); - BOOST_LOG_TRIVIAL(error) << errorString.str(); + ARMNN_LOG(error) << errorString.str(); errors << errorString.str() << "\n"; } 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; diff --git a/src/backends/backendsCommon/DynamicBackendUtils.cpp b/src/backends/backendsCommon/DynamicBackendUtils.cpp index da7c3244f1..b31ce60564 100644 --- a/src/backends/backendsCommon/DynamicBackendUtils.cpp +++ b/src/backends/backendsCommon/DynamicBackendUtils.cpp @@ -7,7 +7,6 @@ #include <boost/filesystem.hpp> #include <boost/algorithm/string.hpp> -#include <boost/log/trivial.hpp> #include <regex> @@ -84,8 +83,8 @@ std::vector<std::string> DynamicBackendUtils::GetBackendPaths(const std::string& { if (!IsPathValid(overrideBackendPath)) { - BOOST_LOG_TRIVIAL(warning) << "WARNING: The given override path for dynamic backends \"" - << overrideBackendPath << "\" is not valid"; + ARMNN_LOG(warning) << "WARNING: The given override path for dynamic backends \"" + << overrideBackendPath << "\" is not valid"; return {}; } @@ -146,7 +145,7 @@ bool DynamicBackendUtils::IsPathValid(const std::string& path) { if (path.empty()) { - BOOST_LOG_TRIVIAL(warning) << "WARNING: The given backend path is empty"; + ARMNN_LOG(warning) << "WARNING: The given backend path is empty"; return false; } @@ -154,19 +153,19 @@ bool DynamicBackendUtils::IsPathValid(const std::string& path) if (!boost::filesystem::exists(boostPath)) { - BOOST_LOG_TRIVIAL(warning) << "WARNING: The given backend path \"" << path << "\" does not exist"; + ARMNN_LOG(warning) << "WARNING: The given backend path \"" << path << "\" does not exist"; return false; } if (!boost::filesystem::is_directory(boostPath)) { - BOOST_LOG_TRIVIAL(warning) << "WARNING: The given backend path \"" << path << "\" is not a directory"; + ARMNN_LOG(warning) << "WARNING: The given backend path \"" << path << "\" is not a directory"; return false; } if (!boostPath.is_absolute()) { - BOOST_LOG_TRIVIAL(warning) << "WARNING: The given backend path \"" << path << "\" is not absolute"; + ARMNN_LOG(warning) << "WARNING: The given backend path \"" << path << "\" is not absolute"; return false; } @@ -214,7 +213,7 @@ std::vector<std::string> DynamicBackendUtils::GetSharedObjects(const std::vector } catch (const filesystem_error& e) { - BOOST_LOG_TRIVIAL(warning) << "GetSharedObjects warning: " << e.what(); + ARMNN_LOG(warning) << "GetSharedObjects warning: " << e.what(); } if (canonicalPath.empty()) { @@ -235,7 +234,7 @@ std::vector<std::string> DynamicBackendUtils::GetSharedObjects(const std::vector } catch (const std::exception& e) { - BOOST_LOG_TRIVIAL(warning) << "GetSharedObjects warning: " << e.what(); + ARMNN_LOG(warning) << "GetSharedObjects warning: " << e.what(); } if (!filenameMatch) { @@ -274,13 +273,13 @@ std::vector<DynamicBackendPtr> DynamicBackendUtils::CreateDynamicBackends(const } catch (const RuntimeException& e) { - BOOST_LOG_TRIVIAL(warning) << "Cannot create a handle to the shared object file \"" - << sharedObject << "\": " << e.what(); + ARMNN_LOG(warning) << "Cannot create a handle to the shared object file \"" + << sharedObject << "\": " << e.what(); continue; } if (!sharedObjectHandle) { - BOOST_LOG_TRIVIAL(warning) << "Invalid handle to the shared object file \"" << sharedObject << "\""; + ARMNN_LOG(warning) << "Invalid handle to the shared object file \"" << sharedObject << "\""; continue; } @@ -293,14 +292,14 @@ std::vector<DynamicBackendPtr> DynamicBackendUtils::CreateDynamicBackends(const } catch (const Exception& e) { - BOOST_LOG_TRIVIAL(warning) << "Cannot create a valid dynamic backend from the shared object file \"" - << sharedObject << "\": " << e.what(); + ARMNN_LOG(warning) << "Cannot create a valid dynamic backend from the shared object file \"" + << sharedObject << "\": " << e.what(); continue; } if (!dynamicBackend) { - BOOST_LOG_TRIVIAL(warning) << "Invalid dynamic backend object for the shared object file \"" - << sharedObject << "\""; + ARMNN_LOG(warning) << "Invalid dynamic backend object for the shared object file \"" + << sharedObject << "\""; continue; } @@ -337,14 +336,14 @@ BackendIdSet DynamicBackendUtils::RegisterDynamicBackendsImpl(BackendRegistry& b } catch (const RuntimeException& e) { - BOOST_LOG_TRIVIAL(warning) << "Cannot register dynamic backend, " - << "an error has occurred when getting the backend id: " << e.what(); + ARMNN_LOG(warning) << "Cannot register dynamic backend, " + << "an error has occurred when getting the backend id: " << e.what(); continue; } if (dynamicBackendId.IsEmpty() || dynamicBackendId.IsUndefined()) { - BOOST_LOG_TRIVIAL(warning) << "Cannot register dynamic backend, invalid backend id: " << dynamicBackendId; + ARMNN_LOG(warning) << "Cannot register dynamic backend, invalid backend id: " << dynamicBackendId; continue; } @@ -352,8 +351,8 @@ BackendIdSet DynamicBackendUtils::RegisterDynamicBackendsImpl(BackendRegistry& b bool backendAlreadyRegistered = backendRegistry.IsBackendRegistered(dynamicBackendId); if (backendAlreadyRegistered) { - BOOST_LOG_TRIVIAL(warning) << "Cannot register dynamic backend \"" << dynamicBackendId - << "\": backend already registered"; + ARMNN_LOG(warning) << "Cannot register dynamic backend \"" << dynamicBackendId + << "\": backend already registered"; continue; } @@ -365,15 +364,15 @@ BackendIdSet DynamicBackendUtils::RegisterDynamicBackendsImpl(BackendRegistry& b } catch (const RuntimeException& e) { - BOOST_LOG_TRIVIAL(warning) << "Cannot register dynamic backend \"" << dynamicBackendId - << "\": an error has occurred when getting the backend factory function: " - << e.what(); + ARMNN_LOG(warning) << "Cannot register dynamic backend \"" << dynamicBackendId + << "\": an error has occurred when getting the backend factory function: " + << e.what(); continue; } if (dynamicBackendFactoryFunction == nullptr) { - BOOST_LOG_TRIVIAL(warning) << "Cannot register dynamic backend \"" << dynamicBackendId - << "\": invalid backend factory function"; + ARMNN_LOG(warning) << "Cannot register dynamic backend \"" << dynamicBackendId + << "\": invalid backend factory function"; continue; } @@ -384,8 +383,8 @@ BackendIdSet DynamicBackendUtils::RegisterDynamicBackendsImpl(BackendRegistry& b } catch (const InvalidArgumentException& e) { - BOOST_LOG_TRIVIAL(warning) << "An error has occurred when registering the dynamic backend \"" - << dynamicBackendId << "\": " << e.what(); + ARMNN_LOG(warning) << "An error has occurred when registering the dynamic backend \"" + << dynamicBackendId << "\": " << e.what(); continue; } diff --git a/src/backends/backendsCommon/OutputHandler.cpp b/src/backends/backendsCommon/OutputHandler.cpp index e3a1b276ea..e3655b08fa 100644 --- a/src/backends/backendsCommon/OutputHandler.cpp +++ b/src/backends/backendsCommon/OutputHandler.cpp @@ -11,7 +11,6 @@ #include <backendsCommon/WorkloadFactory.hpp> #include <boost/assert.hpp> -#include <boost/log/trivial.hpp> namespace armnn { diff --git a/src/backends/cl/ClBackendContext.cpp b/src/backends/cl/ClBackendContext.cpp index 48682b90dd..a82391cce5 100644 --- a/src/backends/cl/ClBackendContext.cpp +++ b/src/backends/cl/ClBackendContext.cpp @@ -4,14 +4,15 @@ // #include "ClBackendContext.hpp" + +#include <armnn/Logging.hpp> + #include "ClContextControl.hpp" #include <arm_compute/core/CL/OpenCL.h> #include <arm_compute/core/CL/CLKernelLibrary.h> #include <arm_compute/runtime/CL/CLScheduler.h> -#include <boost/log/trivial.hpp> - namespace armnn { @@ -34,8 +35,8 @@ struct ClBackendContext::ClContextControlWrapper } catch (const cl::Error&) { - BOOST_LOG_TRIVIAL(warning) << "WARNING: Runtime::UnloadNetwork(): an error occurred while waiting for " - "the queued CL requests to finish"; + ARMNN_LOG(warning) << "Runtime::UnloadNetwork(): an error occurred while waiting for " + "the queued CL requests to finish"; return false; } } diff --git a/src/backends/cl/ClContextControl.cpp b/src/backends/cl/ClContextControl.cpp index 7013b8a4f8..cf5ae64c78 100644 --- a/src/backends/cl/ClContextControl.cpp +++ b/src/backends/cl/ClContextControl.cpp @@ -14,7 +14,6 @@ #include <boost/assert.hpp> #include <boost/format.hpp> -#include <boost/log/trivial.hpp> #include <boost/polymorphic_cast.hpp> #include <boost/core/ignore_unused.hpp> diff --git a/src/backends/cl/ClWorkloadFactory.cpp b/src/backends/cl/ClWorkloadFactory.cpp index 804580575e..531f3710ea 100644 --- a/src/backends/cl/ClWorkloadFactory.cpp +++ b/src/backends/cl/ClWorkloadFactory.cpp @@ -25,7 +25,6 @@ #include <boost/polymorphic_cast.hpp> #include <boost/format.hpp> -#include <boost/log/trivial.hpp> namespace armnn { diff --git a/src/backends/reference/RefWorkloadFactory.cpp b/src/backends/reference/RefWorkloadFactory.cpp index 7fd93435e7..8d044eecb7 100644 --- a/src/backends/reference/RefWorkloadFactory.cpp +++ b/src/backends/reference/RefWorkloadFactory.cpp @@ -12,7 +12,6 @@ #include "workloads/RefWorkloads.hpp" #include "RefTensorHandle.hpp" -#include <boost/log/trivial.hpp> namespace armnn { diff --git a/src/backends/reference/workloads/Activation.cpp b/src/backends/reference/workloads/Activation.cpp index 2b0c84e226..814a0ddd13 100644 --- a/src/backends/reference/workloads/Activation.cpp +++ b/src/backends/reference/workloads/Activation.cpp @@ -5,8 +5,6 @@ #include "Activation.hpp" -#include <boost/log/trivial.hpp> - #include <cmath> namespace armnn diff --git a/src/backends/reference/workloads/RefNormalizationWorkload.cpp b/src/backends/reference/workloads/RefNormalizationWorkload.cpp index 0427baf475..adf452dde1 100644 --- a/src/backends/reference/workloads/RefNormalizationWorkload.cpp +++ b/src/backends/reference/workloads/RefNormalizationWorkload.cpp @@ -14,7 +14,6 @@ #include <Profiling.hpp> -#include <boost/log/trivial.hpp> #include <boost/numeric/conversion/cast.hpp> using namespace armnn; @@ -196,13 +195,13 @@ void RefNormalizationWorkload::Execute() const } else { - BOOST_LOG_TRIVIAL(warning) << "Illegal NORMALIZATION mode in normalization_f32"; + ARMNN_LOG(warning) << "Illegal NORMALIZATION mode in normalization_f32"; return; } } else { - BOOST_LOG_TRIVIAL(warning) << "Lcr method (Jarret 2009: Local Contrast Normalization) not supported yet."; + ARMNN_LOG(warning) << "Lcr method (Jarret 2009: Local Contrast Normalization) not supported yet."; return; } } diff --git a/src/profiling/CommandHandler.cpp b/src/profiling/CommandHandler.cpp index d9722b3183..bb60ac18f0 100644 --- a/src/profiling/CommandHandler.cpp +++ b/src/profiling/CommandHandler.cpp @@ -6,7 +6,7 @@ #include "CommandHandler.hpp" #include "ProfilingService.hpp" -#include <boost/log/trivial.hpp> +#include <armnn/Logging.hpp> namespace armnn { @@ -75,7 +75,7 @@ void CommandHandler::HandleCommands(IProfilingConnection& profilingConnection) catch (const Exception& e) { // Log the error and continue - BOOST_LOG_TRIVIAL(warning) << "An error has occurred when handling a command: " << e.what() << std::endl; + ARMNN_LOG(warning) << "An error has occurred when handling a command: " << e.what(); // Did we get here because the socket failed? if ( !profilingConnection.IsOpen() ) { diff --git a/src/profiling/PeriodicCounterCapture.cpp b/src/profiling/PeriodicCounterCapture.cpp index 12e58f2800..f3bb5e9202 100644 --- a/src/profiling/PeriodicCounterCapture.cpp +++ b/src/profiling/PeriodicCounterCapture.cpp @@ -5,7 +5,8 @@ #include "PeriodicCounterCapture.hpp" -#include <boost/log/trivial.hpp> +#include <armnn/Logging.hpp> + #include <iostream> namespace armnn @@ -85,8 +86,8 @@ void PeriodicCounterCapture::Capture(const IReadCounterValues& readCounterValues catch (const Exception& e) { // Report the error and continue - BOOST_LOG_TRIVIAL(warning) << "An error has occurred when getting a counter value: " - << e.what() << std::endl; + ARMNN_LOG(warning) << "An error has occurred when getting a counter value: " + << e.what(); continue; } values.emplace_back(std::make_pair(requestedId, counterValue)); diff --git a/src/profiling/ProfilingService.cpp b/src/profiling/ProfilingService.cpp index ddd4d80b06..409e71dfa0 100644 --- a/src/profiling/ProfilingService.cpp +++ b/src/profiling/ProfilingService.cpp @@ -5,7 +5,8 @@ #include "ProfilingService.hpp" -#include <boost/log/trivial.hpp> +#include <armnn/Logging.hpp> + #include <boost/format.hpp> namespace armnn @@ -118,8 +119,8 @@ void ProfilingService::Update() } catch (const Exception& e) { - BOOST_LOG_TRIVIAL(warning) << "An error has occurred when creating the profiling connection: " - << e.what() << std::endl; + ARMNN_LOG(warning) << "An error has occurred when creating the profiling connection: " + << e.what(); } // Move to the next state diff --git a/src/profiling/test/ProfilingTests.hpp b/src/profiling/test/ProfilingTests.hpp index 65c182b622..cfac691cff 100644 --- a/src/profiling/test/ProfilingTests.hpp +++ b/src/profiling/test/ProfilingTests.hpp @@ -7,9 +7,10 @@ #include "SendCounterPacketTests.hpp" +#include <armnn/Logging.hpp> + #include <CommandHandlerFunctor.hpp> #include <IProfilingConnection.hpp> -#include <Logging.hpp> #include <ProfilingService.hpp> #include <boost/polymorphic_cast.hpp> |