From 08f4016b8ae8ee836fc813abcbc7db826924f3ec Mon Sep 17 00:00:00 2001 From: James Ward Date: Mon, 7 Sep 2020 16:45:07 +0100 Subject: IVGCVSW-5293 Remove boost::format from armnn/tests * Replaced boost::format with fmt::format Signed-off-by: James Ward Change-Id: Icf5a6508e7be3d31bc063643491fc5e0607f21fa --- tests/InferenceModel.hpp | 23 +++++++++++------------ tests/InferenceTest.inl | 6 +++--- tests/InferenceTestImage.cpp | 30 ++++++++++++++---------------- 3 files changed, 28 insertions(+), 31 deletions(-) (limited to 'tests') diff --git a/tests/InferenceModel.hpp b/tests/InferenceModel.hpp index 68ee8ae81a..8ac44f98fb 100644 --- a/tests/InferenceModel.hpp +++ b/tests/InferenceModel.hpp @@ -28,9 +28,9 @@ #include "armnn/utility/StringUtils.hpp" #include #include -#include #include #include +#include #include #include @@ -134,9 +134,9 @@ public: const size_t numInputBindings = params.m_InputBindings.size(); if (numInputShapes < numInputBindings) { - throw armnn::Exception(boost::str(boost::format( - "Not every input has its tensor shape specified: expected=%1%, got=%2%") - % numInputBindings % numInputShapes)); + throw armnn::Exception(fmt::format( + "Not every input has its tensor shape specified: expected={0}, got={1}", + numInputBindings, numInputShapes)); } for (size_t i = 0; i < numInputShapes; i++) @@ -194,10 +194,9 @@ public: fs::path pathToFile(params.m_ModelPath); if (!fs::exists(pathToFile, errorCode)) { - throw armnn::FileNotFoundException(boost::str( - boost::format("Cannot find the file (%1%) errorCode: %2% %3%") % - params.m_ModelPath % - errorCode % + throw armnn::FileNotFoundException(fmt::format("Cannot find the file ({0}) errorCode: {1} {2}", + params.m_ModelPath, + errorCode.message(), CHECK_LOCATION().AsString())); } std::ifstream file(params.m_ModelPath, std::ios::binary); @@ -454,7 +453,7 @@ public: { if (m_InputBindings.size() < inputIndex + 1) { - throw armnn::Exception(boost::str(boost::format("Input index out of range: %1%") % inputIndex)); + throw armnn::Exception(fmt::format("Input index out of range: {}", inputIndex)); } } @@ -462,7 +461,7 @@ public: { if (m_OutputBindings.size() < outputIndex + 1) { - throw armnn::Exception(boost::str(boost::format("Output index out of range: %1%") % outputIndex)); + throw armnn::Exception(fmt::format("Output index out of range: {}", outputIndex)); } } @@ -493,8 +492,8 @@ public: { unsigned int outputIndex = boost::numeric_cast(i); throw armnn::Exception( - boost::str(boost::format("Not enough data for output #%1%: expected " - "%2% elements, got %3%") % outputIndex % expectedOutputDataSize % actualOutputDataSize)); + fmt::format("Not enough data for output #{0}: expected " + "{1} elements, got {2}", outputIndex, expectedOutputDataSize, actualOutputDataSize)); } }, outputContainers[i]); diff --git a/tests/InferenceTest.inl b/tests/InferenceTest.inl index 362be7bdae..4a97d17018 100644 --- a/tests/InferenceTest.inl +++ b/tests/InferenceTest.inl @@ -6,8 +6,8 @@ #include #include -#include #include +#include #include #include @@ -288,8 +288,8 @@ void ClassifierTestCaseProvider::ReadPredictions() } else { - throw armnn::Exception(boost::str(boost::format("Failed to open input validation file: %1%") - % m_ValidationFileIn)); + throw armnn::Exception(fmt::format("Failed to open input validation file: {}" + , m_ValidationFileIn)); } } } diff --git a/tests/InferenceTestImage.cpp b/tests/InferenceTestImage.cpp index 1cf73caf45..f76c958f4e 100644 --- a/tests/InferenceTestImage.cpp +++ b/tests/InferenceTestImage.cpp @@ -7,8 +7,8 @@ #include #include -#include #include +#include #include @@ -33,8 +33,7 @@ unsigned int GetImageChannelIndex(ImageChannelLayout channelLayout, ImageChannel case ImageChannelLayout::Bgr: return 2u - static_cast(channel); default: - throw UnknownImageChannelLayout(boost::str(boost::format("Unknown layout %1%") - % static_cast(channelLayout))); + throw UnknownImageChannelLayout(fmt::format("Unknown layout {}", static_cast(channelLayout))); } } @@ -139,12 +138,12 @@ InferenceTestImage::InferenceTestImage(char const* filePath) if (stbData == nullptr) { - throw InferenceTestImageLoadFailed(boost::str(boost::format("Could not load the image at %1%") % filePath)); + throw InferenceTestImageLoadFailed(fmt::format("Could not load the image at {}", filePath)); } if (width == 0 || height == 0) { - throw InferenceTestImageLoadFailed(boost::str(boost::format("Could not load empty image at %1%") % filePath)); + throw InferenceTestImageLoadFailed(fmt::format("Could not load empty image at {}", filePath)); } m_Width = boost::numeric_cast(width); @@ -160,8 +159,8 @@ std::tuple InferenceTestImage::GetPixelAs3Channels(un { if (x >= m_Width || y >= m_Height) { - throw InferenceTestImageOutOfBoundsAccess(boost::str(boost::format("Attempted out of bounds image access. " - "Requested (%1%, %2%). Maximum valid coordinates (%3%, %4%).") % x % y % (m_Width - 1) % (m_Height - 1))); + throw InferenceTestImageOutOfBoundsAccess(fmt::format("Attempted out of bounds image access. " + "Requested ({0}, {1}). Maximum valid coordinates ({2}, {3}).", x, y, (m_Width - 1), (m_Height - 1))); } const unsigned int pixelOffset = x * GetNumChannels() + y * GetWidth() * GetNumChannels(); @@ -218,8 +217,8 @@ std::vector InferenceTestImage::Resize(unsigned int newWidth, std::vector out; if (newWidth == 0 || newHeight == 0) { - throw InferenceTestImageResizeFailed(boost::str(boost::format("None of the dimensions passed to a resize " - "operation can be zero. Requested width: %1%. Requested height: %2%.") % newWidth % newHeight)); + throw InferenceTestImageResizeFailed(fmt::format("None of the dimensions passed to a resize " + "operation can be zero. Requested width: {0}. Requested height: {1}.", newWidth, newHeight)); } switch (meth) { @@ -234,9 +233,9 @@ std::vector InferenceTestImage::Resize(unsigned int newWidth, break; } default: - throw InferenceTestImageResizeFailed(boost::str( - boost::format("Unknown resizing method asked ArmNN only supports {STB, BilinearAndNormalized} %1%") - % location.AsString())); + throw InferenceTestImageResizeFailed(fmt::format("Unknown resizing method asked ArmNN only" + " supports {STB, BilinearAndNormalized} {}", + location.AsString())); } return out; } @@ -266,14 +265,13 @@ void InferenceTestImage::Write(WriteFormat format, const char* filePath) const break; } default: - throw InferenceTestImageWriteFailed(boost::str(boost::format("Unknown format %1%") - % static_cast(format))); + throw InferenceTestImageWriteFailed(fmt::format("Unknown format {}", static_cast(format))); } if (res == 0) { - throw InferenceTestImageWriteFailed(boost::str(boost::format("An error occurred when writing to file %1%") - % filePath)); + throw InferenceTestImageWriteFailed(fmt::format("An error occurred when writing to file {}", + filePath)); } } -- cgit v1.2.1