GitHub #292 Build the ML-examples using only ArmNN's public frontend API

 * Refactoring of some of the public API headers

Signed-off-by: Matteo Martincigh <matteo.martincigh@arm.com>
Change-Id: I9006fe49945b10a6b83908b05aa4a6556639b491
diff --git a/include/armnn/Utils.hpp b/include/armnn/Utils.hpp
index d91cc79..26a27f4 100644
--- a/include/armnn/Utils.hpp
+++ b/include/armnn/Utils.hpp
@@ -6,8 +6,6 @@
 
 #include "armnn/TypesUtils.hpp"
 
-#include <vector>
-
 namespace armnn
 {
 
diff --git a/src/armnn/NetworkQuantizer.cpp b/src/armnn/NetworkQuantizer.cpp
index f308d54..4a8bae5 100644
--- a/src/armnn/NetworkQuantizer.cpp
+++ b/src/armnn/NetworkQuantizer.cpp
@@ -3,36 +3,34 @@
 // SPDX-License-Identifier: MIT
 //
 
-#include <armnn/ILayerVisitor.hpp>
-#include <armnn/INetwork.hpp>
-#include <armnn/Tensor.hpp>
-#include <armnn/Types.hpp>
-#include <TensorUtils.hpp>
-#include <TensorIOUtils.hpp>
-
+#include "NetworkQuantizer.hpp"
+#include "NetworkQuantizerUtils.hpp"
 #include "Graph.hpp"
 #include "Layer.hpp"
 #include "Network.hpp"
-#include "NetworkQuantizer.hpp"
-#include "NetworkQuantizerUtils.hpp"
-
 #include "DynamicQuantizationVisitor.hpp"
 #include "StaticRangeVisitor.hpp"
 #include "QuantizerVisitor.hpp"
 #include "OverrideInputRangeVisitor.hpp"
 
-#include <vector>
-#include <cmath>
+#include <armnn/ILayerVisitor.hpp>
+#include <armnn/INetwork.hpp>
+#include <armnn/Tensor.hpp>
+#include <armnn/Types.hpp>
+
+#include <TensorUtils.hpp>
+#include <TensorIOUtils.hpp>
 
 #include <boost/variant.hpp>
 
+#include <vector>
+#include <cmath>
 
 namespace armnn
 {
 
 using TContainer = boost::variant<std::vector<float>, std::vector<int>, std::vector<unsigned char>>;
 
-
 INetworkQuantizer* INetworkQuantizer::CreateRaw(INetwork* inputNetwork, const QuantizerOptions& options)
 {
     return new NetworkQuantizer(inputNetwork, options);
diff --git a/src/armnnUtils/TensorIOUtils.hpp b/src/armnnUtils/TensorIOUtils.hpp
index 07f3723..1dc7f21 100644
--- a/src/armnnUtils/TensorIOUtils.hpp
+++ b/src/armnnUtils/TensorIOUtils.hpp
@@ -6,7 +6,6 @@
 #pragma once
 
 #include <armnn/Tensor.hpp>
-#include <vector>
 
 #include <boost/format.hpp>
 #include <boost/variant/apply_visitor.hpp>
@@ -15,17 +14,18 @@
 {
 
 template<typename TContainer>
-inline armnn::InputTensors MakeInputTensors(
-    const std::vector<armnn::BindingPointInfo>& inputBindings,
-    const std::vector<TContainer>& inputDataContainers)
+inline armnn::InputTensors MakeInputTensors(const std::vector<armnn::BindingPointInfo>& inputBindings,
+                                            const std::vector<TContainer>& inputDataContainers)
 {
     armnn::InputTensors inputTensors;
 
     const size_t numInputs = inputBindings.size();
     if (numInputs != inputDataContainers.size())
     {
-        throw armnn::Exception(boost::str(boost::format("Number of inputs does not match number of "
-            "tensor data containers: %1% != %2%") % 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()));
     }
 
     for (size_t i = 0; i < numInputs; i++)
@@ -34,28 +34,27 @@
         const TContainer& inputData = inputDataContainers[i];
 
         boost::apply_visitor([&](auto&& value)
-                             {
-                                 if (value.size() != inputBinding.second.GetNumElements())
-                                 {
-                                    throw armnn::Exception(boost::str(boost::format("Input tensor has incorrect size "
-                                                                                    "(expected %1% got %2%)")
-                                                                      % inputBinding.second.GetNumElements()
-                                                                      % value.size()));
-                                 }
+        {
+            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()));
+            }
 
-                                 armnn::ConstTensor inputTensor(inputBinding.second, value.data());
-                                 inputTensors.push_back(std::make_pair(inputBinding.first, inputTensor));
-                             },
-                             inputData);
+            armnn::ConstTensor inputTensor(inputBinding.second, value.data());
+            inputTensors.push_back(std::make_pair(inputBinding.first, inputTensor));
+        },
+        inputData);
     }
 
     return inputTensors;
 }
 
 template<typename TContainer>
-inline armnn::OutputTensors MakeOutputTensors(
-    const std::vector<armnn::BindingPointInfo>& outputBindings,
-    std::vector<TContainer>& outputDataContainers)
+inline armnn::OutputTensors MakeOutputTensors(const std::vector<armnn::BindingPointInfo>& outputBindings,
+                                              std::vector<TContainer>& outputDataContainers)
 {
     armnn::OutputTensors outputTensors;
 
@@ -63,7 +62,9 @@
     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()));
+                                                        "tensor data containers: %1% != %2%")
+                                          % numOutputs
+                                          % outputDataContainers.size()));
     }
 
     for (size_t i = 0; i < numOutputs; i++)
@@ -72,16 +73,16 @@
         TContainer& outputData = outputDataContainers[i];
 
         boost::apply_visitor([&](auto&& value)
-                             {
-                                 if (value.size() != outputBinding.second.GetNumElements())
-                                 {
-                                     throw armnn::Exception("Output tensor has incorrect size");
-                                 }
+        {
+            if (value.size() != outputBinding.second.GetNumElements())
+            {
+                throw armnn::Exception("Output tensor has incorrect size");
+            }
 
-                                 armnn::Tensor outputTensor(outputBinding.second, value.data());
-                                 outputTensors.push_back(std::make_pair(outputBinding.first, outputTensor));
-                             },
-                             outputData);
+            armnn::Tensor outputTensor(outputBinding.second, value.data());
+            outputTensors.push_back(std::make_pair(outputBinding.first, outputTensor));
+        },
+        outputData);
     }
 
     return outputTensors;
diff --git a/src/armnnUtils/TensorUtils.cpp b/src/armnnUtils/TensorUtils.cpp
index b4e8d5a..0dbb75c 100644
--- a/src/armnnUtils/TensorUtils.cpp
+++ b/src/armnnUtils/TensorUtils.cpp
@@ -4,55 +4,58 @@
 //
 
 #include "TensorUtils.hpp"
+
 #include <backendsCommon/ITensorHandle.hpp>
 
 #include <boost/assert.hpp>
 #include <boost/format.hpp>
 #include <boost/numeric/conversion/cast.hpp>
 
+using namespace armnn;
+
 namespace armnnUtils
 {
 
-armnn::TensorShape GetTensorShape(unsigned int numberOfBatches,
+TensorShape GetTensorShape(unsigned int numberOfBatches,
                                   unsigned int numberOfChannels,
                                   unsigned int height,
                                   unsigned int width,
-                                  const armnn::DataLayout dataLayout)
+                                  const DataLayout dataLayout)
 {
     switch (dataLayout)
     {
-        case armnn::DataLayout::NCHW:
-            return armnn::TensorShape({numberOfBatches, numberOfChannels, height, width});
-        case armnn::DataLayout::NHWC:
-            return armnn::TensorShape({numberOfBatches, height, width, numberOfChannels});
+        case DataLayout::NCHW:
+            return TensorShape({numberOfBatches, numberOfChannels, height, width});
+        case DataLayout::NHWC:
+            return TensorShape({numberOfBatches, height, width, numberOfChannels});
         default:
-            throw armnn::InvalidArgumentException("Unknown data layout ["
+            throw InvalidArgumentException("Unknown data layout ["
                                                   + std::to_string(static_cast<int>(dataLayout)) +
                                                   "]", CHECK_LOCATION());
     }
 }
 
-armnn::TensorInfo GetTensorInfo(unsigned int numberOfBatches,
+TensorInfo GetTensorInfo(unsigned int numberOfBatches,
                                 unsigned int numberOfChannels,
                                 unsigned int height,
                                 unsigned int width,
-                                const armnn::DataLayout dataLayout,
-                                const armnn::DataType dataType)
+                                const DataLayout dataLayout,
+                                const DataType dataType)
 {
     switch (dataLayout)
     {
-        case armnn::DataLayout::NCHW:
-            return armnn::TensorInfo({numberOfBatches, numberOfChannels, height, width}, dataType);
-        case armnn::DataLayout::NHWC:
-            return armnn::TensorInfo({numberOfBatches, height, width, numberOfChannels}, dataType);
+        case DataLayout::NCHW:
+            return TensorInfo({numberOfBatches, numberOfChannels, height, width}, dataType);
+        case DataLayout::NHWC:
+            return TensorInfo({numberOfBatches, height, width, numberOfChannels}, dataType);
         default:
-            throw armnn::InvalidArgumentException("Unknown data layout ["
+            throw InvalidArgumentException("Unknown data layout ["
                                                   + std::to_string(static_cast<int>(dataLayout)) +
                                                   "]", CHECK_LOCATION());
     }
 }
 
-std::pair<float, float> FindMinMax(armnn::ITensorHandle* tensorHandle)
+std::pair<float, float> FindMinMax(ITensorHandle* tensorHandle)
 {
     auto tensor_data = static_cast<const float *>(tensorHandle->Map(true));
     auto tensor_size = tensorHandle->GetShape().GetNumElements();
@@ -79,13 +82,13 @@
     return std::make_pair(min, max);
 }
 
-armnn::TensorShape ExpandDims(const armnn::TensorShape& tensorShape, int axis)
+TensorShape ExpandDims(const TensorShape& tensorShape, int axis)
 {
     unsigned int outputDim = tensorShape.GetNumDimensions() + 1;
 
     if (axis < -boost::numeric_cast<int>(outputDim) || axis > boost::numeric_cast<int>(tensorShape.GetNumDimensions()))
     {
-        throw armnn::InvalidArgumentException(
+        throw InvalidArgumentException(
             boost::str(boost::format("Invalid expansion axis %1% for %2%D input tensor. %3%") %
                        axis %
                        tensorShape.GetNumDimensions() %
@@ -104,10 +107,10 @@
     }
     outputShape.insert(outputShape.begin() + axis, 1);
 
-    return armnn::TensorShape(outputDim, outputShape.data());
+    return TensorShape(outputDim, outputShape.data());
 }
 
-unsigned int GetNumElementsBetween(const armnn::TensorShape& shape,
+unsigned int GetNumElementsBetween(const TensorShape& shape,
                                    const unsigned int firstAxisInclusive,
                                    const unsigned int lastAxisExclusive)
 {
@@ -135,4 +138,4 @@
     return uAxis;
 }
 
-}
+} // namespace armnnUtils
diff --git a/tests/InferenceTestImage.hpp b/tests/InferenceTestImage.hpp
index 643d060..d15f263 100644
--- a/tests/InferenceTestImage.hpp
+++ b/tests/InferenceTestImage.hpp
@@ -128,15 +128,15 @@
 // and now lie in the range [0,1]. Channel data is stored according to the ArmNN layout (CHW). The order in which
 // channels appear in the resulting vector is defined by the provided layout.
 std::vector<float> GetImageDataInArmNnLayoutAsNormalizedFloats(ImageChannelLayout layout,
-    const InferenceTestImage& image);
+                                                               const InferenceTestImage& image);
 
 // Reads the contents of an inference test image as 3-channel pixels, whose value is the result of subtracting the mean
 // from the values in the original image. Channel data is stored according to the ArmNN layout (CHW). The order in
 // which channels appear in the resulting vector is defined by the provided layout. The order of the channels of the
 // provided mean should also match the given layout.
 std::vector<float> GetImageDataInArmNnLayoutAsFloatsSubtractingMean(ImageChannelLayout layout,
-    const InferenceTestImage& image,
-    const std::array<float, 3>& mean);
+                                                                    const InferenceTestImage& image,
+                                                                    const std::array<float, 3>& mean);
 
 // Reads the contents of an inference test image as 3-channel pixels and returns the image data as normalized float
 // values. The returned image stay in the original order (HWC) order. The C order may be changed according to the