aboutsummaryrefslogtreecommitdiff
path: root/src/armnnUtils
diff options
context:
space:
mode:
authorColm Donelan <Colm.Donelan@arm.com>2020-09-09 12:48:16 +0100
committerTeresaARM <teresa.charlinreyes@arm.com>2020-10-02 15:30:11 +0000
commit5b5c222f6b0c40a8e0f9ef9dedccd6f0f18c4c2c (patch)
tree6ad0552e5efeb7ae3474a7f5019bc2fb33fced03 /src/armnnUtils
parent24ac85943b609e48fc36d16570ca4b5b90d31a6a (diff)
downloadarmnn-5b5c222f6b0c40a8e0f9ef9dedccd6f0f18c4c2c.tar.gz
IVGCVSW-5297 Remove boost::format from rest of ArmNN.
* Replacing calls to boost:format with fmt:format. * TensorUtils.cpp added outputShape.reserve call. Signed-off-by: Colm Donelan <Colm.Donelan@arm.com> Change-Id: I4b2ed0f72039df824a2adca9309b8a9bbb158c5b
Diffstat (limited to 'src/armnnUtils')
-rw-r--r--src/armnnUtils/ParserHelper.cpp16
-rw-r--r--src/armnnUtils/ParserPrototxtFixture.hpp57
-rw-r--r--src/armnnUtils/TensorIOUtils.hpp25
-rw-r--r--src/armnnUtils/TensorUtils.cpp12
-rw-r--r--src/armnnUtils/VerificationHelpers.cpp36
5 files changed, 68 insertions, 78 deletions
diff --git a/src/armnnUtils/ParserHelper.cpp b/src/armnnUtils/ParserHelper.cpp
index 9709773014..af8014d112 100644
--- a/src/armnnUtils/ParserHelper.cpp
+++ b/src/armnnUtils/ParserHelper.cpp
@@ -8,7 +8,7 @@
#include <armnn/Descriptors.hpp>
#include <armnnUtils/Permute.hpp>
-#include <boost/format.hpp>
+#include <fmt/format.h>
namespace armnnUtils
{
@@ -27,14 +27,12 @@ void ProcessConcatInputTensorInfo(armnn::TensorInfo& inputTensorInfo,
// double check dimensions of the tensors
if (inputTensorInfo.GetNumDimensions() != inputRank)
{
- throw armnn::ParseException(
- boost::str(
- boost::format(
- "The number of dimensions: %1% for input tensors of the "
- "concatenation op should be %2% %3%")
- % inputTensorInfo.GetNumDimensions()
- % inputRank
- % CHECK_LOCATION().AsString()));
+ throw armnn::ParseException(fmt::format(
+ "The number of dimensions: {0} for input tensors of the "
+ "concatenation op should be {1} {2}",
+ inputTensorInfo.GetNumDimensions(),
+ inputRank,
+ CHECK_LOCATION().AsString()));
}
for (unsigned int j = 0; j < concatAxis; ++j)
diff --git a/src/armnnUtils/ParserPrototxtFixture.hpp b/src/armnnUtils/ParserPrototxtFixture.hpp
index 8356117e1f..cf28fcf513 100644
--- a/src/armnnUtils/ParserPrototxtFixture.hpp
+++ b/src/armnnUtils/ParserPrototxtFixture.hpp
@@ -6,13 +6,13 @@
#pragma once
#include <armnn/IRuntime.hpp>
-
#include <test/TensorHelpers.hpp>
#include <Network.hpp>
#include <VerificationHelpers.hpp>
#include <boost/format.hpp>
+#include <fmt/format.h>
#include <iomanip>
#include <string>
@@ -129,10 +129,9 @@ void ParserPrototxtFixture<TParser>::Setup(const std::map<std::string, armnn::Te
armnn::Status ret = m_Runtime->LoadNetwork(m_NetworkIdentifier, move(optimized), errorMessage);
if (ret != armnn::Status::Success)
{
- throw armnn::Exception(boost::str(
- boost::format("LoadNetwork failed with error: '%1%' %2%")
- % errorMessage
- % CHECK_LOCATION().AsString()));
+ throw armnn::Exception(fmt::format("LoadNetwork failed with error: '{0}' {1}",
+ errorMessage,
+ CHECK_LOCATION().AsString()));
}
}
@@ -147,10 +146,9 @@ void ParserPrototxtFixture<TParser>::Setup()
armnn::Status ret = m_Runtime->LoadNetwork(m_NetworkIdentifier, move(optimized), errorMessage);
if (ret != armnn::Status::Success)
{
- throw armnn::Exception(boost::str(
- boost::format("LoadNetwork failed with error: '%1%' %2%")
- % errorMessage
- % CHECK_LOCATION().AsString()));
+ throw armnn::Exception(fmt::format("LoadNetwork failed with error: '{0}' {1}",
+ errorMessage,
+ CHECK_LOCATION().AsString()));
}
}
@@ -214,13 +212,12 @@ void ParserPrototxtFixture<TParser>::RunTest(const std::map<std::string, std::ve
armnn::BindingPointInfo bindingInfo = m_Parser->GetNetworkOutputBindingInfo(it.first);
if (bindingInfo.second.GetNumElements() != it.second.size())
{
- throw armnn::Exception(
- boost::str(boost::format("Output tensor %1% is expected to have %2% elements. "
- "%3% elements supplied. %4%") %
- it.first %
- bindingInfo.second.GetNumElements() %
- it.second.size() %
- CHECK_LOCATION().AsString()));
+ throw armnn::Exception(fmt::format("Output tensor {0} is expected to have {1} elements. "
+ "{2} elements supplied. {3}",
+ it.first,
+ bindingInfo.second.GetNumElements(),
+ it.second.size(),
+ CHECK_LOCATION().AsString()));
}
// If the expected output shape is set, the output tensor checks will be carried out.
@@ -234,25 +231,25 @@ void ParserPrototxtFixture<TParser>::RunTest(const std::map<std::string, std::ve
{
if (m_SingleOutputShape[i] != bindingInfo.second.GetShape()[i])
{
- throw armnn::Exception(
- boost::str(boost::format("Output tensor %1% is expected to have %2% shape. "
- "%3% shape supplied. %4%") %
- it.first %
- bindingInfo.second.GetShape() %
- m_SingleOutputShape %
- CHECK_LOCATION().AsString()));
+ // This exception message could not be created by fmt:format because of an oddity in
+ // the operator << of TensorShape.
+ std::stringstream message;
+ message << "Output tensor " << it.first << " is expected to have "
+ << bindingInfo.second.GetShape() << "shape. "
+ << m_SingleOutputShape << " shape supplied. "
+ << CHECK_LOCATION().AsString();
+ throw armnn::Exception(message.str());
}
}
}
else
{
- throw armnn::Exception(
- boost::str(boost::format("Output tensor %1% is expected to have %2% dimensions. "
- "%3% dimensions supplied. %4%") %
- it.first %
- bindingInfo.second.GetShape().GetNumDimensions() %
- NumOutputDimensions %
- CHECK_LOCATION().AsString()));
+ throw armnn::Exception(fmt::format("Output tensor {0} is expected to have {1} dimensions. "
+ "{2} dimensions supplied. {3}",
+ it.first,
+ bindingInfo.second.GetShape().GetNumDimensions(),
+ NumOutputDimensions,
+ CHECK_LOCATION().AsString()));
}
}
diff --git a/src/armnnUtils/TensorIOUtils.hpp b/src/armnnUtils/TensorIOUtils.hpp
index 098b4dadec..b06bb7132b 100644
--- a/src/armnnUtils/TensorIOUtils.hpp
+++ b/src/armnnUtils/TensorIOUtils.hpp
@@ -7,7 +7,7 @@
#include <armnn/Tensor.hpp>
-#include <boost/format.hpp>
+#include <fmt/format.h>
#include <mapbox/variant.hpp>
namespace armnnUtils
@@ -22,10 +22,10 @@ inline armnn::InputTensors MakeInputTensors(const std::vector<armnn::BindingPoin
const size_t numInputs = inputBindings.size();
if (numInputs != inputDataContainers.size())
{
- throw armnn::Exception(boost::str(boost::format("The number of inputs does not match number of "
- "tensor data containers: %1% != %2%")
- % numInputs
- % inputDataContainers.size()));
+ throw armnn::Exception(fmt::format("The number of inputs does not match number of "
+ "tensor data containers: {0} != {1}",
+ numInputs,
+ inputDataContainers.size()));
}
for (size_t i = 0; i < numInputs; i++)
@@ -37,10 +37,9 @@ inline armnn::InputTensors MakeInputTensors(const std::vector<armnn::BindingPoin
{
if (value.size() != inputBinding.second.GetNumElements())
{
- throw armnn::Exception(boost::str(boost::format("The input tensor has incorrect size "
- "(expected %1% got %2%)")
- % inputBinding.second.GetNumElements()
- % value.size()));
+ throw armnn::Exception(fmt::format("The input tensor has incorrect size (expected {0} got {1})",
+ inputBinding.second.GetNumElements(),
+ value.size()));
}
armnn::ConstTensor inputTensor(inputBinding.second, value.data());
@@ -61,10 +60,10 @@ inline armnn::OutputTensors MakeOutputTensors(const std::vector<armnn::BindingPo
const size_t numOutputs = outputBindings.size();
if (numOutputs != outputDataContainers.size())
{
- throw armnn::Exception(boost::str(boost::format("Number of outputs does not match number of "
- "tensor data containers: %1% != %2%")
- % numOutputs
- % outputDataContainers.size()));
+ throw armnn::Exception(fmt::format("Number of outputs does not match number"
+ "of tensor data containers: {0} != {1}",
+ numOutputs,
+ outputDataContainers.size()));
}
for (size_t i = 0; i < numOutputs; i++)
diff --git a/src/armnnUtils/TensorUtils.cpp b/src/armnnUtils/TensorUtils.cpp
index adaf8114f1..2890399cd8 100644
--- a/src/armnnUtils/TensorUtils.cpp
+++ b/src/armnnUtils/TensorUtils.cpp
@@ -9,7 +9,7 @@
#include <armnn/utility/Assert.hpp>
#include <armnn/utility/NumericCast.hpp>
-#include <boost/format.hpp>
+#include <fmt/format.h>
using namespace armnn;
@@ -88,11 +88,10 @@ TensorShape ExpandDims(const TensorShape& tensorShape, int axis)
if (axis < -armnn::numeric_cast<int>(outputDim) || axis > armnn::numeric_cast<int>(tensorShape.GetNumDimensions()))
{
- throw InvalidArgumentException(
- boost::str(boost::format("Invalid expansion axis %1% for %2%D input tensor. %3%") %
- axis %
- tensorShape.GetNumDimensions() %
- CHECK_LOCATION().AsString()));
+ throw InvalidArgumentException(fmt::format("Invalid expansion axis {} for {}D input tensor. {}",
+ axis,
+ tensorShape.GetNumDimensions(),
+ CHECK_LOCATION().AsString()));
}
if (axis < 0)
@@ -101,6 +100,7 @@ TensorShape ExpandDims(const TensorShape& tensorShape, int axis)
}
std::vector<unsigned int> outputShape;
+ outputShape.reserve(tensorShape.GetNumDimensions());
for (unsigned int i = 0; i < tensorShape.GetNumDimensions(); ++i)
{
outputShape.push_back(tensorShape[i]);
diff --git a/src/armnnUtils/VerificationHelpers.cpp b/src/armnnUtils/VerificationHelpers.cpp
index 243d22e444..a4db97adf4 100644
--- a/src/armnnUtils/VerificationHelpers.cpp
+++ b/src/armnnUtils/VerificationHelpers.cpp
@@ -4,9 +4,10 @@
//
#include "VerificationHelpers.hpp"
-#include <boost/format.hpp>
#include <armnn/Exceptions.hpp>
+#include <fmt/format.h>
+
using namespace armnn;
namespace armnnUtils
@@ -23,13 +24,11 @@ void CheckValidSize(std::initializer_list<size_t> validInputCounts,
[&actualValue](size_t x) { return x == actualValue; } );
if (!isValid)
{
- throw ParseException(
- boost::str(
- boost::format("%1% = %2% is not valid, not in {%3%}. %4%") %
- actualExpr %
- actualValue %
- validExpr %
- location.AsString()));
+ throw ParseException(fmt::format("{} = {} is not valid, not in {{}}. {}",
+ actualExpr,
+ actualValue,
+ validExpr,
+ location.AsString()));
}
}
@@ -39,12 +38,10 @@ uint32_t NonNegative(const char* expr,
{
if (value < 0)
{
- throw ParseException(
- boost::str(
- boost::format("'%1%' must be non-negative, received: %2% at %3%") %
- expr %
- value %
- location.AsString() ));
+ throw ParseException(fmt::format("'{}' must be non-negative, received: {} at {}",
+ expr,
+ value,
+ location.AsString()));
}
else
{
@@ -58,12 +55,11 @@ int32_t VerifyInt32(const char* expr,
{
if (value < std::numeric_limits<int>::min() || value > std::numeric_limits<int>::max())
{
- throw ParseException(
- boost::str(
- boost::format("'%1%' must should fit into a int32 (ArmNN don't support int64), received: %2% at %3%") %
- expr %
- value %
- location.AsString() ));
+ throw ParseException(fmt::format("'{}' must should fit into a int32 (ArmNN don't support int64),"
+ " received: {} at {}",
+ expr,
+ value,
+ location.AsString()));
}
else
{