From 5b5c222f6b0c40a8e0f9ef9dedccd6f0f18c4c2c Mon Sep 17 00:00:00 2001 From: Colm Donelan Date: Wed, 9 Sep 2020 12:48:16 +0100 Subject: 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 Change-Id: I4b2ed0f72039df824a2adca9309b8a9bbb158c5b --- src/armnn/Graph.cpp | 13 ++++++------- src/armnn/Layer.cpp | 37 ++++++++++++++++--------------------- src/armnn/LoadedNetwork.cpp | 26 +++++++++++--------------- 3 files changed, 33 insertions(+), 43 deletions(-) (limited to 'src/armnn') diff --git a/src/armnn/Graph.cpp b/src/armnn/Graph.cpp index a497a45da9..30546e1f0a 100644 --- a/src/armnn/Graph.cpp +++ b/src/armnn/Graph.cpp @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include @@ -312,12 +312,11 @@ void Graph::AddCompatibilityLayers(std::map %3% (%4%) ]") - % srcLayer->GetName() - % srcOutputIndex - % dstLayer.GetName() - % dstInputSlot->GetSlotIndex()); - + const std::string compLayerName = fmt::format("[ {} ({}) -> {} ({}) ]", + srcLayer->GetName(), + srcOutputIndex, + dstLayer.GetName(), + dstInputSlot->GetSlotIndex()); Layer* compLayer = nullptr; if (strategy == EdgeStrategy::CopyToTarget) { diff --git a/src/armnn/Layer.cpp b/src/armnn/Layer.cpp index c8d5a1690d..d06b0459f6 100644 --- a/src/armnn/Layer.cpp +++ b/src/armnn/Layer.cpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include @@ -159,8 +159,7 @@ void OutputSlot::ValidateConnectionIndex(unsigned int index) const { if (armnn::numeric_cast(index) >= m_Connections.size()) { - throw InvalidArgumentException( - boost::str(boost::format("GetConnection: Invalid index %1% provided") % index)); + throw InvalidArgumentException((fmt::format("GetConnection: Invalid index {} provided", index))); } } @@ -350,14 +349,12 @@ void Layer::VerifyLayerConnections(unsigned int expectedConnections, const Check if (GetInputSlot(i).GetConnection() == nullptr) { throw LayerValidationException( - boost::str( - boost::format( - "Input connection #%1% must be connected " - "for %2% layer %3% %4%") - % i - % GetLayerTypeAsCString(this->GetType()) - % GetNameStr() - % location.AsString())); + fmt::format("Input connection #{0} must be connected " + "for {1} layer {2} {3}", + i, + GetLayerTypeAsCString(this->GetType()), + GetNameStr(), + location.AsString())); } } } @@ -375,16 +372,14 @@ std::vector Layer::InferOutputShapes(const std::vector if (GetNumInputSlots() != GetNumOutputSlots()) { throw UnimplementedException( - boost::str( - boost::format( - "Default implementation for InferOutputShapes can only be used for " - "layers with the same number of input and output slots. This doesn't " - "hold for %1% layer %2% (#inputs=%3% #outputs=%4%) %5%") - % GetLayerTypeAsCString(this->GetType()) - % GetNameStr() - % GetNumInputSlots() - % GetNumOutputSlots() - % CHECK_LOCATION().AsString())); + fmt::format("Default implementation for InferOutputShapes can only be used for " + "layers with the same number of input and output slots. This doesn't " + "hold for {0} layer {1} (#inputs={2} #outputs={3}) {4}", + GetLayerTypeAsCString(this->GetType()), + GetNameStr(), + GetNumInputSlots(), + GetNumOutputSlots(), + CHECK_LOCATION().AsString())); } return inputShapes; } diff --git a/src/armnn/LoadedNetwork.cpp b/src/armnn/LoadedNetwork.cpp index 33625744c5..00ac90b121 100644 --- a/src/armnn/LoadedNetwork.cpp +++ b/src/armnn/LoadedNetwork.cpp @@ -8,7 +8,6 @@ #include "Graph.hpp" #include "Network.hpp" #include -#include "Runtime.hpp" #include "Profiling.hpp" #include "HeapProfiling.hpp" @@ -23,7 +22,7 @@ #include -#include +#include namespace armnn { @@ -236,9 +235,9 @@ LoadedNetwork::LoadedNetwork(std::unique_ptr net, { const char* const layerName = layer->GetNameStr().length() != 0 ? layer->GetName() : ""; - throw InvalidArgumentException(boost::str( - boost::format("No workload created for layer (name: '%1%' type: '%2%') (compute '%3%')") - % layerName % static_cast(layer->GetType()) % layer->GetBackendId().Get() + throw InvalidArgumentException( + fmt::format("No workload created for layer (name: '{0}' type: '{1}') (compute '{2}')", + layerName, static_cast(layer->GetType()), layer->GetBackendId().Get() )); } @@ -325,7 +324,7 @@ TensorInfo LoadedNetwork::GetInputTensorInfo(LayerBindingId layerId) const } } - throw InvalidArgumentException(boost::str(boost::format("No input layer is associated with id %1%") % layerId)); + throw InvalidArgumentException(fmt::format("No input layer is associated with id {}", layerId)); } TensorInfo LoadedNetwork::GetOutputTensorInfo(LayerBindingId layerId) const @@ -340,7 +339,7 @@ TensorInfo LoadedNetwork::GetOutputTensorInfo(LayerBindingId layerId) const } } - throw InvalidArgumentException(boost::str(boost::format("No output layer is associated with id %1%") % layerId)); + throw InvalidArgumentException(fmt::format("No output layer is associated with id {}", layerId)); } const IWorkloadFactory& LoadedNetwork::GetWorkloadFactory(const Layer& layer) const @@ -350,12 +349,10 @@ const IWorkloadFactory& LoadedNetwork::GetWorkloadFactory(const Layer& layer) co auto it = m_WorkloadFactories.find(layer.GetBackendId()); if (it == m_WorkloadFactories.end()) { - throw RuntimeException( - boost::str( - boost::format("No workload factory for %1% to be used for layer: %2%") - % layer.GetBackendId().Get() - % layer.GetNameStr()), - CHECK_LOCATION()); + throw RuntimeException(fmt::format("No workload factory for {0} to be used for layer: {1}", + layer.GetBackendId().Get(), + layer.GetNameStr()), + CHECK_LOCATION()); } workloadFactory = it->second.first.get(); @@ -411,8 +408,7 @@ static const TensorPin& GetTensorPin(LayerBindingId id, } else { - throw InvalidArgumentException(boost::str( - boost::format("No tensor supplied for %1% %2%") % bindingPointDesc % id)); + throw InvalidArgumentException(fmt::format("No tensor supplied for {0} {1}", bindingPointDesc, id)); } } -- cgit v1.2.1