From e011d20f279e6e67e899bc6930b0266fc357bc1c Mon Sep 17 00:00:00 2001 From: Matteo Martincigh Date: Thu, 28 Nov 2019 11:35:47 +0000 Subject: IVGCVSW-4209 Create a public API for the ArmNN Utils * Moved the relevant armnnUtils headers to the new location: include/armnnUtils * Update the header usage throughout the source code !android-nn-driver:2387 Signed-off-by: Matteo Martincigh Change-Id: I2ba15cebcacafad2b5a1a7b9c3312ffc585e09d6 --- CMakeLists.txt | 8 +- include/armnnUtils/DataLayoutIndexed.hpp | 72 ++++++++++++++ include/armnnUtils/FloatingPointConverter.hpp | 23 +++++ include/armnnUtils/Permute.hpp | 21 ++++ include/armnnUtils/TensorUtils.hpp | 41 ++++++++ src/armnn/NetworkQuantizer.cpp | 5 +- src/armnn/layers/ArgMinMaxLayer.cpp | 9 +- src/armnn/layers/BatchToSpaceNdLayer.cpp | 6 +- src/armnn/layers/Convolution2dLayer.cpp | 7 +- src/armnn/layers/DepthToSpaceLayer.cpp | 5 +- src/armnn/layers/DepthwiseConvolution2dLayer.cpp | 6 +- src/armnn/layers/PermuteLayer.cpp | 6 +- src/armnn/layers/Pooling2dLayer.cpp | 5 +- src/armnn/layers/ResizeLayer.cpp | 6 +- src/armnn/layers/SpaceToBatchNdLayer.cpp | 5 +- src/armnn/layers/SpaceToDepthLayer.cpp | 5 +- src/armnn/layers/TransposeConvolution2dLayer.cpp | 6 +- src/armnn/optimizations/ConvertConstants.hpp | 3 +- src/armnn/optimizations/MovePermuteUp.hpp | 3 +- src/armnn/test/CreateWorkload.hpp | 11 ++- src/armnn/test/FloatingPointConverterTest.cpp | 3 +- src/armnn/test/OptimizerTests.cpp | 7 +- src/armnnDeserializer/Deserializer.cpp | 3 +- src/armnnTfLiteParser/TfLiteParser.cpp | 7 +- src/armnnTfParser/TfParser.cpp | 5 +- src/armnnTfParser/test/DepthwiseConvolution2d.cpp | 10 +- src/armnnUtils/DataLayoutIndexed.cpp | 3 +- src/armnnUtils/DataLayoutIndexed.hpp | 72 -------------- src/armnnUtils/FloatingPointConverter.cpp | 2 +- src/armnnUtils/FloatingPointConverter.hpp | 21 ---- src/armnnUtils/ParserHelper.cpp | 2 +- src/armnnUtils/Permute.cpp | 5 +- src/armnnUtils/Permute.hpp | 20 ---- src/armnnUtils/TensorUtils.cpp | 2 +- src/armnnUtils/TensorUtils.hpp | 41 -------- src/armnnUtils/test/TensorUtilsTest.cpp | 4 +- src/backends/backendsCommon/WorkloadData.cpp | 5 +- src/backends/backendsCommon/WorkloadUtils.hpp | 3 +- .../backendsCommon/test/DataLayoutUtils.hpp | 4 +- .../test/InstanceNormalizationEndToEndTestImpl.cpp | 7 +- .../backendsCommon/test/ResizeEndToEndTestImpl.hpp | 3 +- .../test/SpaceToDepthEndToEndTestImpl.cpp | 7 +- .../TransposeConvolution2dEndToEndTestImpl.hpp | 3 +- .../test/layerTests/BatchNormalizationTestImpl.cpp | 3 +- .../test/layerTests/ConcatTestImpl.cpp | 3 +- .../test/layerTests/ConstantTestImpl.cpp | 3 +- .../test/layerTests/Conv2dTestImpl.cpp | 7 +- .../test/layerTests/L2NormalizationTestImpl.cpp | 5 +- .../test/layerTests/Pooling2dTestImpl.cpp | 11 ++- .../test/layerTests/ResizeTestImpl.cpp | 7 +- .../test/layerTests/SpaceToBatchNdTestImpl.cpp | 3 +- .../test/layerTests/SpaceToDepthTestImpl.cpp | 3 +- .../layerTests/TransposeConvolution2dTestImpl.cpp | 5 +- src/backends/cl/workloads/ClArgMinMaxWorkload.cpp | 2 +- .../neon/workloads/NeonArgMinMaxWorkload.cpp | 4 +- .../workloads/NeonConvertFp16ToFp32Workload.cpp | 4 +- .../workloads/NeonConvertFp32ToFp16Workload.cpp | 4 +- .../workloads/NeonDepthwiseConvolutionWorkload.cpp | 5 +- src/backends/reference/RefLayerSupport.cpp | 11 ++- src/backends/reference/workloads/ArgMinMax.cpp | 2 +- src/backends/reference/workloads/BaseIterator.hpp | 5 +- src/backends/reference/workloads/BatchNormImpl.cpp | 2 +- .../reference/workloads/BatchToSpaceNd.hpp | 11 ++- src/backends/reference/workloads/ConvImpl.hpp | 4 +- src/backends/reference/workloads/Decoders.hpp | 5 +- src/backends/reference/workloads/DepthToSpace.cpp | 4 +- src/backends/reference/workloads/Encoders.hpp | 3 +- src/backends/reference/workloads/InstanceNorm.cpp | 2 +- src/backends/reference/workloads/LogSoftmax.cpp | 2 +- src/backends/reference/workloads/Pooling2d.cpp | 3 +- .../workloads/RefConvertFp16ToFp32Workload.cpp | 4 +- .../workloads/RefConvertFp32ToFp16Workload.cpp | 6 +- .../workloads/RefL2NormalizationWorkload.cpp | 108 ++++++++++----------- .../workloads/RefNormalizationWorkload.cpp | 4 +- .../reference/workloads/RefPermuteWorkload.cpp | 3 +- src/backends/reference/workloads/Resize.hpp | 5 +- src/backends/reference/workloads/Softmax.cpp | 2 +- .../reference/workloads/SpaceToBatchNd.cpp | 2 +- src/backends/reference/workloads/SpaceToDepth.cpp | 2 +- .../reference/workloads/TensorBufferArrayView.hpp | 4 +- .../reference/workloads/TransposeConvolution2d.cpp | 2 +- tests/ImagePreprocessor.cpp | 5 +- .../ImageTensorGenerator/ImageTensorGenerator.hpp | 6 +- 83 files changed, 415 insertions(+), 353 deletions(-) create mode 100644 include/armnnUtils/DataLayoutIndexed.hpp create mode 100644 include/armnnUtils/FloatingPointConverter.hpp create mode 100644 include/armnnUtils/Permute.hpp create mode 100644 include/armnnUtils/TensorUtils.hpp delete mode 100644 src/armnnUtils/DataLayoutIndexed.hpp delete mode 100644 src/armnnUtils/FloatingPointConverter.hpp delete mode 100644 src/armnnUtils/Permute.hpp delete mode 100644 src/armnnUtils/TensorUtils.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 21d1336578..ad9e9ee91d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,14 +36,16 @@ add_custom_target(AdditionalCMakeFiles SOURCES ${additional_cmake_files}) set(armnnUtils_sources) list(APPEND armnnUtils_sources + include/armnnUtils/DataLayoutIndexed.hpp + include/armnnUtils/Permute.hpp + include/armnnUtils/FloatingPointConverter.hpp + include/armnnUtils/TensorUtils.hpp src/armnnUtils/GraphTopologicalSort.hpp src/armnnUtils/Half.hpp src/armnnUtils/Logging.hpp src/armnnUtils/Logging.cpp - src/armnnUtils/Permute.hpp src/armnnUtils/Permute.cpp src/armnnUtils/DataLayoutIndexed.cpp - src/armnnUtils/DataLayoutIndexed.hpp src/armnnUtils/DotSerializer.cpp src/armnnUtils/DotSerializer.hpp src/armnnUtils/HeapProfiling.cpp @@ -55,7 +57,6 @@ list(APPEND armnnUtils_sources src/armnnUtils/CsvReader.cpp src/armnnUtils/CsvReader.hpp src/armnnUtils/FloatingPointConverter.cpp - src/armnnUtils/FloatingPointConverter.hpp src/armnnUtils/VerificationHelpers.hpp src/armnnUtils/VerificationHelpers.cpp src/armnnUtils/ParserHelper.hpp @@ -65,7 +66,6 @@ list(APPEND armnnUtils_sources src/armnnUtils/PrototxtConversions.cpp src/armnnUtils/QuantizeHelper.hpp src/armnnUtils/TensorIOUtils.hpp - src/armnnUtils/TensorUtils.hpp src/armnnUtils/TensorUtils.cpp ) diff --git a/include/armnnUtils/DataLayoutIndexed.hpp b/include/armnnUtils/DataLayoutIndexed.hpp new file mode 100644 index 0000000000..03404bda5d --- /dev/null +++ b/include/armnnUtils/DataLayoutIndexed.hpp @@ -0,0 +1,72 @@ +// +// Copyright © 2019 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#pragma once + +#include +#include + +#include + +namespace armnnUtils +{ + +// Provides access to the appropriate indexes for Channels, Height and Width based on DataLayout +class DataLayoutIndexed +{ +public: + DataLayoutIndexed(armnn::DataLayout dataLayout); + + armnn::DataLayout GetDataLayout() const { return m_DataLayout; } + unsigned int GetChannelsIndex() const { return m_ChannelsIndex; } + unsigned int GetHeightIndex() const { return m_HeightIndex; } + unsigned int GetWidthIndex() const { return m_WidthIndex; } + + inline unsigned int GetIndex(const armnn::TensorShape& shape, + unsigned int batchIndex, unsigned int channelIndex, + unsigned int heightIndex, unsigned int widthIndex) const + { + BOOST_ASSERT( batchIndex < shape[0] || ( shape[0] == 0 && batchIndex == 0 ) ); + BOOST_ASSERT( channelIndex < shape[m_ChannelsIndex] || + ( shape[m_ChannelsIndex] == 0 && channelIndex == 0) ); + BOOST_ASSERT( heightIndex < shape[m_HeightIndex] || + ( shape[m_HeightIndex] == 0 && heightIndex == 0) ); + BOOST_ASSERT( widthIndex < shape[m_WidthIndex] || + ( shape[m_WidthIndex] == 0 && widthIndex == 0) ); + + // Offset the given indices appropriately depending on the data layout + switch (m_DataLayout) + { + case armnn::DataLayout::NHWC: + batchIndex *= shape[1] * shape[2] * shape[3]; // batchIndex *= heightIndex * widthIndex * channelIndex + heightIndex *= shape[m_WidthIndex] * shape[m_ChannelsIndex]; + widthIndex *= shape[m_ChannelsIndex]; + // channelIndex stays unchanged + break; + case armnn::DataLayout::NCHW: + default: + batchIndex *= shape[1] * shape[2] * shape[3]; // batchIndex *= heightIndex * widthIndex * channelIndex + channelIndex *= shape[m_HeightIndex] * shape[m_WidthIndex]; + heightIndex *= shape[m_WidthIndex]; + // widthIndex stays unchanged + break; + } + + // Get the value using the correct offset + return batchIndex + channelIndex + heightIndex + widthIndex; + } + +private: + armnn::DataLayout m_DataLayout; + unsigned int m_ChannelsIndex; + unsigned int m_HeightIndex; + unsigned int m_WidthIndex; +}; + +// Equality methods +bool operator==(const armnn::DataLayout& dataLayout, const DataLayoutIndexed& indexed); +bool operator==(const DataLayoutIndexed& indexed, const armnn::DataLayout& dataLayout); + +} // namespace armnnUtils diff --git a/include/armnnUtils/FloatingPointConverter.hpp b/include/armnnUtils/FloatingPointConverter.hpp new file mode 100644 index 0000000000..cf573a2ee8 --- /dev/null +++ b/include/armnnUtils/FloatingPointConverter.hpp @@ -0,0 +1,23 @@ +// +// Copyright © 2019 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#pragma once + +#include + +namespace armnnUtils +{ + +class FloatingPointConverter +{ +public: + // Converts a buffer of FP32 values to FP16, and stores in the given dstFloat16Buffer. + // dstFloat16Buffer should be (numElements * 2) in size + static void ConvertFloat32To16(const float *srcFloat32Buffer, size_t numElements, void *dstFloat16Buffer); + + static void ConvertFloat16To32(const void *srcFloat16Buffer, size_t numElements, float *dstFloat32Buffer); +}; + +} // namespace armnnUtils diff --git a/include/armnnUtils/Permute.hpp b/include/armnnUtils/Permute.hpp new file mode 100644 index 0000000000..1ae00a136b --- /dev/null +++ b/include/armnnUtils/Permute.hpp @@ -0,0 +1,21 @@ +// +// Copyright © 2019 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#pragma once + +#include +#include + +namespace armnnUtils +{ + +armnn::TensorShape Permuted(const armnn::TensorShape& srcShape, const armnn::PermutationVector& mappings); + +armnn::TensorInfo Permuted(const armnn::TensorInfo& info, const armnn::PermutationVector& mappings); + +void Permute(const armnn::TensorShape& dstShape, const armnn::PermutationVector& mappings, + const void* src, void* dst, size_t dataTypeSize); + +} // namespace armnnUtils diff --git a/include/armnnUtils/TensorUtils.hpp b/include/armnnUtils/TensorUtils.hpp new file mode 100644 index 0000000000..fbfb8f4e1e --- /dev/null +++ b/include/armnnUtils/TensorUtils.hpp @@ -0,0 +1,41 @@ +// +// Copyright © 2019 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#pragma once + +#include + +#include + +namespace armnnUtils +{ +armnn::TensorShape GetTensorShape(unsigned int numberOfBatches, + unsigned int numberOfChannels, + unsigned int height, + unsigned int width, + const armnn::DataLayout dataLayout); + +armnn::TensorInfo GetTensorInfo(unsigned int numberOfBatches, + unsigned int numberOfChannels, + unsigned int height, + unsigned int width, + const armnn::DataLayout dataLayout, + const armnn::DataType dataType); + +std::pair FindMinMax(armnn::ITensorHandle* tensorHandle); + +armnn::TensorShape ExpandDims(const armnn::TensorShape& tensorShape, int axis); + +unsigned int GetNumElementsBetween(const armnn::TensorShape& shape, + unsigned int firstAxisInclusive, + unsigned int lastAxisExclusive); + +unsigned int GetUnsignedAxis(const unsigned int inputDimension, const int axis); + +unsigned int GetNumElementsAfter(const armnn::TensorShape& shape, unsigned int axis); + +std::pair> GetPerAxisParams(const armnn::TensorInfo& info); + +} // namespace armnnUtils diff --git a/src/armnn/NetworkQuantizer.cpp b/src/armnn/NetworkQuantizer.cpp index 4a8bae52f2..dd2f32414a 100644 --- a/src/armnn/NetworkQuantizer.cpp +++ b/src/armnn/NetworkQuantizer.cpp @@ -13,13 +13,14 @@ #include "QuantizerVisitor.hpp" #include "OverrideInputRangeVisitor.hpp" +#include + #include #include #include #include -#include -#include +#include #include diff --git a/src/armnn/layers/ArgMinMaxLayer.cpp b/src/armnn/layers/ArgMinMaxLayer.cpp index bfd71d519b..35bf272e41 100644 --- a/src/armnn/layers/ArgMinMaxLayer.cpp +++ b/src/armnn/layers/ArgMinMaxLayer.cpp @@ -2,13 +2,14 @@ // Copyright © 2017 Arm Ltd. All rights reserved. // SPDX-License-Identifier: MIT // -#include "ArgMinMaxLayer.hpp" +#include "ArgMinMaxLayer.hpp" #include "LayerCloneBase.hpp" -#include - #include + +#include + #include #include @@ -88,4 +89,4 @@ void ArgMinMaxLayer::Accept(ILayerVisitor& visitor) const visitor.VisitArgMinMaxLayer(this, GetParameters(), GetName()); } -} // namespace armnn \ No newline at end of file +} // namespace armnn diff --git a/src/armnn/layers/BatchToSpaceNdLayer.cpp b/src/armnn/layers/BatchToSpaceNdLayer.cpp index a168fe8bbd..335811186c 100644 --- a/src/armnn/layers/BatchToSpaceNdLayer.cpp +++ b/src/armnn/layers/BatchToSpaceNdLayer.cpp @@ -2,20 +2,20 @@ // Copyright © 2017 Arm Ltd. All rights reserved. // SPDX-License-Identifier: MIT // -#include "BatchToSpaceNdLayer.hpp" +#include "BatchToSpaceNdLayer.hpp" #include "LayerCloneBase.hpp" #include "LayerWithParameters.hpp" #include "BatchToSpaceNdLayer.hpp" #include +#include + #include #include #include -#include - #include using namespace armnnUtils; diff --git a/src/armnn/layers/Convolution2dLayer.cpp b/src/armnn/layers/Convolution2dLayer.cpp index 4300d55e1e..b205315b07 100644 --- a/src/armnn/layers/Convolution2dLayer.cpp +++ b/src/armnn/layers/Convolution2dLayer.cpp @@ -2,15 +2,18 @@ // Copyright © 2017 Arm Ltd. All rights reserved. // SPDX-License-Identifier: MIT // -#include "Convolution2dLayer.hpp" +#include "Convolution2dLayer.hpp" #include "LayerCloneBase.hpp" #include + +#include + #include #include + #include -#include using namespace armnnUtils; diff --git a/src/armnn/layers/DepthToSpaceLayer.cpp b/src/armnn/layers/DepthToSpaceLayer.cpp index de01ca9868..80992fa20f 100644 --- a/src/armnn/layers/DepthToSpaceLayer.cpp +++ b/src/armnn/layers/DepthToSpaceLayer.cpp @@ -4,16 +4,15 @@ // #include "DepthToSpaceLayer.hpp" - #include "LayerCloneBase.hpp" #include +#include + #include #include -#include - #include namespace armnn diff --git a/src/armnn/layers/DepthwiseConvolution2dLayer.cpp b/src/armnn/layers/DepthwiseConvolution2dLayer.cpp index a50a0f6310..306bce57fc 100644 --- a/src/armnn/layers/DepthwiseConvolution2dLayer.cpp +++ b/src/armnn/layers/DepthwiseConvolution2dLayer.cpp @@ -2,16 +2,18 @@ // Copyright © 2017 Arm Ltd. All rights reserved. // SPDX-License-Identifier: MIT // -#include "DepthwiseConvolution2dLayer.hpp" +#include "DepthwiseConvolution2dLayer.hpp" #include "LayerCloneBase.hpp" #include +#include + #include #include + #include -#include using namespace armnnUtils; diff --git a/src/armnn/layers/PermuteLayer.cpp b/src/armnn/layers/PermuteLayer.cpp index e6a7a38685..459a755117 100644 --- a/src/armnn/layers/PermuteLayer.cpp +++ b/src/armnn/layers/PermuteLayer.cpp @@ -2,16 +2,18 @@ // Copyright © 2017 Arm Ltd. All rights reserved. // SPDX-License-Identifier: MIT // + #include "PermuteLayer.hpp" #include "LayerCloneBase.hpp" #include + +#include + #include #include -#include - namespace armnn { diff --git a/src/armnn/layers/Pooling2dLayer.cpp b/src/armnn/layers/Pooling2dLayer.cpp index 7c5be01c35..8f5ccb9215 100644 --- a/src/armnn/layers/Pooling2dLayer.cpp +++ b/src/armnn/layers/Pooling2dLayer.cpp @@ -2,17 +2,18 @@ // Copyright © 2017 Arm Ltd. All rights reserved. // SPDX-License-Identifier: MIT // + #include "Pooling2dLayer.hpp" #include "LayerCloneBase.hpp" #include +#include + #include #include -#include - using namespace armnnUtils; namespace armnn diff --git a/src/armnn/layers/ResizeLayer.cpp b/src/armnn/layers/ResizeLayer.cpp index 44b4d9df5f..50d5f243ff 100644 --- a/src/armnn/layers/ResizeLayer.cpp +++ b/src/armnn/layers/ResizeLayer.cpp @@ -2,17 +2,17 @@ // Copyright © 2017 Arm Ltd. All rights reserved. // SPDX-License-Identifier: MIT // -#include "ResizeLayer.hpp" +#include "ResizeLayer.hpp" #include "LayerCloneBase.hpp" #include +#include + #include #include -#include - using namespace armnnUtils; namespace armnn diff --git a/src/armnn/layers/SpaceToBatchNdLayer.cpp b/src/armnn/layers/SpaceToBatchNdLayer.cpp index 6d5827e771..5002160ff7 100644 --- a/src/armnn/layers/SpaceToBatchNdLayer.cpp +++ b/src/armnn/layers/SpaceToBatchNdLayer.cpp @@ -4,16 +4,15 @@ // #include "SpaceToBatchNdLayer.hpp" - #include "LayerCloneBase.hpp" #include +#include + #include #include -#include - #include using namespace armnnUtils; diff --git a/src/armnn/layers/SpaceToDepthLayer.cpp b/src/armnn/layers/SpaceToDepthLayer.cpp index 8a9f1c296c..befb940b4a 100644 --- a/src/armnn/layers/SpaceToDepthLayer.cpp +++ b/src/armnn/layers/SpaceToDepthLayer.cpp @@ -4,16 +4,15 @@ // #include "SpaceToDepthLayer.hpp" - #include "LayerCloneBase.hpp" #include +#include + #include #include -#include - #include using namespace armnnUtils; diff --git a/src/armnn/layers/TransposeConvolution2dLayer.cpp b/src/armnn/layers/TransposeConvolution2dLayer.cpp index 7bd2f3b9d8..1110e04991 100644 --- a/src/armnn/layers/TransposeConvolution2dLayer.cpp +++ b/src/armnn/layers/TransposeConvolution2dLayer.cpp @@ -2,17 +2,17 @@ // Copyright © 2017 Arm Ltd. All rights reserved. // SPDX-License-Identifier: MIT // -#include "TransposeConvolution2dLayer.hpp" +#include "TransposeConvolution2dLayer.hpp" #include "LayerCloneBase.hpp" #include +#include + #include #include -#include - using namespace armnnUtils; namespace armnn diff --git a/src/armnn/optimizations/ConvertConstants.hpp b/src/armnn/optimizations/ConvertConstants.hpp index bb38ae8811..e8a0e62295 100644 --- a/src/armnn/optimizations/ConvertConstants.hpp +++ b/src/armnn/optimizations/ConvertConstants.hpp @@ -7,8 +7,9 @@ #include "Optimization.hpp" +#include + #include -#include #include diff --git a/src/armnn/optimizations/MovePermuteUp.hpp b/src/armnn/optimizations/MovePermuteUp.hpp index 7f4ad1b422..a7a477be84 100644 --- a/src/armnn/optimizations/MovePermuteUp.hpp +++ b/src/armnn/optimizations/MovePermuteUp.hpp @@ -5,7 +5,8 @@ #pragma once #include "Optimization.hpp" -#include "Permute.hpp" + +#include namespace armnn { diff --git a/src/armnn/test/CreateWorkload.hpp b/src/armnn/test/CreateWorkload.hpp index d6d1ab3c5b..0537877b99 100644 --- a/src/armnn/test/CreateWorkload.hpp +++ b/src/armnn/test/CreateWorkload.hpp @@ -6,15 +6,16 @@ #include "TestUtils.hpp" -#include -#include -#include - #include -#include #include #include +#include + +#include +#include +#include + #include #include diff --git a/src/armnn/test/FloatingPointConverterTest.cpp b/src/armnn/test/FloatingPointConverterTest.cpp index 733aa3842b..4497ca70a8 100644 --- a/src/armnn/test/FloatingPointConverterTest.cpp +++ b/src/armnn/test/FloatingPointConverterTest.cpp @@ -3,7 +3,8 @@ // SPDX-License-Identifier: MIT // -#include "FloatingPointConverter.hpp" +#include + #include #include diff --git a/src/armnn/test/OptimizerTests.cpp b/src/armnn/test/OptimizerTests.cpp index c0ad9c8927..ba18aa31e8 100644 --- a/src/armnn/test/OptimizerTests.cpp +++ b/src/armnn/test/OptimizerTests.cpp @@ -5,11 +5,14 @@ #include "TestUtils.hpp" -#include #include #include + +#include + +#include + #include -#include #include diff --git a/src/armnnDeserializer/Deserializer.cpp b/src/armnnDeserializer/Deserializer.cpp index 4cd3cf25d7..3e6d5aa298 100644 --- a/src/armnnDeserializer/Deserializer.cpp +++ b/src/armnnDeserializer/Deserializer.cpp @@ -8,8 +8,9 @@ #include #include +#include + #include -#include #include #include diff --git a/src/armnnTfLiteParser/TfLiteParser.cpp b/src/armnnTfLiteParser/TfLiteParser.cpp index 9a20740914..090fbed8b5 100644 --- a/src/armnnTfLiteParser/TfLiteParser.cpp +++ b/src/armnnTfLiteParser/TfLiteParser.cpp @@ -2,6 +2,7 @@ // Copyright © 2017 Arm Ltd. All rights reserved. // SPDX-License-Identifier: MIT // + #include "TfLiteParser.hpp" #include @@ -10,13 +11,16 @@ #include // armnnUtils: +#include + #include -#include #include // The generated code based on the Tf Lite schema: #include +#include + #include #include #include @@ -28,7 +32,6 @@ #include #include #include -#include using namespace armnn; using armnn::CheckLocation; diff --git a/src/armnnTfParser/TfParser.cpp b/src/armnnTfParser/TfParser.cpp index 51423bf6a7..8c68659b95 100755 --- a/src/armnnTfParser/TfParser.cpp +++ b/src/armnnTfParser/TfParser.cpp @@ -8,10 +8,11 @@ #include #include +#include +#include + #include #include -#include -#include #include #include diff --git a/src/armnnTfParser/test/DepthwiseConvolution2d.cpp b/src/armnnTfParser/test/DepthwiseConvolution2d.cpp index 464e62fc23..43a7ebc28e 100644 --- a/src/armnnTfParser/test/DepthwiseConvolution2d.cpp +++ b/src/armnnTfParser/test/DepthwiseConvolution2d.cpp @@ -3,13 +3,17 @@ // SPDX-License-Identifier: MIT // -#include -#include "armnnTfParser/ITfParser.hpp" #include "ParserPrototxtFixture.hpp" + +#include "armnnTfParser/ITfParser.hpp" + +#include + +#include + #include #include -#include using namespace armnnUtils; using namespace armnn; diff --git a/src/armnnUtils/DataLayoutIndexed.cpp b/src/armnnUtils/DataLayoutIndexed.cpp index 02f1e816ac..92051b6c83 100644 --- a/src/armnnUtils/DataLayoutIndexed.cpp +++ b/src/armnnUtils/DataLayoutIndexed.cpp @@ -3,7 +3,8 @@ // SPDX-License-Identifier: MIT // -#include "DataLayoutIndexed.hpp" +#include + using namespace armnn; namespace armnnUtils diff --git a/src/armnnUtils/DataLayoutIndexed.hpp b/src/armnnUtils/DataLayoutIndexed.hpp deleted file mode 100644 index 8bd9701a5e..0000000000 --- a/src/armnnUtils/DataLayoutIndexed.hpp +++ /dev/null @@ -1,72 +0,0 @@ -// -// Copyright © 2017 Arm Ltd. All rights reserved. -// SPDX-License-Identifier: MIT -// - -#pragma once - -#include -#include - -#include - -namespace armnnUtils -{ - -// Provides access to the appropriate indexes for Channels, Height and Width based on DataLayout -class DataLayoutIndexed -{ -public: - DataLayoutIndexed(armnn::DataLayout dataLayout); - - armnn::DataLayout GetDataLayout() const { return m_DataLayout; } - unsigned int GetChannelsIndex() const { return m_ChannelsIndex; } - unsigned int GetHeightIndex() const { return m_HeightIndex; } - unsigned int GetWidthIndex() const { return m_WidthIndex; } - - inline unsigned int GetIndex(const armnn::TensorShape& shape, - unsigned int batchIndex, unsigned int channelIndex, - unsigned int heightIndex, unsigned int widthIndex) const - { - BOOST_ASSERT( batchIndex < shape[0] || ( shape[0] == 0 && batchIndex == 0 ) ); - BOOST_ASSERT( channelIndex < shape[m_ChannelsIndex] || - ( shape[m_ChannelsIndex] == 0 && channelIndex == 0) ); - BOOST_ASSERT( heightIndex < shape[m_HeightIndex] || - ( shape[m_HeightIndex] == 0 && heightIndex == 0) ); - BOOST_ASSERT( widthIndex < shape[m_WidthIndex] || - ( shape[m_WidthIndex] == 0 && widthIndex == 0) ); - - // Offset the given indices appropriately depending on the data layout - switch (m_DataLayout) - { - case armnn::DataLayout::NHWC: - batchIndex *= shape[1] * shape[2] * shape[3]; // batchIndex *= heightIndex * widthIndex * channelIndex - heightIndex *= shape[m_WidthIndex] * shape[m_ChannelsIndex]; - widthIndex *= shape[m_ChannelsIndex]; - // channelIndex stays unchanged - break; - case armnn::DataLayout::NCHW: - default: - batchIndex *= shape[1] * shape[2] * shape[3]; // batchIndex *= heightIndex * widthIndex * channelIndex - channelIndex *= shape[m_HeightIndex] * shape[m_WidthIndex]; - heightIndex *= shape[m_WidthIndex]; - // widthIndex stays unchanged - break; - } - - // Get the value using the correct offset - return batchIndex + channelIndex + heightIndex + widthIndex; - } - -private: - armnn::DataLayout m_DataLayout; - unsigned int m_ChannelsIndex; - unsigned int m_HeightIndex; - unsigned int m_WidthIndex; -}; - -// Equality methods -bool operator==(const armnn::DataLayout& dataLayout, const DataLayoutIndexed& indexed); -bool operator==(const DataLayoutIndexed& indexed, const armnn::DataLayout& dataLayout); - -} // namespace armnnUtils diff --git a/src/armnnUtils/FloatingPointConverter.cpp b/src/armnnUtils/FloatingPointConverter.cpp index 92409d4eea..3bdde11eb8 100644 --- a/src/armnnUtils/FloatingPointConverter.cpp +++ b/src/armnnUtils/FloatingPointConverter.cpp @@ -3,7 +3,7 @@ // SPDX-License-Identifier: MIT // -#include "FloatingPointConverter.hpp" +#include #include "Half.hpp" diff --git a/src/armnnUtils/FloatingPointConverter.hpp b/src/armnnUtils/FloatingPointConverter.hpp deleted file mode 100644 index 7b201c7ead..0000000000 --- a/src/armnnUtils/FloatingPointConverter.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// -// Copyright © 2017 Arm Ltd. All rights reserved. -// SPDX-License-Identifier: MIT -// - -#pragma once - -#include - -namespace armnnUtils -{ -class FloatingPointConverter -{ -public: - // Converts a buffer of FP32 values to FP16, and stores in the given dstFloat16Buffer. - // dstFloat16Buffer should be (numElements * 2) in size - static void ConvertFloat32To16(const float *srcFloat32Buffer, size_t numElements, void *dstFloat16Buffer); - - static void ConvertFloat16To32(const void *srcFloat16Buffer, size_t numElements, float *dstFloat32Buffer); -}; -} //namespace armnnUtils diff --git a/src/armnnUtils/ParserHelper.cpp b/src/armnnUtils/ParserHelper.cpp index 2286f8b6ed..990a9b2098 100644 --- a/src/armnnUtils/ParserHelper.cpp +++ b/src/armnnUtils/ParserHelper.cpp @@ -6,7 +6,7 @@ #include "ParserHelper.hpp" // armnnUtils -#include "Permute.hpp" +#include #include diff --git a/src/armnnUtils/Permute.cpp b/src/armnnUtils/Permute.cpp index 24a8286bba..a758bd9fbf 100644 --- a/src/armnnUtils/Permute.cpp +++ b/src/armnnUtils/Permute.cpp @@ -3,10 +3,11 @@ // SPDX-License-Identifier: MIT // -#include "Permute.hpp" +#include + +#include #include "Half.hpp" -#include #include #include diff --git a/src/armnnUtils/Permute.hpp b/src/armnnUtils/Permute.hpp deleted file mode 100644 index b9ef94bc86..0000000000 --- a/src/armnnUtils/Permute.hpp +++ /dev/null @@ -1,20 +0,0 @@ -// -// Copyright © 2017 Arm Ltd. All rights reserved. -// SPDX-License-Identifier: MIT -// -#pragma once - -#include -#include - -namespace armnnUtils -{ - -armnn::TensorShape Permuted(const armnn::TensorShape& srcShape, const armnn::PermutationVector& mappings); - -armnn::TensorInfo Permuted(const armnn::TensorInfo& info, const armnn::PermutationVector& mappings); - -void Permute(const armnn::TensorShape& dstShape, const armnn::PermutationVector& mappings, - const void* src, void* dst, size_t dataTypeSize); - -} // namespace armnnUtils diff --git a/src/armnnUtils/TensorUtils.cpp b/src/armnnUtils/TensorUtils.cpp index 601277491c..c1d1200938 100644 --- a/src/armnnUtils/TensorUtils.cpp +++ b/src/armnnUtils/TensorUtils.cpp @@ -3,7 +3,7 @@ // SPDX-License-Identifier: MIT // -#include "TensorUtils.hpp" +#include #include diff --git a/src/armnnUtils/TensorUtils.hpp b/src/armnnUtils/TensorUtils.hpp deleted file mode 100644 index b67431d757..0000000000 --- a/src/armnnUtils/TensorUtils.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// -// Copyright © 2017 Arm Ltd. All rights reserved. -// SPDX-License-Identifier: MIT -// - -#pragma once - -#include - -#include - -namespace armnnUtils -{ -armnn::TensorShape GetTensorShape(unsigned int numberOfBatches, - unsigned int numberOfChannels, - unsigned int height, - unsigned int width, - const armnn::DataLayout dataLayout); - -armnn::TensorInfo GetTensorInfo(unsigned int numberOfBatches, - unsigned int numberOfChannels, - unsigned int height, - unsigned int width, - const armnn::DataLayout dataLayout, - const armnn::DataType dataType); - -std::pair FindMinMax(armnn::ITensorHandle* tensorHandle); - -armnn::TensorShape ExpandDims(const armnn::TensorShape& tensorShape, int axis); - -unsigned int GetNumElementsBetween(const armnn::TensorShape& shape, - unsigned int firstAxisInclusive, - unsigned int lastAxisExclusive); - -unsigned int GetUnsignedAxis(const unsigned int inputDimension, const int axis); - -unsigned int GetNumElementsAfter(const armnn::TensorShape& shape, unsigned int axis); - -std::pair> GetPerAxisParams(const armnn::TensorInfo& info); - -} // namespace armnnUtils diff --git a/src/armnnUtils/test/TensorUtilsTest.cpp b/src/armnnUtils/test/TensorUtilsTest.cpp index a903b63f83..d24740b762 100644 --- a/src/armnnUtils/test/TensorUtilsTest.cpp +++ b/src/armnnUtils/test/TensorUtilsTest.cpp @@ -3,10 +3,10 @@ // SPDX-License-Identifier: MIT // -#include - #include +#include + #include using namespace armnn; diff --git a/src/backends/backendsCommon/WorkloadData.cpp b/src/backends/backendsCommon/WorkloadData.cpp index 6d5c6e8343..251d3b96b8 100644 --- a/src/backends/backendsCommon/WorkloadData.cpp +++ b/src/backends/backendsCommon/WorkloadData.cpp @@ -2,11 +2,13 @@ // Copyright © 2017 Arm Ltd. All rights reserved. // SPDX-License-Identifier: MIT // + #include "WorkloadData.hpp" #include "CpuTensorHandle.hpp" -#include +#include +#include #include #include @@ -15,7 +17,6 @@ #include #include -#include using namespace armnnUtils; diff --git a/src/backends/backendsCommon/WorkloadUtils.hpp b/src/backends/backendsCommon/WorkloadUtils.hpp index d581b5ab9e..6092c5fc90 100644 --- a/src/backends/backendsCommon/WorkloadUtils.hpp +++ b/src/backends/backendsCommon/WorkloadUtils.hpp @@ -10,8 +10,9 @@ #include +#include + #include -#include #include #include diff --git a/src/backends/backendsCommon/test/DataLayoutUtils.hpp b/src/backends/backendsCommon/test/DataLayoutUtils.hpp index f89325829e..9411212f4f 100644 --- a/src/backends/backendsCommon/test/DataLayoutUtils.hpp +++ b/src/backends/backendsCommon/test/DataLayoutUtils.hpp @@ -5,11 +5,11 @@ #pragma once -#include - #include #include +#include + template void PermuteTensorNchwToNhwc(armnn::TensorInfo& tensorInfo, std::vector& tensorData) { diff --git a/src/backends/backendsCommon/test/InstanceNormalizationEndToEndTestImpl.cpp b/src/backends/backendsCommon/test/InstanceNormalizationEndToEndTestImpl.cpp index 0ba2a74895..a3dd88c893 100644 --- a/src/backends/backendsCommon/test/InstanceNormalizationEndToEndTestImpl.cpp +++ b/src/backends/backendsCommon/test/InstanceNormalizationEndToEndTestImpl.cpp @@ -4,12 +4,11 @@ // #include "InstanceNormalizationEndToEndTestImpl.hpp" - -#include "DataLayoutIndexed.hpp" #include "EndToEndTestImpl.hpp" #include "ResolveType.hpp" -#include +#include +#include #include @@ -377,4 +376,4 @@ void InstanceNormalizationNchwEndToEndTest2(const std::vector& gamma, beta, eps); -} \ No newline at end of file +} diff --git a/src/backends/backendsCommon/test/ResizeEndToEndTestImpl.hpp b/src/backends/backendsCommon/test/ResizeEndToEndTestImpl.hpp index 1eeb944805..8cc3a26bd8 100644 --- a/src/backends/backendsCommon/test/ResizeEndToEndTestImpl.hpp +++ b/src/backends/backendsCommon/test/ResizeEndToEndTestImpl.hpp @@ -8,7 +8,8 @@ #include -#include +#include + #include #include diff --git a/src/backends/backendsCommon/test/SpaceToDepthEndToEndTestImpl.cpp b/src/backends/backendsCommon/test/SpaceToDepthEndToEndTestImpl.cpp index 8eb1c97350..6d1a7b0556 100644 --- a/src/backends/backendsCommon/test/SpaceToDepthEndToEndTestImpl.cpp +++ b/src/backends/backendsCommon/test/SpaceToDepthEndToEndTestImpl.cpp @@ -4,15 +4,14 @@ // #include "SpaceToDepthEndToEndTestImpl.hpp" - #include "ResolveType.hpp" -#include "DataLayoutIndexed.hpp" #include "EndToEndTestImpl.hpp" -#include - #include +#include +#include + #include #include diff --git a/src/backends/backendsCommon/test/TransposeConvolution2dEndToEndTestImpl.hpp b/src/backends/backendsCommon/test/TransposeConvolution2dEndToEndTestImpl.hpp index 4935a18b51..970c44d0d9 100644 --- a/src/backends/backendsCommon/test/TransposeConvolution2dEndToEndTestImpl.hpp +++ b/src/backends/backendsCommon/test/TransposeConvolution2dEndToEndTestImpl.hpp @@ -8,7 +8,8 @@ #include -#include +#include + #include #include diff --git a/src/backends/backendsCommon/test/layerTests/BatchNormalizationTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/BatchNormalizationTestImpl.cpp index 68cda7ccf3..a92ff03753 100644 --- a/src/backends/backendsCommon/test/layerTests/BatchNormalizationTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/BatchNormalizationTestImpl.cpp @@ -5,12 +5,13 @@ #include "BatchNormalizationTestImpl.hpp" -#include #include #include #include +#include + #include #include #include diff --git a/src/backends/backendsCommon/test/layerTests/ConcatTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/ConcatTestImpl.cpp index e9932c81ef..53bfc20590 100644 --- a/src/backends/backendsCommon/test/layerTests/ConcatTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/ConcatTestImpl.cpp @@ -5,12 +5,13 @@ #include "ConcatTestImpl.hpp" -#include #include #include #include +#include + #include #include diff --git a/src/backends/backendsCommon/test/layerTests/ConstantTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/ConstantTestImpl.cpp index 3f22c31c7d..17908197c0 100644 --- a/src/backends/backendsCommon/test/layerTests/ConstantTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/ConstantTestImpl.cpp @@ -5,12 +5,13 @@ #include "ConstantTestImpl.hpp" -#include #include #include #include +#include + #include #include diff --git a/src/backends/backendsCommon/test/layerTests/Conv2dTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/Conv2dTestImpl.cpp index 22e7e29db7..e825fffaea 100644 --- a/src/backends/backendsCommon/test/layerTests/Conv2dTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/Conv2dTestImpl.cpp @@ -5,13 +5,14 @@ #include "Conv2dTestImpl.hpp" -#include -#include #include -#include +#include #include +#include +#include + #include #include diff --git a/src/backends/backendsCommon/test/layerTests/L2NormalizationTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/L2NormalizationTestImpl.cpp index 569f5af227..d67f7b64aa 100644 --- a/src/backends/backendsCommon/test/layerTests/L2NormalizationTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/L2NormalizationTestImpl.cpp @@ -5,10 +5,11 @@ #include "L2NormalizationTestImpl.hpp" -#include #include #include -#include + +#include +#include #include #include diff --git a/src/backends/backendsCommon/test/layerTests/Pooling2dTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/Pooling2dTestImpl.cpp index a7fbfefcb0..2012dfd602 100644 --- a/src/backends/backendsCommon/test/layerTests/Pooling2dTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/Pooling2dTestImpl.cpp @@ -5,13 +5,14 @@ #include "Pooling2dTestImpl.hpp" -#include - -#include -#include #include #include -#include + +#include + +#include +#include +#include #include diff --git a/src/backends/backendsCommon/test/layerTests/ResizeTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/ResizeTestImpl.cpp index 895afe06af..198c60a9ad 100644 --- a/src/backends/backendsCommon/test/layerTests/ResizeTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/ResizeTestImpl.cpp @@ -5,13 +5,14 @@ #include "ResizeTestImpl.hpp" -#include -#include #include -#include #include +#include +#include +#include + #include #include #include diff --git a/src/backends/backendsCommon/test/layerTests/SpaceToBatchNdTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/SpaceToBatchNdTestImpl.cpp index f815604aaa..ea2130d325 100644 --- a/src/backends/backendsCommon/test/layerTests/SpaceToBatchNdTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/SpaceToBatchNdTestImpl.cpp @@ -5,12 +5,13 @@ #include "SpaceToBatchNdTestImpl.hpp" -#include #include #include #include +#include + #include #include diff --git a/src/backends/backendsCommon/test/layerTests/SpaceToDepthTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/SpaceToDepthTestImpl.cpp index 05413230dd..c4b11a7213 100644 --- a/src/backends/backendsCommon/test/layerTests/SpaceToDepthTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/SpaceToDepthTestImpl.cpp @@ -5,12 +5,13 @@ #include "SpaceToDepthTestImpl.hpp" -#include #include #include #include +#include + #include #include diff --git a/src/backends/backendsCommon/test/layerTests/TransposeConvolution2dTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/TransposeConvolution2dTestImpl.cpp index 53c1e9d1b7..71b08aa159 100644 --- a/src/backends/backendsCommon/test/layerTests/TransposeConvolution2dTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/TransposeConvolution2dTestImpl.cpp @@ -5,10 +5,11 @@ #include "TransposeConvolution2dTestImpl.hpp" +#include + #include -#include -#include +#include #include diff --git a/src/backends/cl/workloads/ClArgMinMaxWorkload.cpp b/src/backends/cl/workloads/ClArgMinMaxWorkload.cpp index 3270b0a2f3..a79a7b286d 100644 --- a/src/backends/cl/workloads/ClArgMinMaxWorkload.cpp +++ b/src/backends/cl/workloads/ClArgMinMaxWorkload.cpp @@ -10,7 +10,7 @@ #include -#include +#include #include #include diff --git a/src/backends/neon/workloads/NeonArgMinMaxWorkload.cpp b/src/backends/neon/workloads/NeonArgMinMaxWorkload.cpp index 4b43052365..0fa9d43b15 100644 --- a/src/backends/neon/workloads/NeonArgMinMaxWorkload.cpp +++ b/src/backends/neon/workloads/NeonArgMinMaxWorkload.cpp @@ -7,8 +7,10 @@ #include "NeonWorkloadUtils.hpp" #include + #include -#include + +#include #include diff --git a/src/backends/neon/workloads/NeonConvertFp16ToFp32Workload.cpp b/src/backends/neon/workloads/NeonConvertFp16ToFp32Workload.cpp index a86b1086dc..01f09a56f6 100644 --- a/src/backends/neon/workloads/NeonConvertFp16ToFp32Workload.cpp +++ b/src/backends/neon/workloads/NeonConvertFp16ToFp32Workload.cpp @@ -4,9 +4,11 @@ // #include "NeonConvertFp16ToFp32Workload.hpp" -#include + +#include #include + #include namespace armnn diff --git a/src/backends/neon/workloads/NeonConvertFp32ToFp16Workload.cpp b/src/backends/neon/workloads/NeonConvertFp32ToFp16Workload.cpp index 4b6f97bb78..2205b63da1 100644 --- a/src/backends/neon/workloads/NeonConvertFp32ToFp16Workload.cpp +++ b/src/backends/neon/workloads/NeonConvertFp32ToFp16Workload.cpp @@ -6,8 +6,10 @@ #include "NeonConvertFp32ToFp16Workload.hpp" #include -#include #include + +#include + #include namespace armnn diff --git a/src/backends/neon/workloads/NeonDepthwiseConvolutionWorkload.cpp b/src/backends/neon/workloads/NeonDepthwiseConvolutionWorkload.cpp index f039a6bdbe..e39fe54199 100644 --- a/src/backends/neon/workloads/NeonDepthwiseConvolutionWorkload.cpp +++ b/src/backends/neon/workloads/NeonDepthwiseConvolutionWorkload.cpp @@ -7,9 +7,12 @@ #include "NeonWorkloadUtils.hpp" -#include +#include + #include + #include + #include #include diff --git a/src/backends/reference/RefLayerSupport.cpp b/src/backends/reference/RefLayerSupport.cpp index 5a84d8ac78..05684dcbc0 100644 --- a/src/backends/reference/RefLayerSupport.cpp +++ b/src/backends/reference/RefLayerSupport.cpp @@ -6,17 +6,20 @@ #include "RefLayerSupport.hpp" #include "RefBackendId.hpp" -#include -#include -#include - #include #include #include +#include + +#include +#include + #include + #include +#include #include #include diff --git a/src/backends/reference/workloads/ArgMinMax.cpp b/src/backends/reference/workloads/ArgMinMax.cpp index 2687a4e8ac..76616f1465 100644 --- a/src/backends/reference/workloads/ArgMinMax.cpp +++ b/src/backends/reference/workloads/ArgMinMax.cpp @@ -5,7 +5,7 @@ #include "ArgMinMax.hpp" -#include +#include #include diff --git a/src/backends/reference/workloads/BaseIterator.hpp b/src/backends/reference/workloads/BaseIterator.hpp index 95a31fbdd6..ca5110c2fd 100644 --- a/src/backends/reference/workloads/BaseIterator.hpp +++ b/src/backends/reference/workloads/BaseIterator.hpp @@ -5,9 +5,10 @@ #pragma once -#include "FloatingPointConverter.hpp" - #include + +#include + #include #include diff --git a/src/backends/reference/workloads/BatchNormImpl.cpp b/src/backends/reference/workloads/BatchNormImpl.cpp index b80af8c937..e742c7280f 100644 --- a/src/backends/reference/workloads/BatchNormImpl.cpp +++ b/src/backends/reference/workloads/BatchNormImpl.cpp @@ -8,7 +8,7 @@ #include -#include +#include #include diff --git a/src/backends/reference/workloads/BatchToSpaceNd.hpp b/src/backends/reference/workloads/BatchToSpaceNd.hpp index b757d3709c..a375aaae52 100644 --- a/src/backends/reference/workloads/BatchToSpaceNd.hpp +++ b/src/backends/reference/workloads/BatchToSpaceNd.hpp @@ -5,15 +5,16 @@ #pragma once -#include - -#include -#include #include "BaseIterator.hpp" #include "Decoders.hpp" #include "Encoders.hpp" -#include +#include + +#include + +#include +#include namespace armnn { diff --git a/src/backends/reference/workloads/ConvImpl.hpp b/src/backends/reference/workloads/ConvImpl.hpp index 7dba760d87..562fd3e296 100644 --- a/src/backends/reference/workloads/ConvImpl.hpp +++ b/src/backends/reference/workloads/ConvImpl.hpp @@ -13,13 +13,11 @@ #include -#include +#include #include #include -#include - #include #include diff --git a/src/backends/reference/workloads/Decoders.hpp b/src/backends/reference/workloads/Decoders.hpp index dcd498cb63..b9cd7f9573 100644 --- a/src/backends/reference/workloads/Decoders.hpp +++ b/src/backends/reference/workloads/Decoders.hpp @@ -6,8 +6,9 @@ #pragma once #include "BaseIterator.hpp" -#include "FloatingPointConverter.hpp" -#include "TensorUtils.hpp" + +#include +#include #include diff --git a/src/backends/reference/workloads/DepthToSpace.cpp b/src/backends/reference/workloads/DepthToSpace.cpp index d500e9b100..91ca160ae2 100644 --- a/src/backends/reference/workloads/DepthToSpace.cpp +++ b/src/backends/reference/workloads/DepthToSpace.cpp @@ -5,8 +5,8 @@ #include "DepthToSpace.hpp" -#include -#include +#include +#include #include diff --git a/src/backends/reference/workloads/Encoders.hpp b/src/backends/reference/workloads/Encoders.hpp index 5c0cffa7ca..0d578d68de 100644 --- a/src/backends/reference/workloads/Encoders.hpp +++ b/src/backends/reference/workloads/Encoders.hpp @@ -6,7 +6,8 @@ #pragma once #include "BaseIterator.hpp" -#include "TensorUtils.hpp" + +#include #include diff --git a/src/backends/reference/workloads/InstanceNorm.cpp b/src/backends/reference/workloads/InstanceNorm.cpp index 9d6532fa6e..08c555f0e8 100644 --- a/src/backends/reference/workloads/InstanceNorm.cpp +++ b/src/backends/reference/workloads/InstanceNorm.cpp @@ -8,7 +8,7 @@ #include -#include +#include #include diff --git a/src/backends/reference/workloads/LogSoftmax.cpp b/src/backends/reference/workloads/LogSoftmax.cpp index 3fa3dc0d8c..ddf5674fb8 100644 --- a/src/backends/reference/workloads/LogSoftmax.cpp +++ b/src/backends/reference/workloads/LogSoftmax.cpp @@ -5,7 +5,7 @@ #include "LogSoftmax.hpp" -#include +#include #include diff --git a/src/backends/reference/workloads/Pooling2d.cpp b/src/backends/reference/workloads/Pooling2d.cpp index cf83f8ce2b..ea8f4ee7e7 100644 --- a/src/backends/reference/workloads/Pooling2d.cpp +++ b/src/backends/reference/workloads/Pooling2d.cpp @@ -4,11 +4,12 @@ // #include "Pooling2d.hpp" -#include "DataLayoutIndexed.hpp" #include #include +#include + #include #include diff --git a/src/backends/reference/workloads/RefConvertFp16ToFp32Workload.cpp b/src/backends/reference/workloads/RefConvertFp16ToFp32Workload.cpp index 886e77a31b..ef813eb69b 100644 --- a/src/backends/reference/workloads/RefConvertFp16ToFp32Workload.cpp +++ b/src/backends/reference/workloads/RefConvertFp16ToFp32Workload.cpp @@ -4,9 +4,9 @@ // #include "RefConvertFp16ToFp32Workload.hpp" - #include "RefWorkloadUtils.hpp" -#include "FloatingPointConverter.hpp" + +#include #include diff --git a/src/backends/reference/workloads/RefConvertFp32ToFp16Workload.cpp b/src/backends/reference/workloads/RefConvertFp32ToFp16Workload.cpp index 33270ad10f..559901f2f2 100644 --- a/src/backends/reference/workloads/RefConvertFp32ToFp16Workload.cpp +++ b/src/backends/reference/workloads/RefConvertFp32ToFp16Workload.cpp @@ -4,12 +4,12 @@ // #include "RefConvertFp32ToFp16Workload.hpp" - -#include "FloatingPointConverter.hpp" #include "RefWorkloadUtils.hpp" #include "Profiling.hpp" -#include "Half.hpp" +#include + +#include namespace armnn { diff --git a/src/backends/reference/workloads/RefL2NormalizationWorkload.cpp b/src/backends/reference/workloads/RefL2NormalizationWorkload.cpp index 3764b9a49a..6fec1abe6f 100644 --- a/src/backends/reference/workloads/RefL2NormalizationWorkload.cpp +++ b/src/backends/reference/workloads/RefL2NormalizationWorkload.cpp @@ -4,13 +4,13 @@ // #include "RefL2NormalizationWorkload.hpp" - #include "RefWorkloadUtils.hpp" #include "Decoders.hpp" #include "Encoders.hpp" -#include "DataLayoutIndexed.hpp" -#include "Profiling.hpp" +#include + +#include #include @@ -21,80 +21,80 @@ using namespace armnnUtils; namespace armnn { RefL2NormalizationWorkload::RefL2NormalizationWorkload( - const L2NormalizationQueueDescriptor& descriptor, - const WorkloadInfo& info) - : BaseWorkload(descriptor, info) {} + const L2NormalizationQueueDescriptor& descriptor, + const WorkloadInfo& info) + : BaseWorkload(descriptor, info) {} - void RefL2NormalizationWorkload::Execute() const - { - ARMNN_SCOPED_PROFILING_EVENT(Compute::CpuRef, "RefL2NormalizationWorkload_Execute"); +void RefL2NormalizationWorkload::Execute() const +{ + ARMNN_SCOPED_PROFILING_EVENT(Compute::CpuRef, "RefL2NormalizationWorkload_Execute"); - const TensorInfo& inputInfo = GetTensorInfo(m_Data.m_Inputs[0]); - const TensorInfo& outputInfo = GetTensorInfo(m_Data.m_Outputs[0]); + const TensorInfo& inputInfo = GetTensorInfo(m_Data.m_Inputs[0]); + const TensorInfo& outputInfo = GetTensorInfo(m_Data.m_Outputs[0]); - auto inputDecoder = MakeDecoder(inputInfo, m_Data.m_Inputs[0]->Map()); - auto outputEncoder = MakeEncoder(outputInfo, m_Data.m_Outputs[0]->Map()); + auto inputDecoder = MakeDecoder(inputInfo, m_Data.m_Inputs[0]->Map()); + auto outputEncoder = MakeEncoder(outputInfo, m_Data.m_Outputs[0]->Map()); - DataLayoutIndexed dataLayout(m_Data.m_Parameters.m_DataLayout); + DataLayoutIndexed dataLayout(m_Data.m_Parameters.m_DataLayout); - const TensorShape& shape = inputInfo.GetShape(); - unsigned int paddedShapeArray[4]; - const int idxShift = 4 - boost::numeric_cast(shape.GetNumDimensions()); + const TensorShape& shape = inputInfo.GetShape(); + unsigned int paddedShapeArray[4]; + const int idxShift = 4 - boost::numeric_cast(shape.GetNumDimensions()); - const unsigned int batches = (idxShift == 0) ? shape[0] : 1; - paddedShapeArray[0] = batches; + const unsigned int batches = (idxShift == 0) ? shape[0] : 1; + paddedShapeArray[0] = batches; - const int channelsIdx = boost::numeric_cast(dataLayout.GetChannelsIndex()); - const unsigned int channels = (channelsIdx - idxShift >= 0) - ? shape[boost::numeric_cast(channelsIdx - idxShift)] - : 1; - paddedShapeArray[channelsIdx] = channels; + const int channelsIdx = boost::numeric_cast(dataLayout.GetChannelsIndex()); + const unsigned int channels = (channelsIdx - idxShift >= 0) + ? shape[boost::numeric_cast(channelsIdx - idxShift)] + : 1; + paddedShapeArray[channelsIdx] = channels; - const int heightIdx = boost::numeric_cast(dataLayout.GetHeightIndex()); - const unsigned int height = (heightIdx - idxShift >= 0) - ? shape[boost::numeric_cast(heightIdx - idxShift)] - : 1; - paddedShapeArray[heightIdx] = height; + const int heightIdx = boost::numeric_cast(dataLayout.GetHeightIndex()); + const unsigned int height = (heightIdx - idxShift >= 0) + ? shape[boost::numeric_cast(heightIdx - idxShift)] + : 1; + paddedShapeArray[heightIdx] = height; - const int widthIdx = boost::numeric_cast(dataLayout.GetWidthIndex()); - const unsigned int width = (widthIdx - idxShift >= 0) - ? shape[boost::numeric_cast(widthIdx - idxShift)] - : 1; - paddedShapeArray[widthIdx] = width; + const int widthIdx = boost::numeric_cast(dataLayout.GetWidthIndex()); + const unsigned int width = (widthIdx - idxShift >= 0) + ? shape[boost::numeric_cast(widthIdx - idxShift)] + : 1; + paddedShapeArray[widthIdx] = width; - const TensorShape& paddedShape = TensorShape(4, paddedShapeArray); + const TensorShape& paddedShape = TensorShape(4, paddedShapeArray); - for (unsigned int n = 0; n < batches; ++n) + for (unsigned int n = 0; n < batches; ++n) + { + for (unsigned int c = 0; c < channels; ++c) { - for (unsigned int c = 0; c < channels; ++c) + for (unsigned int h = 0; h < height; ++h) { - for (unsigned int h = 0; h < height; ++h) + for (unsigned int w = 0; w < width; ++w) { - for (unsigned int w = 0; w < width; ++w) + float reduction = 0.0; + for (unsigned int d = 0; d < channels; ++d) { - float reduction = 0.0; - for (unsigned int d = 0; d < channels; ++d) - { - unsigned int inputIndex = dataLayout.GetIndex(paddedShape, n, d, h, w); + unsigned int inputIndex = dataLayout.GetIndex(paddedShape, n, d, h, w); - (*inputDecoder)[inputIndex]; - const float value = inputDecoder->Get(); - reduction += value * value; - } + (*inputDecoder)[inputIndex]; + const float value = inputDecoder->Get(); + reduction += value * value; + } - unsigned int index = dataLayout.GetIndex(paddedShape, n, c, h, w); + unsigned int index = dataLayout.GetIndex(paddedShape, n, c, h, w); - float maximum = reduction < m_Data.m_Parameters.m_Eps ? m_Data.m_Parameters.m_Eps : reduction; + float maximum = reduction < m_Data.m_Parameters.m_Eps ? m_Data.m_Parameters.m_Eps : reduction; - const float scale = 1.0f / sqrtf(maximum); + const float scale = 1.0f / sqrtf(maximum); - (*inputDecoder)[index]; - (*outputEncoder)[index]; - outputEncoder->Set(inputDecoder->Get() * scale); - } + (*inputDecoder)[index]; + (*outputEncoder)[index]; + outputEncoder->Set(inputDecoder->Get() * scale); } } } } +} } //namespace armnn diff --git a/src/backends/reference/workloads/RefNormalizationWorkload.cpp b/src/backends/reference/workloads/RefNormalizationWorkload.cpp index 8ff2d9cf92..0427baf475 100644 --- a/src/backends/reference/workloads/RefNormalizationWorkload.cpp +++ b/src/backends/reference/workloads/RefNormalizationWorkload.cpp @@ -4,14 +4,14 @@ // #include "RefNormalizationWorkload.hpp" - #include "RefWorkloadUtils.hpp" #include "Decoders.hpp" #include "Encoders.hpp" #include -#include +#include + #include #include diff --git a/src/backends/reference/workloads/RefPermuteWorkload.cpp b/src/backends/reference/workloads/RefPermuteWorkload.cpp index 4d43b7e560..4e7b76bf0a 100644 --- a/src/backends/reference/workloads/RefPermuteWorkload.cpp +++ b/src/backends/reference/workloads/RefPermuteWorkload.cpp @@ -6,7 +6,8 @@ #include "RefPermuteWorkload.hpp" #include "RefWorkloadUtils.hpp" -#include +#include + #include namespace armnn diff --git a/src/backends/reference/workloads/Resize.hpp b/src/backends/reference/workloads/Resize.hpp index 8bd8999e5d..4c357946d9 100644 --- a/src/backends/reference/workloads/Resize.hpp +++ b/src/backends/reference/workloads/Resize.hpp @@ -6,9 +6,10 @@ #pragma once #include "BaseIterator.hpp" + #include -#include +#include namespace armnn { @@ -20,4 +21,4 @@ void Resize(Decoder& in, armnnUtils::DataLayoutIndexed dataLayout = DataLayout::NCHW, ResizeMethod resizeMethod = ResizeMethod::NearestNeighbor); -} //namespace armnn +} // namespace armnn diff --git a/src/backends/reference/workloads/Softmax.cpp b/src/backends/reference/workloads/Softmax.cpp index f745d816c2..5036389a10 100644 --- a/src/backends/reference/workloads/Softmax.cpp +++ b/src/backends/reference/workloads/Softmax.cpp @@ -5,7 +5,7 @@ #include "Softmax.hpp" -#include +#include #include #include diff --git a/src/backends/reference/workloads/SpaceToBatchNd.cpp b/src/backends/reference/workloads/SpaceToBatchNd.cpp index 0bc2396973..b6bab17367 100644 --- a/src/backends/reference/workloads/SpaceToBatchNd.cpp +++ b/src/backends/reference/workloads/SpaceToBatchNd.cpp @@ -5,7 +5,7 @@ #include "SpaceToBatchNd.hpp" -#include +#include using namespace armnnUtils; diff --git a/src/backends/reference/workloads/SpaceToDepth.cpp b/src/backends/reference/workloads/SpaceToDepth.cpp index 4a4f4183d9..604a9051af 100644 --- a/src/backends/reference/workloads/SpaceToDepth.cpp +++ b/src/backends/reference/workloads/SpaceToDepth.cpp @@ -5,7 +5,7 @@ #include "SpaceToDepth.hpp" -#include +#include using namespace armnnUtils; diff --git a/src/backends/reference/workloads/TensorBufferArrayView.hpp b/src/backends/reference/workloads/TensorBufferArrayView.hpp index c06407241d..e03c42fe60 100644 --- a/src/backends/reference/workloads/TensorBufferArrayView.hpp +++ b/src/backends/reference/workloads/TensorBufferArrayView.hpp @@ -7,9 +7,9 @@ #include -#include +#include -#include +#include namespace armnn { diff --git a/src/backends/reference/workloads/TransposeConvolution2d.cpp b/src/backends/reference/workloads/TransposeConvolution2d.cpp index 5662c58809..5698014181 100644 --- a/src/backends/reference/workloads/TransposeConvolution2d.cpp +++ b/src/backends/reference/workloads/TransposeConvolution2d.cpp @@ -5,7 +5,7 @@ #include "TransposeConvolution2d.hpp" -#include +#include namespace armnn { diff --git a/tests/ImagePreprocessor.cpp b/tests/ImagePreprocessor.cpp index 74bc943ee8..f0184e466e 100644 --- a/tests/ImagePreprocessor.cpp +++ b/tests/ImagePreprocessor.cpp @@ -2,11 +2,14 @@ // Copyright © 2017 Arm Ltd. All rights reserved. // SPDX-License-Identifier: MIT // + #include "InferenceTestImage.hpp" #include "ImagePreprocessor.hpp" -#include "Permute.hpp" + #include +#include + #include #include #include diff --git a/tests/ImageTensorGenerator/ImageTensorGenerator.hpp b/tests/ImageTensorGenerator/ImageTensorGenerator.hpp index 3e164bc9e0..b1cb5e36f5 100644 --- a/tests/ImageTensorGenerator/ImageTensorGenerator.hpp +++ b/tests/ImageTensorGenerator/ImageTensorGenerator.hpp @@ -4,9 +4,11 @@ // #include "../InferenceTestImage.hpp" -#include "Permute.hpp" + #include +#include + #include #include #include @@ -178,4 +180,4 @@ template <> void WriteImageTensorImpl(const std::vector& imageData, std::ofstream& imageTensorFile) { std::copy(imageData.begin(), imageData.end(), std::ostream_iterator(imageTensorFile, " ")); -} \ No newline at end of file +} -- cgit v1.2.1