From c42a987aa53d0fd842c34dee90abef5a9ff15fa4 Mon Sep 17 00:00:00 2001 From: Colm Donelan Date: Wed, 2 Feb 2022 16:35:09 +0000 Subject: IVGCVSW-6635 Move MemCopyTestImpl from acl to armnnTestUtils. * Move MemCopyTestImpl.hpp from src/backends/aclCommon/test/ to include/armnnTestutils. * Refactor MemCopyTests in aclCommon, cl and Neon. * Introduce RefMemCopyTests to exercise this utility in x86 builds. Signed-off-by: Colm Donelan Change-Id: I8824f013d3656658ed0a2904bb79384e3af68641 --- Android.mk | 4 + CMakeLists.txt | 2 +- include/armnnTestUtils/MemCopyTestImpl.hpp | 115 ++++++++++ .../armnnTestUtils/MockWorkloadFactoryHelper.hpp | 41 ++++ include/armnnTestUtils/TensorHelpers.hpp | 235 +++++++++++++++++++++ include/armnnUtils/QuantizeHelper.hpp | 132 ++++++++++++ src/armnn/optimizations/FoldPadIntoLayer2d.hpp | 2 +- src/armnn/test/TensorHelpers.hpp | 9 +- .../test/optimizations/FuseActivationTests.cpp | 2 +- src/armnnDeserializer/test/DeserializeCast.cpp | 2 +- .../test/DeserializeComparison.cpp | 2 +- .../test/ParserFlatbuffersSerializeFixture.hpp | 2 +- src/armnnTestUtils/CMakeLists.txt | 5 +- src/armnnTestUtils/MockBackend.cpp | 6 + src/armnnTestUtils/MockWorkloadFactoryHelper.hpp | 41 ---- src/armnnTestUtils/TensorHelpers.hpp | 235 --------------------- src/armnnTestUtils/UnitTests.hpp | 2 +- .../test/DetectionPostProcess.cpp | 2 +- .../test/ParserFlatbuffersFixture.hpp | 2 +- src/armnnUtils/ParserPrototxtFixture.hpp | 2 +- src/armnnUtils/QuantizeHelper.hpp | 132 ------------ src/armnnUtils/test/QuantizeHelperTest.cpp | 2 +- src/backends/aclCommon/test/MemCopyTestImpl.hpp | 94 +-------- src/backends/aclCommon/test/MemCopyTests.cpp | 48 ++++- .../backendsCommon/test/ActivationFixture.hpp | 2 +- .../test/ArgMinMaxEndToEndTestImpl.hpp | 2 +- .../test/Convolution3dEndToEndTestImpl.hpp | 2 +- .../test/DepthToSpaceEndToEndTestImpl.hpp | 2 +- .../backendsCommon/test/EndToEndTestImpl.hpp | 2 +- .../test/QuantizedLstmEndToEndTestImpl.cpp | 2 +- .../backendsCommon/test/ResizeEndToEndTestImpl.hpp | 5 +- .../TransposeConvolution2dEndToEndTestImpl.hpp | 5 +- .../test/layerTests/ActivationTestImpl.cpp | 4 +- .../test/layerTests/AdditionTestImpl.cpp | 2 +- .../test/layerTests/ArgMinMaxTestImpl.cpp | 2 +- .../test/layerTests/BatchNormalizationTestImpl.cpp | 4 +- .../test/layerTests/BatchToSpaceNdTestImpl.hpp | 4 +- .../test/layerTests/ComparisonTestImpl.cpp | 4 +- .../test/layerTests/ConcatTestImpl.cpp | 4 +- .../test/layerTests/ConstantTestImpl.cpp | 4 +- .../test/layerTests/Conv2dTestImpl.cpp | 4 +- .../test/layerTests/Conv3dTestImpl.cpp | 4 +- .../test/layerTests/ConvertBf16ToFp32TestImpl.cpp | 2 +- .../test/layerTests/ConvertFp16ToFp32TestImpl.cpp | 2 +- .../test/layerTests/ConvertFp32ToBf16TestImpl.cpp | 2 +- .../test/layerTests/ConvertFp32ToFp16TestImpl.cpp | 2 +- .../test/layerTests/DebugTestImpl.cpp | 4 +- .../test/layerTests/DepthToSpaceTestImpl.cpp | 4 +- .../test/layerTests/DequantizeTestImpl.cpp | 2 +- .../layerTests/DetectionPostProcessTestImpl.hpp | 2 +- .../test/layerTests/ElementwiseTestImpl.hpp | 2 +- .../test/layerTests/ElementwiseUnaryTestImpl.hpp | 2 +- .../test/layerTests/FakeQuantizationTestImpl.cpp | 2 +- .../test/layerTests/FillTestImpl.cpp | 2 +- .../test/layerTests/FloorTestImpl.cpp | 2 +- .../test/layerTests/FullyConnectedTestImpl.cpp | 4 +- .../test/layerTests/GatherTestImpl.cpp | 2 +- .../layerTests/InstanceNormalizationTestImpl.cpp | 4 +- .../test/layerTests/L2NormalizationTestImpl.cpp | 4 +- .../test/layerTests/LogSoftmaxTestImpl.cpp | 4 +- .../test/layerTests/LogicalTestImpl.cpp | 2 +- .../test/layerTests/LstmTestImpl.cpp | 4 +- .../test/layerTests/MirrorPadTestImpl.cpp | 4 +- .../test/layerTests/NormalizationTestImpl.cpp | 2 +- .../backendsCommon/test/layerTests/PadTestImpl.cpp | 4 +- .../test/layerTests/PermuteTestImpl.hpp | 2 +- .../test/layerTests/Pooling2dTestImpl.cpp | 4 +- .../test/layerTests/Pooling3dTestImpl.cpp | 4 +- .../test/layerTests/PreluTestImpl.hpp | 4 +- .../test/layerTests/QuantizeTestImpl.cpp | 2 +- .../test/layerTests/RankTestImpl.cpp | 2 +- .../test/layerTests/ReduceProdTestImpl.cpp | 2 +- .../test/layerTests/ReduceSumTestImpl.cpp | 2 +- .../test/layerTests/ReductionTestImpl.cpp | 2 +- .../test/layerTests/ReshapeTestImpl.cpp | 2 +- .../test/layerTests/ResizeTestImpl.cpp | 4 +- .../test/layerTests/ShapeTestImpl.cpp | 2 +- .../test/layerTests/SliceTestImpl.cpp | 4 +- .../test/layerTests/SoftmaxTestImpl.cpp | 4 +- .../test/layerTests/SpaceToBatchNdTestImpl.cpp | 4 +- .../test/layerTests/SpaceToDepthTestImpl.cpp | 4 +- .../test/layerTests/SplitterTestImpl.cpp | 4 +- .../test/layerTests/StackTestImpl.cpp | 2 +- .../test/layerTests/StridedSliceTestImpl.cpp | 4 +- .../layerTests/TransposeConvolution2dTestImpl.cpp | 4 +- .../test/layerTests/TransposeTestImpl.hpp | 2 +- src/backends/cl/test/ClCreateWorkloadTests.cpp | 2 +- src/backends/cl/test/ClLayerSupportTests.cpp | 2 +- src/backends/cl/test/ClLayerTests.cpp | 2 +- src/backends/cl/test/ClMemCopyTests.cpp | 40 +++- src/backends/cl/test/OpenClTimerTest.cpp | 2 +- src/backends/neon/test/NeonLayerSupportTests.cpp | 2 +- src/backends/neon/test/NeonLayerTests.cpp | 2 +- src/backends/neon/test/NeonMemCopyTests.cpp | 40 +++- src/backends/neon/test/NeonTimerTest.cpp | 2 +- src/backends/reference/test/CMakeLists.txt | 1 + .../reference/test/RefLayerSupportTests.cpp | 2 +- src/backends/reference/test/RefMemCopyTests.cpp | 70 ++++++ tests/MobileNetSsdDatabase.hpp | 2 +- 99 files changed, 832 insertions(+), 642 deletions(-) create mode 100644 include/armnnTestUtils/MemCopyTestImpl.hpp create mode 100644 include/armnnTestUtils/MockWorkloadFactoryHelper.hpp create mode 100644 include/armnnTestUtils/TensorHelpers.hpp create mode 100644 include/armnnUtils/QuantizeHelper.hpp delete mode 100644 src/armnnTestUtils/MockWorkloadFactoryHelper.hpp delete mode 100644 src/armnnTestUtils/TensorHelpers.hpp delete mode 100644 src/armnnUtils/QuantizeHelper.hpp create mode 100644 src/backends/reference/test/RefMemCopyTests.cpp diff --git a/Android.mk b/Android.mk index fde1ffa898..3b1e6da44f 100644 --- a/Android.mk +++ b/Android.mk @@ -453,6 +453,10 @@ LOCAL_SRC_FILES := \ src/armnnUtils/test/TensorUtilsTest.cpp \ src/armnnTestUtils/CommonTestUtils.cpp \ src/armnnTestUtils/GraphUtils.cpp \ + src/armnnTestUtils/MockBackend.cpp \ + src/armnnTestUtils/MockMemoryManager.cpp \ + src/armnnTestUtils/MockTensorHandle.cpp \ + src/armnnTestUtils/MockTensorHandleFactory.cpp \ src/armnnTestUtils/TensorCopyUtils.cpp \ src/armnnTestUtils/TestUtils.cpp \ src/armnnTestUtils/UnitTests.cpp \ diff --git a/CMakeLists.txt b/CMakeLists.txt index d0a2d90345..075790a049 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,6 +78,7 @@ list(APPEND armnnUtils_sources include/armnnUtils/Filesystem.hpp include/armnnUtils/FloatingPointComparison.hpp include/armnnUtils/FloatingPointConverter.hpp + include/armnnUtils/QuantizeHelper.hpp include/armnnUtils/TContainer.hpp include/armnnUtils/TensorUtils.hpp include/armnnUtils/Threads.hpp @@ -107,7 +108,6 @@ list(APPEND armnnUtils_sources src/armnnUtils/Processes.cpp src/armnnUtils/PrototxtConversions.hpp src/armnnUtils/PrototxtConversions.cpp - src/armnnUtils/QuantizeHelper.hpp src/armnnUtils/TensorIOUtils.hpp src/armnnUtils/TensorUtils.cpp src/armnnUtils/Threads.cpp diff --git a/include/armnnTestUtils/MemCopyTestImpl.hpp b/include/armnnTestUtils/MemCopyTestImpl.hpp new file mode 100644 index 0000000000..1856dcb056 --- /dev/null +++ b/include/armnnTestUtils/MemCopyTestImpl.hpp @@ -0,0 +1,115 @@ +// +// Copyright © 2017 Arm Ltd and Contributors. All rights reserved. +// SPDX-License-Identifier: MIT +// +#pragma once + +#include "LayerTestResult.hpp" +#include "TensorCopyUtils.hpp" +#include "TensorHelpers.hpp" +#include "WorkloadTestUtils.hpp" +#include +#include +#include + +namespace +{ + +template> +LayerTestResult MemCopyTest(armnn::IWorkloadFactory& srcWorkloadFactory, + armnn::IWorkloadFactory& dstWorkloadFactory, + bool withSubtensors) +{ + const std::array shapeData = { { 1u, 1u, 6u, 5u } }; + const armnn::TensorShape tensorShape(4, shapeData.data()); + const armnn::TensorInfo tensorInfo(tensorShape, dataType); + std::vector inputData = + { + 1, 2, 3, 4, 5, + 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, + }; + + LayerTestResult ret(tensorInfo); + ret.m_ExpectedData = inputData; + + std::vector actualOutput(tensorInfo.GetNumElements()); + + ARMNN_NO_DEPRECATE_WARN_BEGIN + auto inputTensorHandle = srcWorkloadFactory.CreateTensorHandle(tensorInfo); + auto outputTensorHandle = dstWorkloadFactory.CreateTensorHandle(tensorInfo); + ARMNN_NO_DEPRECATE_WARN_END + + AllocateAndCopyDataToITensorHandle(inputTensorHandle.get(), inputData.data()); + outputTensorHandle->Allocate(); + + armnn::MemCopyQueueDescriptor memCopyQueueDesc; + armnn::WorkloadInfo workloadInfo; + + const unsigned int origin[4] = {}; + + ARMNN_NO_DEPRECATE_WARN_BEGIN + auto workloadInput = (withSubtensors && srcWorkloadFactory.SupportsSubTensors()) + ? srcWorkloadFactory.CreateSubTensorHandle(*inputTensorHandle, tensorShape, origin) + : std::move(inputTensorHandle); + auto workloadOutput = (withSubtensors && dstWorkloadFactory.SupportsSubTensors()) + ? dstWorkloadFactory.CreateSubTensorHandle(*outputTensorHandle, tensorShape, origin) + : std::move(outputTensorHandle); + ARMNN_NO_DEPRECATE_WARN_END + + AddInputToWorkload(memCopyQueueDesc, workloadInfo, tensorInfo, workloadInput.get()); + AddOutputToWorkload(memCopyQueueDesc, workloadInfo, tensorInfo, workloadOutput.get()); + + dstWorkloadFactory.CreateWorkload(armnn::LayerType::MemCopy, memCopyQueueDesc, workloadInfo)->Execute(); + + CopyDataFromITensorHandle(actualOutput.data(), workloadOutput.get()); + ret.m_ActualData = actualOutput; + + return ret; +} + +template +struct MemCopyTestHelper +{}; +template <> +struct MemCopyTestHelper +{ + static armnn::IBackendInternal::IMemoryManagerSharedPtr GetMemoryManager() + { + armnn::MockBackend backend; + return backend.CreateMemoryManager(); + } + + static armnn::MockWorkloadFactory + GetFactory(const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager = nullptr) + { + IgnoreUnused(memoryManager); + return armnn::MockWorkloadFactory(); + } +}; + +using MockMemCopyTestHelper = MemCopyTestHelper; + +template > +LayerTestResult MemCopyTest(bool withSubtensors) +{ + + armnn::IBackendInternal::IMemoryManagerSharedPtr srcMemoryManager = + MemCopyTestHelper::GetMemoryManager(); + + armnn::IBackendInternal::IMemoryManagerSharedPtr dstMemoryManager = + MemCopyTestHelper::GetMemoryManager(); + + SrcWorkloadFactory srcWorkloadFactory = MemCopyTestHelper::GetFactory(srcMemoryManager); + DstWorkloadFactory dstWorkloadFactory = MemCopyTestHelper::GetFactory(dstMemoryManager); + + return MemCopyTest(srcWorkloadFactory, dstWorkloadFactory, withSubtensors); +} + +} // anonymous namespace diff --git a/include/armnnTestUtils/MockWorkloadFactoryHelper.hpp b/include/armnnTestUtils/MockWorkloadFactoryHelper.hpp new file mode 100644 index 0000000000..e9f2b2f6cf --- /dev/null +++ b/include/armnnTestUtils/MockWorkloadFactoryHelper.hpp @@ -0,0 +1,41 @@ +// +// Copyright © 2022 Arm Ltd and Contributors. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#pragma once + +#include "MockBackend.hpp" +#include "MockTensorHandleFactory.hpp" +#include + +namespace +{ + +template <> +struct WorkloadFactoryHelper +{ + static armnn::IBackendInternal::IMemoryManagerSharedPtr GetMemoryManager() + { + armnn::MockBackend backend; + return backend.CreateMemoryManager(); + } + + static armnn::MockWorkloadFactory + GetFactory(const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager = nullptr) + { + IgnoreUnused(memoryManager); + return armnn::MockWorkloadFactory(); + } + + static armnn::MockTensorHandleFactory + GetTensorHandleFactory(const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager = nullptr) + { + + return armnn::MockTensorHandleFactory(std::static_pointer_cast(memoryManager)); + } +}; + +using MockWorkloadFactoryHelper = WorkloadFactoryHelper; + +} // anonymous namespace diff --git a/include/armnnTestUtils/TensorHelpers.hpp b/include/armnnTestUtils/TensorHelpers.hpp new file mode 100644 index 0000000000..ca17e621c3 --- /dev/null +++ b/include/armnnTestUtils/TensorHelpers.hpp @@ -0,0 +1,235 @@ +// +// Copyright © 2017 Arm Ltd and Contributors. All rights reserved. +// SPDX-License-Identifier: MIT +// +#pragma once + +#include + +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include + +constexpr float g_FloatCloseToZeroTolerance = 1.0e-6f; + +template +struct SelectiveComparer +{ + static bool Compare(T a, T b) + { + return (std::max(a, b) - std::min(a, b)) <= 1; + } + +}; + +template +struct SelectiveComparer +{ + static bool Compare(T a, T b) + { + // If a or b is zero, percent_tolerance does an exact match, so compare to a small, constant tolerance instead. + if (a == 0.0f || b == 0.0f) + { + return std::abs(a - b) <= g_FloatCloseToZeroTolerance; + } + + if (std::isinf(a) && a == b) + { + return true; + } + + if (std::isnan(a) && std::isnan(b)) + { + return true; + } + + // For unquantized floats we use a tolerance of 1%. + return armnnUtils::within_percentage_tolerance(a, b); + } +}; + +template +bool SelectiveCompare(T a, T b) +{ + return SelectiveComparer()>::Compare(a, b); +}; + +template +bool SelectiveCompareBoolean(T a, T b) +{ + return (((a == 0) && (b == 0)) || ((a != 0) && (b != 0))); +}; + +template +armnn::PredicateResult CompareTensors(const std::vector& actualData, + const std::vector& expectedData, + const armnn::TensorShape& actualShape, + const armnn::TensorShape& expectedShape, + bool compareBoolean = false, + bool isDynamic = false) +{ + if (actualData.size() != expectedData.size()) + { + armnn::PredicateResult res(false); + res.Message() << "Different data size [" + << actualData.size() + << "!=" + << expectedData.size() + << "]"; + return res; + } + + if (actualShape.GetNumDimensions() != expectedShape.GetNumDimensions()) + { + armnn::PredicateResult res(false); + res.Message() << "Different number of dimensions [" + << actualShape.GetNumDimensions() + << "!=" + << expectedShape.GetNumDimensions() + << "]"; + return res; + } + + if (actualShape.GetNumElements() != expectedShape.GetNumElements()) + { + armnn::PredicateResult res(false); + res.Message() << "Different number of elements [" + << actualShape.GetNumElements() + << "!=" + << expectedShape.GetNumElements() + << "]"; + return res; + } + + unsigned int numberOfDimensions = actualShape.GetNumDimensions(); + + if (!isDynamic) + { + // Checks they are same shape. + for (unsigned int i = 0; i < numberOfDimensions; ++i) + { + if (actualShape[i] != expectedShape[i]) + { + armnn::PredicateResult res(false); + res.Message() << "Different shapes [" + << actualShape[i] + << "!=" + << expectedShape[i] + << "]"; + return res; + } + } + } + + // Fun iteration over n dimensions. + std::vector indices; + for (unsigned int i = 0; i < numberOfDimensions; i++) + { + indices.emplace_back(0); + } + + std::stringstream errorString; + int numFailedElements = 0; + constexpr int maxReportedDifferences = 3; + unsigned int index = 0; + + // Compare data element by element. + while (true) + { + bool comparison; + // As true for uint8_t is non-zero (1-255) we must have a dedicated compare for Booleans. + if(compareBoolean) + { + comparison = SelectiveCompareBoolean(actualData[index], expectedData[index]); + } + else + { + comparison = SelectiveCompare(actualData[index], expectedData[index]); + } + + if (!comparison) + { + ++numFailedElements; + + if (numFailedElements <= maxReportedDifferences) + { + if (numFailedElements >= 2) + { + errorString << ", "; + } + errorString << "["; + for (unsigned int i = 0; i < numberOfDimensions; ++i) + { + errorString << indices[i]; + if (i != numberOfDimensions - 1) + { + errorString << ","; + } + } + errorString << "]"; + + errorString << " (" << +actualData[index] << " != " << +expectedData[index] << ")"; + } + } + + ++indices[numberOfDimensions - 1]; + for (unsigned int i=numberOfDimensions-1; i>0; i--) + { + if (indices[i] == actualShape[i]) + { + indices[i] = 0; + ++indices[i - 1]; + } + } + if (indices[0] == actualShape[0]) + { + break; + } + + index++; + } + + armnn::PredicateResult comparisonResult(true); + if (numFailedElements > 0) + { + comparisonResult.SetResult(false); + comparisonResult.Message() << numFailedElements << " different values at: "; + if (numFailedElements > maxReportedDifferences) + { + errorString << ", ... (and " << (numFailedElements - maxReportedDifferences) << " other differences)"; + } + comparisonResult.Message() << errorString.str(); + } + + return comparisonResult; +} + +template +std::vector MakeRandomTensor(const armnn::TensorInfo& tensorInfo, + unsigned int seed, + float min = -10.0f, + float max = 10.0f) +{ + std::mt19937 gen(seed); + std::uniform_real_distribution dist(min, max); + + std::vector init(tensorInfo.GetNumElements()); + for (unsigned int i = 0; i < init.size(); i++) + { + init[i] = dist(gen); + } + + const float qScale = tensorInfo.GetQuantizationScale(); + const int32_t qOffset = tensorInfo.GetQuantizationOffset(); + + return armnnUtils::QuantizedVector(init, qScale, qOffset); +} diff --git a/include/armnnUtils/QuantizeHelper.hpp b/include/armnnUtils/QuantizeHelper.hpp new file mode 100644 index 0000000000..231b8411cb --- /dev/null +++ b/include/armnnUtils/QuantizeHelper.hpp @@ -0,0 +1,132 @@ +// +// Copyright © 2017 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#pragma once + +#include +#include +#include + +#include +#include + +#include +#include +#include + +namespace armnnUtils +{ + +template +struct SelectiveQuantizer +{ + static T Quantize(float value, float scale, int32_t offset) + { + return armnn::Quantize(value, scale, offset); + } + + static float Dequantize(T value, float scale, int32_t offset) + { + return armnn::Dequantize(value, scale, offset); + } +}; + +template +struct SelectiveQuantizer +{ + static T Quantize(float value, float scale, int32_t offset) + { + armnn::IgnoreUnused(scale, offset); + return value; + } + + static float Dequantize(T value, float scale, int32_t offset) + { + armnn::IgnoreUnused(scale, offset); + return value; + } +}; + +template<> +struct SelectiveQuantizer +{ + static armnn::Half Quantize(float value, float scale, int32_t offset) + { + armnn::IgnoreUnused(scale, offset); + return armnn::Half(value); + } + + static float Dequantize(armnn::Half value, float scale, int32_t offset) + { + armnn::IgnoreUnused(scale, offset); + return value; + } +}; + +template<> +struct SelectiveQuantizer +{ + static armnn::BFloat16 Quantize(float value, float scale, int32_t offset) + { + armnn::IgnoreUnused(scale, offset); + return armnn::BFloat16(value); + } + + static float Dequantize(armnn::BFloat16 value, float scale, int32_t offset) + { + armnn::IgnoreUnused(scale, offset); + return value; + } +}; + +template +T SelectiveQuantize(float value, float scale, int32_t offset) +{ + return SelectiveQuantizer()>::Quantize(value, scale, offset); +}; + +template +float SelectiveDequantize(T value, float scale, int32_t offset) +{ + return SelectiveQuantizer()>::Dequantize(value, scale, offset); +}; + +template +struct IsFloatingPointIterator +{ + static constexpr bool value=std::is_floating_point::value_type>::value; +}; + +template ::value, int>::type=0 // Makes sure fp iterator is valid. +> +std::vector QuantizedVector(FloatIt first, FloatIt last, float qScale, int32_t qOffset) +{ + std::vector quantized; + quantized.reserve(armnn::numeric_cast(std::distance(first, last))); + + for (auto it = first; it != last; ++it) + { + auto f = *it; + T q = SelectiveQuantize(f, qScale, qOffset); + quantized.push_back(q); + } + + return quantized; +} + +template +std::vector QuantizedVector(const std::vector& array, float qScale = 1.f, int32_t qOffset = 0) +{ + return QuantizedVector(array.begin(), array.end(), qScale, qOffset); +} + +template +std::vector QuantizedVector(std::initializer_list array, float qScale = 1.f, int32_t qOffset = 0) +{ + return QuantizedVector(array.begin(), array.end(), qScale, qOffset); +} + +} // namespace armnnUtils diff --git a/src/armnn/optimizations/FoldPadIntoLayer2d.hpp b/src/armnn/optimizations/FoldPadIntoLayer2d.hpp index 73188883b2..87117debe9 100644 --- a/src/armnn/optimizations/FoldPadIntoLayer2d.hpp +++ b/src/armnn/optimizations/FoldPadIntoLayer2d.hpp @@ -7,7 +7,7 @@ #include "Optimization.hpp" -#include +#include #include #include diff --git a/src/armnn/test/TensorHelpers.hpp b/src/armnn/test/TensorHelpers.hpp index 626cda3d1c..c3571d0c5b 100644 --- a/src/armnn/test/TensorHelpers.hpp +++ b/src/armnn/test/TensorHelpers.hpp @@ -3,7 +3,8 @@ // SPDX-License-Identifier: MIT // -// This file is deprecated and will be removed soon. -// Please use the new header in armnnTestUtils instead. -// This will use the new armnnTestUtils header. -#include "../../armnnTestUtils/TensorHelpers.hpp" \ No newline at end of file +#pragma message("./src/armnn/test/TensorHelpers.hpp has been deprecated, it" \ + " is due for removal in 22.11 release. Please use public" \ + " interface include/armnnTestUtils/TensorHelpers.hpp") + +#include "armnnTestUtils/TensorHelpers.hpp" \ No newline at end of file diff --git a/src/armnn/test/optimizations/FuseActivationTests.cpp b/src/armnn/test/optimizations/FuseActivationTests.cpp index 99b2b80556..ac327bb609 100644 --- a/src/armnn/test/optimizations/FuseActivationTests.cpp +++ b/src/armnn/test/optimizations/FuseActivationTests.cpp @@ -13,7 +13,7 @@ #include -#include +#include #include using namespace armnn; diff --git a/src/armnnDeserializer/test/DeserializeCast.cpp b/src/armnnDeserializer/test/DeserializeCast.cpp index b56b6ce91f..d9763150f7 100644 --- a/src/armnnDeserializer/test/DeserializeCast.cpp +++ b/src/armnnDeserializer/test/DeserializeCast.cpp @@ -6,7 +6,7 @@ #include "ParserFlatbuffersSerializeFixture.hpp" #include -#include +#include #include #include diff --git a/src/armnnDeserializer/test/DeserializeComparison.cpp b/src/armnnDeserializer/test/DeserializeComparison.cpp index 3dda34c0fd..0f60250377 100644 --- a/src/armnnDeserializer/test/DeserializeComparison.cpp +++ b/src/armnnDeserializer/test/DeserializeComparison.cpp @@ -6,7 +6,7 @@ #include "ParserFlatbuffersSerializeFixture.hpp" #include -#include +#include #include #include diff --git a/src/armnnDeserializer/test/ParserFlatbuffersSerializeFixture.hpp b/src/armnnDeserializer/test/ParserFlatbuffersSerializeFixture.hpp index 246f5b49ca..31ff026887 100644 --- a/src/armnnDeserializer/test/ParserFlatbuffersSerializeFixture.hpp +++ b/src/armnnDeserializer/test/ParserFlatbuffersSerializeFixture.hpp @@ -6,7 +6,7 @@ #pragma once #include "SchemaSerialize.hpp" -#include "TensorHelpers.hpp" +#include #include "flatbuffers/idl.h" #include "flatbuffers/util.h" diff --git a/src/armnnTestUtils/CMakeLists.txt b/src/armnnTestUtils/CMakeLists.txt index cab0ba353e..e33fed77d7 100755 --- a/src/armnnTestUtils/CMakeLists.txt +++ b/src/armnnTestUtils/CMakeLists.txt @@ -11,10 +11,11 @@ list(APPEND armnnTestUtils_sources ../../include/armnnTestUtils/MockBackend.hpp ../../include/armnnTestUtils/MockMemoryManager.hpp ../../include/armnnTestUtils/MockTensorHandle.hpp + ../../include/armnnTestUtils/MockWorkloadFactoryHelper.hpp ../../include/armnnTestUtils/PredicateResult.hpp ../../include/armnnTestUtils/TensorCopyUtils.hpp ../../include/armnnTestUtils/WorkloadTestUtils.hpp - TensorHelpers.hpp + ../../include/armnnTestUtils/TensorHelpers.hpp CreateWorkload.hpp CommonTestUtils.cpp CommonTestUtils.hpp @@ -24,9 +25,7 @@ list(APPEND armnnTestUtils_sources MockBackend.cpp MockMemoryManager.cpp MockTensorHandle.cpp - MockTensorHandleFactory.hpp MockTensorHandleFactory.cpp - MockWorkloadFactoryHelper.hpp TensorCopyUtils.cpp TestUtils.cpp TestUtils.hpp diff --git a/src/armnnTestUtils/MockBackend.cpp b/src/armnnTestUtils/MockBackend.cpp index 40f97cd28e..29996bfd26 100644 --- a/src/armnnTestUtils/MockBackend.cpp +++ b/src/armnnTestUtils/MockBackend.cpp @@ -15,6 +15,12 @@ constexpr const char* MockBackendId() return "CpuMock"; } +const BackendId& MockBackend::GetIdStatic() +{ + static const BackendId s_Id{MockBackendId()}; + return s_Id; +} + namespace { static const BackendId s_Id{ MockBackendId() }; diff --git a/src/armnnTestUtils/MockWorkloadFactoryHelper.hpp b/src/armnnTestUtils/MockWorkloadFactoryHelper.hpp deleted file mode 100644 index 6b61cf6474..0000000000 --- a/src/armnnTestUtils/MockWorkloadFactoryHelper.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// -// Copyright © 2022 Arm Ltd and Contributors. All rights reserved. -// SPDX-License-Identifier: MIT -// - -#pragma once - -#include -#include -#include - -namespace -{ - -template <> -struct WorkloadFactoryHelper -{ - static armnn::IBackendInternal::IMemoryManagerSharedPtr GetMemoryManager() - { - armnn::MockBackend backend; - return backend.CreateMemoryManager(); - } - - static armnn::MockWorkloadFactory - GetFactory(const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager = nullptr) - { - IgnoreUnused(memoryManager); - return armnn::MockWorkloadFactory(); - } - - static armnn::MockTensorHandleFactory - GetTensorHandleFactory(const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager = nullptr) - { - - return armnn::MockTensorHandleFactory(std::static_pointer_cast(memoryManager)); - } -}; - -using MockWorkloadFactoryHelper = WorkloadFactoryHelper; - -} // anonymous namespace diff --git a/src/armnnTestUtils/TensorHelpers.hpp b/src/armnnTestUtils/TensorHelpers.hpp deleted file mode 100644 index d51e4b1bce..0000000000 --- a/src/armnnTestUtils/TensorHelpers.hpp +++ /dev/null @@ -1,235 +0,0 @@ -// -// Copyright © 2017 Arm Ltd and Contributors. All rights reserved. -// SPDX-License-Identifier: MIT -// -#pragma once - -#include - -#include -#include -#include - -#include - -#include - -#include -#include -#include -#include - -constexpr float g_FloatCloseToZeroTolerance = 1.0e-6f; - -template -struct SelectiveComparer -{ - static bool Compare(T a, T b) - { - return (std::max(a, b) - std::min(a, b)) <= 1; - } - -}; - -template -struct SelectiveComparer -{ - static bool Compare(T a, T b) - { - // If a or b is zero, percent_tolerance does an exact match, so compare to a small, constant tolerance instead. - if (a == 0.0f || b == 0.0f) - { - return std::abs(a - b) <= g_FloatCloseToZeroTolerance; - } - - if (std::isinf(a) && a == b) - { - return true; - } - - if (std::isnan(a) && std::isnan(b)) - { - return true; - } - - // For unquantized floats we use a tolerance of 1%. - return armnnUtils::within_percentage_tolerance(a, b); - } -}; - -template -bool SelectiveCompare(T a, T b) -{ - return SelectiveComparer()>::Compare(a, b); -}; - -template -bool SelectiveCompareBoolean(T a, T b) -{ - return (((a == 0) && (b == 0)) || ((a != 0) && (b != 0))); -}; - -template -armnn::PredicateResult CompareTensors(const std::vector& actualData, - const std::vector& expectedData, - const armnn::TensorShape& actualShape, - const armnn::TensorShape& expectedShape, - bool compareBoolean = false, - bool isDynamic = false) -{ - if (actualData.size() != expectedData.size()) - { - armnn::PredicateResult res(false); - res.Message() << "Different data size [" - << actualData.size() - << "!=" - << expectedData.size() - << "]"; - return res; - } - - if (actualShape.GetNumDimensions() != expectedShape.GetNumDimensions()) - { - armnn::PredicateResult res(false); - res.Message() << "Different number of dimensions [" - << actualShape.GetNumDimensions() - << "!=" - << expectedShape.GetNumDimensions() - << "]"; - return res; - } - - if (actualShape.GetNumElements() != expectedShape.GetNumElements()) - { - armnn::PredicateResult res(false); - res.Message() << "Different number of elements [" - << actualShape.GetNumElements() - << "!=" - << expectedShape.GetNumElements() - << "]"; - return res; - } - - unsigned int numberOfDimensions = actualShape.GetNumDimensions(); - - if (!isDynamic) - { - // Checks they are same shape. - for (unsigned int i = 0; i < numberOfDimensions; ++i) - { - if (actualShape[i] != expectedShape[i]) - { - armnn::PredicateResult res(false); - res.Message() << "Different shapes [" - << actualShape[i] - << "!=" - << expectedShape[i] - << "]"; - return res; - } - } - } - - // Fun iteration over n dimensions. - std::vector indices; - for (unsigned int i = 0; i < numberOfDimensions; i++) - { - indices.emplace_back(0); - } - - std::stringstream errorString; - int numFailedElements = 0; - constexpr int maxReportedDifferences = 3; - unsigned int index = 0; - - // Compare data element by element. - while (true) - { - bool comparison; - // As true for uint8_t is non-zero (1-255) we must have a dedicated compare for Booleans. - if(compareBoolean) - { - comparison = SelectiveCompareBoolean(actualData[index], expectedData[index]); - } - else - { - comparison = SelectiveCompare(actualData[index], expectedData[index]); - } - - if (!comparison) - { - ++numFailedElements; - - if (numFailedElements <= maxReportedDifferences) - { - if (numFailedElements >= 2) - { - errorString << ", "; - } - errorString << "["; - for (unsigned int i = 0; i < numberOfDimensions; ++i) - { - errorString << indices[i]; - if (i != numberOfDimensions - 1) - { - errorString << ","; - } - } - errorString << "]"; - - errorString << " (" << +actualData[index] << " != " << +expectedData[index] << ")"; - } - } - - ++indices[numberOfDimensions - 1]; - for (unsigned int i=numberOfDimensions-1; i>0; i--) - { - if (indices[i] == actualShape[i]) - { - indices[i] = 0; - ++indices[i - 1]; - } - } - if (indices[0] == actualShape[0]) - { - break; - } - - index++; - } - - armnn::PredicateResult comparisonResult(true); - if (numFailedElements > 0) - { - comparisonResult.SetResult(false); - comparisonResult.Message() << numFailedElements << " different values at: "; - if (numFailedElements > maxReportedDifferences) - { - errorString << ", ... (and " << (numFailedElements - maxReportedDifferences) << " other differences)"; - } - comparisonResult.Message() << errorString.str(); - } - - return comparisonResult; -} - -template -std::vector MakeRandomTensor(const armnn::TensorInfo& tensorInfo, - unsigned int seed, - float min = -10.0f, - float max = 10.0f) -{ - std::mt19937 gen(seed); - std::uniform_real_distribution dist(min, max); - - std::vector init(tensorInfo.GetNumElements()); - for (unsigned int i = 0; i < init.size(); i++) - { - init[i] = dist(gen); - } - - const float qScale = tensorInfo.GetQuantizationScale(); - const int32_t qOffset = tensorInfo.GetQuantizationOffset(); - - return armnnUtils::QuantizedVector(init, qScale, qOffset); -} diff --git a/src/armnnTestUtils/UnitTests.hpp b/src/armnnTestUtils/UnitTests.hpp index 82b87a1cee..f560720c9b 100644 --- a/src/armnnTestUtils/UnitTests.hpp +++ b/src/armnnTestUtils/UnitTests.hpp @@ -4,7 +4,7 @@ // #pragma once -#include "TensorHelpers.hpp" +#include "armnnTestUtils/TensorHelpers.hpp" #include #include diff --git a/src/armnnTfLiteParser/test/DetectionPostProcess.cpp b/src/armnnTfLiteParser/test/DetectionPostProcess.cpp index 5dc78c697a..2f9f29c223 100644 --- a/src/armnnTfLiteParser/test/DetectionPostProcess.cpp +++ b/src/armnnTfLiteParser/test/DetectionPostProcess.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include TEST_SUITE("TensorflowLiteParser_DetectionPostProcess") { diff --git a/src/armnnTfLiteParser/test/ParserFlatbuffersFixture.hpp b/src/armnnTfLiteParser/test/ParserFlatbuffersFixture.hpp index 116dd157d4..9e98774ada 100644 --- a/src/armnnTfLiteParser/test/ParserFlatbuffersFixture.hpp +++ b/src/armnnTfLiteParser/test/ParserFlatbuffersFixture.hpp @@ -16,7 +16,7 @@ #include -#include +#include #include #include diff --git a/src/armnnUtils/ParserPrototxtFixture.hpp b/src/armnnUtils/ParserPrototxtFixture.hpp index 31ee8293a2..ccb99be594 100644 --- a/src/armnnUtils/ParserPrototxtFixture.hpp +++ b/src/armnnUtils/ParserPrototxtFixture.hpp @@ -6,7 +6,7 @@ #pragma once #include -#include +#include #include #include diff --git a/src/armnnUtils/QuantizeHelper.hpp b/src/armnnUtils/QuantizeHelper.hpp deleted file mode 100644 index 231b8411cb..0000000000 --- a/src/armnnUtils/QuantizeHelper.hpp +++ /dev/null @@ -1,132 +0,0 @@ -// -// Copyright © 2017 Arm Ltd. All rights reserved. -// SPDX-License-Identifier: MIT -// - -#pragma once - -#include -#include -#include - -#include -#include - -#include -#include -#include - -namespace armnnUtils -{ - -template -struct SelectiveQuantizer -{ - static T Quantize(float value, float scale, int32_t offset) - { - return armnn::Quantize(value, scale, offset); - } - - static float Dequantize(T value, float scale, int32_t offset) - { - return armnn::Dequantize(value, scale, offset); - } -}; - -template -struct SelectiveQuantizer -{ - static T Quantize(float value, float scale, int32_t offset) - { - armnn::IgnoreUnused(scale, offset); - return value; - } - - static float Dequantize(T value, float scale, int32_t offset) - { - armnn::IgnoreUnused(scale, offset); - return value; - } -}; - -template<> -struct SelectiveQuantizer -{ - static armnn::Half Quantize(float value, float scale, int32_t offset) - { - armnn::IgnoreUnused(scale, offset); - return armnn::Half(value); - } - - static float Dequantize(armnn::Half value, float scale, int32_t offset) - { - armnn::IgnoreUnused(scale, offset); - return value; - } -}; - -template<> -struct SelectiveQuantizer -{ - static armnn::BFloat16 Quantize(float value, float scale, int32_t offset) - { - armnn::IgnoreUnused(scale, offset); - return armnn::BFloat16(value); - } - - static float Dequantize(armnn::BFloat16 value, float scale, int32_t offset) - { - armnn::IgnoreUnused(scale, offset); - return value; - } -}; - -template -T SelectiveQuantize(float value, float scale, int32_t offset) -{ - return SelectiveQuantizer()>::Quantize(value, scale, offset); -}; - -template -float SelectiveDequantize(T value, float scale, int32_t offset) -{ - return SelectiveQuantizer()>::Dequantize(value, scale, offset); -}; - -template -struct IsFloatingPointIterator -{ - static constexpr bool value=std::is_floating_point::value_type>::value; -}; - -template ::value, int>::type=0 // Makes sure fp iterator is valid. -> -std::vector QuantizedVector(FloatIt first, FloatIt last, float qScale, int32_t qOffset) -{ - std::vector quantized; - quantized.reserve(armnn::numeric_cast(std::distance(first, last))); - - for (auto it = first; it != last; ++it) - { - auto f = *it; - T q = SelectiveQuantize(f, qScale, qOffset); - quantized.push_back(q); - } - - return quantized; -} - -template -std::vector QuantizedVector(const std::vector& array, float qScale = 1.f, int32_t qOffset = 0) -{ - return QuantizedVector(array.begin(), array.end(), qScale, qOffset); -} - -template -std::vector QuantizedVector(std::initializer_list array, float qScale = 1.f, int32_t qOffset = 0) -{ - return QuantizedVector(array.begin(), array.end(), qScale, qOffset); -} - -} // namespace armnnUtils diff --git a/src/armnnUtils/test/QuantizeHelperTest.cpp b/src/armnnUtils/test/QuantizeHelperTest.cpp index 6df6d808cb..e71415b6fa 100644 --- a/src/armnnUtils/test/QuantizeHelperTest.cpp +++ b/src/armnnUtils/test/QuantizeHelperTest.cpp @@ -3,7 +3,7 @@ // SPDX-License-Identifier: MIT // -#include +#include #include #include diff --git a/src/backends/aclCommon/test/MemCopyTestImpl.hpp b/src/backends/aclCommon/test/MemCopyTestImpl.hpp index 956ea27c15..0c38ed99fe 100644 --- a/src/backends/aclCommon/test/MemCopyTestImpl.hpp +++ b/src/backends/aclCommon/test/MemCopyTestImpl.hpp @@ -1,94 +1,10 @@ // -// Copyright © 2017 Arm Ltd. All rights reserved. +// Copyright © 2022 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // -#pragma once -#include -#include +#include -#include - -#include -#include -#include -#include - -namespace -{ - -template> -LayerTestResult MemCopyTest(armnn::IWorkloadFactory& srcWorkloadFactory, - armnn::IWorkloadFactory& dstWorkloadFactory, - bool withSubtensors) -{ - const std::array shapeData = { { 1u, 1u, 6u, 5u } }; - const armnn::TensorShape tensorShape(4, shapeData.data()); - const armnn::TensorInfo tensorInfo(tensorShape, dataType); - std::vector inputData = - { - 1, 2, 3, 4, 5, - 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, - 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, - }; - - LayerTestResult ret(tensorInfo); - ret.m_ExpectedData = inputData; - - std::vector actualOutput(tensorInfo.GetNumElements()); - - ARMNN_NO_DEPRECATE_WARN_BEGIN - auto inputTensorHandle = srcWorkloadFactory.CreateTensorHandle(tensorInfo); - auto outputTensorHandle = dstWorkloadFactory.CreateTensorHandle(tensorInfo); - ARMNN_NO_DEPRECATE_WARN_END - - AllocateAndCopyDataToITensorHandle(inputTensorHandle.get(), inputData.data()); - outputTensorHandle->Allocate(); - - armnn::MemCopyQueueDescriptor memCopyQueueDesc; - armnn::WorkloadInfo workloadInfo; - - const unsigned int origin[4] = {}; - - ARMNN_NO_DEPRECATE_WARN_BEGIN - auto workloadInput = (withSubtensors && srcWorkloadFactory.SupportsSubTensors()) - ? srcWorkloadFactory.CreateSubTensorHandle(*inputTensorHandle, tensorShape, origin) - : std::move(inputTensorHandle); - auto workloadOutput = (withSubtensors && dstWorkloadFactory.SupportsSubTensors()) - ? dstWorkloadFactory.CreateSubTensorHandle(*outputTensorHandle, tensorShape, origin) - : std::move(outputTensorHandle); - ARMNN_NO_DEPRECATE_WARN_END - - AddInputToWorkload(memCopyQueueDesc, workloadInfo, tensorInfo, workloadInput.get()); - AddOutputToWorkload(memCopyQueueDesc, workloadInfo, tensorInfo, workloadOutput.get()); - - dstWorkloadFactory.CreateWorkload(armnn::LayerType::MemCopy, memCopyQueueDesc, workloadInfo)->Execute(); - - CopyDataFromITensorHandle(actualOutput.data(), workloadOutput.get()); - ret.m_ActualData = actualOutput; - - return ret; -} - -template> -LayerTestResult MemCopyTest(bool withSubtensors) -{ - armnn::IBackendInternal::IMemoryManagerSharedPtr srcMemoryManager = - WorkloadFactoryHelper::GetMemoryManager(); - - armnn::IBackendInternal::IMemoryManagerSharedPtr dstMemoryManager = - WorkloadFactoryHelper::GetMemoryManager(); - - SrcWorkloadFactory srcWorkloadFactory = WorkloadFactoryHelper::GetFactory(srcMemoryManager); - DstWorkloadFactory dstWorkloadFactory = WorkloadFactoryHelper::GetFactory(dstMemoryManager); - - return MemCopyTest(srcWorkloadFactory, dstWorkloadFactory, withSubtensors); -} - -} // anonymous namespace +#pragma message("./src/backends/aclCommon/test/MemCopyTestImpl.hpp has been"\ + " deprecated, it is due for removal in 22.11 release. Please"\ + " use public interface include/armnnTestUtils/MemCopyTestImpl.hpp") diff --git a/src/backends/aclCommon/test/MemCopyTests.cpp b/src/backends/aclCommon/test/MemCopyTests.cpp index 132550342c..7b7d4ffb9e 100644 --- a/src/backends/aclCommon/test/MemCopyTests.cpp +++ b/src/backends/aclCommon/test/MemCopyTests.cpp @@ -4,13 +4,13 @@ // #include -#include #if defined(ARMCOMPUTECL_ENABLED) && defined(ARMCOMPUTENEON_ENABLED) +#include +#include #include #include #include - #include #include #endif @@ -42,6 +42,50 @@ TEST_CASE("AclTypeConversions") #if defined(ARMCOMPUTECL_ENABLED) && defined(ARMCOMPUTENEON_ENABLED) +namespace +{ + +template <> +struct MemCopyTestHelper +{ + static armnn::IBackendInternal::IMemoryManagerSharedPtr GetMemoryManager() + { + armnn::NeonBackend backend; + return backend.CreateMemoryManager(); + } + + static armnn::NeonWorkloadFactory GetFactory( + const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, + const armnn::ModelOptions& modelOptions = {}) + { + armnn::NeonBackend backend; + return armnn::NeonWorkloadFactory(armnn::PolymorphicPointerDowncast(memoryManager), + backend.CreateBackendSpecificModelContext(modelOptions)); + } +}; + +template <> +struct MemCopyTestHelper +{ + static armnn::IBackendInternal::IMemoryManagerSharedPtr GetMemoryManager() + { + armnn::ClBackend backend; + return backend.CreateMemoryManager(); + } + + static armnn::ClWorkloadFactory GetFactory( + const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, + const armnn::ModelOptions& modelOptions = {}) + { + armnn::ClBackend backend; + return armnn::ClWorkloadFactory(armnn::PolymorphicPointerDowncast(memoryManager), + backend.CreateBackendSpecificModelContext(modelOptions)); + } +}; +} // namespace + + + TEST_CASE_FIXTURE(ClContextControlFixture, "CopyBetweenNeonAndGpu") { LayerTestResult result = diff --git a/src/backends/backendsCommon/test/ActivationFixture.hpp b/src/backends/backendsCommon/test/ActivationFixture.hpp index 446c77b1f9..879d7e2d95 100644 --- a/src/backends/backendsCommon/test/ActivationFixture.hpp +++ b/src/backends/backendsCommon/test/ActivationFixture.hpp @@ -9,7 +9,7 @@ #include -#include +#include struct ActivationFixture { diff --git a/src/backends/backendsCommon/test/ArgMinMaxEndToEndTestImpl.hpp b/src/backends/backendsCommon/test/ArgMinMaxEndToEndTestImpl.hpp index 1b653858f8..386d6cbbcb 100644 --- a/src/backends/backendsCommon/test/ArgMinMaxEndToEndTestImpl.hpp +++ b/src/backends/backendsCommon/test/ArgMinMaxEndToEndTestImpl.hpp @@ -7,7 +7,7 @@ #include -#include +#include #include diff --git a/src/backends/backendsCommon/test/Convolution3dEndToEndTestImpl.hpp b/src/backends/backendsCommon/test/Convolution3dEndToEndTestImpl.hpp index fab5670a4f..3451ced8b8 100644 --- a/src/backends/backendsCommon/test/Convolution3dEndToEndTestImpl.hpp +++ b/src/backends/backendsCommon/test/Convolution3dEndToEndTestImpl.hpp @@ -5,7 +5,7 @@ #pragma once #include "EndToEndTestImpl.hpp" -#include "QuantizeHelper.hpp" +#include #include diff --git a/src/backends/backendsCommon/test/DepthToSpaceEndToEndTestImpl.hpp b/src/backends/backendsCommon/test/DepthToSpaceEndToEndTestImpl.hpp index 863d66caeb..905e9a1d63 100644 --- a/src/backends/backendsCommon/test/DepthToSpaceEndToEndTestImpl.hpp +++ b/src/backends/backendsCommon/test/DepthToSpaceEndToEndTestImpl.hpp @@ -8,7 +8,7 @@ #include -#include +#include #include diff --git a/src/backends/backendsCommon/test/EndToEndTestImpl.hpp b/src/backends/backendsCommon/test/EndToEndTestImpl.hpp index 59acb23d95..c69a4a5052 100644 --- a/src/backends/backendsCommon/test/EndToEndTestImpl.hpp +++ b/src/backends/backendsCommon/test/EndToEndTestImpl.hpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include diff --git a/src/backends/backendsCommon/test/QuantizedLstmEndToEndTestImpl.cpp b/src/backends/backendsCommon/test/QuantizedLstmEndToEndTestImpl.cpp index 8a535d2b8d..7552abca4e 100644 --- a/src/backends/backendsCommon/test/QuantizedLstmEndToEndTestImpl.cpp +++ b/src/backends/backendsCommon/test/QuantizedLstmEndToEndTestImpl.cpp @@ -15,7 +15,7 @@ #include -#include +#include #include diff --git a/src/backends/backendsCommon/test/ResizeEndToEndTestImpl.hpp b/src/backends/backendsCommon/test/ResizeEndToEndTestImpl.hpp index 94d0a4debc..f8d17a89b7 100644 --- a/src/backends/backendsCommon/test/ResizeEndToEndTestImpl.hpp +++ b/src/backends/backendsCommon/test/ResizeEndToEndTestImpl.hpp @@ -4,12 +4,9 @@ // #pragma once -#include "QuantizeHelper.hpp" - - #include -#include +#include #include #include diff --git a/src/backends/backendsCommon/test/TransposeConvolution2dEndToEndTestImpl.hpp b/src/backends/backendsCommon/test/TransposeConvolution2dEndToEndTestImpl.hpp index d1b6945d6f..e12813ad91 100644 --- a/src/backends/backendsCommon/test/TransposeConvolution2dEndToEndTestImpl.hpp +++ b/src/backends/backendsCommon/test/TransposeConvolution2dEndToEndTestImpl.hpp @@ -4,12 +4,9 @@ // #pragma once -#include "QuantizeHelper.hpp" - - #include -#include +#include #include #include diff --git a/src/backends/backendsCommon/test/layerTests/ActivationTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/ActivationTestImpl.cpp index ea9973b7d3..1ef47ddf7b 100644 --- a/src/backends/backendsCommon/test/layerTests/ActivationTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/ActivationTestImpl.cpp @@ -5,7 +5,7 @@ #include "ActivationTestImpl.hpp" -#include +#include #include #include @@ -15,7 +15,7 @@ #include -#include +#include #include diff --git a/src/backends/backendsCommon/test/layerTests/AdditionTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/AdditionTestImpl.cpp index 56906bc2a1..61669a9ab9 100644 --- a/src/backends/backendsCommon/test/layerTests/AdditionTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/AdditionTestImpl.cpp @@ -7,7 +7,7 @@ #include "ElementwiseTestImpl.hpp" -#include +#include #include template<> diff --git a/src/backends/backendsCommon/test/layerTests/ArgMinMaxTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/ArgMinMaxTestImpl.cpp index 88d92d22f1..07517f45d6 100644 --- a/src/backends/backendsCommon/test/layerTests/ArgMinMaxTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/ArgMinMaxTestImpl.cpp @@ -10,7 +10,7 @@ #include #include -#include +#include namespace { diff --git a/src/backends/backendsCommon/test/layerTests/BatchNormalizationTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/BatchNormalizationTestImpl.cpp index 928918c83a..caaf73bf75 100644 --- a/src/backends/backendsCommon/test/layerTests/BatchNormalizationTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/BatchNormalizationTestImpl.cpp @@ -5,7 +5,7 @@ #include "BatchNormalizationTestImpl.hpp" -#include +#include #include #include @@ -19,7 +19,7 @@ #include #include -#include +#include namespace { diff --git a/src/backends/backendsCommon/test/layerTests/BatchToSpaceNdTestImpl.hpp b/src/backends/backendsCommon/test/layerTests/BatchToSpaceNdTestImpl.hpp index a5fdfa64d0..b3007771c9 100644 --- a/src/backends/backendsCommon/test/layerTests/BatchToSpaceNdTestImpl.hpp +++ b/src/backends/backendsCommon/test/layerTests/BatchToSpaceNdTestImpl.hpp @@ -10,10 +10,10 @@ #include #include +#include #include #include -#include -#include +#include #include namespace diff --git a/src/backends/backendsCommon/test/layerTests/ComparisonTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/ComparisonTestImpl.cpp index 016d27897e..c5da07279d 100644 --- a/src/backends/backendsCommon/test/layerTests/ComparisonTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/ComparisonTestImpl.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include @@ -16,7 +16,7 @@ #include #include -#include +#include namespace { diff --git a/src/backends/backendsCommon/test/layerTests/ConcatTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/ConcatTestImpl.cpp index 88a392cf18..2563fcf14b 100644 --- a/src/backends/backendsCommon/test/layerTests/ConcatTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/ConcatTestImpl.cpp @@ -5,7 +5,7 @@ #include "ConcatTestImpl.hpp" -#include +#include #include @@ -14,7 +14,7 @@ #include #include -#include +#include using namespace armnn; using namespace armnnUtils; diff --git a/src/backends/backendsCommon/test/layerTests/ConstantTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/ConstantTestImpl.cpp index c9da74985e..6863c0d0f6 100644 --- a/src/backends/backendsCommon/test/layerTests/ConstantTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/ConstantTestImpl.cpp @@ -5,7 +5,7 @@ #include "ConstantTestImpl.hpp" -#include +#include #include @@ -16,7 +16,7 @@ #include #include -#include +#include namespace { diff --git a/src/backends/backendsCommon/test/layerTests/Conv2dTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/Conv2dTestImpl.cpp index 33dfc23b7d..bd7cc40f27 100644 --- a/src/backends/backendsCommon/test/layerTests/Conv2dTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/Conv2dTestImpl.cpp @@ -5,7 +5,7 @@ #include "Conv2dTestImpl.hpp" -#include +#include #include #include @@ -19,7 +19,7 @@ #include #include -#include +#include #include diff --git a/src/backends/backendsCommon/test/layerTests/Conv3dTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/Conv3dTestImpl.cpp index 406fcb4700..d62ffedf3f 100644 --- a/src/backends/backendsCommon/test/layerTests/Conv3dTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/Conv3dTestImpl.cpp @@ -5,7 +5,7 @@ #include "Conv3dTestImpl.hpp" -#include +#include #include @@ -15,7 +15,7 @@ #include #include -#include +#include using namespace armnnUtils; diff --git a/src/backends/backendsCommon/test/layerTests/ConvertBf16ToFp32TestImpl.cpp b/src/backends/backendsCommon/test/layerTests/ConvertBf16ToFp32TestImpl.cpp index 49e1cebc0f..0dd8b598ac 100644 --- a/src/backends/backendsCommon/test/layerTests/ConvertBf16ToFp32TestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/ConvertBf16ToFp32TestImpl.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include LayerTestResult ConvertBf16ToFp32Test( armnn::IWorkloadFactory& workloadFactory, diff --git a/src/backends/backendsCommon/test/layerTests/ConvertFp16ToFp32TestImpl.cpp b/src/backends/backendsCommon/test/layerTests/ConvertFp16ToFp32TestImpl.cpp index d581032838..90a12498dc 100644 --- a/src/backends/backendsCommon/test/layerTests/ConvertFp16ToFp32TestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/ConvertFp16ToFp32TestImpl.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include LayerTestResult SimpleConvertFp16ToFp32Test( armnn::IWorkloadFactory& workloadFactory, diff --git a/src/backends/backendsCommon/test/layerTests/ConvertFp32ToBf16TestImpl.cpp b/src/backends/backendsCommon/test/layerTests/ConvertFp32ToBf16TestImpl.cpp index 61a55f26c2..5ee8f1dd9a 100644 --- a/src/backends/backendsCommon/test/layerTests/ConvertFp32ToBf16TestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/ConvertFp32ToBf16TestImpl.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include LayerTestResult ConvertFp32ToBf16Test( armnn::IWorkloadFactory& workloadFactory, diff --git a/src/backends/backendsCommon/test/layerTests/ConvertFp32ToFp16TestImpl.cpp b/src/backends/backendsCommon/test/layerTests/ConvertFp32ToFp16TestImpl.cpp index 060e7a2762..458a9108cf 100644 --- a/src/backends/backendsCommon/test/layerTests/ConvertFp32ToFp16TestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/ConvertFp32ToFp16TestImpl.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include LayerTestResult SimpleConvertFp32ToFp16Test( armnn::IWorkloadFactory& workloadFactory, diff --git a/src/backends/backendsCommon/test/layerTests/DebugTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/DebugTestImpl.cpp index d2cbdd1412..9226f215aa 100644 --- a/src/backends/backendsCommon/test/layerTests/DebugTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/DebugTestImpl.cpp @@ -5,14 +5,14 @@ #include "DebugTestImpl.hpp" -#include +#include #include #include #include -#include +#include #include diff --git a/src/backends/backendsCommon/test/layerTests/DepthToSpaceTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/DepthToSpaceTestImpl.cpp index 6476e7b0da..273ae6f366 100644 --- a/src/backends/backendsCommon/test/layerTests/DepthToSpaceTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/DepthToSpaceTestImpl.cpp @@ -5,14 +5,14 @@ #include "DepthToSpaceTestImpl.hpp" -#include +#include #include #include #include -#include +#include namespace { diff --git a/src/backends/backendsCommon/test/layerTests/DequantizeTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/DequantizeTestImpl.cpp index e8fabea3ba..1f67e33d95 100644 --- a/src/backends/backendsCommon/test/layerTests/DequantizeTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/DequantizeTestImpl.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include namespace { diff --git a/src/backends/backendsCommon/test/layerTests/DetectionPostProcessTestImpl.hpp b/src/backends/backendsCommon/test/layerTests/DetectionPostProcessTestImpl.hpp index 43e7d15158..7846771ccd 100644 --- a/src/backends/backendsCommon/test/layerTests/DetectionPostProcessTestImpl.hpp +++ b/src/backends/backendsCommon/test/layerTests/DetectionPostProcessTestImpl.hpp @@ -16,7 +16,7 @@ #include #include -#include +#include #include diff --git a/src/backends/backendsCommon/test/layerTests/ElementwiseTestImpl.hpp b/src/backends/backendsCommon/test/layerTests/ElementwiseTestImpl.hpp index 1d42e2096f..da6e11fe3e 100644 --- a/src/backends/backendsCommon/test/layerTests/ElementwiseTestImpl.hpp +++ b/src/backends/backendsCommon/test/layerTests/ElementwiseTestImpl.hpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include diff --git a/src/backends/backendsCommon/test/layerTests/ElementwiseUnaryTestImpl.hpp b/src/backends/backendsCommon/test/layerTests/ElementwiseUnaryTestImpl.hpp index 01aff65170..36a875af42 100644 --- a/src/backends/backendsCommon/test/layerTests/ElementwiseUnaryTestImpl.hpp +++ b/src/backends/backendsCommon/test/layerTests/ElementwiseUnaryTestImpl.hpp @@ -20,7 +20,7 @@ #include #include -#include +#include #include diff --git a/src/backends/backendsCommon/test/layerTests/FakeQuantizationTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/FakeQuantizationTestImpl.cpp index e2fb6fa373..0708e25f5f 100644 --- a/src/backends/backendsCommon/test/layerTests/FakeQuantizationTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/FakeQuantizationTestImpl.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include LayerTestResult FakeQuantizationTest( armnn::IWorkloadFactory& workloadFactory, diff --git a/src/backends/backendsCommon/test/layerTests/FillTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/FillTestImpl.cpp index 1be0e40871..4056120691 100644 --- a/src/backends/backendsCommon/test/layerTests/FillTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/FillTestImpl.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include template LayerTestResult SimpleFillTest( diff --git a/src/backends/backendsCommon/test/layerTests/FloorTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/FloorTestImpl.cpp index fbd962584a..2bf8c97af5 100644 --- a/src/backends/backendsCommon/test/layerTests/FloorTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/FloorTestImpl.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include template LayerTestResult SimpleFloorTest( diff --git a/src/backends/backendsCommon/test/layerTests/FullyConnectedTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/FullyConnectedTestImpl.cpp index 71d2d0a81e..5555772c5a 100644 --- a/src/backends/backendsCommon/test/layerTests/FullyConnectedTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/FullyConnectedTestImpl.cpp @@ -6,7 +6,7 @@ #include "FullyConnectedTestImpl.hpp" -#include +#include #include @@ -14,7 +14,7 @@ #include #include -#include +#include // // Implementation templates diff --git a/src/backends/backendsCommon/test/layerTests/GatherTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/GatherTestImpl.cpp index c89d53be66..73da4baca4 100644 --- a/src/backends/backendsCommon/test/layerTests/GatherTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/GatherTestImpl.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include namespace { diff --git a/src/backends/backendsCommon/test/layerTests/InstanceNormalizationTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/InstanceNormalizationTestImpl.cpp index bebbedad87..8d03ff6ea9 100644 --- a/src/backends/backendsCommon/test/layerTests/InstanceNormalizationTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/InstanceNormalizationTestImpl.cpp @@ -5,7 +5,7 @@ #include "InstanceNormalizationTestImpl.hpp" -#include +#include #include @@ -17,7 +17,7 @@ #include #include -#include +#include namespace { diff --git a/src/backends/backendsCommon/test/layerTests/L2NormalizationTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/L2NormalizationTestImpl.cpp index 0a60658b47..aeee91330d 100644 --- a/src/backends/backendsCommon/test/layerTests/L2NormalizationTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/L2NormalizationTestImpl.cpp @@ -5,7 +5,7 @@ #include "L2NormalizationTestImpl.hpp" -#include +#include #include #include @@ -14,7 +14,7 @@ #include #include -#include +#include #include diff --git a/src/backends/backendsCommon/test/layerTests/LogSoftmaxTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/LogSoftmaxTestImpl.cpp index cb182d6d3f..1184652349 100644 --- a/src/backends/backendsCommon/test/layerTests/LogSoftmaxTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/LogSoftmaxTestImpl.cpp @@ -6,7 +6,7 @@ #include "LogSoftmaxTestImpl.hpp" #include -#include +#include #include @@ -17,7 +17,7 @@ #include #include -#include +#include namespace { diff --git a/src/backends/backendsCommon/test/layerTests/LogicalTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/LogicalTestImpl.cpp index 60e14b5d9d..2bd9372fe9 100644 --- a/src/backends/backendsCommon/test/layerTests/LogicalTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/LogicalTestImpl.cpp @@ -14,7 +14,7 @@ #include #include -#include +#include namespace { diff --git a/src/backends/backendsCommon/test/layerTests/LstmTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/LstmTestImpl.cpp index a69f7270b4..2eaaeb5c9b 100644 --- a/src/backends/backendsCommon/test/layerTests/LstmTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/LstmTestImpl.cpp @@ -5,7 +5,7 @@ #include "LstmTestImpl.hpp" -#include +#include #include @@ -18,7 +18,7 @@ #include #include -#include +#include #include namespace diff --git a/src/backends/backendsCommon/test/layerTests/MirrorPadTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/MirrorPadTestImpl.cpp index d99e5c8fbd..ee5a4d97d2 100644 --- a/src/backends/backendsCommon/test/layerTests/MirrorPadTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/MirrorPadTestImpl.cpp @@ -5,12 +5,12 @@ #include "MirrorPadTestImpl.hpp" -#include +#include #include #include -#include +#include // // Implementation templates diff --git a/src/backends/backendsCommon/test/layerTests/NormalizationTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/NormalizationTestImpl.cpp index 2b2ff0cc14..9c21c7d01f 100644 --- a/src/backends/backendsCommon/test/layerTests/NormalizationTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/NormalizationTestImpl.cpp @@ -15,7 +15,7 @@ #include #include -#include +#include namespace { diff --git a/src/backends/backendsCommon/test/layerTests/PadTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/PadTestImpl.cpp index b1d8c31dfc..8b024e5a35 100644 --- a/src/backends/backendsCommon/test/layerTests/PadTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/PadTestImpl.cpp @@ -5,12 +5,12 @@ #include "PadTestImpl.hpp" -#include +#include #include #include -#include +#include // // Implementation templates diff --git a/src/backends/backendsCommon/test/layerTests/PermuteTestImpl.hpp b/src/backends/backendsCommon/test/layerTests/PermuteTestImpl.hpp index bffa3d47a1..44415cc1b5 100644 --- a/src/backends/backendsCommon/test/layerTests/PermuteTestImpl.hpp +++ b/src/backends/backendsCommon/test/layerTests/PermuteTestImpl.hpp @@ -13,7 +13,7 @@ #include -#include +#include template LayerTestResult SimplePermuteTestImpl( diff --git a/src/backends/backendsCommon/test/layerTests/Pooling2dTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/Pooling2dTestImpl.cpp index 643a5df6be..2d2a5922b5 100644 --- a/src/backends/backendsCommon/test/layerTests/Pooling2dTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/Pooling2dTestImpl.cpp @@ -5,7 +5,7 @@ #include "Pooling2dTestImpl.hpp" -#include +#include #include #include @@ -22,7 +22,7 @@ #include #include -#include +#include namespace { diff --git a/src/backends/backendsCommon/test/layerTests/Pooling3dTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/Pooling3dTestImpl.cpp index 013ed03f08..a708afadc8 100644 --- a/src/backends/backendsCommon/test/layerTests/Pooling3dTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/Pooling3dTestImpl.cpp @@ -6,7 +6,7 @@ #include "Pooling3dTestImpl.hpp" -#include +#include #include #include @@ -22,7 +22,7 @@ #include #include -#include +#include namespace { diff --git a/src/backends/backendsCommon/test/layerTests/PreluTestImpl.hpp b/src/backends/backendsCommon/test/layerTests/PreluTestImpl.hpp index 02452452a3..21f10171e4 100644 --- a/src/backends/backendsCommon/test/layerTests/PreluTestImpl.hpp +++ b/src/backends/backendsCommon/test/layerTests/PreluTestImpl.hpp @@ -7,7 +7,7 @@ #include -#include +#include #include @@ -18,7 +18,7 @@ #include #include -#include +#include template> LayerTestResult PreluTest( diff --git a/src/backends/backendsCommon/test/layerTests/QuantizeTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/QuantizeTestImpl.cpp index 38d6fbaac1..6d749de628 100644 --- a/src/backends/backendsCommon/test/layerTests/QuantizeTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/QuantizeTestImpl.cpp @@ -14,7 +14,7 @@ #include #include -#include +#include namespace { diff --git a/src/backends/backendsCommon/test/layerTests/RankTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/RankTestImpl.cpp index be22fc6eed..1dedfc3906 100644 --- a/src/backends/backendsCommon/test/layerTests/RankTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/RankTestImpl.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include template LayerTestResult RankTest( diff --git a/src/backends/backendsCommon/test/layerTests/ReduceProdTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/ReduceProdTestImpl.cpp index 9506f36bd4..278b349d50 100644 --- a/src/backends/backendsCommon/test/layerTests/ReduceProdTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/ReduceProdTestImpl.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include namespace { diff --git a/src/backends/backendsCommon/test/layerTests/ReduceSumTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/ReduceSumTestImpl.cpp index c8a61bb42d..bda8870b56 100644 --- a/src/backends/backendsCommon/test/layerTests/ReduceSumTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/ReduceSumTestImpl.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include namespace { diff --git a/src/backends/backendsCommon/test/layerTests/ReductionTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/ReductionTestImpl.cpp index 4edf3dd689..b4be4f1396 100644 --- a/src/backends/backendsCommon/test/layerTests/ReductionTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/ReductionTestImpl.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include diff --git a/src/backends/backendsCommon/test/layerTests/ReshapeTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/ReshapeTestImpl.cpp index 217d8e9d4b..57f3f32cc5 100644 --- a/src/backends/backendsCommon/test/layerTests/ReshapeTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/ReshapeTestImpl.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include namespace { diff --git a/src/backends/backendsCommon/test/layerTests/ResizeTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/ResizeTestImpl.cpp index 2e8cc66c09..31251501d3 100644 --- a/src/backends/backendsCommon/test/layerTests/ResizeTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/ResizeTestImpl.cpp @@ -5,7 +5,7 @@ #include "ResizeTestImpl.hpp" -#include +#include #include @@ -16,7 +16,7 @@ #include #include -#include +#include namespace { diff --git a/src/backends/backendsCommon/test/layerTests/ShapeTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/ShapeTestImpl.cpp index e30912c9ed..8db5858e74 100644 --- a/src/backends/backendsCommon/test/layerTests/ShapeTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/ShapeTestImpl.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include template LayerTestResult ShapeTest( diff --git a/src/backends/backendsCommon/test/layerTests/SliceTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/SliceTestImpl.cpp index 95d2320508..90c4762e84 100644 --- a/src/backends/backendsCommon/test/layerTests/SliceTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/SliceTestImpl.cpp @@ -5,14 +5,14 @@ #include "SliceTestImpl.hpp" -#include +#include #include #include #include -#include +#include namespace { diff --git a/src/backends/backendsCommon/test/layerTests/SoftmaxTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/SoftmaxTestImpl.cpp index 1956533611..63375f0f2f 100644 --- a/src/backends/backendsCommon/test/layerTests/SoftmaxTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/SoftmaxTestImpl.cpp @@ -5,7 +5,7 @@ #include "SoftmaxTestImpl.hpp" -#include +#include #include @@ -14,7 +14,7 @@ #include #include -#include +#include #include diff --git a/src/backends/backendsCommon/test/layerTests/SpaceToBatchNdTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/SpaceToBatchNdTestImpl.cpp index 103e3363ba..92876e18bd 100644 --- a/src/backends/backendsCommon/test/layerTests/SpaceToBatchNdTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/SpaceToBatchNdTestImpl.cpp @@ -5,7 +5,7 @@ #include "SpaceToBatchNdTestImpl.hpp" -#include +#include #include @@ -14,7 +14,7 @@ #include #include -#include +#include namespace { diff --git a/src/backends/backendsCommon/test/layerTests/SpaceToDepthTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/SpaceToDepthTestImpl.cpp index f67ed9bcd9..a17ce58e56 100644 --- a/src/backends/backendsCommon/test/layerTests/SpaceToDepthTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/SpaceToDepthTestImpl.cpp @@ -5,7 +5,7 @@ #include "SpaceToDepthTestImpl.hpp" -#include +#include #include @@ -14,7 +14,7 @@ #include #include -#include +#include namespace { diff --git a/src/backends/backendsCommon/test/layerTests/SplitterTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/SplitterTestImpl.cpp index f2ee7bff3d..9e9c29b088 100644 --- a/src/backends/backendsCommon/test/layerTests/SplitterTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/SplitterTestImpl.cpp @@ -5,14 +5,14 @@ #include "SplitterTestImpl.hpp" -#include +#include #include #include #include -#include +#include namespace { diff --git a/src/backends/backendsCommon/test/layerTests/StackTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/StackTestImpl.cpp index 6911c868ad..56f49736bb 100644 --- a/src/backends/backendsCommon/test/layerTests/StackTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/StackTestImpl.cpp @@ -15,7 +15,7 @@ #include #include -#include +#include namespace { diff --git a/src/backends/backendsCommon/test/layerTests/StridedSliceTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/StridedSliceTestImpl.cpp index 865b74c610..10edd85a5b 100644 --- a/src/backends/backendsCommon/test/layerTests/StridedSliceTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/StridedSliceTestImpl.cpp @@ -5,14 +5,14 @@ #include "StridedSliceTestImpl.hpp" -#include +#include #include #include #include -#include +#include namespace { diff --git a/src/backends/backendsCommon/test/layerTests/TransposeConvolution2dTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/TransposeConvolution2dTestImpl.cpp index 41e57de734..e53f9a19fb 100644 --- a/src/backends/backendsCommon/test/layerTests/TransposeConvolution2dTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/TransposeConvolution2dTestImpl.cpp @@ -5,7 +5,7 @@ #include "TransposeConvolution2dTestImpl.hpp" -#include +#include #include @@ -18,7 +18,7 @@ #include -#include +#include #include diff --git a/src/backends/backendsCommon/test/layerTests/TransposeTestImpl.hpp b/src/backends/backendsCommon/test/layerTests/TransposeTestImpl.hpp index 66652f28da..ef271691b6 100644 --- a/src/backends/backendsCommon/test/layerTests/TransposeTestImpl.hpp +++ b/src/backends/backendsCommon/test/layerTests/TransposeTestImpl.hpp @@ -14,7 +14,7 @@ #include #include -#include +#include template LayerTestResult SimpleTransposeTestImpl( diff --git a/src/backends/cl/test/ClCreateWorkloadTests.cpp b/src/backends/cl/test/ClCreateWorkloadTests.cpp index 4a28205ade..4f53b921d0 100644 --- a/src/backends/cl/test/ClCreateWorkloadTests.cpp +++ b/src/backends/cl/test/ClCreateWorkloadTests.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/backends/cl/test/ClLayerSupportTests.cpp b/src/backends/cl/test/ClLayerSupportTests.cpp index f3df594762..8d9a7f107d 100644 --- a/src/backends/cl/test/ClLayerSupportTests.cpp +++ b/src/backends/cl/test/ClLayerSupportTests.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/backends/cl/test/ClLayerTests.cpp b/src/backends/cl/test/ClLayerTests.cpp index 967a7e446c..7f63e6326c 100644 --- a/src/backends/cl/test/ClLayerTests.cpp +++ b/src/backends/cl/test/ClLayerTests.cpp @@ -6,7 +6,7 @@ #include "ClContextControlFixture.hpp" #include "ClWorkloadFactoryHelper.hpp" -#include +#include #include #include diff --git a/src/backends/cl/test/ClMemCopyTests.cpp b/src/backends/cl/test/ClMemCopyTests.cpp index 98b873fb6f..739ea7cdb3 100644 --- a/src/backends/cl/test/ClMemCopyTests.cpp +++ b/src/backends/cl/test/ClMemCopyTests.cpp @@ -3,22 +3,42 @@ // SPDX-License-Identifier: MIT // -#include "ClWorkloadFactoryHelper.hpp" - +#include +#include +#include #include -#include +#include +#include + +namespace +{ -#include -#include +template <> +struct MemCopyTestHelper +{ + static armnn::IBackendInternal::IMemoryManagerSharedPtr GetMemoryManager() + { + armnn::ClBackend backend; + return backend.CreateMemoryManager(); + } -#include + static armnn::ClWorkloadFactory GetFactory( + const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, + const armnn::ModelOptions& modelOptions = {}) + { + armnn::ClBackend backend; + return armnn::ClWorkloadFactory(armnn::PolymorphicPointerDowncast(memoryManager), + backend.CreateBackendSpecificModelContext(modelOptions)); + } +}; +} // namespace TEST_SUITE("ClMemCopy") { TEST_CASE("CopyBetweenCpuAndGpu") { LayerTestResult result = - MemCopyTest(false); + MemCopyTest(false); auto predResult = CompareTensors(result.m_ActualData, result.m_ExpectedData, result.m_ActualShape, result.m_ExpectedShape); CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); @@ -27,7 +47,7 @@ TEST_CASE("CopyBetweenCpuAndGpu") TEST_CASE("CopyBetweenGpuAndCpu") { LayerTestResult result = - MemCopyTest(false); + MemCopyTest(false); auto predResult = CompareTensors(result.m_ActualData, result.m_ExpectedData, result.m_ActualShape, result.m_ExpectedShape); CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); @@ -36,7 +56,7 @@ TEST_CASE("CopyBetweenGpuAndCpu") TEST_CASE("CopyBetweenCpuAndGpuWithSubtensors") { LayerTestResult result = - MemCopyTest(true); + MemCopyTest(true); auto predResult = CompareTensors(result.m_ActualData, result.m_ExpectedData, result.m_ActualShape, result.m_ExpectedShape); CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); @@ -45,7 +65,7 @@ TEST_CASE("CopyBetweenCpuAndGpuWithSubtensors") TEST_CASE("CopyBetweenGpuAndCpuWithSubtensors") { LayerTestResult result = - MemCopyTest(true); + MemCopyTest(true); auto predResult = CompareTensors(result.m_ActualData, result.m_ExpectedData, result.m_ActualShape, result.m_ExpectedShape); CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); diff --git a/src/backends/cl/test/OpenClTimerTest.cpp b/src/backends/cl/test/OpenClTimerTest.cpp index 3d273903bd..24a0afacef 100644 --- a/src/backends/cl/test/OpenClTimerTest.cpp +++ b/src/backends/cl/test/OpenClTimerTest.cpp @@ -7,7 +7,7 @@ #include "ClWorkloadFactoryHelper.hpp" -#include +#include #include #include diff --git a/src/backends/neon/test/NeonLayerSupportTests.cpp b/src/backends/neon/test/NeonLayerSupportTests.cpp index e5bdfb9251..d1f188d283 100644 --- a/src/backends/neon/test/NeonLayerSupportTests.cpp +++ b/src/backends/neon/test/NeonLayerSupportTests.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include diff --git a/src/backends/neon/test/NeonLayerTests.cpp b/src/backends/neon/test/NeonLayerTests.cpp index 3b63a88457..9648c1626a 100644 --- a/src/backends/neon/test/NeonLayerTests.cpp +++ b/src/backends/neon/test/NeonLayerTests.cpp @@ -5,7 +5,7 @@ #include "NeonWorkloadFactoryHelper.hpp" -#include +#include #include #include diff --git a/src/backends/neon/test/NeonMemCopyTests.cpp b/src/backends/neon/test/NeonMemCopyTests.cpp index 048509224b..de4195d771 100644 --- a/src/backends/neon/test/NeonMemCopyTests.cpp +++ b/src/backends/neon/test/NeonMemCopyTests.cpp @@ -3,23 +3,43 @@ // SPDX-License-Identifier: MIT // -#include "NeonWorkloadFactoryHelper.hpp" +#include "../NeonWorkloadFactory.hpp" +#include +#include +#include +#include +#include -#include +namespace +{ -#include +template <> +struct MemCopyTestHelper +{ + static armnn::IBackendInternal::IMemoryManagerSharedPtr GetMemoryManager() + { + armnn::NeonBackend backend; + return backend.CreateMemoryManager(); + } -#include -#include + static armnn::NeonWorkloadFactory GetFactory( + const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, + const armnn::ModelOptions& modelOptions = {}) + { + armnn::NeonBackend backend; + return armnn::NeonWorkloadFactory(armnn::PolymorphicPointerDowncast(memoryManager), + backend.CreateBackendSpecificModelContext(modelOptions)); + } +}; +} // namespace -#include TEST_SUITE("NeonMemCopy") { TEST_CASE("CopyBetweenCpuAndNeon") { LayerTestResult result = - MemCopyTest(false); + MemCopyTest(false); auto predResult = CompareTensors(result.m_ActualData, result.m_ExpectedData, result.m_ActualShape, result.m_ExpectedShape); CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); @@ -28,7 +48,7 @@ TEST_CASE("CopyBetweenCpuAndNeon") TEST_CASE("CopyBetweenNeonAndCpu") { LayerTestResult result = - MemCopyTest(false); + MemCopyTest(false); auto predResult = CompareTensors(result.m_ActualData, result.m_ExpectedData, result.m_ActualShape, result.m_ExpectedShape); CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); @@ -37,7 +57,7 @@ TEST_CASE("CopyBetweenNeonAndCpu") TEST_CASE("CopyBetweenCpuAndNeonWithSubtensors") { LayerTestResult result = - MemCopyTest(true); + MemCopyTest(true); auto predResult = CompareTensors(result.m_ActualData, result.m_ExpectedData, result.m_ActualShape, result.m_ExpectedShape); CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); @@ -46,7 +66,7 @@ TEST_CASE("CopyBetweenCpuAndNeonWithSubtensors") TEST_CASE("CopyBetweenNeonAndCpuWithSubtensors") { LayerTestResult result = - MemCopyTest(true); + MemCopyTest(true); auto predResult = CompareTensors(result.m_ActualData, result.m_ExpectedData, result.m_ActualShape, result.m_ExpectedShape); CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); diff --git a/src/backends/neon/test/NeonTimerTest.cpp b/src/backends/neon/test/NeonTimerTest.cpp index 7d73df83bd..e029d2721c 100644 --- a/src/backends/neon/test/NeonTimerTest.cpp +++ b/src/backends/neon/test/NeonTimerTest.cpp @@ -6,7 +6,7 @@ #include "NeonWorkloadFactoryHelper.hpp" -#include +#include #include #include diff --git a/src/backends/reference/test/CMakeLists.txt b/src/backends/reference/test/CMakeLists.txt index 9d6572a4af..2476c31de6 100644 --- a/src/backends/reference/test/CMakeLists.txt +++ b/src/backends/reference/test/CMakeLists.txt @@ -12,6 +12,7 @@ list(APPEND armnnRefBackendUnitTests_sources RefJsonPrinterTests.cpp RefLayerSupportTests.cpp RefLayerTests.cpp + RefMemCopyTests.cpp RefMemoryManagerTests.cpp RefOptimizedNetworkTests.cpp RefPerAxisIteratorTests.cpp diff --git a/src/backends/reference/test/RefLayerSupportTests.cpp b/src/backends/reference/test/RefLayerSupportTests.cpp index 833e254406..9a27c7c0b3 100644 --- a/src/backends/reference/test/RefLayerSupportTests.cpp +++ b/src/backends/reference/test/RefLayerSupportTests.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include diff --git a/src/backends/reference/test/RefMemCopyTests.cpp b/src/backends/reference/test/RefMemCopyTests.cpp new file mode 100644 index 0000000000..e97d979a9b --- /dev/null +++ b/src/backends/reference/test/RefMemCopyTests.cpp @@ -0,0 +1,70 @@ +// +// Copyright © 2022 Arm Ltd and Contributors. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include +#include +#include +#include +#include +#include + +namespace +{ + +template <> +struct MemCopyTestHelper +{ + static armnn::IBackendInternal::IMemoryManagerSharedPtr GetMemoryManager() + { + armnn::RefBackend backend; + return backend.CreateMemoryManager(); + } + + static armnn::RefWorkloadFactory GetFactory(const armnn::IBackendInternal::IMemoryManagerSharedPtr&) + { + return armnn::RefWorkloadFactory(); + } +}; +} // namespace + +TEST_SUITE("RefMemCopy") +{ + + TEST_CASE("CopyBetweenCpuMockAndRef") + { + LayerTestResult result = + MemCopyTest(false); + auto predResult = + CompareTensors(result.m_ActualData, result.m_ExpectedData, result.m_ActualShape, result.m_ExpectedShape); + CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); + } + + TEST_CASE("CopyBetweenRefAndCpuMock") + { + LayerTestResult result = + MemCopyTest(false); + auto predResult = + CompareTensors(result.m_ActualData, result.m_ExpectedData, result.m_ActualShape, result.m_ExpectedShape); + CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); + } + + TEST_CASE("CopyBetweenCpuMockAndRefWithSubtensors") + { + LayerTestResult result = + MemCopyTest(true); + auto predResult = + CompareTensors(result.m_ActualData, result.m_ExpectedData, result.m_ActualShape, result.m_ExpectedShape); + CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); + } + + TEST_CASE("CopyBetweenRefAndCpuMockWithSubtensors") + { + LayerTestResult result = + MemCopyTest(true); + auto predResult = + CompareTensors(result.m_ActualData, result.m_ExpectedData, result.m_ActualShape, result.m_ExpectedShape); + CHECK_MESSAGE(predResult.m_Result, predResult.m_Message.str()); + } +} diff --git a/tests/MobileNetSsdDatabase.hpp b/tests/MobileNetSsdDatabase.hpp index 9cd987d2ed..0c2219d2fc 100644 --- a/tests/MobileNetSsdDatabase.hpp +++ b/tests/MobileNetSsdDatabase.hpp @@ -8,7 +8,7 @@ #include "InferenceTestImage.hpp" #include "ObjectDetectionCommon.hpp" -#include +#include #include #include -- cgit v1.2.1