aboutsummaryrefslogtreecommitdiff
path: root/src/armnn
diff options
context:
space:
mode:
authorDerek Lamberti <derek.lamberti@arm.com>2019-11-26 16:38:31 +0000
committerDerek Lamberti <derek.lamberti@arm.com>2019-12-05 15:35:51 +0000
commit08446976e3b6ce0e02f22b391b37aacaad181e1a (patch)
treeb57106c6a3e28662adb2592ac3e850a8f19b6ec7 /src/armnn
parenta3b31f010004ed397ec04325edf7020984847f21 (diff)
downloadarmnn-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/armnn')
-rw-r--r--src/armnn/Descriptors.cpp12
-rw-r--r--src/armnn/Graph.cpp11
-rw-r--r--src/armnn/Layer.cpp1
-rw-r--r--src/armnn/LoadedNetwork.cpp7
-rw-r--r--src/armnn/Network.cpp7
-rw-r--r--src/armnn/Runtime.cpp11
-rw-r--r--src/armnn/Tensor.cpp1
-rw-r--r--src/armnn/Utils.cpp8
-rw-r--r--src/armnn/test/ModelAccuracyCheckerTest.cpp1
-rw-r--r--src/armnn/test/UnitTests.cpp56
-rw-r--r--src/armnn/test/UnitTests.hpp3
11 files changed, 81 insertions, 37 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: