From a8837bfcf45136f178a9884b7c6f6449b3e6ed41 Mon Sep 17 00:00:00 2001 From: David Monahan Date: Thu, 16 Apr 2020 10:01:56 +0100 Subject: IVGCVSW-4513 Remove boost/algorithm/string * * Removed split, classification, trim, string, join, contains * Added StringUtils.hpp to replace the removed Boost String functionality Signed-off-by: David Monahan Change-Id: I8aa938dc3942cb65c512cccb2c069da66aa24668 --- CMakeLists.txt | 1 + include/armnn/utility/StringUtils.hpp | 120 +++++++++++++++++++++ src/armnn/Profiling.cpp | 2 - src/armnn/test/CsvReaderTest.cpp | 1 - src/armnn/test/InferOutputTests.hpp | 1 - src/armnn/test/ModelAccuracyCheckerTest.cpp | 1 - src/armnn/test/ProfilerTests.cpp | 19 ++-- src/armnn/test/UnitTests.cpp | 14 ++- src/armnnConverter/ArmnnConverter.cpp | 15 +-- src/armnnUtils/CsvReader.cpp | 4 +- src/armnnUtils/DotSerializer.cpp | 6 +- .../backendsCommon/DynamicBackendUtils.cpp | 5 +- .../backendsCommon/test/BackendProfilingTests.cpp | 3 +- .../backendsCommon/test/JsonPrinterTestImpl.cpp | 26 ++--- .../reference/test/RefLayerSupportTests.cpp | 7 +- src/profiling/test/ProfilingTests.cpp | 13 ++- tests/DeepSpeechV1Database.hpp | 12 +-- tests/InferenceModel.hpp | 4 +- tests/InferenceTest.cpp | 1 - tests/InferenceTest.inl | 1 - .../ModelAccuracyTool-Armnn.cpp | 1 - .../NetworkExecutionUtils.hpp | 22 +--- 22 files changed, 176 insertions(+), 103 deletions(-) create mode 100644 include/armnn/utility/StringUtils.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 9697a5a6dc..9e31a0392f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -251,6 +251,7 @@ list(APPEND armnn_sources include/armnn/utility/IgnoreUnused.hpp include/armnn/utility/NumericCast.hpp include/armnn/utility/PolymorphicDowncast.hpp + include/armnn/utility/StringUtils.hpp profiling/common/include/SocketConnectionException.hpp src/armnn/layers/LayerCloneBase.hpp src/armnn/layers/LayerWithParameters.hpp diff --git a/include/armnn/utility/StringUtils.hpp b/include/armnn/utility/StringUtils.hpp new file mode 100644 index 0000000000..c56a215b83 --- /dev/null +++ b/include/armnn/utility/StringUtils.hpp @@ -0,0 +1,120 @@ +// +// Copyright © 2020 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#pragma once + +#include +#include + +namespace armnn +{ + +namespace stringUtils +{ + +/// Function to take a string and a list of delimiters and split the string into tokens based on those delimiters +/// This assumes that tokens are also to be split by newlines +/// Enabling token compression causes this to ignore multiple concurrent delimiters +inline std::vector StringTokenizer(const std::string& str, + const char* delimiters, + bool tokenCompression = true) +{ + std::stringstream stringStream(str); + std::string line; + std::vector wordVector; + while (std::getline(stringStream, line)) + { + std::size_t prev = 0; + std::size_t pos; + while ((pos = line.find_first_of(delimiters, prev)) != std::string::npos) + { + if (pos > prev) + { + // If token compression is enabled ignore delimiters that are next to each other + if (tokenCompression && (pos - prev == 1)) + { + prev = pos + 1; + continue; + } + wordVector.push_back(line.substr(prev, pos - prev)); + } + prev = pos + 1; + } + if (prev < line.length()) + { + wordVector.push_back(line.substr(prev, std::string::npos)); + } + } + return wordVector; +} + +// Set of 3 utility functions for trimming std::strings +// Default char set for common whitespace characters + +/// +/// Trim from the start of a string +/// +inline std::string& StringStartTrim(std::string& str, const std::string& chars = "\t\n\v\f\r ") +{ + str.erase(0, str.find_first_not_of(chars)); + return str; +} + +/// +/// Trim for the end of a string +/// +inline std::string& StringEndTrim(std::string& str, const std::string& chars = "\t\n\v\f\r ") +{ + str.erase(str.find_last_not_of(chars) + 1); + return str; +} + +/// +/// Trim from both the start and the end of a string +/// +inline std::string& StringTrim(std::string& str, const std::string& chars = "\t\n\v\f\r ") +{ + return StringStartTrim(StringEndTrim(str, chars), chars); +} + +/// +/// Trim from both the start and the end of a string, returns a trimmed copy of the string +/// +inline std::string StringTrimCopy(const std::string& str, const std::string& chars = "\t\n\v\f\r ") +{ + std::string strCopy = str; + return StringStartTrim(StringEndTrim(strCopy, chars), chars); +} + +/// Takes a vector of strings and concatenates them together into one long std::string with an optional +/// seperator between each. +inline std::string StringConcat(const std::vector& strings, std::string seperator = "") +{ + std::stringstream ss; + for (auto string : strings) + { + ss << string << seperator; + } + return ss.str(); +} + +/// +/// Iterates over a given str and replaces all instance of substring oldStr with newStr +/// +inline void StringReplaceAll(std::string& str, + const std::string& oldStr, + const std::string& newStr) +{ + std::string::size_type pos = 0u; + while ((pos = str.find(oldStr, pos)) != std::string::npos) + { + str.replace(pos, oldStr.length(), newStr); + pos += newStr.length(); + } +} + +} // namespace stringUtils + +} // namespace armnn \ No newline at end of file diff --git a/src/armnn/Profiling.cpp b/src/armnn/Profiling.cpp index 7194064c11..9a9021a391 100644 --- a/src/armnn/Profiling.cpp +++ b/src/armnn/Profiling.cpp @@ -21,8 +21,6 @@ #include #include -#include - namespace armnn { diff --git a/src/armnn/test/CsvReaderTest.cpp b/src/armnn/test/CsvReaderTest.cpp index ed27e57f8e..8491ad778d 100644 --- a/src/armnn/test/CsvReaderTest.cpp +++ b/src/armnn/test/CsvReaderTest.cpp @@ -4,7 +4,6 @@ // #include "CsvReader.hpp" -#include #include #include diff --git a/src/armnn/test/InferOutputTests.hpp b/src/armnn/test/InferOutputTests.hpp index 70afbc9b3f..0413682dad 100644 --- a/src/armnn/test/InferOutputTests.hpp +++ b/src/armnn/test/InferOutputTests.hpp @@ -14,7 +14,6 @@ #include #include -#include #include void ArgMinMaxInferOutputShapeImpl(const armnn::ArgMinMaxDescriptor descriptor, diff --git a/src/armnn/test/ModelAccuracyCheckerTest.cpp b/src/armnn/test/ModelAccuracyCheckerTest.cpp index 8bbe3d9f41..1bffa9c57c 100644 --- a/src/armnn/test/ModelAccuracyCheckerTest.cpp +++ b/src/armnn/test/ModelAccuracyCheckerTest.cpp @@ -4,7 +4,6 @@ // #include "ModelAccuracyChecker.hpp" -#include #include #include diff --git a/src/armnn/test/ProfilerTests.cpp b/src/armnn/test/ProfilerTests.cpp index 40e9f470ad..7bd258e430 100644 --- a/src/armnn/test/ProfilerTests.cpp +++ b/src/armnn/test/ProfilerTests.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #include @@ -231,21 +230,21 @@ BOOST_AUTO_TEST_CASE(WriteEventResults) BOOST_TEST(!output.is_empty(false)); // output should contain event name 'test' - BOOST_CHECK(boost::contains(output.str(), "test")); + BOOST_CHECK(output.str().find("test") != std::string::npos); // output should contain headers - BOOST_CHECK(boost::contains(output.str(), "Event Sequence - Name")); - BOOST_CHECK(boost::contains(output.str(), "Event Stats - Name")); - BOOST_CHECK(boost::contains(output.str(), "Total")); - BOOST_CHECK(boost::contains(output.str(), "Device")); + BOOST_CHECK(output.str().find("Event Sequence - Name") != std::string::npos); + BOOST_CHECK(output.str().find("Event Stats - Name") != std::string::npos); + BOOST_CHECK(output.str().find("Total") != std::string::npos); + BOOST_CHECK(output.str().find("Device") != std::string::npos); // output should contain compute device 'CpuAcc' - BOOST_CHECK(boost::contains(output.str(), "CpuAcc")); + BOOST_CHECK(output.str().find("CpuAcc") != std::string::npos); // output should not contain un-readable numbers - BOOST_CHECK(!(boost::contains(output.str(), "e+"))); + BOOST_CHECK(output.str().find("e+") == std::string::npos); // output should not contain un-readable numbers - BOOST_CHECK(!(boost::contains(output.str(), "+"))); + BOOST_CHECK(output.str().find("+") == std::string::npos); // output should not contain zero value - BOOST_CHECK(!(boost::contains(output.str(), " 0 "))); + BOOST_CHECK(output.str().find(" 0 ") == std::string::npos); } // Disable profiling here to not print out anything on stdout. diff --git a/src/armnn/test/UnitTests.cpp b/src/armnn/test/UnitTests.cpp index 7d171a8d88..071bff0ed8 100644 --- a/src/armnn/test/UnitTests.cpp +++ b/src/armnn/test/UnitTests.cpp @@ -8,8 +8,6 @@ #include "UnitTests.hpp" #include -#include - struct ConfigureLoggingFixture { ConfigureLoggingFixture() @@ -103,12 +101,12 @@ BOOST_AUTO_TEST_CASE(LoggerTest) } - 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_CHECK(ss.str().find("Trace: My trace message; -2") != std::string::npos); + BOOST_CHECK(ss.str().find("Debug: My debug message; -1") != std::string::npos); + BOOST_CHECK(ss.str().find("Info: My info message; 0") != std::string::npos); + BOOST_CHECK(ss.str().find("Warning: My warning message; 1") != std::string::npos); + BOOST_CHECK(ss.str().find("Error: My error message; 2") != std::string::npos); + BOOST_CHECK(ss.str().find("Fatal: My fatal message; 3") != std::string::npos); } BOOST_AUTO_TEST_SUITE_END() diff --git a/src/armnnConverter/ArmnnConverter.cpp b/src/armnnConverter/ArmnnConverter.cpp index e0a659dca3..6d0952ac01 100644 --- a/src/armnnConverter/ArmnnConverter.cpp +++ b/src/armnnConverter/ArmnnConverter.cpp @@ -21,10 +21,9 @@ #endif #include +#include "armnn/utility/StringUtils.hpp" #include -#include -#include #include #include @@ -43,17 +42,7 @@ armnn::TensorShape ParseTensorShape(std::istream& stream) while (std::getline(stream, line)) { - std::vector tokens; - try - { - // Coverity fix: boost::split() may throw an exception of type boost::bad_function_call. - boost::split(tokens, line, boost::algorithm::is_any_of(","), boost::token_compress_on); - } - catch (const std::exception& e) - { - ARMNN_LOG(error) << "An error occurred when splitting tokens: " << e.what(); - continue; - } + std::vector tokens = armnn::stringUtils::StringTokenizer(line, ","); for (const std::string& token : tokens) { if (!token.empty()) diff --git a/src/armnnUtils/CsvReader.cpp b/src/armnnUtils/CsvReader.cpp index ba6c42c376..feee4d18c6 100644 --- a/src/armnnUtils/CsvReader.cpp +++ b/src/armnnUtils/CsvReader.cpp @@ -4,8 +4,8 @@ // #include "CsvReader.hpp" +#include "armnn/utility/StringUtils.hpp" -#include #include #include @@ -24,7 +24,7 @@ CsvRow ParseLine(const std::string& csvLine) for (const auto &token : tokenizer) { - entry.values.push_back(boost::trim_copy(token)); + entry.values.push_back(armnn::stringUtils::StringTrimCopy(token)); } return entry; } diff --git a/src/armnnUtils/DotSerializer.cpp b/src/armnnUtils/DotSerializer.cpp index 80043a9f90..87376e61d1 100644 --- a/src/armnnUtils/DotSerializer.cpp +++ b/src/armnnUtils/DotSerializer.cpp @@ -4,8 +4,8 @@ // #include "DotSerializer.hpp" +#include "armnn/utility/StringUtils.hpp" -#include #include #include @@ -26,8 +26,8 @@ std::string Indent(int numSpaces) std::string Escape(std::string s) { - boost::replace_all(s, "<", "\\<"); - boost::replace_all(s, ">", "\\>"); + armnn::stringUtils::StringReplaceAll(s, "<", "\\<"); + armnn::stringUtils::StringReplaceAll(s, ">", "\\>"); return s; } diff --git a/src/backends/backendsCommon/DynamicBackendUtils.cpp b/src/backends/backendsCommon/DynamicBackendUtils.cpp index ea0869220f..5b675ba476 100644 --- a/src/backends/backendsCommon/DynamicBackendUtils.cpp +++ b/src/backends/backendsCommon/DynamicBackendUtils.cpp @@ -5,9 +5,9 @@ #include #include +#include "armnn/utility/StringUtils.hpp" #include -#include #include @@ -110,11 +110,10 @@ std::vector DynamicBackendUtils::GetBackendPathsImpl(const std::str } std::unordered_set uniqueBackendPaths; - std::vector tempBackendPaths; std::vector validBackendPaths; // Split the given list of paths - boost::split(tempBackendPaths, backendPaths, boost::is_any_of(":")); + std::vector tempBackendPaths = armnn::stringUtils::StringTokenizer(backendPaths, ":"); for (const std::string& path : tempBackendPaths) { diff --git a/src/backends/backendsCommon/test/BackendProfilingTests.cpp b/src/backends/backendsCommon/test/BackendProfilingTests.cpp index 7c78e14733..9f1898aa01 100644 --- a/src/backends/backendsCommon/test/BackendProfilingTests.cpp +++ b/src/backends/backendsCommon/test/BackendProfilingTests.cpp @@ -21,7 +21,6 @@ #include #include -#include #include #include #include @@ -441,7 +440,7 @@ BOOST_AUTO_TEST_CASE(TestBackendCounterLogging) periodicCounterCapture.Stop(); SetLogFilter(armnn::LogSeverity::Fatal); - BOOST_CHECK(boost::contains(ss.str(), "ActivateCounters example test error")); + BOOST_CHECK(ss.str().find("ActivateCounters example test error") != std::string::npos); } BOOST_AUTO_TEST_CASE(BackendProfilingContextGetSendTimelinePacket) diff --git a/src/backends/backendsCommon/test/JsonPrinterTestImpl.cpp b/src/backends/backendsCommon/test/JsonPrinterTestImpl.cpp index 91ce150e0e..2aa713f1ed 100644 --- a/src/backends/backendsCommon/test/JsonPrinterTestImpl.cpp +++ b/src/backends/backendsCommon/test/JsonPrinterTestImpl.cpp @@ -4,6 +4,7 @@ // #include "JsonPrinterTestImpl.hpp" +#include "armnn/utility/StringUtils.hpp" #include @@ -11,7 +12,6 @@ #include #include -#include #include #include @@ -62,7 +62,7 @@ std::vector ExtractMeasurements(const std::string& exp) { try { - boost::trim_if(numberString, boost::is_any_of("\t,\n")); + armnn::stringUtils::StringTrim(numberString, "\t,\n"); numbers.push_back(std::stod(numberString)); } catch (std::invalid_argument const& e) @@ -77,7 +77,7 @@ std::vector ExtractMeasurements(const std::string& exp) { try { - boost::trim_if(numberString, boost::is_any_of("\t,\n")); + armnn::stringUtils::StringTrim(numberString, "\t,\n"); numbers.push_back(std::stod(numberString)); } catch (std::invalid_argument const& e) @@ -212,8 +212,9 @@ inline void ValidateProfilerJson(std::string& result) std::vector sectionVector = ExtractSections(result); for (size_t i = 0; i < sectionVector.size(); ++i) { - if (boost::contains(sectionVector[i], "\"ArmNN\":") - || boost::contains(sectionVector[i], "\"inference_measurements\":")) + + if (sectionVector[i].find("\"ArmNN\":") != std::string::npos + || sectionVector[i].find("\"inference_measurements\":") != std::string::npos) { sectionVector.erase(sectionVector.begin() + static_cast(i)); } @@ -221,10 +222,10 @@ inline void ValidateProfilerJson(std::string& result) BOOST_CHECK(!sectionVector.empty()); BOOST_CHECK(std::all_of(sectionVector.begin(), sectionVector.end(), - [](std::string i) { return boost::contains(i, "\"raw\":"); })); + [](std::string i) { return (i.find("\"raw\":") != std::string::npos); })); BOOST_CHECK(std::all_of(sectionVector.begin(), sectionVector.end(), - [](std::string i) { return boost::contains(i, "\"unit\":"); })); + [](std::string i) { return (i.find("\"unit\":") != std::string::npos); })); } // remove the time measurements as they vary from test to test @@ -234,8 +235,8 @@ inline void ValidateProfilerJson(std::string& result) result.erase(std::remove_if (result.begin(),result.end(), [](char c) { return c == '\t'; }), result.end()); - BOOST_CHECK(boost::contains(result, "ArmNN")); - BOOST_CHECK(boost::contains(result, "inference_measurements")); + BOOST_CHECK(result.find("ArmNN") != std::string::npos); + BOOST_CHECK(result.find("inference_measurements") != std::string::npos); // ensure no spare parenthesis present in print output BOOST_CHECK(AreParenthesesMatching(result)); @@ -252,12 +253,11 @@ void RunSoftmaxProfilerJsonPrinterTest(const std::vector& back const armnn::BackendId& firstBackend = backends.at(0); if (firstBackend == armnn::Compute::GpuAcc) { - BOOST_CHECK(boost::contains(result, - "OpenClKernelTimer/: softmax_layer_max_shift_exp_sum_quantized_serial GWS[,,]")); + BOOST_CHECK(result.find("OpenClKernelTimer/: softmax_layer_max_shift_exp_sum_quantized_serial GWS[,,]") + != std::string::npos); } else if (firstBackend == armnn::Compute::CpuAcc) { - BOOST_CHECK(boost::contains(result, - "NeonKernelTimer/: NEFillBorderKernel")); + BOOST_CHECK(result.find("NeonKernelTimer/: NEFillBorderKernel") != std::string::npos); } } diff --git a/src/backends/reference/test/RefLayerSupportTests.cpp b/src/backends/reference/test/RefLayerSupportTests.cpp index f0c69f92cc..1d4b4a0f3a 100644 --- a/src/backends/reference/test/RefLayerSupportTests.cpp +++ b/src/backends/reference/test/RefLayerSupportTests.cpp @@ -14,7 +14,6 @@ #include #include -#include #include @@ -231,9 +230,9 @@ BOOST_AUTO_TEST_CASE(IsLayerNotSupportedMeanDimensionsReference) BOOST_CHECK(!result); - boost::algorithm::trim(reasonIfUnsupported); - BOOST_CHECK_EQUAL(reasonIfUnsupported, - "Reference Mean: Expected 4 dimensions but got 2 dimensions instead, for the 'output' tensor."); + BOOST_CHECK(reasonIfUnsupported.find( + "Reference Mean: Expected 4 dimensions but got 2 dimensions instead, for the 'output' tensor.") + != std::string::npos); } BOOST_AUTO_TEST_SUITE_END() diff --git a/src/profiling/test/ProfilingTests.cpp b/src/profiling/test/ProfilingTests.cpp index f252579022..b3326e0173 100644 --- a/src/profiling/test/ProfilingTests.cpp +++ b/src/profiling/test/ProfilingTests.cpp @@ -37,7 +37,6 @@ #include #include -#include #include #include @@ -3054,7 +3053,7 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceEnabled) streamRedirector.CancelRedirect(); // Check that the expected error has occurred and logged to the standard output - if (!boost::contains(ss.str(), "Cannot connect to stream socket: Connection refused")) + if (ss.str().find("Cannot connect to stream socket: Connection refused") == std::string::npos) { std::cout << ss.str(); BOOST_FAIL("Expected string not found."); @@ -3089,7 +3088,7 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceEnabledRuntime) streamRedirector.CancelRedirect(); // Check that the expected error has occurred and logged to the standard output - if (!boost::contains(ss.str(), "Cannot connect to stream socket: Connection refused")) + if (ss.str().find("Cannot connect to stream socket: Connection refused") == std::string::npos) { std::cout << ss.str(); BOOST_FAIL("Expected string not found."); @@ -3152,7 +3151,7 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceBadConnectionAcknowledgedPacket) streamRedirector.CancelRedirect(); // Check that the expected error has occurred and logged to the standard output - if (!boost::contains(ss.str(), "Functor with requested PacketId=37 and Version=4194304 does not exist")) + if (ss.str().find("Functor with requested PacketId=37 and Version=4194304 does not exist") == std::string::npos) { std::cout << ss.str(); BOOST_FAIL("Expected string not found."); @@ -3216,7 +3215,7 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceBadRequestCounterDirectoryPacket) streamRedirector.CancelRedirect(); // Check that the expected error has occurred and logged to the standard output - if (!boost::contains(ss.str(), "Functor with requested PacketId=123 and Version=4194304 does not exist")) + if (ss.str().find("Functor with requested PacketId=123 and Version=4194304 does not exist") == std::string::npos) { std::cout << ss.str(); BOOST_FAIL("Expected string not found."); @@ -3280,7 +3279,7 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceBadPeriodicCounterSelectionPacket) streamRedirector.CancelRedirect(); // Check that the expected error has occurred and logged to the standard output - if (!boost::contains(ss.str(), "Functor with requested PacketId=999 and Version=4194304 does not exist")) + if (ss.str().find("Functor with requested PacketId=999 and Version=4194304 does not exist") == std::string::npos) { std::cout << ss.str(); BOOST_FAIL("Expected string not found."); @@ -3604,7 +3603,7 @@ BOOST_AUTO_TEST_CASE(CheckFileFormat) { streamRedirector.CancelRedirect(); // Check that the expected error has occurred and logged to the standard output - if (!boost::contains(ss.str(), "Unsupported profiling file format, only binary is supported")) + if (ss.str().find("Unsupported profiling file format, only binary is supported") == std::string::npos) { std::cout << ss.str(); BOOST_FAIL("Expected string not found."); diff --git a/tests/DeepSpeechV1Database.hpp b/tests/DeepSpeechV1Database.hpp index 81523775db..85654b6beb 100644 --- a/tests/DeepSpeechV1Database.hpp +++ b/tests/DeepSpeechV1Database.hpp @@ -30,17 +30,7 @@ std::vector ParseArrayImpl(std::istream& stream, TParseElementFunc parseEleme std::string line; while (std::getline(stream, line)) { - std::vector tokens; - try - { - // Coverity fix: boost::split() may throw an exception of type boost::bad_function_call. - boost::split(tokens, line, boost::algorithm::is_any_of(chars), boost::token_compress_on); - } - catch (const std::exception& e) - { - ARMNN_LOG(error) << "An error occurred when splitting tokens: " << e.what(); - continue; - } + std::vector tokens = armnn::stringUtils::StringTokenizer(line, chars); for (const std::string& token : tokens) { if (!token.empty()) // See https://stackoverflow.com/questions/10437406/ diff --git a/tests/InferenceModel.hpp b/tests/InferenceModel.hpp index af931f99f8..410bc7c04e 100644 --- a/tests/InferenceModel.hpp +++ b/tests/InferenceModel.hpp @@ -22,7 +22,7 @@ #include #include -#include +#include "armnn/utility/StringUtils.hpp" #include #include #include @@ -354,7 +354,7 @@ public: ("model-dir,m", po::value(&options.m_ModelDir)->required(), "Path to directory containing model files (.caffemodel/.prototxt/.tflite)") ("compute,c", po::value>(&options.m_ComputeDevices)-> - default_value(defaultComputes, boost::algorithm::join(defaultComputes, ", "))-> + default_value(defaultComputes, armnn::stringUtils::StringConcat(defaultComputes, ", "))-> multitoken(), backendsMessage.c_str()) ("dynamic-backends-path,b", po::value(&options.m_DynamicBackendsPath), "Path where to load any available dynamic backend from. " diff --git a/tests/InferenceTest.cpp b/tests/InferenceTest.cpp index 7e165b5137..1df399b6a4 100644 --- a/tests/InferenceTest.cpp +++ b/tests/InferenceTest.cpp @@ -7,7 +7,6 @@ #include #include "../src/armnn/Profiling.hpp" -#include #include #include #include diff --git a/tests/InferenceTest.inl b/tests/InferenceTest.inl index ed16464787..32a164dc43 100644 --- a/tests/InferenceTest.inl +++ b/tests/InferenceTest.inl @@ -5,7 +5,6 @@ #include "InferenceTest.hpp" #include -#include #include #include #include diff --git a/tests/ModelAccuracyTool-Armnn/ModelAccuracyTool-Armnn.cpp b/tests/ModelAccuracyTool-Armnn/ModelAccuracyTool-Armnn.cpp index dd1c295d37..20f6180700 100644 --- a/tests/ModelAccuracyTool-Armnn/ModelAccuracyTool-Armnn.cpp +++ b/tests/ModelAccuracyTool-Armnn/ModelAccuracyTool-Armnn.cpp @@ -8,7 +8,6 @@ #include "ModelAccuracyChecker.hpp" #include "armnnDeserializer/IDeserializer.hpp" -#include #include #include #include diff --git a/tests/NetworkExecutionUtils/NetworkExecutionUtils.hpp b/tests/NetworkExecutionUtils/NetworkExecutionUtils.hpp index 278ba1b46a..a922228689 100644 --- a/tests/NetworkExecutionUtils/NetworkExecutionUtils.hpp +++ b/tests/NetworkExecutionUtils/NetworkExecutionUtils.hpp @@ -26,9 +26,6 @@ #include #include -#include -#include -#include #include #include @@ -53,17 +50,7 @@ std::vector ParseArrayImpl(std::istream& stream, TParseElementFunc parseEleme std::string line; while (std::getline(stream, line)) { - std::vector tokens; - try - { - // Coverity fix: boost::split() may throw an exception of type boost::bad_function_call. - boost::split(tokens, line, boost::algorithm::is_any_of(chars), boost::token_compress_on); - } - catch (const std::exception& e) - { - ARMNN_LOG(error) << "An error occurred when splitting tokens: " << e.what(); - continue; - } + std::vector tokens = armnn::stringUtils::StringTokenizer(line, chars); for (const std::string& token : tokens) { if (!token.empty()) // See https://stackoverflow.com/questions/10437406/ @@ -174,7 +161,8 @@ std::vector ParseArray(std::istream& stream) std::vector ParseStringList(const std::string & inputString, const char * delimiter) { std::stringstream stream(inputString); - return ParseArrayImpl(stream, [](const std::string& s) { return boost::trim_copy(s); }, delimiter); + return ParseArrayImpl(stream, [](const std::string& s) { + return armnn::stringUtils::StringTrimCopy(s); }, delimiter); } void RemoveDuplicateDevices(std::vector& computeDevices) @@ -559,8 +547,8 @@ int RunTest(const std::string& format, bool parseUnsupported = false, const std::shared_ptr& runtime = nullptr) { - std::string modelFormat = boost::trim_copy(format); - std::string modelPath = boost::trim_copy(path); + std::string modelFormat = armnn::stringUtils::StringTrimCopy(format); + std::string modelPath = armnn::stringUtils::StringTrimCopy(path); std::vector inputNamesVector = ParseStringList(inputNames, ","); std::vector inputTensorShapesVector = ParseStringList(inputTensorShapesStr, ":"); std::vector inputTensorDataFilePathsVector = ParseStringList( -- cgit v1.2.1