From c6f9510bcb754afaadfe9477ff85d6c55ffcf43b Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Tue, 30 Mar 2021 10:03:01 +0100 Subject: Remove Computer Vision generic interfaces and types Removes: - reference validation routines - CV related types and structures - CV related interfaces Signed-off-by: Georgios Pinitas Change-Id: I3a203da12d9b04c154059b190aeba18a611149a9 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5340 Tested-by: Arm Jenkins Reviewed-by: Michele Di Giorgio Comments-Addressed: Arm Jenkins --- Android.bp | 32 -- arm_compute/core/CL/CLDevice.h | 3 +- arm_compute/core/CL/CLHelpers.h | 1 + arm_compute/core/CL/CLTypes.h | 37 +- arm_compute/core/CL/ICLArray.h | 10 +- arm_compute/core/CL/ICLDistribution1D.h | 102 ---- arm_compute/core/CL/ICLHOG.h | 113 ----- arm_compute/core/CL/ICLLut.h | 94 ---- arm_compute/core/CL/ICLMultiHOG.h | 56 --- arm_compute/core/CL/ICLMultiImage.h | 59 --- arm_compute/core/CPP/CPPKernels.h | 5 +- .../core/CPP/kernels/CPPCornerCandidatesKernel.h | 80 --- .../CPPDetectionWindowNonMaximaSuppressionKernel.h | 77 --- .../CPP/kernels/CPPSortEuclideanDistanceKernel.h | 73 --- arm_compute/core/HOGInfo.h | 152 ------ arm_compute/core/IArray.h | 15 +- arm_compute/core/IDistribution.h | 59 --- arm_compute/core/IDistribution1D.h | 84 ---- arm_compute/core/IHOG.h | 54 --- arm_compute/core/ILut.h | 69 --- arm_compute/core/IMultiHOG.h | 61 --- arm_compute/core/IMultiImage.h | 60 --- arm_compute/core/IPyramid.h | 56 --- arm_compute/core/KernelDescriptors.h | 24 - arm_compute/core/MultiImageInfo.h | 66 --- arm_compute/core/PyramidInfo.h | 131 ----- arm_compute/core/TensorInfo.h | 28 -- arm_compute/core/Types.h | 87 ---- arm_compute/core/Utils.h | 201 -------- arm_compute/core/Validate.h | 28 +- arm_compute/runtime/Array.h | 10 +- arm_compute/runtime/CL/CLArray.h | 11 +- arm_compute/runtime/CL/CLDistribution1D.h | 79 --- arm_compute/runtime/CL/CLHOG.h | 80 --- arm_compute/runtime/CL/CLLut.h | 89 ---- arm_compute/runtime/CL/CLLutAllocator.h | 94 ---- arm_compute/runtime/CL/CLMultiHOG.h | 56 --- arm_compute/runtime/CL/CLMultiImage.h | 87 ---- arm_compute/runtime/CL/CLPyramid.h | 82 ---- .../runtime/CL/functions/CLROIPoolingLayer.h | 3 +- arm_compute/runtime/Distribution1D.h | 56 --- arm_compute/runtime/HOG.h | 56 --- arm_compute/runtime/ILutAllocator.h | 84 ---- arm_compute/runtime/Lut.h | 68 --- arm_compute/runtime/LutAllocator.h | 61 --- arm_compute/runtime/MultiHOG.h | 58 --- arm_compute/runtime/MultiImage.h | 96 ---- arm_compute/runtime/Pyramid.h | 76 --- arm_compute/runtime/common/LSTMParams.h | 4 +- docs/00_introduction.dox | 8 +- src/core/CL/CLKernels.h | 1 - src/core/CL/CLTracePoint.cpp | 25 - src/core/CL/ICLDistribution1D.cpp | 51 -- src/core/CL/ICLHOG.cpp | 47 -- src/core/CL/ICLLut.cpp | 47 -- src/core/CL/ICLMultiHOG.cpp | 38 -- src/core/CL/ICLMultiImage.cpp | 39 -- .../CL/kernels/CLBoundingBoxTransformKernel.cpp | 3 +- .../CL/kernels/CLGenerateProposalsLayerKernel.cpp | 3 +- src/core/CL/kernels/CLLKTrackerKernel.cpp | 314 ------------ src/core/CL/kernels/CLLKTrackerKernel.h | 206 -------- src/core/CL/kernels/CLROIAlignLayerKernel.cpp | 1 - src/core/CL/kernels/CLROIAlignLayerKernel.h | 4 +- src/core/CL/kernels/CLROIPoolingLayerKernel.cpp | 1 - src/core/CL/kernels/CLROIPoolingLayerKernel.h | 5 +- src/core/CPP/kernels/CPPCornerCandidatesKernel.cpp | 102 ---- ...PPDetectionWindowNonMaximaSuppressionKernel.cpp | 140 ------ .../CPP/kernels/CPPSortEuclideanDistanceKernel.cpp | 117 ----- src/core/HOGInfo.cpp | 134 ----- src/core/IDistribution.cpp | 36 -- src/core/IDistribution1D.cpp | 69 --- src/core/MultiImageInfo.cpp | 53 -- src/core/NEON/NEKernels.h | 3 - .../kernels/NECumulativeDistributionKernel.cpp | 114 ----- .../NEON/kernels/NECumulativeDistributionKernel.h | 85 ---- src/core/NEON/kernels/NEFillArrayKernel.cpp | 92 ---- src/core/NEON/kernels/NEFillArrayKernel.h | 77 --- src/core/NEON/kernels/NELKTrackerKernel.cpp | 540 --------------------- src/core/NEON/kernels/NELKTrackerKernel.h | 141 ------ src/core/NEON/kernels/NEROIPoolingLayerKernel.h | 5 +- src/core/PyramidInfo.cpp | 105 ---- src/core/TensorInfo.cpp | 35 -- src/core/TracePoint.cpp | 28 -- src/core/Utils.cpp | 25 - src/core/Validate.cpp | 22 - src/runtime/CL/CLDistribution1D.cpp | 61 --- src/runtime/CL/CLHOG.cpp | 84 ---- src/runtime/CL/CLLut.cpp | 99 ---- src/runtime/CL/CLLutAllocator.cpp | 77 --- src/runtime/CL/CLMultiHOG.cpp | 52 -- src/runtime/CL/CLMultiImage.cpp | 172 ------- src/runtime/CL/CLPyramid.cpp | 127 ----- src/runtime/Distribution1D.cpp | 40 -- src/runtime/HOG.cpp | 49 -- src/runtime/ILutAllocator.cpp | 58 --- src/runtime/Lut.cpp | 75 --- src/runtime/LutAllocator.cpp | 50 -- src/runtime/MultiHOG.cpp | 52 -- src/runtime/MultiImage.cpp | 224 --------- src/runtime/Pyramid.cpp | 117 ----- tests/CL/CLHOGAccessor.h | 70 --- tests/CL/CLLutAccessor.h | 96 ---- tests/IHOGAccessor.h | 48 -- tests/ILutAccessor.h | 72 --- tests/NEON/HOGAccessor.h | 64 --- tests/NEON/LutAccessor.h | 90 ---- tests/RawLutAccessor.h | 77 --- tests/TypePrinter.h | 72 --- tests/Types.h | 42 +- tests/Utils.h | 239 --------- tests/framework/datasets/ContainerDataset.h | 3 +- tests/validation/CL/BoundingBoxTransform.cpp | 3 +- tests/validation/Helpers.cpp | 78 +-- tests/validation/Helpers.h | 49 -- tests/validation/Validation.h | 214 -------- tests/validation/fixtures/CropResizeFixture.h | 3 +- .../validation/fixtures/SliceOperationsFixtures.h | 3 +- tests/validation/fixtures/SplitFixture.h | 3 +- tests/validation/reference/Box3x3.cpp | 59 --- tests/validation/reference/Box3x3.h | 43 -- tests/validation/reference/CannyEdgeDetector.cpp | 254 ---------- tests/validation/reference/CannyEdgeDetector.h | 46 -- tests/validation/reference/ChannelCombine.cpp | 204 -------- tests/validation/reference/ChannelCombine.h | 43 -- tests/validation/reference/ChannelExtract.cpp | 78 --- tests/validation/reference/ChannelExtract.h | 43 -- tests/validation/reference/ColorConvert.cpp | 213 -------- tests/validation/reference/ColorConvert.h | 43 -- tests/validation/reference/Derivative.cpp | 106 ---- tests/validation/reference/Derivative.h | 44 -- tests/validation/reference/Dilate.cpp | 85 ---- tests/validation/reference/Dilate.h | 43 -- tests/validation/reference/EqualizeHistogram.cpp | 93 ---- tests/validation/reference/EqualizeHistogram.h | 43 -- tests/validation/reference/FastCorners.cpp | 241 --------- tests/validation/reference/FastCorners.h | 44 -- tests/validation/reference/Gaussian3x3.cpp | 60 --- tests/validation/reference/Gaussian3x3.h | 43 -- tests/validation/reference/Gaussian5x5.cpp | 66 --- tests/validation/reference/Gaussian5x5.h | 43 -- tests/validation/reference/GaussianPyramidHalf.cpp | 67 --- tests/validation/reference/GaussianPyramidHalf.h | 43 -- tests/validation/reference/HOGDescriptor.cpp | 264 ---------- tests/validation/reference/HOGDescriptor.h | 49 -- tests/validation/reference/HOGDetector.cpp | 132 ----- tests/validation/reference/HOGDetector.h | 48 -- tests/validation/reference/HOGMultiDetection.cpp | 279 ----------- tests/validation/reference/HOGMultiDetection.h | 48 -- .../validation/reference/HarrisCornerDetector.cpp | 205 -------- tests/validation/reference/HarrisCornerDetector.h | 48 -- tests/validation/reference/Histogram.cpp | 65 --- tests/validation/reference/Histogram.h | 43 -- tests/validation/reference/IntegralImage.cpp | 86 ---- tests/validation/reference/IntegralImage.h | 43 -- tests/validation/reference/LaplacianPyramid.cpp | 73 --- tests/validation/reference/LaplacianPyramid.h | 43 -- .../validation/reference/LaplacianReconstruct.cpp | 69 --- tests/validation/reference/LaplacianReconstruct.h | 43 -- tests/validation/reference/Magnitude.cpp | 68 --- tests/validation/reference/Magnitude.h | 43 -- tests/validation/reference/Median3x3.cpp | 77 --- tests/validation/reference/Median3x3.h | 43 -- tests/validation/reference/NonLinearFilter.cpp | 105 ---- tests/validation/reference/NonLinearFilter.h | 44 -- tests/validation/reference/OpticalFlow.cpp | 404 --------------- tests/validation/reference/OpticalFlow.h | 49 -- tests/validation/reference/Phase.cpp | 66 --- tests/validation/reference/Phase.h | 43 -- tests/validation/reference/Scharr.cpp | 106 ---- tests/validation/reference/Scharr.h | 44 -- tests/validation/reference/Sobel.cpp | 153 ------ tests/validation/reference/Sobel.h | 45 -- tests/validation/reference/Threshold.cpp | 76 --- tests/validation/reference/Threshold.h | 43 -- tests/validation/reference/Utils.h | 21 - tests/validation/reference/WarpAffine.cpp | 136 ------ tests/validation/reference/WarpAffine.h | 43 -- tests/validation/reference/WarpPerspective.cpp | 133 ----- tests/validation/reference/WarpPerspective.h | 43 -- tests/validation/reference/YOLOLayer.cpp | 84 ---- tests/validation/reference/YOLOLayer.h | 47 -- utils/TypePrinter.h | 301 +----------- utils/Utils.h | 20 - 183 files changed, 33 insertions(+), 14135 deletions(-) delete mode 100644 arm_compute/core/CL/ICLDistribution1D.h delete mode 100644 arm_compute/core/CL/ICLHOG.h delete mode 100644 arm_compute/core/CL/ICLLut.h delete mode 100644 arm_compute/core/CL/ICLMultiHOG.h delete mode 100644 arm_compute/core/CL/ICLMultiImage.h delete mode 100644 arm_compute/core/CPP/kernels/CPPCornerCandidatesKernel.h delete mode 100644 arm_compute/core/CPP/kernels/CPPDetectionWindowNonMaximaSuppressionKernel.h delete mode 100644 arm_compute/core/CPP/kernels/CPPSortEuclideanDistanceKernel.h delete mode 100644 arm_compute/core/HOGInfo.h delete mode 100644 arm_compute/core/IDistribution.h delete mode 100644 arm_compute/core/IDistribution1D.h delete mode 100644 arm_compute/core/IHOG.h delete mode 100644 arm_compute/core/ILut.h delete mode 100644 arm_compute/core/IMultiHOG.h delete mode 100644 arm_compute/core/IMultiImage.h delete mode 100644 arm_compute/core/IPyramid.h delete mode 100644 arm_compute/core/MultiImageInfo.h delete mode 100644 arm_compute/core/PyramidInfo.h delete mode 100644 arm_compute/runtime/CL/CLDistribution1D.h delete mode 100644 arm_compute/runtime/CL/CLHOG.h delete mode 100644 arm_compute/runtime/CL/CLLut.h delete mode 100644 arm_compute/runtime/CL/CLLutAllocator.h delete mode 100644 arm_compute/runtime/CL/CLMultiHOG.h delete mode 100644 arm_compute/runtime/CL/CLMultiImage.h delete mode 100644 arm_compute/runtime/CL/CLPyramid.h delete mode 100644 arm_compute/runtime/Distribution1D.h delete mode 100644 arm_compute/runtime/HOG.h delete mode 100644 arm_compute/runtime/ILutAllocator.h delete mode 100644 arm_compute/runtime/Lut.h delete mode 100644 arm_compute/runtime/LutAllocator.h delete mode 100644 arm_compute/runtime/MultiHOG.h delete mode 100644 arm_compute/runtime/MultiImage.h delete mode 100644 arm_compute/runtime/Pyramid.h delete mode 100644 src/core/CL/ICLDistribution1D.cpp delete mode 100644 src/core/CL/ICLHOG.cpp delete mode 100644 src/core/CL/ICLLut.cpp delete mode 100644 src/core/CL/ICLMultiHOG.cpp delete mode 100644 src/core/CL/ICLMultiImage.cpp delete mode 100644 src/core/CL/kernels/CLLKTrackerKernel.cpp delete mode 100644 src/core/CL/kernels/CLLKTrackerKernel.h delete mode 100644 src/core/CPP/kernels/CPPCornerCandidatesKernel.cpp delete mode 100644 src/core/CPP/kernels/CPPDetectionWindowNonMaximaSuppressionKernel.cpp delete mode 100644 src/core/CPP/kernels/CPPSortEuclideanDistanceKernel.cpp delete mode 100644 src/core/HOGInfo.cpp delete mode 100644 src/core/IDistribution.cpp delete mode 100644 src/core/IDistribution1D.cpp delete mode 100644 src/core/MultiImageInfo.cpp delete mode 100644 src/core/NEON/kernels/NECumulativeDistributionKernel.cpp delete mode 100644 src/core/NEON/kernels/NECumulativeDistributionKernel.h delete mode 100644 src/core/NEON/kernels/NEFillArrayKernel.cpp delete mode 100644 src/core/NEON/kernels/NEFillArrayKernel.h delete mode 100644 src/core/NEON/kernels/NELKTrackerKernel.cpp delete mode 100644 src/core/NEON/kernels/NELKTrackerKernel.h delete mode 100644 src/core/PyramidInfo.cpp delete mode 100644 src/runtime/CL/CLDistribution1D.cpp delete mode 100644 src/runtime/CL/CLHOG.cpp delete mode 100644 src/runtime/CL/CLLut.cpp delete mode 100644 src/runtime/CL/CLLutAllocator.cpp delete mode 100644 src/runtime/CL/CLMultiHOG.cpp delete mode 100644 src/runtime/CL/CLMultiImage.cpp delete mode 100644 src/runtime/CL/CLPyramid.cpp delete mode 100644 src/runtime/Distribution1D.cpp delete mode 100644 src/runtime/HOG.cpp delete mode 100644 src/runtime/ILutAllocator.cpp delete mode 100644 src/runtime/Lut.cpp delete mode 100644 src/runtime/LutAllocator.cpp delete mode 100644 src/runtime/MultiHOG.cpp delete mode 100644 src/runtime/MultiImage.cpp delete mode 100644 src/runtime/Pyramid.cpp delete mode 100644 tests/CL/CLHOGAccessor.h delete mode 100644 tests/CL/CLLutAccessor.h delete mode 100644 tests/IHOGAccessor.h delete mode 100644 tests/ILutAccessor.h delete mode 100644 tests/NEON/HOGAccessor.h delete mode 100644 tests/NEON/LutAccessor.h delete mode 100644 tests/RawLutAccessor.h delete mode 100644 tests/TypePrinter.h delete mode 100644 tests/validation/reference/Box3x3.cpp delete mode 100644 tests/validation/reference/Box3x3.h delete mode 100644 tests/validation/reference/CannyEdgeDetector.cpp delete mode 100644 tests/validation/reference/CannyEdgeDetector.h delete mode 100644 tests/validation/reference/ChannelCombine.cpp delete mode 100644 tests/validation/reference/ChannelCombine.h delete mode 100644 tests/validation/reference/ChannelExtract.cpp delete mode 100644 tests/validation/reference/ChannelExtract.h delete mode 100644 tests/validation/reference/ColorConvert.cpp delete mode 100644 tests/validation/reference/ColorConvert.h delete mode 100644 tests/validation/reference/Derivative.cpp delete mode 100644 tests/validation/reference/Derivative.h delete mode 100644 tests/validation/reference/Dilate.cpp delete mode 100644 tests/validation/reference/Dilate.h delete mode 100644 tests/validation/reference/EqualizeHistogram.cpp delete mode 100644 tests/validation/reference/EqualizeHistogram.h delete mode 100644 tests/validation/reference/FastCorners.cpp delete mode 100644 tests/validation/reference/FastCorners.h delete mode 100644 tests/validation/reference/Gaussian3x3.cpp delete mode 100644 tests/validation/reference/Gaussian3x3.h delete mode 100644 tests/validation/reference/Gaussian5x5.cpp delete mode 100644 tests/validation/reference/Gaussian5x5.h delete mode 100644 tests/validation/reference/GaussianPyramidHalf.cpp delete mode 100644 tests/validation/reference/GaussianPyramidHalf.h delete mode 100644 tests/validation/reference/HOGDescriptor.cpp delete mode 100644 tests/validation/reference/HOGDescriptor.h delete mode 100644 tests/validation/reference/HOGDetector.cpp delete mode 100644 tests/validation/reference/HOGDetector.h delete mode 100644 tests/validation/reference/HOGMultiDetection.cpp delete mode 100644 tests/validation/reference/HOGMultiDetection.h delete mode 100644 tests/validation/reference/HarrisCornerDetector.cpp delete mode 100644 tests/validation/reference/HarrisCornerDetector.h delete mode 100644 tests/validation/reference/Histogram.cpp delete mode 100644 tests/validation/reference/Histogram.h delete mode 100644 tests/validation/reference/IntegralImage.cpp delete mode 100644 tests/validation/reference/IntegralImage.h delete mode 100644 tests/validation/reference/LaplacianPyramid.cpp delete mode 100644 tests/validation/reference/LaplacianPyramid.h delete mode 100644 tests/validation/reference/LaplacianReconstruct.cpp delete mode 100644 tests/validation/reference/LaplacianReconstruct.h delete mode 100644 tests/validation/reference/Magnitude.cpp delete mode 100644 tests/validation/reference/Magnitude.h delete mode 100644 tests/validation/reference/Median3x3.cpp delete mode 100644 tests/validation/reference/Median3x3.h delete mode 100644 tests/validation/reference/NonLinearFilter.cpp delete mode 100644 tests/validation/reference/NonLinearFilter.h delete mode 100644 tests/validation/reference/OpticalFlow.cpp delete mode 100644 tests/validation/reference/OpticalFlow.h delete mode 100644 tests/validation/reference/Phase.cpp delete mode 100644 tests/validation/reference/Phase.h delete mode 100644 tests/validation/reference/Scharr.cpp delete mode 100644 tests/validation/reference/Scharr.h delete mode 100644 tests/validation/reference/Sobel.cpp delete mode 100644 tests/validation/reference/Sobel.h delete mode 100644 tests/validation/reference/Threshold.cpp delete mode 100644 tests/validation/reference/Threshold.h delete mode 100644 tests/validation/reference/WarpAffine.cpp delete mode 100644 tests/validation/reference/WarpAffine.h delete mode 100644 tests/validation/reference/WarpPerspective.cpp delete mode 100644 tests/validation/reference/WarpPerspective.h delete mode 100644 tests/validation/reference/YOLOLayer.cpp delete mode 100644 tests/validation/reference/YOLOLayer.h diff --git a/Android.bp b/Android.bp index 90e28a67fc..219836f812 100644 --- a/Android.bp +++ b/Android.bp @@ -63,12 +63,7 @@ cc_library_static { "src/core/CL/CLHelpers.cpp", "src/core/CL/CLKernelLibrary.cpp", "src/core/CL/CLUtils.cpp", - "src/core/CL/ICLDistribution1D.cpp", - "src/core/CL/ICLHOG.cpp", "src/core/CL/ICLKernel.cpp", - "src/core/CL/ICLLut.cpp", - "src/core/CL/ICLMultiHOG.cpp", - "src/core/CL/ICLMultiImage.cpp", "src/core/CL/ICLSimple2DKernel.cpp", "src/core/CL/ICLSimple3DKernel.cpp", "src/core/CL/ICLSimpleKernel.cpp", @@ -124,7 +119,6 @@ cc_library_static { "src/core/CL/kernels/CLIm2ColKernel.cpp", "src/core/CL/kernels/CLInstanceNormalizationLayerKernel.cpp", "src/core/CL/kernels/CLL2NormalizeLayerKernel.cpp", - "src/core/CL/kernels/CLLKTrackerKernel.cpp", "src/core/CL/kernels/CLMaxUnpoolingLayerKernel.cpp", "src/core/CL/kernels/CLMeanStdDevNormalizationKernel.cpp", "src/core/CL/kernels/CLMinMaxLayerKernel.cpp", @@ -153,24 +147,17 @@ cc_library_static { "src/core/CPP/CPPTypes.cpp", "src/core/CPP/ICPPSimpleKernel.cpp", "src/core/CPP/kernels/CPPBoxWithNonMaximaSuppressionLimitKernel.cpp", - "src/core/CPP/kernels/CPPCornerCandidatesKernel.cpp", - "src/core/CPP/kernels/CPPDetectionWindowNonMaximaSuppressionKernel.cpp", "src/core/CPP/kernels/CPPNonMaximumSuppressionKernel.cpp", "src/core/CPP/kernels/CPPPermuteKernel.cpp", - "src/core/CPP/kernels/CPPSortEuclideanDistanceKernel.cpp", "src/core/CPP/kernels/CPPTopKVKernel.cpp", "src/core/CPP/kernels/CPPUpsampleKernel.cpp", "src/core/Error.cpp", "src/core/GPUTarget.cpp", - "src/core/HOGInfo.cpp", "src/core/Helpers.cpp", "src/core/IAccessWindow.cpp", - "src/core/IDistribution.cpp", - "src/core/IDistribution1D.cpp", "src/core/IKernel.cpp", "src/core/ITensor.cpp", "src/core/ITensorPack.cpp", - "src/core/MultiImageInfo.cpp", "src/core/NEON/kernels/NEBatchNormalizationLayerKernel.cpp", "src/core/NEON/kernels/NEBatchToSpaceLayerKernel.cpp", "src/core/NEON/kernels/NEBitwiseAndKernel.cpp", @@ -183,7 +170,6 @@ cc_library_static { "src/core/NEON/kernels/NEConvertFullyConnectedWeightsKernel.cpp", "src/core/NEON/kernels/NEConvertQuantizedSignednessKernel.cpp", "src/core/NEON/kernels/NECropKernel.cpp", - "src/core/NEON/kernels/NECumulativeDistributionKernel.cpp", "src/core/NEON/kernels/NEDepthConvertLayerKernel.cpp", "src/core/NEON/kernels/NEDepthToSpaceLayerKernel.cpp", "src/core/NEON/kernels/NEDepthwiseConvolutionLayerNativeKernel.cpp", @@ -192,7 +178,6 @@ cc_library_static { "src/core/NEON/kernels/NEFFTDigitReverseKernel.cpp", "src/core/NEON/kernels/NEFFTRadixStageKernel.cpp", "src/core/NEON/kernels/NEFFTScaleKernel.cpp", - "src/core/NEON/kernels/NEFillArrayKernel.cpp", "src/core/NEON/kernels/NEFillBorderKernel.cpp", "src/core/NEON/kernels/NEFuseBatchNormalizationKernel.cpp", "src/core/NEON/kernels/NEGEMMInterleave4x4Kernel.cpp", @@ -212,7 +197,6 @@ cc_library_static { "src/core/NEON/kernels/NEIm2ColKernel.cpp", "src/core/NEON/kernels/NEInstanceNormalizationLayerKernel.cpp", "src/core/NEON/kernels/NEL2NormalizeLayerKernel.cpp", - "src/core/NEON/kernels/NELKTrackerKernel.cpp", "src/core/NEON/kernels/NELogicalKernel.cpp", "src/core/NEON/kernels/NEMaxUnpoolingLayerKernel.cpp", "src/core/NEON/kernels/NEMeanStdDevNormalizationKernel.cpp", @@ -299,7 +283,6 @@ cc_library_static { "src/core/NEON/kernels/convolution/winograd/winograd_transforms/weights_4x4_3x3_fp16_fp16_integers.cpp", "src/core/NEON/kernels/convolution/winograd/winograd_transforms/weights_4x4_3x3_fp32_fp32_integers.cpp", "src/core/NEON/kernels/convolution/winograd/winograd_transforms/weights_6_3_fp32_fp32_integers.cpp", - "src/core/PyramidInfo.cpp", "src/core/Rounding.cpp", "src/core/Size2D.cpp", "src/core/SubTensorInfo.cpp", @@ -408,18 +391,11 @@ cc_library_static { "src/runtime/BlobLifetimeManager.cpp", "src/runtime/BlobMemoryPool.cpp", "src/runtime/CL/CLBufferAllocator.cpp", - "src/runtime/CL/CLDistribution1D.cpp", "src/runtime/CL/CLGEMMHeuristicsHandle.cpp", - "src/runtime/CL/CLHOG.cpp", "src/runtime/CL/CLHelpers.cpp", - "src/runtime/CL/CLLut.cpp", - "src/runtime/CL/CLLutAllocator.cpp", "src/runtime/CL/CLMemory.cpp", "src/runtime/CL/CLMemoryRegion.cpp", - "src/runtime/CL/CLMultiHOG.cpp", - "src/runtime/CL/CLMultiImage.cpp", "src/runtime/CL/CLOperator.cpp", - "src/runtime/CL/CLPyramid.cpp", "src/runtime/CL/CLRuntimeContext.cpp", "src/runtime/CL/CLScheduler.cpp", "src/runtime/CL/CLSubTensor.cpp", @@ -536,20 +512,13 @@ cc_library_static { "src/runtime/CPP/functions/CPPUpsample.cpp", "src/runtime/CPUUtils.cpp", "src/runtime/DeviceProperties.cpp", - "src/runtime/Distribution1D.cpp", - "src/runtime/HOG.cpp", - "src/runtime/ILutAllocator.cpp", "src/runtime/IScheduler.cpp", "src/runtime/ISimpleLifetimeManager.cpp", "src/runtime/ITensorAllocator.cpp", "src/runtime/IWeightsManager.cpp", - "src/runtime/Lut.cpp", - "src/runtime/LutAllocator.cpp", "src/runtime/MEMUtils.cpp", "src/runtime/Memory.cpp", "src/runtime/MemoryManagerOnDemand.cpp", - "src/runtime/MultiHOG.cpp", - "src/runtime/MultiImage.cpp", "src/runtime/NEON/INEOperator.cpp", "src/runtime/NEON/INESimpleFunction.cpp", "src/runtime/NEON/INESimpleFunctionNoBorder.cpp", @@ -642,7 +611,6 @@ cc_library_static { "src/runtime/OffsetMemoryPool.cpp", "src/runtime/OperatorTensor.cpp", "src/runtime/PoolManager.cpp", - "src/runtime/Pyramid.cpp", "src/runtime/RuntimeContext.cpp", "src/runtime/Scheduler.cpp", "src/runtime/SchedulerFactory.cpp", diff --git a/arm_compute/core/CL/CLDevice.h b/arm_compute/core/CL/CLDevice.h index 033bf8fa96..06aaac88f4 100644 --- a/arm_compute/core/CL/CLDevice.h +++ b/arm_compute/core/CL/CLDevice.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Arm Limited. + * Copyright (c) 2020-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -30,6 +30,7 @@ #include "arm_compute/core/IDevice.h" #include +#include #include namespace arm_compute diff --git a/arm_compute/core/CL/CLHelpers.h b/arm_compute/core/CL/CLHelpers.h index 0e9aa5d6e5..03f956f6f8 100644 --- a/arm_compute/core/CL/CLHelpers.h +++ b/arm_compute/core/CL/CLHelpers.h @@ -26,6 +26,7 @@ #include "arm_compute/core/CL/CLTypes.h" #include "arm_compute/core/CL/OpenCL.h" +#include "arm_compute/core/Types.h" #include #include diff --git a/arm_compute/core/CL/CLTypes.h b/arm_compute/core/CL/CLTypes.h index 0f6eb0dfa4..2ba2e8dd62 100644 --- a/arm_compute/core/CL/CLTypes.h +++ b/arm_compute/core/CL/CLTypes.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2020 Arm Limited. + * Copyright (c) 2017-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -75,40 +75,5 @@ struct CLQuantization const ICLFloatArray *scale; /**< Quantization scale array */ const ICLInt32Array *offset; /**< Quantization offset array */ }; - -/** Internal keypoint structure for Lucas-Kanade Optical Flow */ -struct CLLKInternalKeypoint -{ - float x{ 0.f }; /**< x coordinate of the keypoint */ - float y{ 0.f }; /**< y coordinate of the keypoint */ - float tracking_status{ 0.f }; /**< the tracking status of the keypoint */ - float dummy{ 0.f }; /**< Dummy field, to make sure the data structure 128-bit align, so that GPU can use vload4 */ -}; - -/** Structure for storing Spatial Gradient Matrix and the minimum eigenvalue for each keypoint */ -struct CLCoefficientTable -{ - float A11; /**< iA11 * FLT_SCALE */ - float A12; /**< iA11 * FLT_SCALE */ - float A22; /**< iA11 * FLT_SCALE */ - float min_eig; /**< Minimum eigenvalue */ -}; - -/** Structure for storing ival, ixval and iyval for each point inside the window */ -struct CLOldValue -{ - int16_t ival; /**< ival extracts from old image */ - int16_t ixval; /**< ixval extracts from scharr Gx image */ - int16_t iyval; /**< iyval extracts from scharr Gy image */ - int16_t dummy; /**< Dummy field, to make sure the data structure 128-bit align, so that GPU can use vload4 */ -}; - -/** Interface for OpenCL Array of Internal Key Points. */ -using ICLLKInternalKeypointArray = ICLArray; -/** Interface for OpenCL Array of Coefficient Tables. */ -using ICLCoefficientTableArray = ICLArray; -/** Interface for OpenCL Array of Old Values. */ -using ICLOldValArray = ICLArray; - } // namespace arm_compute #endif /* ARM_COMPUTE_CL_TYPES_H */ diff --git a/arm_compute/core/CL/ICLArray.h b/arm_compute/core/CL/ICLArray.h index 2fa2f34c5d..b900117724 100644 --- a/arm_compute/core/CL/ICLArray.h +++ b/arm_compute/core/CL/ICLArray.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2019 Arm Limited. + * Copyright (c) 2016-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -115,14 +115,6 @@ private: uint8_t *_mapping; }; -/** Interface for OpenCL Array of Key Points. */ -using ICLKeyPointArray = ICLArray; -/** Interface for OpenCL Array of 2D Coordinates. */ -using ICLCoordinates2DArray = ICLArray; -/** Interface for OpenCL Array of Detection Windows. */ -using ICLDetectionWindowArray = ICLArray; -/** Interface for OpenCL Array of 2D Sizes. */ -using ICLSize2DArray = ICLArray; /** Interface for OpenCL Array of uint8s. */ using ICLUInt8Array = ICLArray; /** Interface for OpenCL Array of uint16s. */ diff --git a/arm_compute/core/CL/ICLDistribution1D.h b/arm_compute/core/CL/ICLDistribution1D.h deleted file mode 100644 index 18afabd52e..0000000000 --- a/arm_compute/core/CL/ICLDistribution1D.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2016-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_ICLDISTRIBUTION1D_H -#define ARM_COMPUTE_ICLDISTRIBUTION1D_H - -#include "arm_compute/core/IDistribution1D.h" - -#include -#include - -namespace cl -{ -class Buffer; -class CommandQueue; -} - -namespace arm_compute -{ -/** ICLDistribution1D interface class */ -class ICLDistribution1D : public IDistribution1D -{ -public: - /** Constructor: Creates a 1D CLDistribution of a consecutive interval [offset, offset + range - 1] - * defined by a start offset and valid range, divided equally into num_bins parts. - * - * @param[in] num_bins The number of bins the distribution is divided in. - * @param[in] offset The start of the values to use. - * @param[in] range The total number of the consecutive values of the distribution interval. - */ - ICLDistribution1D(size_t num_bins, int32_t offset, uint32_t range); - /** Prevent instances of this class from being copied (As this class contains pointers) */ - ICLDistribution1D(const ICLDistribution1D &) = delete; - /** Prevent instances of this class from being copied (As this class contains pointers) */ - const ICLDistribution1D &operator=(const ICLDistribution1D &) = delete; - /** Enqueue a map operation of the allocated buffer on the given queue. - * - * @param[in,out] q The CL command queue to use for the mapping operation. - * @param[in] blocking If true, then the mapping will be ready to use by the time - * this method returns, else it is the caller's responsibility - * to flush the queue and wait for the mapping operation to have completed before using the returned mapping pointer. - */ - void map(cl::CommandQueue &q, bool blocking = true); - /** Enqueue an unmap operation of the allocated and mapped buffer on the given queue. - * - * @note This method simply enqueues the unmap operation, it is the caller's responsibility to flush the queue and make sure the unmap is finished before - * the memory is accessed by the device. - * - * @param[in,out] q The CL command queue to use for the mapping operation. - */ - void unmap(cl::CommandQueue &q); - /** Interface to be implemented by the child class to return a reference to the OpenCL buffer containing the distribution's data. - * - * @return A reference to an OpenCL buffer containing the distribution's data. - */ - virtual cl::Buffer &cl_buffer() = 0; - // Inherited methods overridden: - uint32_t *buffer() const override; - -protected: - /** Method to be implemented by the child class to map the OpenCL buffer - * - * @param[in,out] q The CL command queue to use for the mapping operation. - * @param[in] blocking If true, then the mapping will be ready to use by the time - * this method returns, else it is the caller's responsibility - * to flush the queue and wait for the mapping operation to have completed before using the returned mapping pointer. - */ - virtual uint32_t *do_map(cl::CommandQueue &q, bool blocking) = 0; - /** Method to be implemented by the child class to unmap the OpenCL buffer - * - * @note This method simply enqueues the unmap operation, it is the caller's responsibility to flush the queue and make sure the unmap is finished before - * the memory is accessed by the device. - * - * @param[in,out] q The CL command queue to use for the mapping operation. - */ - virtual void do_unmap(cl::CommandQueue &q) = 0; - -protected: - uint32_t *_mapping; /**< The distribution data. */ -}; -} -#endif /* ARM_COMPUTE_ICLDISTRIBUTION1D_H */ diff --git a/arm_compute/core/CL/ICLHOG.h b/arm_compute/core/CL/ICLHOG.h deleted file mode 100644 index da3c0c65c8..0000000000 --- a/arm_compute/core/CL/ICLHOG.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_ICLHOG_H -#define ARM_COMPUTE_ICLHOG_H - -#include "arm_compute/core/IHOG.h" - -#include - -namespace cl -{ -class Buffer; -class CommandQueue; -} - -namespace arm_compute -{ -/** Interface for OpenCL HOG data-object */ -class ICLHOG : public IHOG -{ -public: - /** Default constructor */ - ICLHOG(); - /** Prevent instances of this class from being copied (As this class contains pointers) */ - ICLHOG(const ICLHOG &) = delete; - /** Prevent instances of this class from being copied (As this class contains pointers) */ - ICLHOG &operator=(const ICLHOG &) = delete; - /** Allow instances of this class to be moved */ - ICLHOG(ICLHOG &&) = default; - /** Allow instances of this class to be moved */ - ICLHOG &operator=(ICLHOG &&) = default; - /** Default destructor */ - virtual ~ICLHOG() = default; - - /** Interface to be implemented by the child class to return a reference to the OpenCL buffer containing the hog's descriptor - * - * @return A reference to an OpenCL buffer containing the hog's descriptor - */ - virtual const cl::Buffer &cl_buffer() const = 0; - - /** Enqueue a map operation of the allocated buffer on the given queue. - * - * @param[in,out] q The CL command queue to use for the mapping operation. - * @param[in] blocking If true, then the mapping will be ready to use by the time - * this method returns, else it is the caller's responsibility - * to flush the queue and wait for the mapping operation to have completed before using the returned mapping pointer. - * - * @return The mapping address. - */ - void map(cl::CommandQueue &q, bool blocking = true); - - /** Enqueue an unmap operation of the allocated and mapped buffer on the given queue. - * - * @note This method simply enqueues the unmap operation, it is the caller's responsibility to flush the queue and make sure the unmap is finished before - * the memory is accessed by the device. - * - * @param[in,out] q The CL command queue to use for the mapping operation. - */ - void unmap(cl::CommandQueue &q); - - /** Interface to be implemented by the child class to free the allocated cl buffer. - * - * @warning The buffer must have been allocated previously. Otherwise calling the function will fail. - */ - virtual void free() = 0; - - // Inherited methods overridden: - float *descriptor() const override; - -protected: - /** Method to be implemented by the child class to map the OpenCL buffer - * - * @param[in,out] q The CL command queue to use for the mapping operation. - * @param[in] blocking If true, then the mapping will be ready to use by the time - * this method returns, else it is the caller's responsibility - * to flush the queue and wait for the mapping operation to have completed before using the returned mapping pointer. - */ - virtual uint8_t *do_map(cl::CommandQueue &q, bool blocking) = 0; - /** Method to be implemented by the child class to unmap the OpenCL buffer - * - * @note This method simply enqueues the unmap operation, it is the caller's responsibility to flush the queue and make sure the unmap is finished before - * the memory is accessed by the device. - * - * @param[in,out] q The CL command queue to use for the mapping operation. - */ - virtual void do_unmap(cl::CommandQueue &q) = 0; - -private: - uint8_t *_mapping; -}; -} -#endif /*ARM_COMPUTE_ICLHOG_H */ diff --git a/arm_compute/core/CL/ICLLut.h b/arm_compute/core/CL/ICLLut.h deleted file mode 100644 index b4d7471e1f..0000000000 --- a/arm_compute/core/CL/ICLLut.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2016-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_ICLLUT_H -#define ARM_COMPUTE_ICLLUT_H - -#include "arm_compute/core/ILut.h" - -#include - -namespace cl -{ -class Buffer; -class CommandQueue; -} - -namespace arm_compute -{ -/** Interface for OpenCL LUT */ -class ICLLut : public ILut -{ -public: - ICLLut(); - ICLLut(const ICLLut &) = delete; - ICLLut &operator=(const ICLLut &) = delete; - - /** Interface to be implemented by the child class to return a reference to the OpenCL buffer containing the lut's data. - * - * @return A reference to an OpenCL buffer containing the lut's data. - */ - virtual const cl::Buffer &cl_buffer() const = 0; - /** Enqueue a map operation of the allocated buffer on the given queue. - * - * @param[in,out] q The CL command queue to use for the mapping operation. - * @param[in] blocking If true, then the mapping will be ready to use by the time - * this method returns, else it is the caller's responsibility - * to flush the queue and wait for the mapping operation to have completed before using the returned mapping pointer. - */ - void map(cl::CommandQueue &q, bool blocking = true); - /** Enqueue an unmap operation of the allocated and mapped buffer on the given queue. - * - * @note This method simply enqueues the unmap operation, it is the caller's responsibility to flush the queue and make sure the unmap is finished before - * the memory is accessed by the device. - * - * @param[in,out] q The CL command queue to use for the mapping operation. - */ - void unmap(cl::CommandQueue &q); - - // Inherited methods overridden: - uint8_t *buffer() const override; - -protected: - /** Method to be implemented by the child class to map the OpenCL buffer - * - * @param[in,out] q The CL command queue to use for the mapping operation. - * @param[in] blocking If true, then the mapping will be ready to use by the time - * this method returns, else it is the caller's responsibility - * to flush the queue and wait for the mapping operation to have completed before using the returned mapping pointer. - */ - virtual uint8_t *do_map(cl::CommandQueue &q, bool blocking) = 0; - /** Method to be implemented by the child class to unmap the OpenCL buffer - * - * @note This method simply enqueues the unmap operation, it is the caller's responsibility to flush the queue and make sure the unmap is finished before - * the memory is accessed by the device. - * - * @param[in,out] q The CL command queue to use for the mapping operation. - */ - virtual void do_unmap(cl::CommandQueue &q) = 0; - -private: - uint8_t *_mapping; -}; -} -#endif /*ARM_COMPUTE_ICLLUT_H */ diff --git a/arm_compute/core/CL/ICLMultiHOG.h b/arm_compute/core/CL/ICLMultiHOG.h deleted file mode 100644 index 109b4d480d..0000000000 --- a/arm_compute/core/CL/ICLMultiHOG.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_ICLMULTIHOG_H -#define ARM_COMPUTE_ICLMULTIHOG_H - -#include "arm_compute/core/CL/ICLHOG.h" -#include "arm_compute/core/IMultiHOG.h" - -namespace arm_compute -{ -/** Interface for storing multiple HOG data-objects */ -class ICLMultiHOG : public IMultiHOG -{ -public: - /** Return a pointer to the requested OpenCL HOG model - * - * @param[in] index The index of the wanted OpenCL HOG model. - * - * @return A pointer pointed to the HOG model - */ - virtual ICLHOG *cl_model(size_t index) = 0; - /** Return a constant pointer to the requested OpenCL HOG model - * - * @param[in] index The index of the wanted OpenCL HOG model. - * - * @return A constant pointer pointed to the OpenCL HOG model - */ - virtual const ICLHOG *cl_model(size_t index) const = 0; - - // Inherited methods overridden: - IHOG *model(size_t index) override; - const IHOG *model(size_t index) const override; -}; -} -#endif /*ARM_COMPUTE_ICLMULTIHOG_H */ diff --git a/arm_compute/core/CL/ICLMultiImage.h b/arm_compute/core/CL/ICLMultiImage.h deleted file mode 100644 index 23ed04a484..0000000000 --- a/arm_compute/core/CL/ICLMultiImage.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2016-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_ICLMULTIIMAGE_H -#define ARM_COMPUTE_ICLMULTIIMAGE_H - -#include "arm_compute/core/IMultiImage.h" - -namespace arm_compute -{ -class ICLTensor; -/** Interface for OpenCL images */ -using ICLImage = ICLTensor; - -/** Interface for OpenCL multi-planar images */ -class ICLMultiImage : public IMultiImage -{ -public: - /** Return a pointer to the requested OpenCL plane of the image. - * - * @param[in] index The index of the wanted planed. - * - * @return A pointer pointed to the OpenCL plane - */ - virtual ICLImage *cl_plane(unsigned int index) = 0; - /** Return a constant pointer to the requested OpenCL plane of the image. - * - * @param[in] index The index of the wanted planed. - * - * @return A constant pointer pointed to the OpenCL plane - */ - virtual const ICLImage *cl_plane(unsigned int index) const = 0; - - // Inherited methods overridden: - IImage *plane(unsigned int index) override; - const IImage *plane(unsigned int index) const override; -}; -} -#endif /*ARM_COMPUTE_ICLMULTIIMAGE_H */ diff --git a/arm_compute/core/CPP/CPPKernels.h b/arm_compute/core/CPP/CPPKernels.h index 7187613488..f6f36596c4 100644 --- a/arm_compute/core/CPP/CPPKernels.h +++ b/arm_compute/core/CPP/CPPKernels.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2020 Arm Limited. + * Copyright (c) 2017-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -26,11 +26,8 @@ /* Header regrouping all the CPP kernels */ #include "arm_compute/core/CPP/kernels/CPPBoxWithNonMaximaSuppressionLimitKernel.h" -#include "arm_compute/core/CPP/kernels/CPPCornerCandidatesKernel.h" -#include "arm_compute/core/CPP/kernels/CPPDetectionWindowNonMaximaSuppressionKernel.h" #include "arm_compute/core/CPP/kernels/CPPNonMaximumSuppressionKernel.h" #include "arm_compute/core/CPP/kernels/CPPPermuteKernel.h" -#include "arm_compute/core/CPP/kernels/CPPSortEuclideanDistanceKernel.h" #include "arm_compute/core/CPP/kernels/CPPTopKVKernel.h" #include "arm_compute/core/CPP/kernels/CPPUpsampleKernel.h" diff --git a/arm_compute/core/CPP/kernels/CPPCornerCandidatesKernel.h b/arm_compute/core/CPP/kernels/CPPCornerCandidatesKernel.h deleted file mode 100644 index e4fd250a61..0000000000 --- a/arm_compute/core/CPP/kernels/CPPCornerCandidatesKernel.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2017-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_CPPCORNERCANDIDATESKERNEL_H -#define ARM_COMPUTE_CPPCORNERCANDIDATESKERNEL_H - -#include "arm_compute/core/CPP/ICPPKernel.h" -#include "arm_compute/core/IArray.h" - -#include "support/Mutex.h" - -#include - -namespace arm_compute -{ -class ITensor; -/** Interface for CPP Images. */ -using IImage = ITensor; - -/** CPP kernel to perform corner candidates - */ -class CPPCornerCandidatesKernel : public ICPPKernel -{ -public: - const char *name() const override - { - return "CPPCornerCandidatesKernel"; - } - /** Default constructor */ - CPPCornerCandidatesKernel(); - /** Prevent instances of this class from being copied (As this class contains pointers) */ - CPPCornerCandidatesKernel(const CPPCornerCandidatesKernel &) = delete; - /** Prevent instances of this class from being copied (As this class contains pointers) */ - CPPCornerCandidatesKernel &operator=(const CPPCornerCandidatesKernel &) = delete; - /** Prevent instances of this class from being moved (As this class contains non movable objects) */ - CPPCornerCandidatesKernel(CPPCornerCandidatesKernel &&) = delete; - /** Prevent instances of this class from being moved (As this class contains non movable objects) */ - CPPCornerCandidatesKernel &operator=(CPPCornerCandidatesKernel &&) = delete; - /** Default destructor */ - ~CPPCornerCandidatesKernel() = default; - - /** Setup the kernel parameters - * - * @param[in] input Source image (harris score). Format supported F32 - * @param[out] output Destination array of InternalKeypoint - * @param[out] num_corner_candidates Number of corner candidates - */ - void configure(const IImage *input, InternalKeypoint *output, int32_t *num_corner_candidates); - - // Inherited methods overridden: - void run(const Window &window, const ThreadInfo &info) override; - -private: - int32_t *_num_corner_candidates; /**< Number of corner candidates */ - arm_compute::Mutex _corner_candidates_mutex; /**< Mutex to preventing race conditions */ - const IImage *_input; /**< Source image - Harris score */ - InternalKeypoint *_output; /**< Array of NEInternalKeypoint */ -}; -} // namespace arm_compute -#endif /* ARM_COMPUTE_CPPCORNERCANDIDATESKERNEL_H */ diff --git a/arm_compute/core/CPP/kernels/CPPDetectionWindowNonMaximaSuppressionKernel.h b/arm_compute/core/CPP/kernels/CPPDetectionWindowNonMaximaSuppressionKernel.h deleted file mode 100644 index 5275a357b3..0000000000 --- a/arm_compute/core/CPP/kernels/CPPDetectionWindowNonMaximaSuppressionKernel.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2017-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_CPPDETECTIONWINDOWNONMAXIMASUPPRESSIONKERNEL_H -#define ARM_COMPUTE_CPPDETECTIONWINDOWNONMAXIMASUPPRESSIONKERNEL_H - -#include "arm_compute/core/CPP/ICPPKernel.h" -#include "arm_compute/core/IArray.h" -#include "arm_compute/core/IHOG.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -/** CPP kernel to perform in-place computation of euclidean distance on IDetectionWindowArray - * - * @note This kernel is meant to be used alongside HOG or other object detection algorithms to perform a non-maxima suppression on a - * IDetectionWindowArray - */ -class CPPDetectionWindowNonMaximaSuppressionKernel : public ICPPKernel -{ -public: - const char *name() const override - { - return "CPPDetectionWindowNonMaximaSuppressionKernel"; - } - /** Default constructor */ - CPPDetectionWindowNonMaximaSuppressionKernel(); - /** Prevent instances of this class from being copied (As this class contains pointers) */ - CPPDetectionWindowNonMaximaSuppressionKernel(const CPPDetectionWindowNonMaximaSuppressionKernel &) = delete; - /** Prevent instances of this class from being copied (As this class contains pointers) */ - CPPDetectionWindowNonMaximaSuppressionKernel &operator=(const CPPDetectionWindowNonMaximaSuppressionKernel &) = delete; - /** Allow instances of this class to be moved */ - CPPDetectionWindowNonMaximaSuppressionKernel(CPPDetectionWindowNonMaximaSuppressionKernel &&) = default; - /** Allow instances of this class to be moved */ - CPPDetectionWindowNonMaximaSuppressionKernel &operator=(CPPDetectionWindowNonMaximaSuppressionKernel &&) = default; - /** Default destructor */ - ~CPPDetectionWindowNonMaximaSuppressionKernel() = default; - /** Initialise the kernel's input, output and the euclidean minimum distance - * - * @attention: If @ref IDetectionWindowArray is passed to the kernel, the map() and unmap() methods @ref IDetectionWindowArray must be called respectively before and after - * the run() method of @ref CPPDetectionWindowNonMaximaSuppressionKernel - * - * @param[in, out] input_output Input/Output array of @ref DetectionWindow - * @param[in] min_distance Radial Euclidean distance for non-maxima suppression - */ - void configure(IDetectionWindowArray *input_output, float min_distance); - - // Inherited methods overridden: - void run(const Window &window, const ThreadInfo &info) override; - bool is_parallelisable() const override; - -private: - IDetectionWindowArray *_input_output; - float _min_distance; -}; -} // namespace arm_compute -#endif /* ARM_COMPUTE_CPPDETECTIONWINDOWNONMAXIMASUPPRESSIONKERNEL_H */ diff --git a/arm_compute/core/CPP/kernels/CPPSortEuclideanDistanceKernel.h b/arm_compute/core/CPP/kernels/CPPSortEuclideanDistanceKernel.h deleted file mode 100644 index be4076f5ce..0000000000 --- a/arm_compute/core/CPP/kernels/CPPSortEuclideanDistanceKernel.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_CPPSORTEUCLIDEANDISTANCEKERNEL_H -#define ARM_COMPUTE_CPPSORTEUCLIDEANDISTANCEKERNEL_H - -#include "arm_compute/core/CPP/ICPPKernel.h" -#include "arm_compute/core/IArray.h" - -#include -#include - -namespace arm_compute -{ -/** CPP kernel to perform sorting and euclidean distance */ -class CPPSortEuclideanDistanceKernel : public ICPPKernel -{ -public: - const char *name() const override - { - return "CPPSortEuclideanDistanceKernel"; - } - /** Default constructor */ - CPPSortEuclideanDistanceKernel(); - /** Prevent instances of this class from being copied (As this class contains pointers) */ - CPPSortEuclideanDistanceKernel(const CPPSortEuclideanDistanceKernel &) = delete; - /** Prevent instances of this class from being copied (As this class contains pointers) */ - CPPSortEuclideanDistanceKernel &operator=(const CPPSortEuclideanDistanceKernel &) = delete; - /** Allow instances of this class to be moved */ - CPPSortEuclideanDistanceKernel(CPPSortEuclideanDistanceKernel &&) = default; - /** Allow instances of this class to be moved */ - CPPSortEuclideanDistanceKernel &operator=(CPPSortEuclideanDistanceKernel &&) = default; - /** Initialise the kernel's source, destination and border mode. - * - * @param[in,out] in_out Input internal keypoints. Marked as out as the kernel writes 0 in the strength member. - * @param[out] output Output keypoints. - * @param[in] num_corner_candidates Pointer to the number of corner candidates in the input array - * @param[in] min_distance Radial Euclidean distance to use - */ - void configure(InternalKeypoint *in_out, IKeyPointArray *output, const int32_t *num_corner_candidates, float min_distance); - - // Inherited methods overridden: - void run(const Window &window, const ThreadInfo &info) override; - bool is_parallelisable() const override; - -private: - const int32_t *_num_corner_candidates; /**< Number of corner candidates */ - float _min_distance; /**< Radial Euclidean distance */ - InternalKeypoint *_in_out; /**< Source array of InternalKeypoint */ - IKeyPointArray *_output; /**< Destination array of IKeyPointArray */ -}; -} // namespace arm_compute -#endif /* ARM_COMPUTE_CPPSORTEUCLIDEANDISTANCEKERNEL_H */ diff --git a/arm_compute/core/HOGInfo.h b/arm_compute/core/HOGInfo.h deleted file mode 100644 index 7314d9a638..0000000000 --- a/arm_compute/core/HOGInfo.h +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (c) 2016-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_HOGINFO_H -#define ARM_COMPUTE_HOGINFO_H - -#include "arm_compute/core/Size2D.h" -#include "arm_compute/core/Types.h" - -#include - -namespace arm_compute -{ -/** Store the HOG's metadata */ -class HOGInfo -{ -public: - /** Default constructor */ - HOGInfo(); - /** Default destructor */ - virtual ~HOGInfo() = default; - /** Allow instances of this class to be copy constructed */ - HOGInfo(const HOGInfo &) = default; - /** Allow instances of this class to be copied */ - HOGInfo &operator=(const HOGInfo &) = default; - /** Allow instances of this class to be move constructed */ - HOGInfo(HOGInfo &&) = default; - /** Allow instances of this class to be moved */ - HOGInfo &operator=(HOGInfo &&) = default; - /** Constructor - * - * @param[in] cell_size Cell size in pixels - * @param[in] block_size Block size in pixels. Must be a multiple of cell_size. - * @param[in] detection_window_size Detection window size in pixels. Must be a multiple of block_size and block_stride. - * @param[in] block_stride Distance in pixels between 2 consecutive blocks along the x and y direction. Must be a multiple of cell size - * @param[in] num_bins Number of histogram bins for each cell - * @param[in] normalization_type (Optional) Normalization type to use for each block - * @param[in] l2_hyst_threshold (Optional) Threshold used for L2HYS_NORM normalization method - * @param[in] phase_type (Optional) Type of @ref PhaseType - */ - HOGInfo(const Size2D &cell_size, const Size2D &block_size, const Size2D &detection_window_size, const Size2D &block_stride, size_t num_bins, - HOGNormType normalization_type = HOGNormType::L2HYS_NORM, float l2_hyst_threshold = 0.2f, PhaseType phase_type = PhaseType::UNSIGNED); - /** Initialize the metadata structure with the given parameters - * - * @param[in] cell_size Cell size in pixels - * @param[in] block_size Block size in pixels. Must be a multiple of cell_size. - * @param[in] detection_window_size Detection window size in pixels. Must be a multiple of block_size and block_stride. - * @param[in] block_stride Distance in pixels between 2 consecutive blocks along the x and y direction. Must be a multiple of cell size - * @param[in] num_bins Number of histogram bins for each cell - * @param[in] normalization_type (Optional) Normalization type to use for each block - * @param[in] l2_hyst_threshold (Optional) Threshold used for L2HYS_NORM normalization method - * @param[in] phase_type (Optional) Type of @ref PhaseType - */ - void init(const Size2D &cell_size, const Size2D &block_size, const Size2D &detection_window_size, const Size2D &block_stride, size_t num_bins, - HOGNormType normalization_type = HOGNormType::L2HYS_NORM, float l2_hyst_threshold = 0.2f, PhaseType phase_type = PhaseType::UNSIGNED); - /** The cell size in pixels - * - * @return The cell size in pixels - */ - const Size2D &cell_size() const; - /** The block size in pixels - * - * @return The block size in pixels - */ - const Size2D &block_size() const; - /** The detection window size in pixels - * - * @return The detection window size in pixels - */ - const Size2D &detection_window_size() const; - /** The block stride in pixels. The block stride is the distance between 2 consecutive blocks - * - * @return The block stride in pixels - */ - const Size2D &block_stride() const; - /** The number of histogram bins for each cell - * - * @return The number of histogram bins for each cell - */ - size_t num_bins() const; - /** The normalization type - * - * @return The normalization type - */ - HOGNormType normalization_type() const; - /** Threshold used for L2HYS_NORM normalization type - * - * @return Threshold used for L2HYS_NORM normalization type - */ - float l2_hyst_threshold() const; - /** The type of @ref PhaseType - * - * @return The type of @ref PhaseType - */ - PhaseType phase_type() const; - /** The size of HOG descriptor - * - * @return The size of HOG descriptor - */ - size_t descriptor_size() const; - /** Calculates the number of cells for each block - * - * @return The Size2D data object which stores the number of cells along the x and y directions - */ - Size2D num_cells_per_block() const; - - /** Calculates the number of cells per block stride - * - * @return The Size2D data object which stores the number of cells per block stride along the x and y directions - */ - Size2D num_cells_per_block_stride() const; - /** Calculates the number of block positions for the given image size - * - * @param[in] image_size The input image size data object - * - * @return The Size2D data object which stores the number of block positions along the x and y directions - */ - Size2D num_block_positions_per_image(const Size2D &image_size) const; - -private: - Size2D _cell_size; - Size2D _block_size; - Size2D _detection_window_size; - Size2D _block_stride; - size_t _num_bins; - HOGNormType _normalization_type; - float _l2_hyst_threshold; - PhaseType _phase_type; - size_t _descriptor_size; -}; -} -#endif /*ARM_COMPUTE_HOGINFO_H */ diff --git a/arm_compute/core/IArray.h b/arm_compute/core/IArray.h index 5f8b13d7f9..6edbc1d5d5 100644 --- a/arm_compute/core/IArray.h +++ b/arm_compute/core/IArray.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2019 Arm Limited. + * Copyright (c) 2016-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -30,11 +30,6 @@ namespace arm_compute { -struct KeyPoint; -struct Coordinates2D; -struct DetectionWindow; -class Size2D; - /** Array of type T */ template class IArray @@ -135,14 +130,6 @@ private: size_t _num_values; size_t _max_size; }; -/** Interface for Array of Key Points. */ -using IKeyPointArray = IArray; -/** Interface for Array of 2D Coordinates. */ -using ICoordinates2DArray = IArray; -/** Interface for Array of Detection Windows. */ -using IDetectionWindowArray = IArray; -/** Interface for Array of 2D Sizes. */ -using ISize2DArray = IArray; /** Interface for Array of uint8s. */ using IUInt8Array = IArray; /** Interface for Array of uint16s. */ diff --git a/arm_compute/core/IDistribution.h b/arm_compute/core/IDistribution.h deleted file mode 100644 index dd511bf8a9..0000000000 --- a/arm_compute/core/IDistribution.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2016-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_IDISTRIBUTION_H -#define ARM_COMPUTE_IDISTRIBUTION_H - -#include -#include - -namespace arm_compute -{ -/** Interface for distribution objects */ -class IDistribution -{ -public: - /** Default virtual destructor */ - virtual ~IDistribution() = default; - /** Returns the dimensions of the distribution. - * - * @note This is fixed to 1-dimensional distribution for now. - * @return Dimensions of the distribution. - */ - virtual size_t dimensions() const = 0; - /** Returns the total size in bytes of the distribution. - * - * @return Total size of the distribution in bytes. - */ - virtual size_t size() const = 0; - /** Returns a pointer to the start of the distribution. - * Other elements of the array can be accessed using buffer()[idx] for 0 <= idx < num_bins() - * - * @return Pointer to the start of the distribution. - */ - virtual uint32_t *buffer() const = 0; - /** Clears the distribution by setting every element to zero. */ - void clear() const; -}; -} -#endif /* ARM_COMPUTE_IDISTRIBUTION_H */ diff --git a/arm_compute/core/IDistribution1D.h b/arm_compute/core/IDistribution1D.h deleted file mode 100644 index 28a38f4c78..0000000000 --- a/arm_compute/core/IDistribution1D.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2016-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_IDISTRIBUTION1D_H -#define ARM_COMPUTE_IDISTRIBUTION1D_H - -#include "arm_compute/core/IDistribution.h" - -#include -#include - -namespace arm_compute -{ -/** 1D Distribution interface */ -class IDistribution1D : public IDistribution -{ -public: - /** Constructor: Creates a 1D Distribution of a consecutive interval [offset, offset + range - 1] - * defined by a start offset and valid range, divided equally into num_bins parts. - * - * @param[in] num_bins The number of bins the distribution is divided in. - * @param[in] offset The start of the values to use. - * @param[in] range The total number of the consecutive values of the distribution interval. - */ - IDistribution1D(size_t num_bins, int32_t offset, uint32_t range); - /** Returns the number of bins that the distribution has. - * - * @return Number of bins of the distribution. - */ - size_t num_bins() const; - /** Returns the offset of the distribution. - * - * @return Offset of the distribution. - */ - int32_t offset() const; - /** Returns the range of the distribution. - * - * @return Range of the distribution. - */ - uint32_t range() const; - /** Returns the window of the distribution, which is the range divided by the number of bins. - * - * @note If range is not divided by the number of bins then it is invalid. - * - * @return Window of the distribution. - */ - uint32_t window() const; - /** Sets the range of the distribution. - * - * @param[in] range New range of the distribution to be set. - */ - void set_range(uint32_t range); - - // Inherited methods overridden: - size_t size() const override; - size_t dimensions() const override; - -private: - size_t _num_bins; /**< Number of bins. */ - int32_t _offset; /**< Offset, which indicate the start of the usable values. */ - uint32_t _range; /**< The total number of consecutive values of the distribution interval */ -}; -} -#endif /* ARM_COMPUTE_IDISTRIBUTION1D_H */ diff --git a/arm_compute/core/IHOG.h b/arm_compute/core/IHOG.h deleted file mode 100644 index a21095af5d..0000000000 --- a/arm_compute/core/IHOG.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2016-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_IHOG_H -#define ARM_COMPUTE_IHOG_H - -#include "arm_compute/core/Types.h" - -#include - -namespace arm_compute -{ -class HOGInfo; -/** Interface for HOG data-object */ -class IHOG -{ -public: - /** Interface to be implemented by the child class to return the HOG's metadata - * - * @return A pointer to the HOG's metadata. - */ - virtual const HOGInfo *info() const = 0; - /** Default virtual destructor */ - virtual ~IHOG() = default; - /** Pointer to the first element of the array which stores the linear SVM coefficients of HOG descriptor - * - * @note Other elements of the array can be accessed using descriptor()[idx] for idx=[0, descriptor_size() - 1] - * - * @return A pointer to the first element of the array which stores the linear SVM coefficients of HOG descriptor - */ - virtual float *descriptor() const = 0; -}; -} -#endif /* ARM_COMPUTE_IHOG_H */ diff --git a/arm_compute/core/ILut.h b/arm_compute/core/ILut.h deleted file mode 100644 index bb0ae8b070..0000000000 --- a/arm_compute/core/ILut.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2016-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_ILUT_H -#define ARM_COMPUTE_ILUT_H - -#include "arm_compute/core/Types.h" - -#include - -namespace arm_compute -{ -/** Lookup Table object interface. */ -class ILut -{ -public: - /** Default virtual destructor */ - virtual ~ILut() = default; - /** Returns the total number of elements in the LUT. - * - * @return Total number of elements. - */ - virtual size_t num_elements() const = 0; - /** Indicates the offset that needs to be applied to the raw index before performing a lookup in the LUT. - * - * @return The normalization offset. - */ - virtual uint32_t index_offset() const = 0; - /** Returns the total size in bytes of the LUT. - * - * @return Total size of the LUT in bytes. - */ - virtual size_t size_in_bytes() const = 0; - /** Returns the type of the LUT. - * - * @return The type of the LUT. - */ - virtual DataType type() const = 0; - /** Returns a pointer to the start of the LUT. - * Other elements of the LUT can be accessed using buffer()[idx] for 0 <= idx < num_elements(). - * - * @return Pointer to the start of the lut. - */ - virtual uint8_t *buffer() const = 0; - /** Clears the LUT by setting every element to zero. */ - virtual void clear() = 0; -}; -} -#endif /* ARM_COMPUTE_ILUT_H */ diff --git a/arm_compute/core/IMultiHOG.h b/arm_compute/core/IMultiHOG.h deleted file mode 100644 index 6b93fcfd31..0000000000 --- a/arm_compute/core/IMultiHOG.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2016-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_IMULTIHOG_H -#define ARM_COMPUTE_IMULTIHOG_H - -#include "arm_compute/core/IHOG.h" - -#include - -namespace arm_compute -{ -/** Interface for storing multiple HOG data-objects */ -class IMultiHOG -{ -public: - /** Default destructor */ - virtual ~IMultiHOG() = default; - /** The number of HOG models stored - * - * @return The number of HOG models stored - */ - virtual size_t num_models() const = 0; - /** Return a pointer to the requested HOG model - * - * @param[in] index The index of the wanted HOG model. - * - * @return A pointer pointed to the HOG model - */ - virtual IHOG *model(size_t index) = 0; - /** Return a const pointer to the requested HOG model - * - * @param[in] index The index of the wanted HOG model. - * - * @return A const pointer pointed to the HOG model - */ - virtual const IHOG *model(size_t index) const = 0; -}; -} - -#endif /* ARM_COMPUTE_IMULTIHOG_H */ diff --git a/arm_compute/core/IMultiImage.h b/arm_compute/core/IMultiImage.h deleted file mode 100644 index 672c2fefde..0000000000 --- a/arm_compute/core/IMultiImage.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2016-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_IMULTIIMAGE_H -#define ARM_COMPUTE_IMULTIIMAGE_H - -namespace arm_compute -{ -class ITensor; -using IImage = ITensor; -class MultiImageInfo; - -/** Interface for multi-planar images */ -class IMultiImage -{ -public: - /** Destructor */ - virtual ~IMultiImage() = default; - /** Interface to be implemented by the child class to return the multi-planar image's metadata - * - * @return A pointer to the image's metadata. - */ - virtual const MultiImageInfo *info() const = 0; - /** Return a pointer to the requested plane of the image. - * - * @param[in] index The index of the wanted planed. - * - * @return A pointer pointed to the plane - */ - virtual IImage *plane(unsigned int index) = 0; - /** Return a constant pointer to the requested plane of the image. - * - * @param[in] index The index of the wanted planed. - * - * @return A constant pointer pointed to the plane - */ - virtual const IImage *plane(unsigned int index) const = 0; -}; -} -#endif /*ARM_COMPUTE_IMULTIIMAGE_H */ diff --git a/arm_compute/core/IPyramid.h b/arm_compute/core/IPyramid.h deleted file mode 100644 index 58fb0b4620..0000000000 --- a/arm_compute/core/IPyramid.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2016-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_IPYRAMID_H -#define ARM_COMPUTE_IPYRAMID_H - -#include "arm_compute/core/ITensor.h" -#include "arm_compute/core/PyramidInfo.h" -#include "arm_compute/core/Types.h" - -#include - -namespace arm_compute -{ -/** Interface for pyramid data-object */ -class IPyramid -{ -public: - /** Default virtual destructor */ - virtual ~IPyramid() = default; - /** Interface to be implemented by the child class to return the Pyramid's metadata - * - * @return A pointer to the Pyramid's metadata. - */ - virtual const PyramidInfo *info() const = 0; - /** Retrieves a level of the pyramid as a ITensor pointer - * - * @param[in] index The index of the level, such that index is less than levels. - * - * @return An ITensor pointer - */ - virtual ITensor *get_pyramid_level(size_t index) const = 0; -}; -} - -#endif /* ARM_COMPUTE_IPYRAMID_H */ diff --git a/arm_compute/core/KernelDescriptors.h b/arm_compute/core/KernelDescriptors.h index 0025301e48..1a7ead4700 100644 --- a/arm_compute/core/KernelDescriptors.h +++ b/arm_compute/core/KernelDescriptors.h @@ -210,29 +210,5 @@ struct ScaleKernelInfo bool align_corners; /**< Align corners of input and output */ DataLayout data_layout; /**< Data layout to use */ }; - -struct ThresholdKernelInfo -{ - /** Default constructor */ - ThresholdKernelInfo() = default; - /** Constructor - * - * @param[in] threshold Threshold. When the threshold type is RANGE, this is used as the lower threshold. - * @param[in] false_value value to set when the condition is not respected. - * @param[in] true_value value to set when the condition is respected. - * @param[in] type Thresholding type. Either RANGE or BINARY. - * @param[in] upper Upper threshold. Only used when the thresholding type is RANGE. - */ - ThresholdKernelInfo(uint8_t threshold, uint8_t false_value, uint8_t true_value, ThresholdType type, uint8_t upper) - : threshold(threshold), false_value(false_value), true_value(true_value), type(type), upper(upper) - { - } - - uint8_t threshold{ 0 }; - uint8_t false_value{ 0 }; - uint8_t true_value{ 0 }; - ThresholdType type{ ThresholdType::BINARY }; - uint8_t upper{ 0 }; -}; } // namespace arm_compute #endif /* ARM_COMPUTE_CORE_KERNEL_DESCRIPTORS_H */ diff --git a/arm_compute/core/MultiImageInfo.h b/arm_compute/core/MultiImageInfo.h deleted file mode 100644 index 0d776e1723..0000000000 --- a/arm_compute/core/MultiImageInfo.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2016-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_MULTIIMAGEINFO_H -#define ARM_COMPUTE_MULTIIMAGEINFO_H - -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -/** Store the multi-planar image's metadata */ -class MultiImageInfo -{ -public: - /** Constructor */ - MultiImageInfo(); - /** Initialize the metadata structure with the given parameters - * - * @param[in] width Width of the image (in number of pixels) - * @param[in] height Height of the image (in number of pixels) - * @param[in] format Colour format of the image. - */ - void init(unsigned int width, unsigned int height, Format format); - /** Colour format of the image - * - * @return Colour format of the image - */ - Format format() const; - /** Width in pixels - * - * @return The width in pixels - */ - unsigned int width() const; - /** Height in pixels - * - * @return The height in pixels - */ - unsigned int height() const; - -protected: - unsigned int _width; - unsigned int _height; - Format _format; -}; -} -#endif /*ARM_COMPUTE_MULTIIMAGEINFO_H */ diff --git a/arm_compute/core/PyramidInfo.h b/arm_compute/core/PyramidInfo.h deleted file mode 100644 index c6bfa1bba1..0000000000 --- a/arm_compute/core/PyramidInfo.h +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (c) 2016-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_PYRAMIDINFO_H -#define ARM_COMPUTE_PYRAMIDINFO_H - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -#include - -namespace arm_compute -{ -/** Store the Pyramid's metadata */ -class PyramidInfo -{ -public: - /** Default constructor */ - PyramidInfo(); - /** Default destructor */ - virtual ~PyramidInfo() = default; - /** Allow instances of this class to be copy constructed */ - PyramidInfo(const PyramidInfo &) = default; - /** Allow instances of this class to be copied */ - PyramidInfo &operator=(const PyramidInfo &) = default; - /** Allow instances of this class to be move constructed */ - PyramidInfo(PyramidInfo &&) = default; - /** Allow instances of this class to be moved */ - PyramidInfo &operator=(PyramidInfo &&) = default; - - /** Create pyramid info for 2D tensors - * - * @param[in] num_levels The number of pyramid levels. This is required to be a non-zero value - * @param[in] scale Used to indicate the scale between the pyramid levels. - * This is required to be a non-zero positive value. - * @param[in] width The width of the 2D tensor at 0th pyramid level - * @param[in] height The height of the 2D tensor at 0th pyramid level - * @param[in] format The format of all 2D tensors in the pyramid - * NV12, NV21, IYUV, UYVY and YUYV formats are not supported. - */ - PyramidInfo(size_t num_levels, float scale, size_t width, size_t height, Format format); - - /** Create pyramid info using TensorShape - * - * @param[in] num_levels The number of pyramid levels. This is required to be a non-zero value - * @param[in] scale Used to indicate the scale between the pyramid levels. - * This is required to be a non-zero positive value. - * @param[in] tensor_shape It specifies the size for each dimension of the tensor 0th pyramid level in number of elements - * @param[in] format The format of all tensors in the pyramid - */ - PyramidInfo(size_t num_levels, float scale, const TensorShape &tensor_shape, Format format); - - /** Initialize pyramid's metadata for 2D tensors - * - * @param[in] num_levels The number of pyramid levels. This is required to be a non-zero value - * @param[in] scale Used to indicate the scale between the pyramid levels. - * This is required to be a non-zero positive value. - * @param[in] width The width of the 2D tensor at 0th pyramid level - * @param[in] height The height of the 2D tensor at 0th pyramid level - * @param[in] format The format of all 2D tensors in the pyramid - * NV12, NV21, IYUV, UYVY and YUYV formats are not supported. - */ - void init(size_t num_levels, float scale, size_t width, size_t height, Format format); - /** Initialize pyramid's metadata using TensorShape - * - * @param[in] num_levels The number of pyramid levels. This is required to be a non-zero value - * @param[in] scale Used to indicate the scale between the pyramid levels. - * This is required to be a non-zero positive value. - * @param[in] tensor_shape It specifies the size for each dimension of the tensor 0th pyramid level in number of elements - * @param[in] format The format of all tensors in the pyramid - */ - void init(size_t num_levels, float scale, const TensorShape &tensor_shape, Format format); - /** Return the number of the pyramid levels - * - * @return The number of the pyramid levels - */ - size_t num_levels() const; - /** Return the width of the 0th level tensor - * - * @return The width of the 0th level tensor - */ - size_t width() const; - /** Return the height of the 0th level tensor - * - * @return The height of the 0th level tensor - */ - size_t height() const; - /** Return the TensorShape of the o-th level tensor - * - * @return - */ - const TensorShape &tensor_shape() const; - /** Return the image format of all tensor in the pyramid - * - * @return The image format - */ - Format format() const; - /** Return the scale factor of the pyramid - * - * @return Return the scale factor - */ - float scale() const; - -private: - size_t _num_levels; - TensorShape _tensor_shape; - Format _format; - float _scale; -}; -} -#endif /*ARM_COMPUTE_PYRAMIDINFO_H */ diff --git a/arm_compute/core/TensorInfo.h b/arm_compute/core/TensorInfo.h index 633daca063..a4330849bf 100644 --- a/arm_compute/core/TensorInfo.h +++ b/arm_compute/core/TensorInfo.h @@ -39,8 +39,6 @@ namespace arm_compute { -class HOGInfo; - /** Store the tensor's metadata */ class TensorInfo final : public ITensorInfo { @@ -117,14 +115,6 @@ public: */ TensorInfo(const TensorShape &tensor_shape, size_t num_channels, DataType data_type, QuantizationInfo quantization_info); - /** Constructor - * - * @param[in] hog_info HOG's metadata used to allocate normalized HOG space - * @param[in] width Width of the 2D tensor where the HOG descriptor will be computed on - * @param[in] height Height of the 2D tensor where the HOG descriptor will be computed on - */ - TensorInfo(const HOGInfo &hog_info, unsigned int width, unsigned int height); - /** Initialize the tensor info with just a format. * * Can be used for automatic derivation of the shape by the function. @@ -177,13 +167,6 @@ public: */ void init(const TensorShape &tensor_shape, size_t num_channels, DataType data_type, const Strides &strides_in_bytes, size_t offset_first_element_in_bytes, size_t total_size_in_bytes); - /** Initialize the metadata structure for the given HOG's metadata - * - * @param[in] hog_info HOG's metadata used to allocate normalized HOG space - * @param[in] width Width of the 2D tensor where the HOG descriptor will be computed on - * @param[in] height Height of the 2D tensor where the HOG descriptor will be computed on - */ - void init(const HOGInfo &hog_info, unsigned int width, unsigned int height); /** Initialize the metadata structure for the given tensor shape and single-plane format, (Padding is automatically calculated) * * @note The padding used by this method is really conservative so that the tensor can be used for most functions. @@ -206,17 +189,6 @@ public: * @return Total allocation size including padding in bytes. */ size_t init_auto_padding(const TensorShape &tensor_shape, size_t num_channels, DataType data_type); - /** Initialize the metadata structure for the given HOG's metadata - * - * @note init_auto_padding will be used for the tensor initialization. - * - * @param[in] hog_info HOG's metadata used to allocate normalized HOG space - * @param[in] width Width of the 2D tensor where the HOG descriptor will be computed on - * @param[in] height Height of the 2D tensor where the HOG descriptor will be computed on - * - * @return Total allocation size including padding in bytes. - */ - size_t init_auto_padding(const HOGInfo &hog_info, unsigned int width, unsigned int height); // Inherited methods overridden: std::unique_ptr clone() const override; diff --git a/arm_compute/core/Types.h b/arm_compute/core/Types.h index a2ad51526b..53333ff608 100644 --- a/arm_compute/core/Types.h +++ b/arm_compute/core/Types.h @@ -108,12 +108,6 @@ enum class SamplingPolicy /** Constant value of the border pixels when using BorderMode::CONSTANT */ constexpr uint8_t CONSTANT_BORDER_VALUE = 199; -/** Constant value used to indicate a half-scale pyramid */ -constexpr float SCALE_PYRAMID_HALF = 0.5f; - -/** Constant value used to indicate a ORB scaled pyramid */ -constexpr float SCALE_PYRAMID_ORB = 8.408964152537146130583778358414e-01; - /** [DataLayout enum definition] **/ /** Supported tensor data layouts */ @@ -409,53 +403,6 @@ enum class BilinearInterpolation BILINEAR_SCHARR /**< Scharr method */ }; -/** Threshold mode */ -enum class ThresholdType -{ - BINARY, /**< Threshold with one value */ - RANGE /**< Threshold with two values*/ -}; - -/** Termination criteria */ -enum class Termination -{ - TERM_CRITERIA_EPSILON, /**< Terminate when within epsilon of a threshold */ - TERM_CRITERIA_ITERATIONS, /**< Terminate after a maximum number of iterations */ - TERM_CRITERIA_BOTH /**< Terminate on whichever of the other conditions occurs first */ -}; - -/** Magnitude calculation type. */ -enum class MagnitudeType -{ - L1NORM, /**< L1 normalization type */ - L2NORM /**< L2 normalization type */ -}; - -/** Phase calculation type. - * - * @note When PhaseType == SIGNED, each angle is mapped to the range 0 to 255 inclusive otherwise angles between 0 and 180 - */ -enum class PhaseType -{ - SIGNED, /**< Angle range: [0, 360] */ - UNSIGNED /**< Angle range: [0, 180] */ -}; - -/** Keypoint type */ -struct KeyPoint -{ - int32_t x{ 0 }; /**< X coordinates */ - int32_t y{ 0 }; /**< Y coordinates */ - float strength{ 0.f }; /**< Strength of the point */ - float scale{ 0.f }; /**< Scale initialized to 0 by the corner detector */ - float orientation{ 0.f }; /**< Orientation initialized to 0 by the corner detector */ - int32_t tracking_status{ 0 }; /**< Status initialized to 1 by the corner detector, set to 0 when the point is lost */ - float error{ 0.f }; /**< Tracking error initialized to 0 by the corner detector */ -}; - -/** Internal key point */ -using InternalKeypoint = std::tuple; /* x,y,strength */ - /** Rectangle type */ struct Rectangle { @@ -506,23 +453,6 @@ enum class Channel V /**< Cr/V/Value channel. */ }; -/** Available matrix patterns */ -enum class MatrixPattern -{ - BOX, /**< Box pattern matrix. */ - CROSS, /**< Cross pattern matrix. */ - DISK, /**< Disk pattern matrix. */ - OTHER /**< Any other matrix pattern. */ -}; - -/** Available non linear functions. */ -enum class NonLinearFilterFunction : unsigned -{ - MEDIAN = 0, /**< Non linear median filter. */ - MIN = 1, /**< Non linear erode. */ - MAX = 2, /**< Non linear dilate. */ -}; - /** Available reduction operations */ enum class ReductionOperation { @@ -579,14 +509,6 @@ enum class NormType CROSS_MAP /**< Normalization applied cross maps */ }; -/** Normalization type for Histogram of Oriented Gradients (HOG) */ -enum class HOGNormType -{ - L2_NORM = 1, /**< L2-norm */ - L2HYS_NORM = 2, /**< L2-norm followed by clipping */ - L1_NORM = 3 /**< L1 norm */ -}; - /** Detection window used for the object detection. The detection window keeps the following information: * * -# Geometry of the rectangular window (x/y of top-left corner and width/height) @@ -2263,14 +2185,5 @@ struct IOFormatInfo /** Align columns */ bool align_columns; }; - -/** Internal keypoint class for Lucas-Kanade Optical Flow */ -struct NELKInternalKeypoint -{ - float x{ 0.f }; /**< x coordinate of the keypoint */ - float y{ 0.f }; /**< y coordinate of the keypoint */ - bool tracking_status{ false }; /**< the tracking status of the keypoint */ -}; - } // namespace arm_compute #endif /* ARM_COMPUTE_TYPES_H */ diff --git a/arm_compute/core/Utils.h b/arm_compute/core/Utils.h index 19ed73781e..d5c365e6ab 100644 --- a/arm_compute/core/Utils.h +++ b/arm_compute/core/Utils.h @@ -655,82 +655,6 @@ inline bool has_format_vertical_subsampling(Format format) return (format == Format::NV12 || format == Format::NV21 || format == Format::IYUV || format == Format::UV88) ? true : false; } -/** Separate a 2D convolution into two 1D convolutions - * - * @param[in] conv 2D convolution - * @param[out] conv_col 1D vertical convolution - * @param[out] conv_row 1D horizontal convolution - * @param[in] size Size of the 2D convolution - * - * @return true if the separation was successful - */ -inline bool separate_matrix(const int16_t *conv, int16_t *conv_col, int16_t *conv_row, uint8_t size) -{ - int32_t min_col = -1; - int16_t min_col_val = -1; - - for(int32_t i = 0; i < size; ++i) - { - if(conv[i] != 0 && (min_col < 0 || abs(min_col_val) > abs(conv[i]))) - { - min_col = i; - min_col_val = conv[i]; - } - } - - if(min_col < 0) - { - return false; - } - - for(uint32_t j = 0; j < size; ++j) - { - conv_col[j] = conv[min_col + j * size]; - } - - for(uint32_t i = 0; i < size; i++) - { - if(static_cast(i) == min_col) - { - conv_row[i] = 1; - } - else - { - int16_t coeff = conv[i] / conv[min_col]; - - for(uint32_t j = 1; j < size; ++j) - { - if(conv[i + j * size] != (conv_col[j] * coeff)) - { - return false; - } - } - - conv_row[i] = coeff; - } - } - - return true; -} - -/** Calculate the scale of the given square matrix - * - * The scale is the absolute value of the sum of all the coefficients in the matrix. - * - * @note If the coefficients add up to 0 then the scale is set to 1. - * - * @param[in] matrix Matrix coefficients - * @param[in] matrix_size Number of elements per side of the square matrix. (Number of coefficients = matrix_size * matrix_size). - * - * @return The absolute value of the sum of the coefficients if they don't add up to 0, otherwise 1. - */ -inline uint32_t calculate_matrix_scale(const int16_t *matrix, unsigned int matrix_size) -{ - const size_t size = matrix_size * matrix_size; - - return std::max(1, std::abs(std::accumulate(matrix, matrix + size, 0))); -} - /** Adjust tensor shape size if width or height are odd for a given multi-planar format. No modification is done for other formats. * * @note Adding here a few links discussing the issue of odd size and sharing the same solution: @@ -794,117 +718,6 @@ inline TensorShape calculate_subsampled_shape(const TensorShape &shape, Format f return output; } -/** Calculate accurary required by the horizontal and vertical convolution computations - * - * @param[in] conv_col Pointer to the vertical vector of the separated convolution filter - * @param[in] conv_row Pointer to the horizontal vector of the convolution filter - * @param[in] size Number of elements per vector of the separated matrix - * - * @return The return type is a pair. The first element of the pair is the biggest data type needed for the first stage. The second - * element of the pair is the biggest data type needed for the second stage. - */ -inline std::pair data_type_for_convolution(const int16_t *conv_col, const int16_t *conv_row, size_t size) -{ - DataType first_stage = DataType::UNKNOWN; - DataType second_stage = DataType::UNKNOWN; - - auto gez = [](const int16_t &v) - { - return v >= 0; - }; - - auto accu_neg = [](const int &first, const int &second) - { - return first + (second < 0 ? second : 0); - }; - - auto accu_pos = [](const int &first, const int &second) - { - return first + (second > 0 ? second : 0); - }; - - const bool only_positive_coefficients = std::all_of(conv_row, conv_row + size, gez) && std::all_of(conv_col, conv_col + size, gez); - - if(only_positive_coefficients) - { - const int max_row_value = std::accumulate(conv_row, conv_row + size, 0) * UINT8_MAX; - const int max_value = std::accumulate(conv_col, conv_col + size, 0) * max_row_value; - - first_stage = (max_row_value <= UINT16_MAX) ? DataType::U16 : DataType::S32; - - second_stage = (max_value <= UINT16_MAX) ? DataType::U16 : DataType::S32; - } - else - { - const int min_row_value = std::accumulate(conv_row, conv_row + size, 0, accu_neg) * UINT8_MAX; - const int max_row_value = std::accumulate(conv_row, conv_row + size, 0, accu_pos) * UINT8_MAX; - const int neg_coeffs_sum = std::accumulate(conv_col, conv_col + size, 0, accu_neg); - const int pos_coeffs_sum = std::accumulate(conv_col, conv_col + size, 0, accu_pos); - const int min_value = neg_coeffs_sum * max_row_value + pos_coeffs_sum * min_row_value; - const int max_value = neg_coeffs_sum * min_row_value + pos_coeffs_sum * max_row_value; - - first_stage = ((INT16_MIN <= min_row_value) && (max_row_value <= INT16_MAX)) ? DataType::S16 : DataType::S32; - - second_stage = ((INT16_MIN <= min_value) && (max_value <= INT16_MAX)) ? DataType::S16 : DataType::S32; - } - - return std::make_pair(first_stage, second_stage); -} - -/** Calculate the accuracy required by the squared convolution calculation. - * - * - * @param[in] conv Pointer to the squared convolution matrix - * @param[in] size The total size of the convolution matrix - * - * @return The return is the biggest data type needed to do the convolution - */ -inline DataType data_type_for_convolution_matrix(const int16_t *conv, size_t size) -{ - auto gez = [](const int16_t v) - { - return v >= 0; - }; - - const bool only_positive_coefficients = std::all_of(conv, conv + size, gez); - - if(only_positive_coefficients) - { - const int max_conv_value = std::accumulate(conv, conv + size, 0) * UINT8_MAX; - if(max_conv_value <= UINT16_MAX) - { - return DataType::U16; - } - else - { - return DataType::S32; - } - } - else - { - const int min_value = std::accumulate(conv, conv + size, 0, [](int a, int b) - { - return b < 0 ? a + b : a; - }) - * UINT8_MAX; - - const int max_value = std::accumulate(conv, conv + size, 0, [](int a, int b) - { - return b > 0 ? a + b : a; - }) - * UINT8_MAX; - - if((INT16_MIN <= min_value) && (INT16_MAX >= max_value)) - { - return DataType::S16; - } - else - { - return DataType::S32; - } - } -} - /** Permutes the given dimensions according the permutation vector * * @param[in,out] dimensions Dimensions to be permuted. @@ -1024,13 +837,6 @@ const std::string &string_from_data_layout(DataLayout dl); * @return The string describing the data type. */ const std::string &string_from_data_type(DataType dt); -/** Convert a matrix pattern into a string. - * - * @param[in] pattern @ref MatrixPattern to be translated to string. - * - * @return The string describing the matrix pattern. - */ -const std::string &string_from_matrix_pattern(MatrixPattern pattern); /** Translates a given activation function to a string. * * @param[in] act @ref ActivationLayerInfo::ActivationFunction to be translated to string. @@ -1038,13 +844,6 @@ const std::string &string_from_matrix_pattern(MatrixPattern pattern); * @return The string describing the activation function. */ const std::string &string_from_activation_func(ActivationLayerInfo::ActivationFunction act); -/** Translates a given non linear function to a string. - * - * @param[in] function @ref NonLinearFilterFunction to be translated to string. - * - * @return The string describing the non linear function. - */ -const std::string &string_from_non_linear_filter_function(NonLinearFilterFunction function); /** Translates a given interpolation policy to a string. * * @param[in] policy @ref InterpolationPolicy to be translated to string. diff --git a/arm_compute/core/Validate.h b/arm_compute/core/Validate.h index 68b3de56ce..e755cacae6 100644 --- a/arm_compute/core/Validate.h +++ b/arm_compute/core/Validate.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2019 Arm Limited. + * Copyright (c) 2016-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -25,12 +25,8 @@ #define ARM_COMPUTE_VALIDATE_H #include "arm_compute/core/Error.h" -#include "arm_compute/core/HOGInfo.h" #include "arm_compute/core/IKernel.h" -#include "arm_compute/core/IMultiHOG.h" -#include "arm_compute/core/IMultiImage.h" #include "arm_compute/core/ITensor.h" -#include "arm_compute/core/MultiImageInfo.h" #include "arm_compute/core/Window.h" #include @@ -905,28 +901,6 @@ arm_compute::Status error_on_channel_not_in_known_format(const char *function, c #define ARM_COMPUTE_RETURN_ERROR_ON_CHANNEL_NOT_IN_KNOWN_FORMAT(f, c) \ ARM_COMPUTE_RETURN_ON_ERROR(::arm_compute::error_on_channel_not_in_known_format(__func__, __FILE__, __LINE__, f, c)) -/** Return an error if the @ref IMultiHOG container is invalid - * - * An @ref IMultiHOG container is invalid if: - * - * -# it is a nullptr - * -# it doesn't contain models - * -# it doesn't have the HOG data objects with the same phase_type, normalization_type and l2_hyst_threshold (if normalization_type == L2HYS_NORM) - * - * @param[in] function Function in which the error occurred. - * @param[in] file Name of the file where the error occurred. - * @param[in] line Line on which the error occurred. - * @param[in] multi_hog IMultiHOG container to validate - * - * @return Status - */ -arm_compute::Status error_on_invalid_multi_hog(const char *function, const char *file, const int line, - const IMultiHOG *multi_hog); -#define ARM_COMPUTE_ERROR_ON_INVALID_MULTI_HOG(m) \ - ARM_COMPUTE_ERROR_THROW_ON(::arm_compute::error_on_invalid_multi_hog(__func__, __FILE__, __LINE__, m)) -#define ARM_COMPUTE_RETURN_ERROR_ON_INVALID_MULTI_HOG(m) \ - ARM_COMPUTE_RETURN_ON_ERROR(::arm_compute::error_on_invalid_multi_hog(__func__, __FILE__, __LINE__, m)) - /** Return an error if the kernel is not configured. * * @param[in] function Function in which the error occurred. diff --git a/arm_compute/runtime/Array.h b/arm_compute/runtime/Array.h index 5b98b6c2bc..21d9c25c87 100644 --- a/arm_compute/runtime/Array.h +++ b/arm_compute/runtime/Array.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2020 Arm Limited. + * Copyright (c) 2016-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -60,14 +60,6 @@ private: std::unique_ptr _values; }; -/** Array of Key Points. */ -using KeyPointArray = Array; -/** Array of 2D Coordinates. */ -using Coordinates2DArray = Array; -/** Array of Detection Windows. */ -using DetectionWindowArray = Array; -/** Array of 2D Sizes. */ -using Size2DArray = Array; /** Array of uint8s. */ using UInt8Array = Array; /** Array of uint16s. */ diff --git a/arm_compute/runtime/CL/CLArray.h b/arm_compute/runtime/CL/CLArray.h index 76d0ee6777..7efe208b9f 100644 --- a/arm_compute/runtime/CL/CLArray.h +++ b/arm_compute/runtime/CL/CLArray.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2019 Arm Limited. + * Copyright (c) 2016-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -102,15 +102,6 @@ protected: private: cl::Buffer _buffer; }; - -/** OpenCL Array of Key Points. */ -using CLKeyPointArray = CLArray; -/** OpenCL Array of 2D Coordinates. */ -using CLCoordinates2DArray = CLArray; -/** OpenCL Array of Detection Windows. */ -using CLDetectionWindowArray = CLArray; -/** OpenCL Array of 2D Sizes. */ -using CLSize2DArray = CLArray; /** OpenCL Array of uint8s. */ using CLUInt8Array = CLArray; /** OpenCL Array of uint16s. */ diff --git a/arm_compute/runtime/CL/CLDistribution1D.h b/arm_compute/runtime/CL/CLDistribution1D.h deleted file mode 100644 index 0597582d68..0000000000 --- a/arm_compute/runtime/CL/CLDistribution1D.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2016-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_CLDISTRIBUTION1D_H -#define ARM_COMPUTE_CLDISTRIBUTION1D_H - -#include "arm_compute/core/CL/ICLDistribution1D.h" -#include "arm_compute/core/CL/OpenCL.h" - -#include -#include - -namespace arm_compute -{ -/** CLDistribution1D object class */ -class CLDistribution1D : public ICLDistribution1D -{ -public: - /** Constructor: Creates a 1D CLDistribution of a consecutive interval [offset, offset + range - 1] - * defined by a start offset and valid range, divided equally into num_bins parts. - * - * @param[in] num_bins The number of bins the distribution is divided in. - * @param[in] offset The start of the values to use. - * @param[in] range The total number of the consecutive values of the distribution interval. - */ - CLDistribution1D(size_t num_bins, int32_t offset, uint32_t range); - /** Prevent instances of this class from being copied (As this class contains pointers) */ - CLDistribution1D(const CLDistribution1D &) = delete; - /** Prevent instances of this class from being copied (As this class contains pointers) */ - CLDistribution1D &operator=(const CLDistribution1D &) = delete; - /** Enqueue a map operation of the allocated buffer. - * - * @param[in] blocking If true, then the mapping will be ready to use by the time - * this method returns, else it is the caller's responsibility - * to flush the queue and wait for the mapping operation to have completed. - */ - void map(bool blocking = true); - using ICLDistribution1D::map; - /** Enqueue an unmap operation of the allocated and mapped buffer. - * - * @note This method simply enqueues the unmap operation, it is the caller's responsibility to flush the queue and make sure the unmap is finished before - * the memory is accessed by the device. - */ - void unmap(); - using ICLDistribution1D::unmap; - - // Inherited methods overridden: - cl::Buffer &cl_buffer() override; - -protected: - // Inherited methods overridden: - uint32_t *do_map(cl::CommandQueue &q, bool blocking) override; - void do_unmap(cl::CommandQueue &q) override; - -private: - cl::Buffer _mem; -}; -} -#endif /* ARM_COMPUTE_CLDISTRIBUTION1D_H */ diff --git a/arm_compute/runtime/CL/CLHOG.h b/arm_compute/runtime/CL/CLHOG.h deleted file mode 100644 index 7594f46107..0000000000 --- a/arm_compute/runtime/CL/CLHOG.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_CLHOG_H -#define ARM_COMPUTE_CLHOG_H - -#include "arm_compute/core/CL/ICLHOG.h" -#include "arm_compute/core/CL/OpenCL.h" -#include "arm_compute/core/HOGInfo.h" -#include "arm_compute/core/Types.h" - -#include - -namespace arm_compute -{ -/** OpenCL implementation of HOG data-object */ -class CLHOG : public ICLHOG -{ -public: - /** Default constructor */ - CLHOG(); - /** Allocate the HOG descriptor using the given HOG's metadata - * - * @param[in] input HOG's metadata used to allocate the HOG descriptor - */ - void init(const HOGInfo &input); - - /** Enqueue a map operation of the allocated buffer. - * - * @param[in] blocking If true, then the mapping will be ready to use by the time - * this method returns, else it is the caller's responsibility - * to flush the queue and wait for the mapping operation to have completed. - */ - void map(bool blocking = true); - using ICLHOG::map; - - /** Enqueue an unmap operation of the allocated and mapped buffer. - * - * @note This method simply enqueues the unmap operation, it is the caller's responsibility to flush the queue and make sure the unmap is finished before - * the memory is accessed by the device. - */ - void unmap(); - using ICLHOG::unmap; - - // Inherited method overridden: - void free() override; - const HOGInfo *info() const override; - const cl::Buffer &cl_buffer() const override; - -protected: - // Inherited methods overridden: - uint8_t *do_map(cl::CommandQueue &q, bool blocking) override; - void do_unmap(cl::CommandQueue &q) override; - -private: - HOGInfo _info; - cl::Buffer _buffer; -}; -} -#endif /* ARM_COMPUTE_CLHOG_H */ diff --git a/arm_compute/runtime/CL/CLLut.h b/arm_compute/runtime/CL/CLLut.h deleted file mode 100644 index 8c48863418..0000000000 --- a/arm_compute/runtime/CL/CLLut.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2016-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_CLLUT_H -#define ARM_COMPUTE_CLLUT_H - -#include "arm_compute/core/CL/ICLLut.h" -#include "arm_compute/core/CL/OpenCL.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLLutAllocator.h" - -#include -#include - -namespace arm_compute -{ -class ILutAllocator; - -/** Basic implementation of the OpenCL lut interface */ -class CLLut : public ICLLut -{ -public: - /** Constructor */ - CLLut(); - /** Constructor: initializes a LUT which can contain num_values values of data_type type. - * - * @param[in] num_elements Number of elements of the LUT. - * @param[in] data_type Data type of each element. - */ - CLLut(size_t num_elements, DataType data_type); - /** Return a pointer to the lut's allocator - * - * @return A pointer to the lut's allocator - */ - ILutAllocator *allocator(); - /** Enqueue a map operation of the allocated buffer. - * - * @param[in] blocking If true, then the mapping will be ready to use by the time - * this method returns, else it is the caller's responsibility - * to flush the queue and wait for the mapping operation to have completed. - */ - void map(bool blocking = true); - using ICLLut::map; - /** Enqueue an unmap operation of the allocated and mapped buffer. - * - * @note This method simply enqueues the unmap operation, it is the caller's responsibility to flush the queue and make sure the unmap is finished before - * the memory is accessed by the device. - */ - void unmap(); - using ICLLut::unmap; - - // Inherited methods overridden: - size_t num_elements() const override; - uint32_t index_offset() const override; - size_t size_in_bytes() const override; - DataType type() const override; - const cl::Buffer &cl_buffer() const override; - void clear() override; - -protected: - // Inherited methods overridden: - uint8_t *do_map(cl::CommandQueue &q, bool blocking) override; - void do_unmap(cl::CommandQueue &q) override; - -private: - CLLutAllocator _allocator; /**< Instance of the OpenCL lut allocator */ -}; -} -#endif /*ARM_COMPUTE_CLLUT_H */ diff --git a/arm_compute/runtime/CL/CLLutAllocator.h b/arm_compute/runtime/CL/CLLutAllocator.h deleted file mode 100644 index 169442c739..0000000000 --- a/arm_compute/runtime/CL/CLLutAllocator.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2016-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_CLLUTALLOCATOR_H -#define ARM_COMPUTE_CLLUTALLOCATOR_H - -#include "arm_compute/runtime/ILutAllocator.h" - -#include "arm_compute/core/CL/OpenCL.h" - -#include - -namespace arm_compute -{ -/** Basic implementation of a CL memory LUT allocator. */ -class CLLutAllocator : public ILutAllocator -{ -public: - /** Default constructor. */ - CLLutAllocator(); - /** Default destructor. */ - ~CLLutAllocator() = default; - /** Prevent instances of this class from being copied (As this class contains pointers) */ - CLLutAllocator(const CLLutAllocator &) = delete; - /** Prevent instances of this class from being copy assigned (As this class contains pointers) */ - const CLLutAllocator &operator=(const CLLutAllocator &) = delete; - /** Interface to be implemented by the child class to return the pointer to the mapped data. - * - * @return pointer to the mapped data. - */ - uint8_t *data(); - /** Interface to be implemented by the child class to return the pointer to the CL data. - * - * @return pointer to the CL data. - */ - const cl::Buffer &cl_data() const; - /** Enqueue a map operation of the allocated buffer on the given queue. - * - * @param[in,out] q The CL command queue to use for the mapping operation. - * @param[in] blocking If true, then the mapping will be ready to use by the time - * this method returns, else it is the caller's responsibility - * to flush the queue and wait for the mapping operation to have completed before using the returned mapping pointer. - * - * @return The mapping address. - */ - uint8_t *map(cl::CommandQueue &q, bool blocking); - /** Enqueue an unmap operation of the allocated buffer on the given queue. - * - * @note This method simply enqueue the unmap operation, it is the caller's responsibility to flush the queue and make sure the unmap is finished before - * the memory is accessed by the device. - * - * @param[in,out] q The CL command queue to use for the mapping operation. - * @param[in] mapping The cpu mapping to unmap. - */ - void unmap(cl::CommandQueue &q, uint8_t *mapping); - -protected: - /** Allocate num_elements() * sizeof(type()) of OpenCL memory. */ - void allocate() override; - /** Call map() on the OpenCL buffer. - * - * @return A pointer to the beginning of the LUT's allocation. - */ - uint8_t *lock() override; - /** Call unmap() on the OpenCL buffer. */ - void unlock() override; - -private: - cl::Buffer _buffer; /**< OpenCL buffer containing the LUT data. */ - uint8_t *_mapping; /**< Pointer to the CPU mapping of the OpenCL buffer. */ -}; -} - -#endif /* ARM_COMPUTE_CLLUTALLOCATOR_H */ diff --git a/arm_compute/runtime/CL/CLMultiHOG.h b/arm_compute/runtime/CL/CLMultiHOG.h deleted file mode 100644 index 5b26467ac1..0000000000 --- a/arm_compute/runtime/CL/CLMultiHOG.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_CLMULTIHOG_H -#define ARM_COMPUTE_CLMULTIHOG_H - -#include "arm_compute/core/CL/ICLMultiHOG.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLHOG.h" - -#include - -namespace arm_compute -{ -/** Basic implementation of the CL multi HOG data-objects */ -class CLMultiHOG : public ICLMultiHOG -{ -public: - /** Constructor - * - * @param[in] num_models Number of HOG data objects to contain - * - */ - CLMultiHOG(size_t num_models); - - // Inherited methods overridden: - size_t num_models() const override; - ICLHOG *cl_model(size_t index) override; - const ICLHOG *cl_model(size_t index) const override; - -private: - size_t _num_models; - std::vector _model; -}; -} -#endif /*ARM_COMPUTE_CLMULTIHOG_H */ diff --git a/arm_compute/runtime/CL/CLMultiImage.h b/arm_compute/runtime/CL/CLMultiImage.h deleted file mode 100644 index a12108c023..0000000000 --- a/arm_compute/runtime/CL/CLMultiImage.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2016-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_CLMULTIIMAGE_H -#define ARM_COMPUTE_CLMULTIIMAGE_H - -#include "arm_compute/core/CL/ICLMultiImage.h" -#include "arm_compute/core/MultiImageInfo.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLTensor.h" - -#include - -namespace arm_compute -{ -class ICLTensor; -using ICLImage = ICLTensor; - -/** Basic implementation of the CL multi-planar image interface */ -class CLMultiImage : public ICLMultiImage -{ -public: - /** Constructor */ - CLMultiImage(); - /** Init the multi-planar image - * - * @param[in] width Width of the whole image - * @param[in] height Heigth of the whole image - * @param[in] format Format of the whole image - */ - void init(unsigned int width, unsigned int height, Format format); - /** Init the multi-planar image - * - * @note Uses conservative padding strategy which fits all kernels. - * - * @param[in] width Width of the whole image - * @param[in] height Height of the whole image - * @param[in] format Format of the whole image - */ - void init_auto_padding(unsigned int width, unsigned int height, Format format); - /** Allocated a previously initialised multi image - * - * @note The multi image must not already be allocated when calling this function. - * - **/ - void allocate(); - - // Inherited methods overridden: - const MultiImageInfo *info() const override; - CLImage *cl_plane(unsigned int index) override; - const CLImage *cl_plane(unsigned int index) const override; - -private: - /** Init the multi-planar image - * - * @param[in] width Width of the whole image - * @param[in] height Height of the whole image - * @param[in] format Format of the whole image - * @param[in] auto_padding Specifies whether the image uses auto padding - */ - void internal_init(unsigned int width, unsigned int height, Format format, bool auto_padding); - - MultiImageInfo _info; /** Instance of the multi-planar image's meta data */ - std::array _plane; /* Instance CLImage to hold the planar's information */ -}; -} -#endif /*ARM_COMPUTE_CLMULTIIMAGE_H */ diff --git a/arm_compute/runtime/CL/CLPyramid.h b/arm_compute/runtime/CL/CLPyramid.h deleted file mode 100644 index 573b0fd182..0000000000 --- a/arm_compute/runtime/CL/CLPyramid.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2016-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_CLPYRAMID_H -#define ARM_COMPUTE_CLPYRAMID_H - -#include "arm_compute/core/IPyramid.h" -#include "arm_compute/core/PyramidInfo.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLTensor.h" - -#include -#include - -namespace arm_compute -{ -class CLTensor; - -/** Basic implementation of the OpenCL pyramid interface */ -class CLPyramid : public IPyramid -{ -public: - /** Default constructor */ - CLPyramid(); - /** Initialize pyramid data-object using the given Pyramid's metadata - * - * @param[in] info Pyramid's metadata - */ - void init(const PyramidInfo &info); - - /** Initialize pyramid data-object using the given Pyramid's metadata - * - * @note Uses conservative padding strategy which fits all kernels. - * - * @param[in] info Pyramid's metadata - */ - void init_auto_padding(const PyramidInfo &info); - - /** Allocate the planes in the pyramid - * - * @note The pyramid must not already be allocated when calling this function. - * - **/ - void allocate(); - - // Inherited method overridden - const PyramidInfo *info() const override; - CLTensor *get_pyramid_level(size_t index) const override; - -private: - /** Initialize pyramid data-object using the given Pyramid's metadata - * - * @param[in] info Pyramid's metadata - * @param[in] auto_padding Specifies whether the image in the pyramid use auto padding - */ - void internal_init(const PyramidInfo &info, bool auto_padding); - - PyramidInfo _info; - mutable std::vector _pyramid; -}; -} -#endif /*ARM_COMPUTE_CLPYRAMID_H */ diff --git a/arm_compute/runtime/CL/functions/CLROIPoolingLayer.h b/arm_compute/runtime/CL/functions/CLROIPoolingLayer.h index 836575ef68..fded3006ad 100644 --- a/arm_compute/runtime/CL/functions/CLROIPoolingLayer.h +++ b/arm_compute/runtime/CL/functions/CLROIPoolingLayer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2020 Arm Limited. + * Copyright (c) 2017-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -24,7 +24,6 @@ #ifndef ARM_COMPUTE_CLROIPOOLINGLAYER_H #define ARM_COMPUTE_CLROIPOOLINGLAYER_H -#include "arm_compute/core/CL/ICLArray.h" #include "arm_compute/runtime/CL/ICLSimpleFunction.h" namespace arm_compute diff --git a/arm_compute/runtime/Distribution1D.h b/arm_compute/runtime/Distribution1D.h deleted file mode 100644 index 5f98f8fc3c..0000000000 --- a/arm_compute/runtime/Distribution1D.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2016-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_DISTRIBUTION1D_H -#define ARM_COMPUTE_DISTRIBUTION1D_H - -#include "arm_compute/core/IDistribution1D.h" - -#include -#include -#include -#include - -namespace arm_compute -{ -/** Basic implementation of the 1D distribution interface */ -class Distribution1D : public IDistribution1D -{ -public: - /** Constructor: Creates a 1D Distribution of a consecutive interval [offset, offset + range - 1] - * defined by a start offset and valid range, divided equally into num_bins parts. - * - * @param[in] num_bins The number of bins the distribution is divided in. - * @param[in] offset The start of the values to use. - * @param[in] range The total number of the consecutive values of the distribution interval. - */ - Distribution1D(size_t num_bins, int32_t offset, uint32_t range); - - // Inherited methods overridden: - uint32_t *buffer() const override; - -private: - mutable std::vector _data; /**< The distribution data. */ -}; -} -#endif /* ARM_COMPUTE_DISTRIBUTION1D_H */ diff --git a/arm_compute/runtime/HOG.h b/arm_compute/runtime/HOG.h deleted file mode 100644 index 5aa724c31e..0000000000 --- a/arm_compute/runtime/HOG.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2016-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_HOG_H -#define ARM_COMPUTE_HOG_H - -#include "arm_compute/core/HOGInfo.h" -#include "arm_compute/core/IHOG.h" -#include "arm_compute/core/Types.h" - -#include - -namespace arm_compute -{ -/** CPU implementation of HOG data-object */ -class HOG : public IHOG -{ -public: - /** Default constructor */ - HOG(); - /** Allocate the HOG descriptor using the given HOG's metadata - * - * @param[in] input HOG's metadata used to allocate the HOG descriptor - */ - void init(const HOGInfo &input); - - // Inherited method overridden: - const HOGInfo *info() const override; - float *descriptor() const override; - -private: - HOGInfo _info; - mutable std::vector _descriptor; -}; -} -#endif /* ARM_COMPUTE_HOG_H */ diff --git a/arm_compute/runtime/ILutAllocator.h b/arm_compute/runtime/ILutAllocator.h deleted file mode 100644 index 227e8221df..0000000000 --- a/arm_compute/runtime/ILutAllocator.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2016-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_ILUTALLOCATOR_H -#define ARM_COMPUTE_ILUTALLOCATOR_H - -#include "arm_compute/core/Types.h" - -#include -#include - -namespace arm_compute -{ -/** Basic interface to allocate LUTs' */ -class ILutAllocator -{ -public: - /** Default constructor */ - ILutAllocator(); - /** Default virtual destructor */ - virtual ~ILutAllocator() = default; - /** Allow instances of this class to be move constructed */ - ILutAllocator(ILutAllocator &&) = default; - /** Allow instances of this class to be moved */ - ILutAllocator &operator=(ILutAllocator &&) = default; - /** Allocate an LUT of the requested number of elements and data_type. - * - * @param[in] num_elements Number of elements of the LUT. - * @param[in] data_type Data type of each element. - */ - void init(size_t num_elements, DataType data_type); - /** Returns the total number of elements in the LUT. - * - * @return Total number of elements. - */ - size_t num_elements() const; - /** Returns the type of the LUT. - * - * @return The type of the LUT. - */ - DataType type() const; - /** Returns the total size in bytes of the LUT. - * - * @return Total size of the LUT in bytes. - */ - size_t size() const; - -protected: - /** Interface to be implemented by the child class to allocate the LUT. */ - virtual void allocate() = 0; - /** Interface to be implemented by the child class to lock the memory allocation for the CPU to access. - * - * @return Pointer to a CPU mapping of the memory - */ - virtual uint8_t *lock() = 0; - /** Interface to be implemented by the child class to unlock the memory allocation after the CPU is done accessing it. */ - virtual void unlock() = 0; - -private: - size_t _num_elements; /**< Number of elements allocated */ - DataType _data_type; /**< Data type of LUT elements. */ -}; -} -#endif /* ARM_COMPUTE_ILUTALLOCATOR_H */ diff --git a/arm_compute/runtime/Lut.h b/arm_compute/runtime/Lut.h deleted file mode 100644 index af18680801..0000000000 --- a/arm_compute/runtime/Lut.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2016-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_LUT_H -#define ARM_COMPUTE_LUT_H - -#include "arm_compute/core/ILut.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/LutAllocator.h" - -#include -#include - -namespace arm_compute -{ -class ILutAllocator; - -/** Basic implementation of the LUT interface */ -class Lut : public ILut -{ -public: - /** Constructor */ - Lut(); - /** Constructor: initializes a LUT which can contain num_values values of data_type type. - * - * @param[in] num_elements Number of elements of the LUT. - * @param[in] data_type Data type of each element. - */ - Lut(size_t num_elements, DataType data_type); - /** Return a pointer to the lut's allocator - * - * @return A pointer to the lut's allocator - */ - ILutAllocator *allocator(); - - // Inherited methods overridden: - size_t num_elements() const override; - uint32_t index_offset() const override; - size_t size_in_bytes() const override; - DataType type() const override; - uint8_t *buffer() const override; - void clear() override; - -private: - LutAllocator _allocator; /**< Instance of the basic CPU allocator.*/ -}; -} -#endif /* ARM_COMPUTE_LUT_H */ diff --git a/arm_compute/runtime/LutAllocator.h b/arm_compute/runtime/LutAllocator.h deleted file mode 100644 index 3be863558f..0000000000 --- a/arm_compute/runtime/LutAllocator.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2016-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_LUTALLOCATOR_H -#define ARM_COMPUTE_LUTALLOCATOR_H - -#include "arm_compute/runtime/ILutAllocator.h" - -#include -#include - -namespace arm_compute -{ -/** Basic implementation of a CPU memory LUT allocator. */ -class LutAllocator : public ILutAllocator -{ -public: - /** Default constructor. */ - LutAllocator(); - /** Interface to be implemented by the child class to return the pointer to the allocate data. - * - * @return a pointer to the data. - */ - uint8_t *data() const; - -protected: - /** Allocate num_elements() * sizeof(type()) of CPU memory. */ - void allocate() override; - /** No-op for CPU memory - * - * @return A pointer to the beginning of the look up table's allocation. - */ - uint8_t *lock() override; - /** No-op for CPU memory. */ - void unlock() override; - -private: - mutable std::vector _buffer; /**< CPU memory allocation. */ -}; -} -#endif /* ARM_COMPUTE_LUTALLOCATOR_H */ diff --git a/arm_compute/runtime/MultiHOG.h b/arm_compute/runtime/MultiHOG.h deleted file mode 100644 index ca946191ad..0000000000 --- a/arm_compute/runtime/MultiHOG.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2016-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_MULTIHOG_H -#define ARM_COMPUTE_MULTIHOG_H - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/IMultiHOG.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/HOG.h" - -#include - -namespace arm_compute -{ -/** CPU implementation of multi HOG data-object */ -class MultiHOG : public IMultiHOG -{ -public: - /** Constructor - * - * @param[in] num_models Number of HOG data objects to contain - * - */ - MultiHOG(size_t num_models); - - // Inherited methods overridden: - size_t num_models() const override; - IHOG *model(size_t index) override; - const IHOG *model(size_t index) const override; - -private: - size_t _num_models; - std::vector _model; -}; -} - -#endif /* ARM_COMPUTE_MULTIHOG_H */ diff --git a/arm_compute/runtime/MultiImage.h b/arm_compute/runtime/MultiImage.h deleted file mode 100644 index 0be91ada7c..0000000000 --- a/arm_compute/runtime/MultiImage.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2016-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_MULTIIMAGE_H -#define ARM_COMPUTE_MULTIIMAGE_H - -#include "arm_compute/core/IMultiImage.h" -#include "arm_compute/core/MultiImageInfo.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Tensor.h" - -#include - -namespace arm_compute -{ -class Coordinates; -class ITensor; -using IImage = ITensor; - -/** Basic implementation of the multi-planar image interface */ -class MultiImage : public IMultiImage -{ -public: - /** Constructor */ - MultiImage(); - /** Allocate the multi-planar image - * - * @param[in] width Width of the whole image - * @param[in] height Height of the whole image - * @param[in] format Format of the whole image - */ - void init(unsigned int width, unsigned int height, Format format); - /** Allocate the multi-planar image - * - * @note Uses conservative padding strategy which fits all kernels. - * - * @param[in] width Width of the whole image - * @param[in] height Height of the whole image - * @param[in] format Format of the whole image - */ - void init_auto_padding(unsigned int width, unsigned int height, Format format); - /** Allocated a previously initialised multi image - * - * @note The multi image must not already be allocated when calling this function. - * - **/ - void allocate(); - /** Create a subimage from an existing MultiImage. - * - * @param[in] image Image to use backing memory from - * @param[in] coords Starting coordinates of the new image. Should be within the parent image sizes - * @param[in] width The width of the subimage - * @param[in] height The height of the subimage - */ - void create_subimage(MultiImage *image, const Coordinates &coords, unsigned int width, unsigned int height); - - // Inherited methods overridden: - const MultiImageInfo *info() const override; - Image *plane(unsigned int index) override; - const Image *plane(unsigned int index) const override; - -private: - /** Init the multi-planar image - * - * @param[in] width Width of the whole image - * @param[in] height Height of the whole image - * @param[in] format Format of the whole image - * @param[in] auto_padding Specifies whether the image uses auto padding - */ - void internal_init(unsigned int width, unsigned int height, Format format, bool auto_padding); - - MultiImageInfo _info; /** Instance of the multi-planar image's meta data */ - std::array _plane; /* Instance Image to hold the planar's information */ -}; -} -#endif /*ARM_COMPUTE_MULTIIMAGE_H */ diff --git a/arm_compute/runtime/Pyramid.h b/arm_compute/runtime/Pyramid.h deleted file mode 100644 index 6e6fecaede..0000000000 --- a/arm_compute/runtime/Pyramid.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2016-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_PYRAMID_H -#define ARM_COMPUTE_PYRAMID_H - -#include "arm_compute/core/IPyramid.h" -#include "arm_compute/core/PyramidInfo.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Tensor.h" - -#include -#include - -namespace arm_compute -{ -class Tensor; - -/** Basic implementation of the pyramid interface */ -class Pyramid : public IPyramid -{ -public: - /** Initialize pyramid data-object using the given Pyramid's metadata - * - * @param[in] info Pyramid's metadata - */ - void init(const PyramidInfo &info); - - /** Initialize pyramid data-object using the given Pyramid's metadata - * - * @note Uses conservative padding strategy which fits all kernels. - * - * @param[in] info Pyramid's metadata - */ - void init_auto_padding(const PyramidInfo &info); - - /** Allocate the planes in the pyramid */ - void allocate(); - - // Inherited method overridden - const PyramidInfo *info() const override; - Tensor *get_pyramid_level(size_t index) const override; - -private: - /** Initialize pyramid data-object using the given Pyramid's metadata - * - * @param[in] info Pyramid's metadata - * @param[in] auto_padding Specifies whether the image in the pyramid use auto padding - */ - void internal_init(const PyramidInfo &info, bool auto_padding); - - PyramidInfo _info{}; - mutable std::vector _pyramid{}; -}; -} -#endif /*ARM_COMPUTE_PYRAMID_H */ diff --git a/arm_compute/runtime/common/LSTMParams.h b/arm_compute/runtime/common/LSTMParams.h index ffb4ddd9d3..aedb9c0d46 100644 --- a/arm_compute/runtime/common/LSTMParams.h +++ b/arm_compute/runtime/common/LSTMParams.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020 Arm Limited. + * Copyright (c) 2018-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -24,8 +24,6 @@ #ifndef ARM_COMPUTE_LSTMPARAMS_H #define ARM_COMPUTE_LSTMPARAMS_H -#include "arm_compute/core/IPyramid.h" -#include "arm_compute/core/PyramidInfo.h" #include "arm_compute/core/Types.h" #include "arm_compute/runtime/Tensor.h" diff --git a/docs/00_introduction.dox b/docs/00_introduction.dox index b5bf34644a..e199ee9d6f 100644 --- a/docs/00_introduction.dox +++ b/docs/00_introduction.dox @@ -567,7 +567,7 @@ v20.08 Public major release - NEDepthConcatenateLayerKernel - @ref NENormalizationLayerKernel - @ref NEL2NormalizeLayerKernel - - @ref NEFillArrayKernel + - NEFillArrayKernel - @ref NEDepthConvertLayerKernel - @ref NERangeKernel - @ref NEPriorBoxLayer @@ -1334,7 +1334,7 @@ v17.06 Public major release - CLLocallyConnectedMatrixMultiplyKernel / CLLocallyConnectedLayer - @ref CLWeightsReshapeKernel / @ref CLConvolutionLayerReshapeWeights - New C++ kernels: - - @ref CPPDetectionWindowNonMaximaSuppressionKernel + - CPPDetectionWindowNonMaximaSuppressionKernel - New Neon kernels / functions: - @ref NEBatchNormalizationLayerKernel / @ref NEBatchNormalizationLayer - NEDepthConcatenateLayerKernel / NEDepthConcatenateLayer @@ -1359,7 +1359,7 @@ v17.04 Public bug fixes release - CLGaussianPyramidVertKernel - CLGradientKernel - NEChannelCombineKernel - - @ref NEFillArrayKernel + - NEFillArrayKernel - NEGaussianPyramidHorKernel - NEGaussianPyramidVertKernel - NEHarrisScoreFP16Kernel @@ -1391,7 +1391,7 @@ v17.03 Sources preview - GEMM refactoring + FP16 support: CLGEMMInterleave4x4Kernel, CLGEMMTranspose1xWKernel, @ref CLGEMMMatrixMultiplyKernel, CLGEMMMatrixAdditionKernel / @ref CLGEMM - CLGEMMMatrixAccumulateBiasesKernel / @ref CLFullyConnectedLayer - CLTransposeKernel / @ref CLTranspose - - @ref CLLKTrackerInitKernel, @ref CLLKTrackerStage0Kernel, @ref CLLKTrackerStage1Kernel, @ref CLLKTrackerFinalizeKernel / CLOpticalFlow + - CLLKTrackerInitKernel, CLLKTrackerStage0Kernel, CLLKTrackerStage1Kernel, CLLKTrackerFinalizeKernel / CLOpticalFlow - @ref CLNormalizationLayerKernel / @ref CLNormalizationLayer - CLLaplacianPyramid, CLLaplacianReconstruct - New Neon kernels / functions: diff --git a/src/core/CL/CLKernels.h b/src/core/CL/CLKernels.h index d81b60b663..9676fa6018 100644 --- a/src/core/CL/CLKernels.h +++ b/src/core/CL/CLKernels.h @@ -67,7 +67,6 @@ #include "src/core/CL/kernels/CLIm2ColKernel.h" #include "src/core/CL/kernels/CLInstanceNormalizationLayerKernel.h" #include "src/core/CL/kernels/CLL2NormalizeLayerKernel.h" -#include "src/core/CL/kernels/CLLKTrackerKernel.h" #include "src/core/CL/kernels/CLMaxUnpoolingLayerKernel.h" #include "src/core/CL/kernels/CLMeanStdDevNormalizationKernel.h" #include "src/core/CL/kernels/CLMinMaxLayerKernel.h" diff --git a/src/core/CL/CLTracePoint.cpp b/src/core/CL/CLTracePoint.cpp index c3d4899740..c76eee74ad 100644 --- a/src/core/CL/CLTracePoint.cpp +++ b/src/core/CL/CLTracePoint.cpp @@ -23,13 +23,6 @@ */ #include "arm_compute/core/TracePoint.h" -#include "arm_compute/core/CL/CLTypes.h" -#include "arm_compute/core/CL/ICLArray.h" -#include "arm_compute/core/CL/ICLDistribution1D.h" -#include "arm_compute/core/CL/ICLHOG.h" -#include "arm_compute/core/CL/ICLLut.h" -#include "arm_compute/core/CL/ICLMultiHOG.h" -#include "arm_compute/core/CL/ICLMultiImage.h" #include "arm_compute/core/CL/ICLTensor.h" #include "utils/TypePrinter.h" @@ -52,34 +45,16 @@ TracePoint::Args &&operator<<(TracePoint::Args &&tp, const ICLTensor *arg) } ARM_COMPUTE_TRACE_TO_STRING(std::vector) -ARM_COMPUTE_TRACE_TO_STRING(ICLMultiImage) -ARM_COMPUTE_TRACE_TO_STRING(ICLDetectionWindowArray) -ARM_COMPUTE_TRACE_TO_STRING(ICLKeyPointArray) ARM_COMPUTE_TRACE_TO_STRING(ICLLKInternalKeypointArray) ARM_COMPUTE_TRACE_TO_STRING(ICLCoefficientTableArray) -ARM_COMPUTE_TRACE_TO_STRING(ICLCoordinates2DArray) ARM_COMPUTE_TRACE_TO_STRING(ICLOldValArray) ARM_COMPUTE_TRACE_TO_STRING(cl::Buffer) -ARM_COMPUTE_TRACE_TO_STRING(ICLDistribution1D) -ARM_COMPUTE_TRACE_TO_STRING(ICLMultiHOG) -ARM_COMPUTE_TRACE_TO_STRING(ICLHOG) -ARM_COMPUTE_TRACE_TO_STRING(ICLLut) -ARM_COMPUTE_TRACE_TO_STRING(ICLSize2DArray) ARM_COMPUTE_TRACE_TO_STRING(std::vector) ARM_COMPUTE_CONST_PTR_CLASS(std::vector) -ARM_COMPUTE_CONST_PTR_CLASS(ICLMultiImage) -ARM_COMPUTE_CONST_PTR_CLASS(ICLDetectionWindowArray) -ARM_COMPUTE_CONST_PTR_CLASS(ICLKeyPointArray) ARM_COMPUTE_CONST_PTR_CLASS(ICLLKInternalKeypointArray) ARM_COMPUTE_CONST_PTR_CLASS(ICLCoefficientTableArray) -ARM_COMPUTE_CONST_PTR_CLASS(ICLCoordinates2DArray) ARM_COMPUTE_CONST_PTR_CLASS(ICLOldValArray) ARM_COMPUTE_CONST_PTR_CLASS(cl::Buffer) -ARM_COMPUTE_CONST_PTR_CLASS(ICLDistribution1D) -ARM_COMPUTE_CONST_PTR_CLASS(ICLMultiHOG) -ARM_COMPUTE_CONST_PTR_CLASS(ICLHOG) -ARM_COMPUTE_CONST_PTR_CLASS(ICLLut) -ARM_COMPUTE_CONST_PTR_CLASS(ICLSize2DArray) ARM_COMPUTE_CONST_PTR_CLASS(std::vector) } // namespace arm_compute diff --git a/src/core/CL/ICLDistribution1D.cpp b/src/core/CL/ICLDistribution1D.cpp deleted file mode 100644 index d185f1365f..0000000000 --- a/src/core/CL/ICLDistribution1D.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2016, 2017 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/CL/ICLDistribution1D.h" - -#include "arm_compute/core/Error.h" - -using namespace arm_compute; - -ICLDistribution1D::ICLDistribution1D(size_t num_bins, int32_t offset, uint32_t range) - : IDistribution1D(num_bins, offset, range), _mapping(nullptr) -{ -} - -void ICLDistribution1D::map(cl::CommandQueue &q, bool blocking) -{ - ARM_COMPUTE_ERROR_ON(_mapping != nullptr); - _mapping = do_map(q, blocking); -} - -void ICLDistribution1D::unmap(cl::CommandQueue &q) -{ - ARM_COMPUTE_ERROR_ON(_mapping == nullptr); - do_unmap(q); - _mapping = nullptr; -} - -uint32_t *ICLDistribution1D::buffer() const -{ - return _mapping; -} diff --git a/src/core/CL/ICLHOG.cpp b/src/core/CL/ICLHOG.cpp deleted file mode 100644 index aaabe869b6..0000000000 --- a/src/core/CL/ICLHOG.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2017 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/CL/ICLHOG.h" - -using namespace arm_compute; - -ICLHOG::ICLHOG() - : _mapping(nullptr) -{ -} - -void ICLHOG::map(cl::CommandQueue &q, bool blocking) -{ - _mapping = do_map(q, blocking); -} - -void ICLHOG::unmap(cl::CommandQueue &q) -{ - do_unmap(q); - _mapping = nullptr; -} - -float *ICLHOG::descriptor() const -{ - return reinterpret_cast(_mapping); -} \ No newline at end of file diff --git a/src/core/CL/ICLLut.cpp b/src/core/CL/ICLLut.cpp deleted file mode 100644 index 007a5240f2..0000000000 --- a/src/core/CL/ICLLut.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2016, 2017 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/CL/ICLLut.h" - -using namespace arm_compute; - -ICLLut::ICLLut() - : _mapping(nullptr) -{ -} - -void ICLLut::map(cl::CommandQueue &q, bool blocking) -{ - _mapping = do_map(q, blocking); -} - -void ICLLut::unmap(cl::CommandQueue &q) -{ - do_unmap(q); - _mapping = nullptr; -} - -uint8_t *ICLLut::buffer() const -{ - return _mapping; -} diff --git a/src/core/CL/ICLMultiHOG.cpp b/src/core/CL/ICLMultiHOG.cpp deleted file mode 100644 index 73bee39883..0000000000 --- a/src/core/CL/ICLMultiHOG.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2017 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/CL/ICLMultiHOG.h" - -#include "arm_compute/core/IHOG.h" - -using namespace arm_compute; - -IHOG *ICLMultiHOG::model(size_t index) -{ - return cl_model(index); -} - -const IHOG *ICLMultiHOG::model(size_t index) const -{ - return cl_model(index); -} \ No newline at end of file diff --git a/src/core/CL/ICLMultiImage.cpp b/src/core/CL/ICLMultiImage.cpp deleted file mode 100644 index 01b05fc036..0000000000 --- a/src/core/CL/ICLMultiImage.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2016, 2017 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/CL/ICLMultiImage.h" - -#include "arm_compute/core/CL/ICLTensor.h" -#include "arm_compute/core/ITensor.h" - -using namespace arm_compute; - -IImage *ICLMultiImage::plane(unsigned int index) -{ - return cl_plane(index); -} - -const IImage *ICLMultiImage::plane(unsigned int index) const -{ - return cl_plane(index); -} diff --git a/src/core/CL/kernels/CLBoundingBoxTransformKernel.cpp b/src/core/CL/kernels/CLBoundingBoxTransformKernel.cpp index 2c12275e57..4c20d934dd 100644 --- a/src/core/CL/kernels/CLBoundingBoxTransformKernel.cpp +++ b/src/core/CL/kernels/CLBoundingBoxTransformKernel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020 Arm Limited. + * Copyright (c) 2018-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -25,7 +25,6 @@ #include "arm_compute/core/CL/CLHelpers.h" #include "arm_compute/core/CL/CLKernelLibrary.h" -#include "arm_compute/core/CL/ICLArray.h" #include "arm_compute/core/CL/ICLTensor.h" #include "arm_compute/core/CL/OpenCL.h" #include "arm_compute/core/Helpers.h" diff --git a/src/core/CL/kernels/CLGenerateProposalsLayerKernel.cpp b/src/core/CL/kernels/CLGenerateProposalsLayerKernel.cpp index 988bb39d88..8c94fb5b47 100644 --- a/src/core/CL/kernels/CLGenerateProposalsLayerKernel.cpp +++ b/src/core/CL/kernels/CLGenerateProposalsLayerKernel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020 Arm Limited. + * Copyright (c) 2019-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -25,7 +25,6 @@ #include "arm_compute/core/CL/CLHelpers.h" #include "arm_compute/core/CL/CLKernelLibrary.h" -#include "arm_compute/core/CL/ICLArray.h" #include "arm_compute/core/CL/ICLTensor.h" #include "arm_compute/core/CL/OpenCL.h" #include "arm_compute/core/Helpers.h" diff --git a/src/core/CL/kernels/CLLKTrackerKernel.cpp b/src/core/CL/kernels/CLLKTrackerKernel.cpp deleted file mode 100644 index a439c2448e..0000000000 --- a/src/core/CL/kernels/CLLKTrackerKernel.cpp +++ /dev/null @@ -1,314 +0,0 @@ -/* - * Copyright (c) 2017-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "src/core/CL/kernels/CLLKTrackerKernel.h" - -#include "arm_compute/core/CL/CLKernelLibrary.h" -#include "arm_compute/core/CL/ICLArray.h" -#include "arm_compute/core/CL/ICLTensor.h" -#include "arm_compute/core/Coordinates.h" -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/TensorInfo.h" -#include "arm_compute/core/Validate.h" -#include "src/core/AccessWindowStatic.h" -#include "src/core/helpers/WindowHelpers.h" - -#include - -using namespace arm_compute; - -void CLLKTrackerInitKernel::configure(const ICLKeyPointArray *old_points, const ICLKeyPointArray *new_points_estimates, - ICLLKInternalKeypointArray *old_points_internal, ICLLKInternalKeypointArray *new_points_internal, - bool use_initial_estimate, size_t level, size_t num_levels, float pyramid_scale) -{ - configure(CLKernelLibrary::get().get_compile_context(), old_points, new_points_estimates, old_points_internal, new_points_internal, use_initial_estimate, level, num_levels, pyramid_scale); -} - -void CLLKTrackerInitKernel::configure(const CLCompileContext &compile_context, const ICLKeyPointArray *old_points, const ICLKeyPointArray *new_points_estimates, - ICLLKInternalKeypointArray *old_points_internal, ICLLKInternalKeypointArray *new_points_internal, - bool use_initial_estimate, size_t level, size_t num_levels, float pyramid_scale) - -{ - ARM_COMPUTE_ERROR_ON(old_points == nullptr); - ARM_COMPUTE_ERROR_ON(old_points_internal == nullptr); - ARM_COMPUTE_ERROR_ON(new_points_internal == nullptr); - - const float scale = std::pow(pyramid_scale, level); - - // Create kernel - std::string kernel_name = "init_level"; - if(level == (num_levels - 1)) - { - kernel_name += (use_initial_estimate) ? std::string("_max_initial_estimate") : std::string("_max"); - } - _kernel = create_kernel(compile_context, kernel_name); - - // Set static kernel arguments - unsigned int idx = 0; - if(level == (num_levels - 1)) - { - _kernel.setArg(idx++, old_points->cl_buffer()); - if(use_initial_estimate) - { - _kernel.setArg(idx++, new_points_estimates->cl_buffer()); - } - } - _kernel.setArg(idx++, old_points_internal->cl_buffer()); - _kernel.setArg(idx++, new_points_internal->cl_buffer()); - _kernel.setArg(idx++, scale); - - // Configure kernel window - Window window; - window.set(Window::DimX, Window::Dimension(0, old_points->num_values(), 1)); - window.set(Window::DimY, Window::Dimension(0, 1, 1)); - ICLKernel::configure_internal(window); -} - -void CLLKTrackerInitKernel::run(const Window &window, cl::CommandQueue &queue) -{ - ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); - ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(ICLKernel::window(), window); - - enqueue(queue, *this, window, lws_hint()); -} - -void CLLKTrackerFinalizeKernel::configure(ICLLKInternalKeypointArray *new_points_internal, ICLKeyPointArray *new_points) -{ - configure(CLKernelLibrary::get().get_compile_context(), new_points_internal, new_points); -} - -void CLLKTrackerFinalizeKernel::configure(const CLCompileContext &compile_context, ICLLKInternalKeypointArray *new_points_internal, ICLKeyPointArray *new_points) - -{ - ARM_COMPUTE_ERROR_ON(new_points_internal == nullptr); - ARM_COMPUTE_ERROR_ON(new_points == nullptr); - - // Create kernel - _kernel = create_kernel(compile_context, "finalize"); - - // Set static kernel arguments - unsigned int idx = 0; - _kernel.setArg(idx++, new_points_internal->cl_buffer()); - _kernel.setArg(idx++, new_points->cl_buffer()); - - // Configure kernel window - Window window; - window.set(Window::DimX, Window::Dimension(0, new_points_internal->num_values(), 1)); - window.set(Window::DimY, Window::Dimension(0, 1, 1)); - ICLKernel::configure_internal(window); -} - -void CLLKTrackerFinalizeKernel::run(const Window &window, cl::CommandQueue &queue) -{ - ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); - ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(ICLKernel::window(), window); - - enqueue(queue, *this, window, lws_hint()); -} - -CLLKTrackerStage0Kernel::CLLKTrackerStage0Kernel() - : _old_input(nullptr), _old_scharr_gx(nullptr), _old_scharr_gy(nullptr) -{ -} - -void CLLKTrackerStage0Kernel::configure(const ICLTensor *old_input, const ICLTensor *old_scharr_gx, const ICLTensor *old_scharr_gy, - ICLLKInternalKeypointArray *old_points_internal, ICLLKInternalKeypointArray *new_points_internal, - ICLCoefficientTableArray *coeff_table, ICLOldValArray *old_ival, - size_t window_dimension, size_t level) -{ - configure(CLKernelLibrary::get().get_compile_context(), old_input, old_scharr_gx, old_scharr_gy, old_points_internal, new_points_internal, coeff_table, old_ival, window_dimension, level); -} - -void CLLKTrackerStage0Kernel::configure(const CLCompileContext &compile_context, const ICLTensor *old_input, const ICLTensor *old_scharr_gx, const ICLTensor *old_scharr_gy, - ICLLKInternalKeypointArray *old_points_internal, ICLLKInternalKeypointArray *new_points_internal, - ICLCoefficientTableArray *coeff_table, ICLOldValArray *old_ival, - size_t window_dimension, size_t level) - -{ - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(old_input, 1, DataType::U8); - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(old_scharr_gx, 1, DataType::S16); - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(old_scharr_gy, 1, DataType::S16); - ARM_COMPUTE_ERROR_ON(old_points_internal == nullptr); - ARM_COMPUTE_ERROR_ON(new_points_internal == nullptr); - ARM_COMPUTE_ERROR_ON(coeff_table == nullptr); - ARM_COMPUTE_ERROR_ON(old_ival == nullptr); - - _old_input = old_input; - _old_scharr_gx = old_scharr_gx; - _old_scharr_gy = old_scharr_gy; - - // Configure kernel window - Window window; - window.set(Window::DimX, Window::Dimension(0, new_points_internal->num_values(), 1)); - window.set(Window::DimY, Window::Dimension(0, 1, 1)); - - const ValidRegion valid_region = intersect_valid_regions( - old_input->info()->valid_region(), - old_scharr_gx->info()->valid_region(), - old_scharr_gy->info()->valid_region()); - - update_window_and_padding(window, - AccessWindowStatic(old_input->info(), valid_region.start(0), valid_region.start(1), - valid_region.end(0), valid_region.end(1)), - AccessWindowStatic(old_scharr_gx->info(), valid_region.start(0), valid_region.start(1), - valid_region.end(0), valid_region.end(1)), - AccessWindowStatic(old_scharr_gy->info(), valid_region.start(0), valid_region.start(1), - valid_region.end(0), valid_region.end(1))); - - ICLKernel::configure_internal(window); - - // Initialize required variables - const int level0 = (level == 0) ? 1 : 0; - const int window_size = window_dimension; - const int window_size_squared = window_dimension * window_dimension; - const int window_size_half = window_dimension / 2; - const float eig_const = 1.0f / (2.0f * window_size_squared); - const cl_float3 border_limits = - { - { - // -1 because we load 2 values at once for bilinear interpolation - static_cast(valid_region.end(0) - window_size - 1), - static_cast(valid_region.end(1) - window_size - 1), - static_cast(valid_region.start(0)) - } - }; - - // Create kernel - _kernel = create_kernel(compile_context, "lktracker_stage0"); - - // Set arguments - unsigned int idx = 3 * num_arguments_per_2D_tensor(); - _kernel.setArg(idx++, old_points_internal->cl_buffer()); - _kernel.setArg(idx++, new_points_internal->cl_buffer()); - _kernel.setArg(idx++, coeff_table->cl_buffer()); - _kernel.setArg(idx++, old_ival->cl_buffer()); - _kernel.setArg(idx++, window_size); - _kernel.setArg(idx++, window_size_squared); - _kernel.setArg(idx++, window_size_half); - _kernel.setArg(idx++, border_limits); - _kernel.setArg(idx++, eig_const); - _kernel.setArg(idx++, level0); -} - -void CLLKTrackerStage0Kernel::run(const Window &window, cl::CommandQueue &queue) -{ - ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); - ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(ICLKernel::window(), window); - - // Set static tensor arguments. Setting here as allocation might be deferred. - unsigned int idx = 0; - add_2D_tensor_argument(idx, _old_input, window); - add_2D_tensor_argument(idx, _old_scharr_gx, window); - add_2D_tensor_argument(idx, _old_scharr_gy, window); - - enqueue(queue, *this, window, lws_hint()); -} - -CLLKTrackerStage1Kernel::CLLKTrackerStage1Kernel() - : _new_input(nullptr) -{ -} - -void CLLKTrackerStage1Kernel::configure(const ICLTensor *new_input, ICLLKInternalKeypointArray *new_points_internal, ICLCoefficientTableArray *coeff_table, ICLOldValArray *old_ival, - Termination termination, float epsilon, size_t num_iterations, size_t window_dimension, size_t level) -{ - configure(CLKernelLibrary::get().get_compile_context(), new_input, new_points_internal, coeff_table, old_ival, termination, epsilon, num_iterations, window_dimension, level); -} - -void CLLKTrackerStage1Kernel::configure(const CLCompileContext &compile_context, const ICLTensor *new_input, ICLLKInternalKeypointArray *new_points_internal, ICLCoefficientTableArray *coeff_table, - ICLOldValArray *old_ival, - Termination termination, float epsilon, size_t num_iterations, size_t window_dimension, size_t level) - -{ - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(new_input, 1, DataType::U8); - ARM_COMPUTE_ERROR_ON(new_points_internal == nullptr); - ARM_COMPUTE_ERROR_ON(coeff_table == nullptr); - ARM_COMPUTE_ERROR_ON(old_ival == nullptr); - - _new_input = new_input; - - // Configure kernel window - Window window; - window.set(Window::DimX, Window::Dimension(0, new_points_internal->num_values(), 1)); - window.set(Window::DimY, Window::Dimension(0, 1, 1)); - - const ValidRegion &valid_region = new_input->info()->valid_region(); - - update_window_and_padding(window, - AccessWindowStatic(new_input->info(), valid_region.start(0), valid_region.start(1), - valid_region.end(0), valid_region.end(1))); - - ICLKernel::configure_internal(window); - - // Initialize required variables - const int level0 = (level == 0) ? 1 : 0; - const int window_size = window_dimension; - const int window_size_squared = window_dimension * window_dimension; - const int window_size_half = window_dimension / 2; - const float eig_const = 1.0f / (2.0f * window_size_squared); - const cl_float3 border_limits = - { - { - // -1 because we load 2 values at once for bilinear interpolation - static_cast(valid_region.end(0) - window_size - 1), - static_cast(valid_region.end(1) - window_size - 1), - static_cast(valid_region.start(0)) - } - }; - - // Set maximum number of iterations used for convergence - const size_t max_iterations = 1000; - num_iterations = (termination == Termination::TERM_CRITERIA_EPSILON) ? max_iterations : num_iterations; - - const int term_epsilon = (termination == Termination::TERM_CRITERIA_EPSILON || termination == Termination::TERM_CRITERIA_BOTH) ? 1 : 0; - - // Create kernel - _kernel = create_kernel(compile_context, "lktracker_stage1"); - - // Set static kernel arguments - unsigned int idx = num_arguments_per_2D_tensor(); - _kernel.setArg(idx++, new_points_internal->cl_buffer()); - _kernel.setArg(idx++, coeff_table->cl_buffer()); - _kernel.setArg(idx++, old_ival->cl_buffer()); - _kernel.setArg(idx++, window_size); - _kernel.setArg(idx++, window_size_squared); - _kernel.setArg(idx++, window_size_half); - _kernel.setArg(idx++, num_iterations); - _kernel.setArg(idx++, epsilon); - _kernel.setArg(idx++, border_limits); - _kernel.setArg(idx++, eig_const); - _kernel.setArg(idx++, level0); - _kernel.setArg(idx++, term_epsilon); -} - -void CLLKTrackerStage1Kernel::run(const Window &window, cl::CommandQueue &queue) -{ - ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); - ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(ICLKernel::window(), window); - - // Set static tensor arguments. Setting here as allocation might be deferred. - unsigned int idx = 0; - add_2D_tensor_argument(idx, _new_input, window); - - enqueue(queue, *this, window, lws_hint()); -} diff --git a/src/core/CL/kernels/CLLKTrackerKernel.h b/src/core/CL/kernels/CLLKTrackerKernel.h deleted file mode 100644 index 2d2966854a..0000000000 --- a/src/core/CL/kernels/CLLKTrackerKernel.h +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Copyright (c) 2017-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_CLLKTRACKERKERNEL_H -#define ARM_COMPUTE_CLLKTRACKERKERNEL_H - -#include "arm_compute/core/CL/ICLArray.h" -#include "arm_compute/core/Types.h" -#include "src/core/CL/ICLKernel.h" - -#include -#include - -namespace arm_compute -{ -class ICLTensor; - -/** Interface to run the initialization step of LKTracker */ -class CLLKTrackerInitKernel : public ICLKernel -{ -public: - /** Initialise the kernel input and output - * - * @param[in] old_points Pointer to the @ref ICLKeyPointArray storing old key points - * @param[in] new_points_estimates Pointer to the @ref ICLKeyPointArray storing new estimates key points - * @param[out] old_points_internal Pointer to the array of internal @ref CLLKInternalKeypoint old points - * @param[out] new_points_internal Pointer to the array of internal @ref CLLKInternalKeypoint new points - * @param[in] use_initial_estimate The flag to indicate whether the initial estimated position should be used - * @param[in] level The pyramid level - * @param[in] num_levels The number of pyramid levels - * @param[in] pyramid_scale Scale factor used for generating the pyramid - */ - void configure(const ICLKeyPointArray *old_points, const ICLKeyPointArray *new_points_estimates, - ICLLKInternalKeypointArray *old_points_internal, ICLLKInternalKeypointArray *new_points_internal, - bool use_initial_estimate, size_t level, size_t num_levels, float pyramid_scale); - /** Initialise the kernel input and output - * - * @param[in] compile_context The compile context to be used. - * @param[in] old_points Pointer to the @ref ICLKeyPointArray storing old key points - * @param[in] new_points_estimates Pointer to the @ref ICLKeyPointArray storing new estimates key points - * @param[out] old_points_internal Pointer to the array of internal @ref CLLKInternalKeypoint old points - * @param[out] new_points_internal Pointer to the array of internal @ref CLLKInternalKeypoint new points - * @param[in] use_initial_estimate The flag to indicate whether the initial estimated position should be used - * @param[in] level The pyramid level - * @param[in] num_levels The number of pyramid levels - * @param[in] pyramid_scale Scale factor used for generating the pyramid - */ - void configure(const CLCompileContext &compile_context, const ICLKeyPointArray *old_points, const ICLKeyPointArray *new_points_estimates, - ICLLKInternalKeypointArray *old_points_internal, ICLLKInternalKeypointArray *new_points_internal, - bool use_initial_estimate, size_t level, size_t num_levels, float pyramid_scale); - - // Inherited methods overridden: - void run(const Window &window, cl::CommandQueue &queue) override; -}; - -/** Interface to run the finalize step of LKTracker, where it truncates the coordinates stored in new_points array */ -class CLLKTrackerFinalizeKernel : public ICLKernel -{ -public: - /** Initialise the kernel input and output - * - * @param[in] new_points_internal Pointer to the array of internal @ref CLLKInternalKeypoint new points - * @param[out] new_points Pointer to the @ref ICLKeyPointArray storing new key points - */ - void configure(ICLLKInternalKeypointArray *new_points_internal, ICLKeyPointArray *new_points); - /** Initialise the kernel input and output - * - * @param[in] compile_context The compile context to be used. - * @param[in] new_points_internal Pointer to the array of internal @ref CLLKInternalKeypoint new points - * @param[out] new_points Pointer to the @ref ICLKeyPointArray storing new key points - */ - void configure(const CLCompileContext &compile_context, ICLLKInternalKeypointArray *new_points_internal, ICLKeyPointArray *new_points); - - // Inherited methods overridden: - void run(const Window &window, cl::CommandQueue &queue) override; -}; - -/** Interface to run the first stage of LKTracker, where A11, A12, A22, min_eig, ival, ixval and iyval are computed */ -class CLLKTrackerStage0Kernel : public ICLKernel -{ -public: - /** Default constructor */ - CLLKTrackerStage0Kernel(); - /** Prevent instances of this class from being copied (As this class contains pointers) */ - CLLKTrackerStage0Kernel(const CLLKTrackerStage0Kernel &) = delete; - /** Prevent instances of this class from being copied (As this class contains pointers) */ - CLLKTrackerStage0Kernel &operator=(const CLLKTrackerStage0Kernel &) = delete; - /** Allow instances of this class to be moved */ - CLLKTrackerStage0Kernel(CLLKTrackerStage0Kernel &&) = default; - /** Allow instances of this class to be moved */ - CLLKTrackerStage0Kernel &operator=(CLLKTrackerStage0Kernel &&) = default; - /** Initialise the kernel input and output - * - * @param[in] old_input Pointer to the input old tensor. Data types supported: U8 - * @param[in] old_scharr_gx Pointer to the input scharr X tensor. Data types supported: S16 - * @param[in] old_scharr_gy Pointer to the input scharr Y tensor. Data types supported: S16 - * @param[in] old_points_internal Pointer to the array of CLLKInternalKeypoint old points - * @param[in, out] new_points_internal Pointer to the array of CLLKInternalKeypoint new points - * @param[out] coeff_table Pointer to the array holding the Spatial Gradient coefficients - * @param[out] old_ival Pointer to the array holding internal values - * @param[in] window_dimension The size of the window on which to perform the algorithm - * @param[in] level The pyramid level - */ - void configure(const ICLTensor *old_input, const ICLTensor *old_scharr_gx, const ICLTensor *old_scharr_gy, - ICLLKInternalKeypointArray *old_points_internal, ICLLKInternalKeypointArray *new_points_internal, - ICLCoefficientTableArray *coeff_table, ICLOldValArray *old_ival, - size_t window_dimension, size_t level); - /** Initialise the kernel input and output - * - * @param[in] compile_context The compile context to be used. - * @param[in] old_input Pointer to the input old tensor. Data types supported: U8 - * @param[in] old_scharr_gx Pointer to the input scharr X tensor. Data types supported: S16 - * @param[in] old_scharr_gy Pointer to the input scharr Y tensor. Data types supported: S16 - * @param[in] old_points_internal Pointer to the array of CLLKInternalKeypoint old points - * @param[in, out] new_points_internal Pointer to the array of CLLKInternalKeypoint new points - * @param[out] coeff_table Pointer to the array holding the Spatial Gradient coefficients - * @param[out] old_ival Pointer to the array holding internal values - * @param[in] window_dimension The size of the window on which to perform the algorithm - * @param[in] level The pyramid level - */ - void configure(const CLCompileContext &compile_context, const ICLTensor *old_input, const ICLTensor *old_scharr_gx, const ICLTensor *old_scharr_gy, - ICLLKInternalKeypointArray *old_points_internal, ICLLKInternalKeypointArray *new_points_internal, - ICLCoefficientTableArray *coeff_table, ICLOldValArray *old_ival, - size_t window_dimension, size_t level); - - // Inherited methods overridden: - void run(const Window &window, cl::CommandQueue &queue) override; - -private: - const ICLTensor *_old_input; - const ICLTensor *_old_scharr_gx; - const ICLTensor *_old_scharr_gy; -}; - -/** Interface to run the second stage of LKTracker, where the motion vectors of the given points are computed */ -class CLLKTrackerStage1Kernel : public ICLKernel -{ -public: - /** Default constructor */ - CLLKTrackerStage1Kernel(); - /** Prevent instances of this class from being copied (As this class contains pointers) */ - CLLKTrackerStage1Kernel(const CLLKTrackerStage1Kernel &) = delete; - /** Prevent instances of this class from being copied (As this class contains pointers) */ - CLLKTrackerStage1Kernel &operator=(const CLLKTrackerStage1Kernel &) = delete; - /** Allow instances of this class to be moved */ - CLLKTrackerStage1Kernel(CLLKTrackerStage1Kernel &&) = default; - /** Allow instances of this class to be moved */ - CLLKTrackerStage1Kernel &operator=(CLLKTrackerStage1Kernel &&) = default; - /** Initialise the kernel input and output - * - * @param[in] new_input Pointer to the input new tensor. Data types supported: U8 - * @param[in, out] new_points_internal Pointer to the array of CLLKInternalKeypoint for new points - * @param[in] coeff_table Pointer to the array holding the Spatial Gradient coefficients - * @param[in] old_ival Pointer to the array holding internal values - * @param[in] termination The criteria to terminate the search of each keypoint. - * @param[in] epsilon The error for terminating the algorithm - * @param[in] num_iterations The maximum number of iterations before terminating the algorithm - * @param[in] window_dimension The size of the window on which to perform the algorithm - * @param[in] level The pyramid level - */ - void configure(const ICLTensor *new_input, ICLLKInternalKeypointArray *new_points_internal, ICLCoefficientTableArray *coeff_table, ICLOldValArray *old_ival, - Termination termination, float epsilon, size_t num_iterations, size_t window_dimension, size_t level); - /** Initialise the kernel input and output - * - * @param[in] compile_context The compile context to be used. - * @param[in] new_input Pointer to the input new tensor. Data types supported: U8 - * @param[in, out] new_points_internal Pointer to the array of CLLKInternalKeypoint for new points - * @param[in] coeff_table Pointer to the array holding the Spatial Gradient coefficients - * @param[in] old_ival Pointer to the array holding internal values - * @param[in] termination The criteria to terminate the search of each keypoint. - * @param[in] epsilon The error for terminating the algorithm - * @param[in] num_iterations The maximum number of iterations before terminating the algorithm - * @param[in] window_dimension The size of the window on which to perform the algorithm - * @param[in] level The pyramid level - */ - void configure(const CLCompileContext &compile_context, const ICLTensor *new_input, ICLLKInternalKeypointArray *new_points_internal, ICLCoefficientTableArray *coeff_table, ICLOldValArray *old_ival, - Termination termination, float epsilon, size_t num_iterations, size_t window_dimension, size_t level); - - // Inherited methods overridden: - void run(const Window &window, cl::CommandQueue &queue) override; - -private: - const ICLTensor *_new_input; -}; -} // namespace arm_compute -#endif /*ARM_COMPUTE_CLLKTRACKERKERNEL_H */ diff --git a/src/core/CL/kernels/CLROIAlignLayerKernel.cpp b/src/core/CL/kernels/CLROIAlignLayerKernel.cpp index 87f4a5d7f3..fdaa86ce4a 100644 --- a/src/core/CL/kernels/CLROIAlignLayerKernel.cpp +++ b/src/core/CL/kernels/CLROIAlignLayerKernel.cpp @@ -25,7 +25,6 @@ #include "arm_compute/core/CL/CLHelpers.h" #include "arm_compute/core/CL/CLKernelLibrary.h" -#include "arm_compute/core/CL/ICLArray.h" #include "arm_compute/core/CL/ICLTensor.h" #include "arm_compute/core/CL/OpenCL.h" #include "arm_compute/core/Helpers.h" diff --git a/src/core/CL/kernels/CLROIAlignLayerKernel.h b/src/core/CL/kernels/CLROIAlignLayerKernel.h index cbf0e00165..5284a5913f 100644 --- a/src/core/CL/kernels/CLROIAlignLayerKernel.h +++ b/src/core/CL/kernels/CLROIAlignLayerKernel.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020 Arm Limited. + * Copyright (c) 2018-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -24,9 +24,7 @@ #ifndef ARM_COMPUTE_CLROIALIGNLAYERKERNEL_H #define ARM_COMPUTE_CLROIALIGNLAYERKERNEL_H -#include "arm_compute/core/CL/ICLArray.h" #include "src/core/CL/ICLKernel.h" - namespace arm_compute { class ICLTensor; diff --git a/src/core/CL/kernels/CLROIPoolingLayerKernel.cpp b/src/core/CL/kernels/CLROIPoolingLayerKernel.cpp index 175691a0d2..5867cde3bd 100644 --- a/src/core/CL/kernels/CLROIPoolingLayerKernel.cpp +++ b/src/core/CL/kernels/CLROIPoolingLayerKernel.cpp @@ -25,7 +25,6 @@ #include "arm_compute/core/CL/CLHelpers.h" #include "arm_compute/core/CL/CLKernelLibrary.h" -#include "arm_compute/core/CL/ICLArray.h" #include "arm_compute/core/CL/ICLTensor.h" #include "arm_compute/core/CL/OpenCL.h" #include "arm_compute/core/Helpers.h" diff --git a/src/core/CL/kernels/CLROIPoolingLayerKernel.h b/src/core/CL/kernels/CLROIPoolingLayerKernel.h index 35f42a9676..124ae3f268 100644 --- a/src/core/CL/kernels/CLROIPoolingLayerKernel.h +++ b/src/core/CL/kernels/CLROIPoolingLayerKernel.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2020 Arm Limited. + * Copyright (c) 2017-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -25,9 +25,6 @@ #define ARM_COMPUTE_CLROIPOOLINGLAYERKERNEL_H #include "src/core/CL/ICLKernel.h" - -#include "arm_compute/core/CL/ICLArray.h" - namespace arm_compute { class ICLTensor; diff --git a/src/core/CPP/kernels/CPPCornerCandidatesKernel.cpp b/src/core/CPP/kernels/CPPCornerCandidatesKernel.cpp deleted file mode 100644 index a134e3e5c1..0000000000 --- a/src/core/CPP/kernels/CPPCornerCandidatesKernel.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2017-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/CPP/kernels/CPPCornerCandidatesKernel.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/TensorInfo.h" -#include "src/core/helpers/WindowHelpers.h" - -using namespace arm_compute; - -namespace -{ -inline void check_corner(float x, float y, float strength, InternalKeypoint *output, int32_t *num_corner_candidates, arm_compute::Mutex *corner_candidates_mutex) -{ - if(strength != 0.0f) - { - /* Set index and update num_corner_candidate */ - arm_compute::unique_lock lock(*corner_candidates_mutex); - - const int32_t idx = *num_corner_candidates; - - *num_corner_candidates += 1; - - lock.unlock(); - - /* Add keypoint */ - output[idx] = std::make_tuple(x, y, strength); - } -} - -inline void corner_candidates(const float *__restrict input, InternalKeypoint *__restrict output, int32_t x, int32_t y, int32_t *num_corner_candidates, arm_compute::Mutex *corner_candidates_mutex) -{ - check_corner(x, y, *input, output, num_corner_candidates, corner_candidates_mutex); -} -} // namespace - -bool keypoint_compare(const InternalKeypoint &lhs, const InternalKeypoint &rhs) -{ - return std::get<2>(lhs) > std::get<2>(rhs); -} - -CPPCornerCandidatesKernel::CPPCornerCandidatesKernel() - : _num_corner_candidates(nullptr), _corner_candidates_mutex(), _input(nullptr), _output(nullptr) -{ -} - -void CPPCornerCandidatesKernel::configure(const IImage *input, InternalKeypoint *output, int32_t *num_corner_candidates) -{ - ARM_COMPUTE_ERROR_ON_TENSOR_NOT_2D(input); - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::F32); - ARM_COMPUTE_ERROR_ON(nullptr == output); - ARM_COMPUTE_ERROR_ON(nullptr == num_corner_candidates); - ARM_COMPUTE_ERROR_ON(*num_corner_candidates != 0); - - _input = input; - _output = output; - _num_corner_candidates = num_corner_candidates; - - const unsigned int num_elems_processed_per_iteration = 1; - - // Configure kernel window - Window win = calculate_max_window(*input->info(), Steps(num_elems_processed_per_iteration)); - - update_window_and_padding(win, AccessWindowHorizontal(input->info(), 0, num_elems_processed_per_iteration)); - - ICPPKernel::configure(win); -} - -void CPPCornerCandidatesKernel::run(const Window &window, const ThreadInfo &info) -{ - ARM_COMPUTE_UNUSED(info); - ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); - ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(ICPPKernel::window(), window); - Iterator input(_input, window); - - execute_window_loop(window, [&](const Coordinates & id) - { - corner_candidates(reinterpret_cast(input.ptr()), &_output[0], id.x(), id.y(), _num_corner_candidates, &_corner_candidates_mutex); - }, - input); -} diff --git a/src/core/CPP/kernels/CPPDetectionWindowNonMaximaSuppressionKernel.cpp b/src/core/CPP/kernels/CPPDetectionWindowNonMaximaSuppressionKernel.cpp deleted file mode 100644 index 3166faba48..0000000000 --- a/src/core/CPP/kernels/CPPDetectionWindowNonMaximaSuppressionKernel.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (c) 2017-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/CPP/kernels/CPPDetectionWindowNonMaximaSuppressionKernel.h" - -#include "arm_compute/core/Helpers.h" - -#include -#include - -using namespace arm_compute; - -namespace -{ -bool compare_detection_window(const DetectionWindow &lhs, const DetectionWindow &rhs) -{ - if(lhs.idx_class < rhs.idx_class) - { - return true; - } - if(rhs.idx_class < lhs.idx_class) - { - return false; - } - - // idx_classes are equal so compare by score - if(lhs.score > rhs.score) - { - return true; - } - if(rhs.score > lhs.score) - { - return false; - } - - return false; -} -} // namespace - -CPPDetectionWindowNonMaximaSuppressionKernel::CPPDetectionWindowNonMaximaSuppressionKernel() - : _input_output(nullptr), _min_distance(0.0f) -{ -} - -bool CPPDetectionWindowNonMaximaSuppressionKernel::is_parallelisable() const -{ - return false; -} - -void CPPDetectionWindowNonMaximaSuppressionKernel::configure(IDetectionWindowArray *input_output, float min_distance) -{ - ARM_COMPUTE_ERROR_ON(nullptr == input_output); - - _input_output = input_output; - _min_distance = min_distance; - - IKernel::configure(Window()); // Default 1 iteration window -} - -void CPPDetectionWindowNonMaximaSuppressionKernel::run(const Window &window, const ThreadInfo &info) -{ - ARM_COMPUTE_UNUSED(info); - ARM_COMPUTE_UNUSED(window); - ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); - ARM_COMPUTE_ERROR_ON_MISMATCHING_WINDOWS(IKernel::window(), window); - ARM_COMPUTE_ERROR_ON(_input_output->buffer() == nullptr); - - const size_t num_candidates = _input_output->num_values(); - size_t num_detections = 0; - - // Sort list of candidates by idx_class and then score - std::sort(_input_output->buffer(), _input_output->buffer() + num_candidates, compare_detection_window); - - const float min_distance_pow2 = _min_distance * _min_distance; - - // Euclidean distance - for(size_t i = 0; i < num_candidates; ++i) - { - if(0.0f != _input_output->at(i).score) - { - DetectionWindow cur; - cur.x = _input_output->at(i).x; - cur.y = _input_output->at(i).y; - cur.width = _input_output->at(i).width; - cur.height = _input_output->at(i).height; - cur.idx_class = _input_output->at(i).idx_class; - cur.score = _input_output->at(i).score; - - // Store window - _input_output->at(num_detections) = cur; - - ++num_detections; - - const float xc = cur.x + cur.width * 0.5f; - const float yc = cur.y + cur.height * 0.5f; - - for(size_t k = i + 1; k < (num_candidates) && (cur.idx_class == _input_output->at(k).idx_class); ++k) - { - const float xn = _input_output->at(k).x + _input_output->at(k).width * 0.5f; - const float yn = _input_output->at(k).y + _input_output->at(k).height * 0.5f; - - const float dx = std::fabs(xn - xc); - const float dy = std::fabs(yn - yc); - - if(dx < _min_distance && dy < _min_distance) - { - const float d = dx * dx + dy * dy; - - if(d < min_distance_pow2) - { - // Invalidate detection window - _input_output->at(k).score = 0.0f; - } - } - } - } - } - - _input_output->resize(num_detections); -} diff --git a/src/core/CPP/kernels/CPPSortEuclideanDistanceKernel.cpp b/src/core/CPP/kernels/CPPSortEuclideanDistanceKernel.cpp deleted file mode 100644 index 603b05ea8a..0000000000 --- a/src/core/CPP/kernels/CPPSortEuclideanDistanceKernel.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2017 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/CPP/kernels/CPPSortEuclideanDistanceKernel.h" - -#include "arm_compute/core/Coordinates.h" -#include "arm_compute/core/Error.h" -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/TensorInfo.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/core/Utils.h" -#include "arm_compute/core/Validate.h" -#include "arm_compute/core/Window.h" - -#include - -using namespace arm_compute; - -namespace -{ -bool keypoint_compare(const InternalKeypoint &lhs, const InternalKeypoint &rhs) -{ - return std::get<2>(lhs) > std::get<2>(rhs); -} -} // namespace - -CPPSortEuclideanDistanceKernel::CPPSortEuclideanDistanceKernel() - : _num_corner_candidates(), _min_distance(0.0f), _in_out(nullptr), _output(nullptr) -{ -} - -void CPPSortEuclideanDistanceKernel::configure(InternalKeypoint *in_out, IKeyPointArray *output, const int32_t *num_corner_candidates, float min_distance) -{ - ARM_COMPUTE_ERROR_ON(nullptr == in_out); - ARM_COMPUTE_ERROR_ON(nullptr == output); - ARM_COMPUTE_ERROR_ON(nullptr == num_corner_candidates); - ARM_COMPUTE_ERROR_ON(!((min_distance > 0) && (min_distance <= 30))); - - _in_out = in_out; - _output = output; - _min_distance = min_distance * min_distance; // We compare squares of distances - _num_corner_candidates = num_corner_candidates; - ICPPKernel::configure(Window()); // Default 1 iteration window -} - -bool CPPSortEuclideanDistanceKernel::is_parallelisable() const -{ - return false; -} - -void CPPSortEuclideanDistanceKernel::run(const Window &window, const ThreadInfo &info) -{ - ARM_COMPUTE_UNUSED(info); - ARM_COMPUTE_UNUSED(window); - ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); - ARM_COMPUTE_ERROR_ON_MISMATCHING_WINDOWS(ICPPKernel::window(), window); - - const int32_t num_corner_candidates = *_num_corner_candidates; - - /* Sort list of corner candidates */ - std::sort(_in_out, _in_out + num_corner_candidates, keypoint_compare); - - /* Euclidean distance */ - for(int32_t i = 0; i < num_corner_candidates; ++i) - { - if(std::get<2>(_in_out[i]) != 0.0f) - { - KeyPoint keypt; - const auto xc = std::get<0>(_in_out[i]); - const auto yc = std::get<1>(_in_out[i]); - - keypt.x = xc; - keypt.y = yc; - keypt.strength = std::get<2>(_in_out[i]); - keypt.tracking_status = 1; - - /* Store corner */ - _output->push_back(keypt); - for(int32_t k = i + 1; k < num_corner_candidates; ++k) - { - const float dx = std::fabs(std::get<0>(_in_out[k]) - xc); - const float dy = std::fabs(std::get<1>(_in_out[k]) - yc); - - if((dx < _min_distance) && (dy < _min_distance)) - { - const float d = (dx * dx + dy * dy); - - if(d < _min_distance) - { - /* Invalidate keypoint */ - std::get<2>(_in_out[k]) = 0.0f; - } - } - } - } - } -} diff --git a/src/core/HOGInfo.cpp b/src/core/HOGInfo.cpp deleted file mode 100644 index 1c27585a1e..0000000000 --- a/src/core/HOGInfo.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) 2016-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/HOGInfo.h" - -#include "arm_compute/core/Error.h" -#include "arm_compute/core/Validate.h" - -using namespace arm_compute; - -HOGInfo::HOGInfo() - : _cell_size(), _block_size(), _detection_window_size(), _block_stride(), _num_bins(0), _normalization_type(HOGNormType::L2HYS_NORM), _l2_hyst_threshold(0.0f), _phase_type(PhaseType::UNSIGNED), - _descriptor_size(0) -{ -} - -HOGInfo::HOGInfo(const Size2D &cell_size, const Size2D &block_size, const Size2D &detection_window_size, const Size2D &block_stride, size_t num_bins, - HOGNormType normalization_type, float l2_hyst_threshold, PhaseType phase_type) - : HOGInfo() -{ - init(cell_size, block_size, detection_window_size, block_stride, num_bins, normalization_type, l2_hyst_threshold, phase_type); -} - -void HOGInfo::init(const Size2D &cell_size, const Size2D &block_size, const Size2D &detection_window_size, const Size2D &block_stride, size_t num_bins, - HOGNormType normalization_type, float l2_hyst_threshold, PhaseType phase_type) -{ - ARM_COMPUTE_ERROR_ON_MSG((block_size.width % cell_size.width), "The block width must be multiple of cell width"); - ARM_COMPUTE_ERROR_ON_MSG((block_size.height % cell_size.height), "Block height must be multiple of cell height"); - ARM_COMPUTE_ERROR_ON_MSG((block_stride.width % cell_size.width), "Block stride width must be multiple of cell width"); - ARM_COMPUTE_ERROR_ON_MSG((block_stride.height % cell_size.height), "Block stride height must be multiple of cell height"); - ARM_COMPUTE_ERROR_ON_MSG(((detection_window_size.width - block_size.width) % block_stride.width), "Window width must be multiple of block width and block stride width"); - ARM_COMPUTE_ERROR_ON_MSG(((detection_window_size.height - block_size.height) % block_stride.height), "Window height must be multiple of block height and block stride height"); - - _cell_size = cell_size; - _block_size = block_size; - _detection_window_size = detection_window_size; - _block_stride = block_stride; - _num_bins = num_bins; - _normalization_type = normalization_type; - _l2_hyst_threshold = l2_hyst_threshold; - _phase_type = phase_type; - - // Compute descriptor size. +1 takes into account of the bias - _descriptor_size = num_cells_per_block().area() * num_block_positions_per_image(_detection_window_size).area() * _num_bins + 1; -} - -Size2D HOGInfo::num_cells_per_block() const -{ - ARM_COMPUTE_ERROR_ON(_cell_size.width == 0 || _cell_size.height == 0); - - return Size2D{ _block_size.width / _cell_size.width, - _block_size.height / _cell_size.height }; -} - -Size2D HOGInfo::num_cells_per_block_stride() const -{ - ARM_COMPUTE_ERROR_ON(_cell_size.width == 0 || _cell_size.height == 0); - - return Size2D{ _block_stride.width / _cell_size.width, - _block_stride.height / _cell_size.height }; -} - -Size2D HOGInfo::num_block_positions_per_image(const Size2D &image_size) const -{ - ARM_COMPUTE_ERROR_ON(_block_stride.width == 0 || _block_stride.height == 0); - - return Size2D{ ((image_size.width - _block_size.width) / _block_stride.width) + 1, - ((image_size.height - _block_size.height) / _block_stride.height) + 1 }; -} - -const Size2D &HOGInfo::cell_size() const -{ - return _cell_size; -} - -const Size2D &HOGInfo::block_size() const -{ - return _block_size; -} - -const Size2D &HOGInfo::detection_window_size() const -{ - return _detection_window_size; -} - -const Size2D &HOGInfo::block_stride() const -{ - return _block_stride; -} - -size_t HOGInfo::num_bins() const -{ - return _num_bins; -} - -HOGNormType HOGInfo::normalization_type() const -{ - return _normalization_type; -} - -float HOGInfo::l2_hyst_threshold() const -{ - return _l2_hyst_threshold; -} - -PhaseType HOGInfo::phase_type() const -{ - return _phase_type; -} - -size_t HOGInfo::descriptor_size() const -{ - return _descriptor_size; -} diff --git a/src/core/IDistribution.cpp b/src/core/IDistribution.cpp deleted file mode 100644 index c7e734611f..0000000000 --- a/src/core/IDistribution.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2016, 2017 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/IDistribution.h" - -#include "arm_compute/core/Error.h" - -#include - -using namespace arm_compute; - -void IDistribution::clear() const -{ - ARM_COMPUTE_ERROR_ON(nullptr == buffer()); - std::memset(buffer(), 0, size()); -} diff --git a/src/core/IDistribution1D.cpp b/src/core/IDistribution1D.cpp deleted file mode 100644 index 4dbb081286..0000000000 --- a/src/core/IDistribution1D.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2016, 2017 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/IDistribution1D.h" - -#include "arm_compute/core/Error.h" - -using namespace arm_compute; - -IDistribution1D::IDistribution1D(size_t num_bins, int32_t offset, uint32_t range) - : _num_bins(num_bins), _offset(offset), _range(range) -{ - ARM_COMPUTE_ERROR_ON_MSG(0 == _num_bins, "Invalid number of bins, it should be greater than 0"); -} - -size_t IDistribution1D::num_bins() const -{ - return _num_bins; -} - -int32_t IDistribution1D::offset() const -{ - return _offset; -} - -uint32_t IDistribution1D::range() const -{ - return _range; -} - -uint32_t IDistribution1D::window() const -{ - return _range / _num_bins; -} - -size_t IDistribution1D::size() const -{ - return _num_bins * sizeof(uint32_t); -} - -void IDistribution1D::set_range(uint32_t range) -{ - _range = range; -} - -size_t IDistribution1D::dimensions() const -{ - return 1; -} diff --git a/src/core/MultiImageInfo.cpp b/src/core/MultiImageInfo.cpp deleted file mode 100644 index 9ec1e1d75f..0000000000 --- a/src/core/MultiImageInfo.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2016, 2017 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/MultiImageInfo.h" - -using namespace arm_compute; - -MultiImageInfo::MultiImageInfo() - : _width(0), _height(0), _format(Format::UNKNOWN) -{ -} - -void MultiImageInfo::init(unsigned int width, unsigned int height, Format format) -{ - _format = format; - _width = width; - _height = height; -} - -Format MultiImageInfo::format() const -{ - return _format; -} - -unsigned int MultiImageInfo::width() const -{ - return _width; -} - -unsigned int MultiImageInfo::height() const -{ - return _height; -} diff --git a/src/core/NEON/NEKernels.h b/src/core/NEON/NEKernels.h index 0acaebb582..59884e2d05 100644 --- a/src/core/NEON/NEKernels.h +++ b/src/core/NEON/NEKernels.h @@ -36,7 +36,6 @@ #include "src/core/NEON/kernels/NEConvertFullyConnectedWeightsKernel.h" #include "src/core/NEON/kernels/NEConvertQuantizedSignednessKernel.h" #include "src/core/NEON/kernels/NECropKernel.h" -#include "src/core/NEON/kernels/NECumulativeDistributionKernel.h" #include "src/core/NEON/kernels/NEDepthConvertLayerKernel.h" #include "src/core/NEON/kernels/NEDepthToSpaceLayerKernel.h" #include "src/core/NEON/kernels/NEDepthwiseConvolutionLayerNativeKernel.h" @@ -45,7 +44,6 @@ #include "src/core/NEON/kernels/NEFFTDigitReverseKernel.h" #include "src/core/NEON/kernels/NEFFTRadixStageKernel.h" #include "src/core/NEON/kernels/NEFFTScaleKernel.h" -#include "src/core/NEON/kernels/NEFillArrayKernel.h" #include "src/core/NEON/kernels/NEFillBorderKernel.h" #include "src/core/NEON/kernels/NEFuseBatchNormalizationKernel.h" #include "src/core/NEON/kernels/NEGEMMInterleave4x4Kernel.h" @@ -65,7 +63,6 @@ #include "src/core/NEON/kernels/NEIm2ColKernel.h" #include "src/core/NEON/kernels/NEInstanceNormalizationLayerKernel.h" #include "src/core/NEON/kernels/NEL2NormalizeLayerKernel.h" -#include "src/core/NEON/kernels/NELKTrackerKernel.h" #include "src/core/NEON/kernels/NELogicalKernel.h" #include "src/core/NEON/kernels/NEMaxUnpoolingLayerKernel.h" #include "src/core/NEON/kernels/NEMeanStdDevNormalizationKernel.h" diff --git a/src/core/NEON/kernels/NECumulativeDistributionKernel.cpp b/src/core/NEON/kernels/NECumulativeDistributionKernel.cpp deleted file mode 100644 index 58a9a2f1fb..0000000000 --- a/src/core/NEON/kernels/NECumulativeDistributionKernel.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "src/core/NEON/kernels/NECumulativeDistributionKernel.h" - -#include "arm_compute/core/Error.h" -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/IDistribution1D.h" -#include "arm_compute/core/ILut.h" -#include "arm_compute/core/ITensor.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/core/Validate.h" -#include "src/core/helpers/AutoConfiguration.h" -#include "src/core/helpers/WindowHelpers.h" - -#include -#include -#include - -using namespace arm_compute; - -NECumulativeDistributionKernel::NECumulativeDistributionKernel() - : _input(nullptr), _distribution(nullptr), _cumulative_sum(nullptr), _output(nullptr) -{ -} - -bool NECumulativeDistributionKernel::is_parallelisable() const -{ - return false; -} - -void NECumulativeDistributionKernel::configure(const IImage *input, const IDistribution1D *distribution, IDistribution1D *cumulative_sum, ILut *output) -{ - ARM_COMPUTE_ERROR_ON_NULLPTR(input, distribution, cumulative_sum, output); - ARM_COMPUTE_ERROR_ON_TENSOR_NOT_2D(input); - - set_format_if_unknown(*input->info(), Format::U8); - - ARM_COMPUTE_ERROR_ON(distribution->num_bins() != cumulative_sum->num_bins()); - ARM_COMPUTE_ERROR_ON(distribution->num_bins() != output->num_elements()); - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8); - ARM_COMPUTE_ERROR_ON(input->info()->data_type() != output->type()); - - _input = input; - _distribution = distribution; - _cumulative_sum = cumulative_sum; - _output = output; - - INEKernel::configure(calculate_max_window(*input->info())); -} - -void NECumulativeDistributionKernel::run(const Window &window, const ThreadInfo &info) -{ - ARM_COMPUTE_UNUSED(info); - ARM_COMPUTE_UNUSED(window); - ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); - ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(INEKernel::window(), window); - ARM_COMPUTE_ERROR_ON(_distribution->buffer() == nullptr); - ARM_COMPUTE_ERROR_ON(_cumulative_sum->buffer() == nullptr); - ARM_COMPUTE_ERROR_ON(_output->buffer() == nullptr); - ARM_COMPUTE_ERROR_ON_MSG(_distribution->num_bins() < 256, "Distribution must have 256 bins"); - - // Calculate the cumulative distribution (summed histogram). - const uint32_t *hist = _distribution->buffer(); - uint32_t *cumulative_sum = _cumulative_sum->buffer(); - uint8_t *output = _output->buffer(); - - // Calculate cumulative distribution - std::partial_sum(hist, hist + _histogram_size, cumulative_sum); - - // Get the number of pixels that have the lowest value in the input image - const uint32_t cd_min = *std::find_if(hist, hist + _histogram_size, [](const uint32_t &v) - { - return v > 0; - }); - const uint32_t image_size = cumulative_sum[_histogram_size - 1]; - - ARM_COMPUTE_ERROR_ON(cd_min > image_size); - - // Create mapping lookup table - if(image_size == cd_min) - { - std::iota(output, output + _histogram_size, 0); - } - else - { - const float diff = image_size - cd_min; - - for(unsigned int x = 0; x < _histogram_size; ++x) - { - output[x] = lround((cumulative_sum[x] - cd_min) / diff * 255.0f); - } - } -} diff --git a/src/core/NEON/kernels/NECumulativeDistributionKernel.h b/src/core/NEON/kernels/NECumulativeDistributionKernel.h deleted file mode 100644 index 1f8c65b5fa..0000000000 --- a/src/core/NEON/kernels/NECumulativeDistributionKernel.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_NECUMULATIVEDISTRIBUTIONKERNEL_H -#define ARM_COMPUTE_NECUMULATIVEDISTRIBUTIONKERNEL_H - -#include "src/core/NEON/INEKernel.h" - -#include - -namespace arm_compute -{ -class IDistribution1D; -class ILut; -class ITensor; -using IImage = ITensor; - -/** Interface for the cumulative distribution (cummulative summmation) calculation kernel. - * - * This kernel calculates the cumulative sum of a given distribution (meaning that each output element - * is the sum of all its previous elements including itself) and creates a lookup table with the normalized - * pixel intensities which is used for improve the constrast of the image. - */ -class NECumulativeDistributionKernel : public INEKernel -{ -public: - const char *name() const override - { - return "NECumulativeDistributionKernel"; - } - /** Default constructor */ - NECumulativeDistributionKernel(); - /** Prevent instances of this class from being copied (As this class contains pointers) */ - NECumulativeDistributionKernel(const NECumulativeDistributionKernel &) = delete; - /** Prevent instances of this class from being copied (As this class contains pointers) */ - NECumulativeDistributionKernel &operator=(const NECumulativeDistributionKernel &) = delete; - /** Allow instances of this class to be moved */ - NECumulativeDistributionKernel(NECumulativeDistributionKernel &&) = default; - /** Allow instances of this class to be moved */ - NECumulativeDistributionKernel &operator=(NECumulativeDistributionKernel &&) = default; - /** Default destructor */ - ~NECumulativeDistributionKernel() = default; - /** Set the input and output distribution. - * - * @param[in] input Input image. Data type supported: U8 - * @param[in] distribution Unnormalized 256-bin distribution of the input image. - * @param[out] cumulative_sum Cummulative distribution (Summed histogram). Should be same size as @p distribution. - * @param[out] output Equalization lookup table. Should consist of 256 entries of U8 elements. - */ - void configure(const IImage *input, const IDistribution1D *distribution, IDistribution1D *cumulative_sum, ILut *output); - - // Inherited methods overridden: - void run(const Window &window, const ThreadInfo &info) override; - bool is_parallelisable() const override; - -private: - const IImage *_input; /**< Input image. */ - const IDistribution1D *_distribution; /**< Input histogram of the input image. */ - IDistribution1D *_cumulative_sum; /**< The cummulative distribution. */ - ILut *_output; /**< Output with the equalization lookup table. */ -private: - static const uint32_t _histogram_size = 256; /**< Default histogram size of 256. */ -}; -} // namespace arm_compute -#endif /*ARM_COMPUTE_NECUMULATIVEDISTRIBUTIONKERNEL_H */ diff --git a/src/core/NEON/kernels/NEFillArrayKernel.cpp b/src/core/NEON/kernels/NEFillArrayKernel.cpp deleted file mode 100644 index e8ae926fbf..0000000000 --- a/src/core/NEON/kernels/NEFillArrayKernel.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "src/core/NEON/kernels/NEFillArrayKernel.h" - -#include "arm_compute/core/Coordinates.h" -#include "arm_compute/core/Error.h" -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/IAccessWindow.h" -#include "arm_compute/core/Validate.h" -#include "src/core/helpers/WindowHelpers.h" - -using namespace arm_compute; - -NEFillArrayKernel::NEFillArrayKernel() - : _input(nullptr), _output(nullptr), _threshold(0) -{ -} - -void NEFillArrayKernel::configure(const IImage *input, uint8_t threshold, IKeyPointArray *output) -{ - ARM_COMPUTE_ERROR_ON_TENSOR_NOT_2D(input); - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8); - ARM_COMPUTE_ERROR_ON(nullptr == output); - - _input = input; - _output = output; - _threshold = threshold; - - constexpr unsigned int num_elems_processed_per_iteration = 1; - - // Configure kernel window - Window win = calculate_max_window(*input->info(), Steps(num_elems_processed_per_iteration)); - INEKernel::configure(win); -} - -bool NEFillArrayKernel::is_parallelisable() const -{ - return false; -} - -void NEFillArrayKernel::run(const Window &window, const ThreadInfo &info) -{ - ARM_COMPUTE_UNUSED(info); - ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); - ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(INEKernel::window(), window); - - Iterator input(_input, window); - - execute_window_loop(window, [&](const Coordinates & id) - { - const uint8_t value = *input.ptr(); - - if(value >= _threshold) - { - KeyPoint p; - p.x = id.x(); - p.y = id.y(); - p.strength = value; - p.tracking_status = 1; - p.scale = 0.f; - p.orientation = 0.f; - p.error = 0.f; - - if(!_output->push_back(p)) - { - return; //Overflowed: stop trying to add more points - } - } - }, - input); -} diff --git a/src/core/NEON/kernels/NEFillArrayKernel.h b/src/core/NEON/kernels/NEFillArrayKernel.h deleted file mode 100644 index c9841679d1..0000000000 --- a/src/core/NEON/kernels/NEFillArrayKernel.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_NEFILLARRAYKERNEL_H -#define ARM_COMPUTE_NEFILLARRAYKERNEL_H - -#include "arm_compute/core/IArray.h" -#include "arm_compute/core/Types.h" -#include "src/core/NEON/INEKernel.h" - -#include - -namespace arm_compute -{ -class ITensor; -using IImage = ITensor; - -/** This kernel adds all texels greater than or equal to the threshold value to the keypoint array. */ -class NEFillArrayKernel : public INEKernel -{ -public: - const char *name() const override - { - return "NEFillArrayKernel"; - } - /** Default contructor */ - NEFillArrayKernel(); - /** Prevent instances of this class from being copied (As this class contains pointers) */ - NEFillArrayKernel(const NEFillArrayKernel &) = delete; - /** Prevent instances of this class from being copied (As this class contains pointers) */ - NEFillArrayKernel &operator=(const NEFillArrayKernel &) = delete; - /** Allow instances of this class to be moved */ - NEFillArrayKernel(NEFillArrayKernel &&) = default; - /** Allow instances of this class to be moved */ - NEFillArrayKernel &operator=(NEFillArrayKernel &&) = default; - /** Default detructor */ - ~NEFillArrayKernel() = default; - - /** Initialise the kernel. - * - * @param[in] input Source image. Data type supported: U8. - * @param[in] threshold Texels greater than the threshold will be added to the array. - * @param[out] output Arrays of keypoints to store the results. - */ - void configure(const IImage *input, uint8_t threshold, IKeyPointArray *output); - - // Inherited methods overridden: - void run(const Window &window, const ThreadInfo &info) override; - bool is_parallelisable() const override; - -private: - const IImage *_input; - IKeyPointArray *_output; - uint8_t _threshold; -}; -} // namespace arm_compute -#endif /* ARM_COMPUTE_NEFILLARRAYKERNEL_H*/ diff --git a/src/core/NEON/kernels/NELKTrackerKernel.cpp b/src/core/NEON/kernels/NELKTrackerKernel.cpp deleted file mode 100644 index 442f001102..0000000000 --- a/src/core/NEON/kernels/NELKTrackerKernel.cpp +++ /dev/null @@ -1,540 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "src/core/NEON/kernels/NELKTrackerKernel.h" - -#include "arm_compute/core/Coordinates.h" -#include "arm_compute/core/Error.h" -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/ITensor.h" -#include "arm_compute/core/TensorInfo.h" -#include "arm_compute/core/Validate.h" -#include "arm_compute/core/Window.h" -#include "src/core/AccessWindowStatic.h" -#include "src/core/helpers/AutoConfiguration.h" -#include "src/core/helpers/WindowHelpers.h" - -#include -#include - -using namespace arm_compute; - -/** Constants used for Lucas-Kanade Algorithm */ -constexpr int W_BITS = 14; -constexpr float D0 = 1 << W_BITS; -constexpr float DETERMINANT_THRESHOLD = 1.0e-07f; // Threshold for the determinant. Used for lost tracking criteria -constexpr float EIGENVALUE_THRESHOLD = 1.0e-04f; // Thresholds for minimum eigenvalue. Used for lost tracking criteria -constexpr float FLT_SCALE = 1.0f / (1 << 20); - -namespace -{ -enum class BilinearInterpolation -{ - BILINEAR_OLD_NEW, - BILINEAR_SCHARR -}; - -template -constexpr int INT_ROUND(T x, int n) -{ - return (x + (1 << (n - 1))) >> n; -} - -template -inline int get_pixel(const ITensor *tensor, int xi, int yi, int iw00, int iw01, int iw10, int iw11, int scale) -{ - const auto px00 = *reinterpret_cast(tensor->buffer() + tensor->info()->offset_element_in_bytes(Coordinates(xi, yi))); - const auto px01 = *reinterpret_cast(tensor->buffer() + tensor->info()->offset_element_in_bytes(Coordinates(xi + 1, yi))); - const auto px10 = *reinterpret_cast(tensor->buffer() + tensor->info()->offset_element_in_bytes(Coordinates(xi, yi + 1))); - const auto px11 = *reinterpret_cast(tensor->buffer() + tensor->info()->offset_element_in_bytes(Coordinates(xi + 1, yi + 1))); - - return INT_ROUND(px00 * iw00 + px01 * iw01 + px10 * iw10 + px11 * iw11, scale); -} - -inline int32x4_t compute_bilinear_interpolation(int16x8_t top_row, int16x8_t bottom_row, int16x4_t w00, int16x4_t w01, int16x4_t w10, int16x4_t w11, int32x4_t shift) -{ - // Get the left column of upper row - const int16x4_t px00 = vget_low_s16(top_row); - - // Get the right column of upper row - const int16x4_t px01 = vext_s16(px00, vget_high_s16(top_row), 1); - - // Get the left column of lower row - const int16x4_t px10 = vget_low_s16(bottom_row); - - // Get the right column of right row - const int16x4_t px11 = vext_s16(px10, vget_high_s16(bottom_row), 1); - - // Apply the bilinear filter - return vqrshlq_s32(vmull_s16(px00, w00) + vmull_s16(px01, w01) + vmull_s16(px10, w10) + vmull_s16(px11, w11), shift); -} -} // namespace - -void NELKTrackerKernel::init_keypoints(int start, int end) -{ - if(_level == _num_levels - 1) - { - const float level_scale = pow(_pyramid_scale, _level); - - for(int i = start; i < end; ++i) - { - _old_points_internal->at(i).x = _old_points->at(i).x * level_scale; - _old_points_internal->at(i).y = _old_points->at(i).y * level_scale; - _old_points_internal->at(i).tracking_status = true; - - NELKInternalKeypoint keypoint_to_track; - - if(_use_initial_estimate) - { - keypoint_to_track.x = _new_points_estimates->at(i).x * level_scale; - keypoint_to_track.y = _new_points_estimates->at(i).y * level_scale; - keypoint_to_track.tracking_status = (_new_points_estimates->at(i).tracking_status == 1); - } - else - { - keypoint_to_track.x = _old_points_internal->at(i).x; - keypoint_to_track.y = _old_points_internal->at(i).y; - keypoint_to_track.tracking_status = true; - } - - _new_points_internal->at(i) = keypoint_to_track; - } - } - else - { - for(int i = start; i < end; ++i) - { - _old_points_internal->at(i).x /= _pyramid_scale; - _old_points_internal->at(i).y /= _pyramid_scale; - _new_points_internal->at(i).x /= _pyramid_scale; - _new_points_internal->at(i).y /= _pyramid_scale; - } - } -} - -std::tuple NELKTrackerKernel::compute_spatial_gradient_matrix(const NELKInternalKeypoint &keypoint, int32_t *bilinear_ix, int32_t *bilinear_iy) -{ - int iA11 = 0; - int iA12 = 0; - int iA22 = 0; - - int32x4_t nA11 = vdupq_n_s32(0); - int32x4_t nA12 = vdupq_n_s32(0); - int32x4_t nA22 = vdupq_n_s32(0); - - float keypoint_int_x = 0; - float keypoint_int_y = 0; - - const float wx = std::modf(keypoint.x, &keypoint_int_x); - const float wy = std::modf(keypoint.y, &keypoint_int_y); - - const int iw00 = roundf((1.0f - wx) * (1.0f - wy) * D0); - const int iw01 = roundf(wx * (1.0f - wy) * D0); - const int iw10 = roundf((1.0f - wx) * wy * D0); - const int iw11 = D0 - iw00 - iw01 - iw10; - - const int16x4_t nw00 = vdup_n_s16(iw00); - const int16x4_t nw01 = vdup_n_s16(iw01); - const int16x4_t nw10 = vdup_n_s16(iw10); - const int16x4_t nw11 = vdup_n_s16(iw11); - - // Convert stride from uint_t* to int16_t* - const size_t row_stride = _old_scharr_gx->info()->strides_in_bytes()[1] / 2; - const Coordinates top_left_window_corner(static_cast(keypoint_int_x) - _window_dimension / 2, static_cast(keypoint_int_y) - _window_dimension / 2); - auto idx = reinterpret_cast(_old_scharr_gx->buffer() + _old_scharr_gx->info()->offset_element_in_bytes(top_left_window_corner)); - auto idy = reinterpret_cast(_old_scharr_gy->buffer() + _old_scharr_gy->info()->offset_element_in_bytes(top_left_window_corner)); - static const int32x4_t nshifter_scharr = vdupq_n_s32(-W_BITS); - - for(int ky = 0; ky < _window_dimension; ++ky, idx += row_stride, idy += row_stride) - { - int kx = 0; - - // Calculate elements in blocks of four as long as possible - for(; kx <= _window_dimension - 4; kx += 4) - { - // Interpolation X - const int16x8_t ndx_row1 = vld1q_s16(idx + kx); - const int16x8_t ndx_row2 = vld1q_s16(idx + kx + row_stride); - - const int32x4_t nxval = compute_bilinear_interpolation(ndx_row1, ndx_row2, nw00, nw01, nw10, nw11, nshifter_scharr); - - // Interpolation Y - const int16x8_t ndy_row1 = vld1q_s16(idy + kx); - const int16x8_t ndy_row2 = vld1q_s16(idy + kx + row_stride); - - const int32x4_t nyval = compute_bilinear_interpolation(ndy_row1, ndy_row2, nw00, nw01, nw10, nw11, nshifter_scharr); - - // Store the intermediate data so that we don't need to recalculate them in later stage - vst1q_s32(bilinear_ix + kx + ky * _window_dimension, nxval); - vst1q_s32(bilinear_iy + kx + ky * _window_dimension, nyval); - - // Accumulate Ix^2 - nA11 = vmlaq_s32(nA11, nxval, nxval); - // Accumulate Ix * Iy - nA12 = vmlaq_s32(nA12, nxval, nyval); - // Accumulate Iy^2 - nA22 = vmlaq_s32(nA22, nyval, nyval); - } - - // Calculate the leftover elements - for(; kx < _window_dimension; ++kx) - { - const int32_t ixval = get_pixel(_old_scharr_gx, top_left_window_corner.x() + kx, top_left_window_corner.y() + ky, - iw00, iw01, iw10, iw11, W_BITS); - const int32_t iyval = get_pixel(_old_scharr_gy, top_left_window_corner.x() + kx, top_left_window_corner.y() + ky, - iw00, iw01, iw10, iw11, W_BITS); - - iA11 += ixval * ixval; - iA12 += ixval * iyval; - iA22 += iyval * iyval; - - bilinear_ix[kx + ky * _window_dimension] = ixval; - bilinear_iy[kx + ky * _window_dimension] = iyval; - } - } - - iA11 += vgetq_lane_s32(nA11, 0) + vgetq_lane_s32(nA11, 1) + vgetq_lane_s32(nA11, 2) + vgetq_lane_s32(nA11, 3); - iA12 += vgetq_lane_s32(nA12, 0) + vgetq_lane_s32(nA12, 1) + vgetq_lane_s32(nA12, 2) + vgetq_lane_s32(nA12, 3); - iA22 += vgetq_lane_s32(nA22, 0) + vgetq_lane_s32(nA22, 1) + vgetq_lane_s32(nA22, 2) + vgetq_lane_s32(nA22, 3); - - return std::make_tuple(iA11, iA12, iA22); -} - -std::pair NELKTrackerKernel::compute_image_mismatch_vector(const NELKInternalKeypoint &old_keypoint, const NELKInternalKeypoint &new_keypoint, const int32_t *bilinear_ix, - const int32_t *bilinear_iy) -{ - int ib1 = 0; - int ib2 = 0; - - int32x4_t nb1 = vdupq_n_s32(0); - int32x4_t nb2 = vdupq_n_s32(0); - - // Compute weights for the old keypoint - float old_keypoint_int_x = 0; - float old_keypoint_int_y = 0; - - const float old_wx = std::modf(old_keypoint.x, &old_keypoint_int_x); - const float old_wy = std::modf(old_keypoint.y, &old_keypoint_int_y); - - const int iw00_old = roundf((1.0f - old_wx) * (1.0f - old_wy) * D0); - const int iw01_old = roundf(old_wx * (1.0f - old_wy) * D0); - const int iw10_old = roundf((1.0f - old_wx) * old_wy * D0); - const int iw11_old = D0 - iw00_old - iw01_old - iw10_old; - - const int16x4_t nw00_old = vdup_n_s16(iw00_old); - const int16x4_t nw01_old = vdup_n_s16(iw01_old); - const int16x4_t nw10_old = vdup_n_s16(iw10_old); - const int16x4_t nw11_old = vdup_n_s16(iw11_old); - - // Compute weights for the new keypoint - float new_keypoint_int_x = 0; - float new_keypoint_int_y = 0; - - const float new_wx = std::modf(new_keypoint.x, &new_keypoint_int_x); - const float new_wy = std::modf(new_keypoint.y, &new_keypoint_int_y); - - const int iw00_new = roundf((1.0f - new_wx) * (1.0f - new_wy) * D0); - const int iw01_new = roundf(new_wx * (1.0f - new_wy) * D0); - const int iw10_new = roundf((1.0f - new_wx) * new_wy * D0); - const int iw11_new = D0 - iw00_new - iw01_new - iw10_new; - - const int16x4_t nw00_new = vdup_n_s16(iw00_new); - const int16x4_t nw01_new = vdup_n_s16(iw01_new); - const int16x4_t nw10_new = vdup_n_s16(iw10_new); - const int16x4_t nw11_new = vdup_n_s16(iw11_new); - - const int row_stride = _input_new->info()->strides_in_bytes()[1]; - const Coordinates top_left_window_corner_old(static_cast(old_keypoint_int_x) - _window_dimension / 2, static_cast(old_keypoint_int_y) - _window_dimension / 2); - const Coordinates top_left_window_corner_new(static_cast(new_keypoint_int_x) - _window_dimension / 2, static_cast(new_keypoint_int_y) - _window_dimension / 2); - const uint8_t *old_ptr = _input_old->buffer() + _input_old->info()->offset_element_in_bytes(top_left_window_corner_old); - const uint8_t *new_ptr = _input_new->buffer() + _input_new->info()->offset_element_in_bytes(top_left_window_corner_new); - static const int32x4_t nshifter_tensor = vdupq_n_s32(-(W_BITS - 5)); - - for(int ky = 0; ky < _window_dimension; ++ky, new_ptr += row_stride, old_ptr += row_stride) - { - int kx = 0; - - // Calculate elements in blocks of four as long as possible - for(; kx <= _window_dimension - 4; kx += 4) - { - // Interpolation old tensor - const int16x8_t nold_row1 = vreinterpretq_s16_u16(vmovl_u8(vld1_u8(old_ptr + kx))); - const int16x8_t nold_row2 = vreinterpretq_s16_u16(vmovl_u8(vld1_u8(old_ptr + kx + row_stride))); - - const int32x4_t noldval = compute_bilinear_interpolation(nold_row1, nold_row2, nw00_old, nw01_old, nw10_old, nw11_old, nshifter_tensor); - - // Interpolation new tensor - const int16x8_t nnew_row1 = vreinterpretq_s16_u16(vmovl_u8(vld1_u8(new_ptr + kx))); - const int16x8_t nnew_row2 = vreinterpretq_s16_u16(vmovl_u8(vld1_u8(new_ptr + kx + row_stride))); - - const int32x4_t nnewval = compute_bilinear_interpolation(nnew_row1, nnew_row2, nw00_new, nw01_new, nw10_new, nw11_new, nshifter_tensor); - - // Calculate It gradient, i.e. pixelwise difference between old and new tensor - const int32x4_t diff = vsubq_s32(nnewval, noldval); - - // Load the Ix and Iy gradient computed in the previous stage - const int32x4_t nxval = vld1q_s32(bilinear_ix + kx + ky * _window_dimension); - const int32x4_t nyval = vld1q_s32(bilinear_iy + kx + ky * _window_dimension); - - // Caculate Ix * It and Iy * It, and accumulate the results - nb1 = vmlaq_s32(nb1, diff, nxval); - nb2 = vmlaq_s32(nb2, diff, nyval); - } - - // Calculate the leftover elements - for(; kx < _window_dimension; ++kx) - { - const int32_t ival = get_pixel(_input_old, top_left_window_corner_old.x() + kx, top_left_window_corner_old.y() + ky, - iw00_old, iw01_old, iw10_old, iw11_old, W_BITS - 5); - const int32_t jval = get_pixel(_input_new, top_left_window_corner_new.x() + kx, top_left_window_corner_new.y() + ky, - iw00_new, iw01_new, iw10_new, iw11_new, W_BITS - 5); - - const int32_t diff = jval - ival; - - ib1 += diff * bilinear_ix[kx + ky * _window_dimension]; - ib2 += diff * bilinear_iy[kx + ky * _window_dimension]; - } - } - - ib1 += vgetq_lane_s32(nb1, 0) + vgetq_lane_s32(nb1, 1) + vgetq_lane_s32(nb1, 2) + vgetq_lane_s32(nb1, 3); - ib2 += vgetq_lane_s32(nb2, 0) + vgetq_lane_s32(nb2, 1) + vgetq_lane_s32(nb2, 2) + vgetq_lane_s32(nb2, 3); - - return std::make_pair(ib1, ib2); -} - -NELKTrackerKernel::NELKTrackerKernel() - : _input_old(nullptr), _input_new(nullptr), _old_scharr_gx(nullptr), _old_scharr_gy(nullptr), _new_points(nullptr), _new_points_estimates(nullptr), _old_points(nullptr), _old_points_internal(), - _new_points_internal(), _termination(Termination::TERM_CRITERIA_EPSILON), _use_initial_estimate(false), _pyramid_scale(0.0f), _epsilon(0.0f), _num_iterations(0), _window_dimension(0), _level(0), - _num_levels(0), _valid_region() -{ -} - -BorderSize NELKTrackerKernel::border_size() const -{ - return BorderSize(1); -} - -void NELKTrackerKernel::configure(const ITensor *input_old, const ITensor *input_new, const ITensor *old_scharr_gx, const ITensor *old_scharr_gy, - const IKeyPointArray *old_points, const IKeyPointArray *new_points_estimates, IKeyPointArray *new_points, - INELKInternalKeypointArray *old_points_internal, INELKInternalKeypointArray *new_points_internal, - Termination termination, bool use_initial_estimate, float epsilon, unsigned int num_iterations, size_t window_dimension, - size_t level, size_t num_levels, float pyramid_scale) - -{ - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input_old, 1, DataType::U8); - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input_new, 1, DataType::U8); - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(old_scharr_gx, 1, DataType::S16); - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(old_scharr_gy, 1, DataType::S16); - - _input_old = input_old; - _input_new = input_new; - _old_scharr_gx = old_scharr_gx; - _old_scharr_gy = old_scharr_gy; - _old_points = old_points; - _new_points_estimates = new_points_estimates; - _new_points = new_points; - _old_points_internal = old_points_internal; - _new_points_internal = new_points_internal; - _termination = termination; - _use_initial_estimate = use_initial_estimate; - _epsilon = epsilon; - _window_dimension = window_dimension; - _level = level; - _num_levels = num_levels; - _pyramid_scale = pyramid_scale; - _num_levels = num_levels; - - // Set maximum number of iterations used for convergence - const size_t max_iterations = 1000; - _num_iterations = (termination == Termination::TERM_CRITERIA_EPSILON) ? max_iterations : num_iterations; - - Window window; - window.set(Window::DimX, Window::Dimension(0, old_points->num_values())); - window.set(Window::DimY, Window::Dimension(0, 1)); - - _valid_region = intersect_valid_regions( - input_old->info()->valid_region(), - input_new->info()->valid_region(), - old_scharr_gx->info()->valid_region(), - old_scharr_gy->info()->valid_region()); - - update_window_and_padding(window, - AccessWindowStatic(input_old->info(), _valid_region.start(0), _valid_region.start(1), - _valid_region.end(0), _valid_region.end(1)), - AccessWindowStatic(input_new->info(), _valid_region.start(0), _valid_region.start(1), - _valid_region.end(0), _valid_region.end(1)), - AccessWindowStatic(old_scharr_gx->info(), _valid_region.start(0), _valid_region.start(1), - _valid_region.end(0), _valid_region.end(1)), - AccessWindowStatic(old_scharr_gy->info(), _valid_region.start(0), _valid_region.start(1), - _valid_region.end(0), _valid_region.end(1))); - - INEKernel::configure(window); -} - -void NELKTrackerKernel::run(const Window &window, const ThreadInfo &info) -{ - ARM_COMPUTE_UNUSED(info); - ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); - ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(INEKernel::window(), window); - - ARM_COMPUTE_ERROR_ON(_input_old->buffer() == nullptr); - ARM_COMPUTE_ERROR_ON(_input_new->buffer() == nullptr); - ARM_COMPUTE_ERROR_ON(_old_scharr_gx->buffer() == nullptr); - ARM_COMPUTE_ERROR_ON(_old_scharr_gy->buffer() == nullptr); - - const int list_end = window.x().end(); - const int list_start = window.x().start(); - - init_keypoints(list_start, list_end); - - const int buffer_size = _window_dimension * _window_dimension; - std::vector bilinear_ix(buffer_size); - std::vector bilinear_iy(buffer_size); - - const int half_window = _window_dimension / 2; - - auto is_invalid_keypoint = [&](const NELKInternalKeypoint & keypoint) - { - const int x = std::floor(keypoint.x); - const int y = std::floor(keypoint.y); - - return (x - half_window < _valid_region.start(0)) || (x + half_window >= _valid_region.end(0) - 1) || (y - half_window < _valid_region.start(1)) || (y + half_window >= _valid_region.end(1) - 1); - }; - - for(int list_indx = list_start; list_indx < list_end; ++list_indx) - { - NELKInternalKeypoint &old_keypoint = _old_points_internal->at(list_indx); - NELKInternalKeypoint &new_keypoint = _new_points_internal->at(list_indx); - - if(!old_keypoint.tracking_status) - { - continue; - } - - if(is_invalid_keypoint(old_keypoint)) - { - if(_level == 0) - { - new_keypoint.tracking_status = false; - } - - continue; - } - - // Compute spatial gradient matrix - int iA11 = 0; - int iA12 = 0; - int iA22 = 0; - - std::tie(iA11, iA12, iA22) = compute_spatial_gradient_matrix(old_keypoint, bilinear_ix.data(), bilinear_iy.data()); - - const float A11 = iA11 * FLT_SCALE; - const float A12 = iA12 * FLT_SCALE; - const float A22 = iA22 * FLT_SCALE; - - // Calculate minimum eigenvalue - const float sum_A11_A22 = A11 + A22; - const float discriminant = sum_A11_A22 * sum_A11_A22 - 4.0f * (A11 * A22 - A12 * A12); - // Divide by _window_dimension^2 to reduce the floating point accummulation error - const float minimum_eigenvalue = (sum_A11_A22 - std::sqrt(discriminant)) / (2.0f * _window_dimension * _window_dimension); - - // Determinant - const double D = A11 * A22 - A12 * A12; - - // Check if it is a good point to track - if(minimum_eigenvalue < EIGENVALUE_THRESHOLD || D < DETERMINANT_THRESHOLD) - { - // Invalidate tracked point - if(_level == 0) - { - new_keypoint.tracking_status = false; - } - - continue; - } - - float prev_delta_x = 0.0f; - float prev_delta_y = 0.0f; - - for(unsigned int j = 0; j < _num_iterations; ++j) - { - if(is_invalid_keypoint(new_keypoint)) - { - if(_level == 0) - { - new_keypoint.tracking_status = false; - } - - break; - } - - // Compute image mismatch vector - int ib1 = 0; - int ib2 = 0; - - std::tie(ib1, ib2) = compute_image_mismatch_vector(old_keypoint, new_keypoint, bilinear_ix.data(), bilinear_iy.data()); - - double b1 = ib1 * FLT_SCALE; - double b2 = ib2 * FLT_SCALE; - - // Compute motion vector -> A^-1 * -b - const float delta_x = (A12 * b2 - A22 * b1) / D; - const float delta_y = (A12 * b1 - A11 * b2) / D; - - // Update the new position - new_keypoint.x += delta_x; - new_keypoint.y += delta_y; - - const float mag2 = delta_x * delta_x + delta_y * delta_y; - - // Check if termination criteria is EPSILON and if it is satisfied - if(mag2 <= _epsilon && (_termination == Termination::TERM_CRITERIA_EPSILON || _termination == Termination::TERM_CRITERIA_BOTH)) - { - break; - } - - // Check convergence analyzing the previous delta - if(j > 0 && std::fabs(delta_x + prev_delta_x) < 0.01f && std::fabs(delta_y + prev_delta_y) < 0.01f) - { - new_keypoint.x -= delta_x * _pyramid_scale; - new_keypoint.y -= delta_y * _pyramid_scale; - break; - } - - prev_delta_x = delta_x; - prev_delta_y = delta_y; - } - } - - if(_level == 0) - { - for(int list_indx = list_start; list_indx < list_end; ++list_indx) - { - const NELKInternalKeypoint &new_keypoint = _new_points_internal->at(list_indx); - - _new_points->at(list_indx).x = roundf(new_keypoint.x); - _new_points->at(list_indx).y = roundf(new_keypoint.y); - _new_points->at(list_indx).tracking_status = new_keypoint.tracking_status ? 1 : 0; - } - } -} diff --git a/src/core/NEON/kernels/NELKTrackerKernel.h b/src/core/NEON/kernels/NELKTrackerKernel.h deleted file mode 100644 index bc4f6ce296..0000000000 --- a/src/core/NEON/kernels/NELKTrackerKernel.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2016-2021 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_LKTRACKERKERNEL_H -#define ARM_COMPUTE_LKTRACKERKERNEL_H - -#include "arm_compute/core/IArray.h" -#include "arm_compute/core/Types.h" -#include "src/core/NEON/INEKernel.h" - -#include -#include -#include -#include - -namespace arm_compute -{ -class ITensor; - -/** Interface for Neon Array of Internal Key Points. */ -using INELKInternalKeypointArray = IArray; - -/** Interface for the Lucas-Kanade tracker kernel */ -class NELKTrackerKernel : public INEKernel -{ -public: - const char *name() const override - { - return "NELKTrackerKernel"; - } - /** Default constructor */ - NELKTrackerKernel(); - /** Prevent instances of this class from being copied (As this class contains pointers) */ - NELKTrackerKernel(const NELKTrackerKernel &) = delete; - /** Prevent instances of this class from being copied (As this class contains pointers) */ - NELKTrackerKernel &operator=(const NELKTrackerKernel &) = delete; - /** Allow instances of this class to be moved */ - NELKTrackerKernel(NELKTrackerKernel &&) = default; - /** Allow instances of this class to be moved */ - NELKTrackerKernel &operator=(NELKTrackerKernel &&) = default; - /** Default destructor */ - ~NELKTrackerKernel() = default; - - /** Initialise the kernel input and output - * - * @param[in] input_old Pointer to the input old tensor. Data type supported: U8 - * @param[in] input_new Pointer to the input new tensor. Data type supported. U8 - * @param[in] old_scharr_gx Pointer to the input scharr X tensor. Data type supported: S16 - * @param[in] old_scharr_gy Pointer to the input scharr Y tensor. Data type supported: S16 - * @param[in] old_points Pointer to the IKeyPointArray storing old key points - * @param[in] new_points_estimates Pointer to the IKeyPointArray storing new estimates key points - * @param[out] new_points Pointer to the IKeyPointArray storing new key points - * @param[in, out] old_points_internal Pointer to the array of NELKInternalKeypoint for old points - * @param[out] new_points_internal Pointer to the array of NELKInternalKeypoint for new points - * @param[in] termination The criteria to terminate the search of each keypoint. - * @param[in] use_initial_estimate The flag to indicate whether the initial estimated position should be used - * @param[in] epsilon The error for terminating the algorithm - * @param[in] num_iterations The maximum number of iterations before terminate the algorithm - * @param[in] window_dimension The size of the window on which to perform the algorithm - * @param[in] level The pyramid level - * @param[in] num_levels The number of pyramid levels - * @param[in] pyramid_scale Scale factor used for generating the pyramid - */ - void configure(const ITensor *input_old, const ITensor *input_new, const ITensor *old_scharr_gx, const ITensor *old_scharr_gy, - const IKeyPointArray *old_points, const IKeyPointArray *new_points_estimates, IKeyPointArray *new_points, - INELKInternalKeypointArray *old_points_internal, INELKInternalKeypointArray *new_points_internal, - Termination termination, bool use_initial_estimate, float epsilon, unsigned int num_iterations, size_t window_dimension, - size_t level, size_t num_levels, float pyramid_scale); - - // Inherited methods overridden: - void run(const Window &window, const ThreadInfo &info) override; - BorderSize border_size() const override; - -private: - /** Initialise the array of keypoints in the provide range - * - * @param[in] start Index of first element in the keypoints array to be initialised - * @param[in] end Index after last elelemnt in the keypoints array to be initialised - */ - void init_keypoints(int start, int end); - /** Compute the structure tensor A^T * A based on the scharr gradients I_x and I_y - * - * @param[in] keypoint Keypoint for which gradients are computed - * @param[out] bilinear_ix Intermediate interpolated data for X gradient - * @param[out] bilinear_iy Intermediate interpolated data for Y gradient - * - * @return Values A11, A12, A22 - */ - std::tuple compute_spatial_gradient_matrix(const NELKInternalKeypoint &keypoint, int32_t *bilinear_ix, int32_t *bilinear_iy); - /** Compute the vector A^T * b, i.e. -sum(I_d * I_t) for d in {x,y} - * - * @param[in] old_keypoint Old keypoint for which gradient is computed - * @param[in] new_keypoint New keypoint for which gradient is computed - * @param[in] bilinear_ix Intermediate interpolated data for X gradient - * @param[in] bilinear_iy Intermediate interpolated data for Y gradient - * - * @return Values b1, b2 - */ - std::pair compute_image_mismatch_vector(const NELKInternalKeypoint &old_keypoint, const NELKInternalKeypoint &new_keypoint, const int32_t *bilinear_ix, const int32_t *bilinear_iy); - - const ITensor *_input_old; - const ITensor *_input_new; - const ITensor *_old_scharr_gx; - const ITensor *_old_scharr_gy; - IKeyPointArray *_new_points; - const IKeyPointArray *_new_points_estimates; - const IKeyPointArray *_old_points; - INELKInternalKeypointArray *_old_points_internal; - INELKInternalKeypointArray *_new_points_internal; - Termination _termination; - bool _use_initial_estimate; - float _pyramid_scale; - float _epsilon; - unsigned int _num_iterations; - int _window_dimension; - unsigned int _level; - unsigned int _num_levels; - ValidRegion _valid_region; -}; -} // namespace arm_compute -#endif /*ARM_COMPUTE_NELKTRACKERKERNEL_H */ diff --git a/src/core/NEON/kernels/NEROIPoolingLayerKernel.h b/src/core/NEON/kernels/NEROIPoolingLayerKernel.h index 2fcdb81eb6..e7a7e90eef 100644 --- a/src/core/NEON/kernels/NEROIPoolingLayerKernel.h +++ b/src/core/NEON/kernels/NEROIPoolingLayerKernel.h @@ -25,9 +25,6 @@ #define ARM_COMPUTE_NEROIPOOLINGLAYERKERNEL_H #include "src/core/NEON/INEKernel.h" - -#include "arm_compute/core/IArray.h" - namespace arm_compute { class ITensor; @@ -90,7 +87,7 @@ public: private: const ITensor *_input; const ITensor *_rois; - const ITensor *_output; + const ITensor *_output; ROIPoolingLayerInfo _pool_info; }; } // namespace arm_compute diff --git a/src/core/PyramidInfo.cpp b/src/core/PyramidInfo.cpp deleted file mode 100644 index 7a8fa0b608..0000000000 --- a/src/core/PyramidInfo.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2016, 2017 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/PyramidInfo.h" - -#include "arm_compute/core/Error.h" -#include "arm_compute/core/TensorShape.h" - -#include - -using namespace arm_compute; - -PyramidInfo::PyramidInfo() - : _num_levels(0), _tensor_shape(), _format(Format::UNKNOWN), _scale(0.0f) -{ -} - -PyramidInfo::PyramidInfo(size_t num_levels, float scale, size_t width, size_t height, Format format) - : PyramidInfo() -{ - init(num_levels, scale, width, height, format); -} - -PyramidInfo::PyramidInfo(size_t num_levels, float scale, const TensorShape &tensor_shape, Format format) - : PyramidInfo() -{ - init(num_levels, scale, tensor_shape, format); -} - -void PyramidInfo::init(size_t num_levels, float scale, size_t width, size_t height, Format format) -{ - init(num_levels, scale, TensorShape(width, height), format); -} - -void PyramidInfo::init(size_t num_levels, float scale, const TensorShape &tensor_shape, Format format) -{ - ARM_COMPUTE_ERROR_ON(0 == num_levels); - ARM_COMPUTE_ERROR_ON(0.0f == scale); - ARM_COMPUTE_ERROR_ON(0 == tensor_shape.x()); - ARM_COMPUTE_ERROR_ON(0 == tensor_shape.y()); - ARM_COMPUTE_ERROR_ON(Format::IYUV == format); - ARM_COMPUTE_ERROR_ON(Format::NV12 == format); - ARM_COMPUTE_ERROR_ON(Format::NV21 == format); - ARM_COMPUTE_ERROR_ON(Format::UYVY422 == format); - ARM_COMPUTE_ERROR_ON(Format::YUV444 == format); - ARM_COMPUTE_ERROR_ON(Format::YUYV422 == format); - ARM_COMPUTE_ERROR_ON_MSG(0 != _num_levels, "PyramidInfo already initialized"); - ARM_COMPUTE_ERROR_ON(0 == (tensor_shape.x() * pow(scale, num_levels))); - ARM_COMPUTE_ERROR_ON(0 == (tensor_shape.y() * pow(scale, num_levels))); - - _num_levels = num_levels; - _format = format; - _scale = scale; - _tensor_shape = tensor_shape; -} - -size_t PyramidInfo::num_levels() const -{ - return _num_levels; -} - -size_t PyramidInfo::width() const -{ - return _tensor_shape.x(); -} - -size_t PyramidInfo::height() const -{ - return _tensor_shape.y(); -} - -const TensorShape &PyramidInfo::tensor_shape() const -{ - return _tensor_shape; -} - -Format PyramidInfo::format() const -{ - return _format; -} - -float PyramidInfo::scale() const -{ - return _scale; -} diff --git a/src/core/TensorInfo.cpp b/src/core/TensorInfo.cpp index bedfe147b0..c471615ee8 100644 --- a/src/core/TensorInfo.cpp +++ b/src/core/TensorInfo.cpp @@ -24,7 +24,6 @@ #include "arm_compute/core/TensorInfo.h" #include "arm_compute/core/Error.h" -#include "arm_compute/core/HOGInfo.h" #include "arm_compute/core/Helpers.h" #include "arm_compute/core/TensorInfo.h" #include "arm_compute/core/Validate.h" @@ -100,12 +99,6 @@ TensorInfo::TensorInfo(const TensorShape &tensor_shape, size_t num_channels, Dat _data_layout = data_layout; } -TensorInfo::TensorInfo(const HOGInfo &hog_info, unsigned int width, unsigned int height) - : TensorInfo() -{ - init(hog_info, width, height); -} - void TensorInfo::init(Format format) { init(TensorShape(), format); @@ -166,20 +159,6 @@ void TensorInfo::init(const TensorShape &tensor_shape, size_t num_channels, Data _valid_region = ValidRegion{ Coordinates(), _tensor_shape }; } -void TensorInfo::init(const HOGInfo &hog_info, unsigned int width, unsigned int height) -{ - // Number of cells for each block - const Size2D num_cells_per_block = hog_info.num_cells_per_block(); - - // Tensor Size = (Number of horizontal block positions) * (Number of vertical block positions) - const Size2D num_block_positions_per_img = hog_info.num_block_positions_per_image(Size2D(width, height)); - - // Number of tensor channels = (Number of cells per block) * (Number of bins per cell) - const size_t num_channels = num_cells_per_block.area() * hog_info.num_bins(); - - init(TensorShape(num_block_positions_per_img.width, num_block_positions_per_img.height), num_channels, DataType::F32); -} - size_t TensorInfo::init_auto_padding(const TensorShape &tensor_shape, Format format) { const size_t num_channels = num_channels_from_format(format); @@ -207,20 +186,6 @@ size_t TensorInfo::init_auto_padding(const TensorShape &tensor_shape, size_t num return _total_size; } -size_t TensorInfo::init_auto_padding(const HOGInfo &hog_info, unsigned int width, unsigned int height) -{ - // Number of cells for each block - const Size2D num_cells_per_block = hog_info.num_cells_per_block(); - - // Tensor Size = (Number of horizontal block positions) * (Number of vertical block positions) - const Size2D num_block_positions_per_img = hog_info.num_block_positions_per_image(Size2D(width, height)); - - // Number of tensor channels = (Number of cells per block) * (Number of bins per cell) - const size_t num_channels = num_cells_per_block.area() * hog_info.num_bins(); - - return init_auto_padding(TensorShape(num_block_positions_per_img.width, num_block_positions_per_img.height), num_channels, DataType::F32); -} - bool TensorInfo::auto_padding() { ARM_COMPUTE_ERROR_ON(!_is_resizable); diff --git a/src/core/TracePoint.cpp b/src/core/TracePoint.cpp index 69374fbc8c..c72c15f13d 100644 --- a/src/core/TracePoint.cpp +++ b/src/core/TracePoint.cpp @@ -23,14 +23,6 @@ */ #include "arm_compute/core/TracePoint.h" -#include "arm_compute/core/HOGInfo.h" -#include "arm_compute/core/IArray.h" -#include "arm_compute/core/IDistribution1D.h" -#include "arm_compute/core/IHOG.h" -#include "arm_compute/core/ILut.h" -#include "arm_compute/core/IMultiHOG.h" -#include "arm_compute/core/IMultiImage.h" -#include "arm_compute/core/IPyramid.h" #include "arm_compute/core/ITensor.h" #include "arm_compute/core/KernelDescriptors.h" #include "arm_compute/core/PixelValue.h" @@ -124,18 +116,8 @@ std::string to_ptr_string(const void *arg) } ARM_COMPUTE_TRACE_TO_STRING(ThresholdType) -ARM_COMPUTE_TRACE_TO_STRING(IDetectionWindowArray) -ARM_COMPUTE_TRACE_TO_STRING(ICoordinates2DArray) -ARM_COMPUTE_TRACE_TO_STRING(IMultiImage) using pair_uint = std::pair; ARM_COMPUTE_TRACE_TO_STRING(pair_uint) -ARM_COMPUTE_TRACE_TO_STRING(IKeyPointArray) -ARM_COMPUTE_TRACE_TO_STRING(IDistribution1D) -ARM_COMPUTE_TRACE_TO_STRING(IHOG) -ARM_COMPUTE_TRACE_TO_STRING(ILut) -ARM_COMPUTE_TRACE_TO_STRING(IPyramid) -ARM_COMPUTE_TRACE_TO_STRING(IMultiHOG) -ARM_COMPUTE_TRACE_TO_STRING(ISize2DArray) ARM_COMPUTE_TRACE_TO_STRING(MemoryGroup) ARM_COMPUTE_TRACE_TO_STRING(BoxNMSLimitInfo) ARM_COMPUTE_TRACE_TO_STRING(DepthwiseConvolutionReshapeInfo) @@ -236,18 +218,8 @@ ARM_COMPUTE_CONST_PTR_CLASS(ITensor) ARM_COMPUTE_CONST_PTR_CLASS(ITensorInfo) ARM_COMPUTE_CONST_PTR_CLASS(IWeightsManager) ARM_COMPUTE_CONST_PTR_CLASS(InternalKeypoint) -ARM_COMPUTE_CONST_PTR_CLASS(IDetectionWindowArray) -ARM_COMPUTE_CONST_PTR_CLASS(ICoordinates2DArray) -ARM_COMPUTE_CONST_PTR_CLASS(IMultiImage) ARM_COMPUTE_CONST_PTR_CLASS(Window) -ARM_COMPUTE_CONST_PTR_CLASS(IKeyPointArray) ARM_COMPUTE_CONST_PTR_CLASS(HOGInfo) -ARM_COMPUTE_CONST_PTR_CLASS(IDistribution1D) -ARM_COMPUTE_CONST_PTR_CLASS(IHOG) -ARM_COMPUTE_CONST_PTR_CLASS(ILut) -ARM_COMPUTE_CONST_PTR_CLASS(IPyramid) -ARM_COMPUTE_CONST_PTR_CLASS(IMultiHOG) -ARM_COMPUTE_CONST_PTR_CLASS(ISize2DArray) ARM_COMPUTE_CONST_PTR_CLASS(std::allocator) ARM_COMPUTE_CONST_PTR_CLASS(std::vector) diff --git a/src/core/Utils.cpp b/src/core/Utils.cpp index 8deb5979ac..e44c86db88 100644 --- a/src/core/Utils.cpp +++ b/src/core/Utils.cpp @@ -184,31 +184,6 @@ const std::string &string_from_activation_func(ActivationLayerInfo::ActivationFu return act_map[act]; } -const std::string &string_from_matrix_pattern(MatrixPattern pattern) -{ - static std::map pattern_map = - { - { MatrixPattern::BOX, "BOX" }, - { MatrixPattern::CROSS, "CROSS" }, - { MatrixPattern::DISK, "DISK" }, - { MatrixPattern::OTHER, "OTHER" }, - }; - - return pattern_map[pattern]; -} - -const std::string &string_from_non_linear_filter_function(NonLinearFilterFunction function) -{ - static std::map func_map = - { - { NonLinearFilterFunction::MAX, "MAX" }, - { NonLinearFilterFunction::MEDIAN, "MEDIAN" }, - { NonLinearFilterFunction::MIN, "MIN" }, - }; - - return func_map[function]; -} - const std::string &string_from_interpolation_policy(InterpolationPolicy policy) { static std::map interpolation_policy_map = diff --git a/src/core/Validate.cpp b/src/core/Validate.cpp index 8bb507921a..5a6486e11e 100644 --- a/src/core/Validate.cpp +++ b/src/core/Validate.cpp @@ -141,28 +141,6 @@ arm_compute::Status arm_compute::error_on_channel_not_in_known_format(const char return arm_compute::Status{}; } -arm_compute::Status arm_compute::error_on_invalid_multi_hog(const char *function, const char *file, const int line, - const arm_compute::IMultiHOG *multi_hog) -{ - ARM_COMPUTE_RETURN_ERROR_ON_LOC(nullptr == multi_hog, function, file, line); - ARM_COMPUTE_RETURN_ERROR_ON_LOC(0 == multi_hog->num_models(), function, file, line); - - for(size_t i = 1; i < multi_hog->num_models(); ++i) - { - ARM_COMPUTE_RETURN_ERROR_ON_LOC_MSG(multi_hog->model(0)->info()->phase_type() != multi_hog->model(i)->info()->phase_type(), - function, file, line, - "All HOG parameters must have the same phase type"); - ARM_COMPUTE_RETURN_ERROR_ON_LOC_MSG(multi_hog->model(0)->info()->normalization_type() != multi_hog->model(i)->info()->normalization_type(), - function, file, line, - "All HOG parameters must have the same normalization type"); - ARM_COMPUTE_RETURN_ERROR_ON_LOC_MSG((multi_hog->model(0)->info()->l2_hyst_threshold() != multi_hog->model(i)->info()->l2_hyst_threshold()) - && (multi_hog->model(0)->info()->normalization_type() == arm_compute::HOGNormType::L2HYS_NORM), - function, file, line, - "All HOG parameters must have the same l2 hysteresis threshold if you use L2 hysteresis normalization type"); - } - return arm_compute::Status{}; -} - arm_compute::Status arm_compute::error_on_unconfigured_kernel(const char *function, const char *file, const int line, const arm_compute::IKernel *kernel) { diff --git a/src/runtime/CL/CLDistribution1D.cpp b/src/runtime/CL/CLDistribution1D.cpp deleted file mode 100644 index 91d67cbd0a..0000000000 --- a/src/runtime/CL/CLDistribution1D.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2016, 2017 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/CLDistribution1D.h" - -#include "arm_compute/core/Error.h" -#include "arm_compute/runtime/CL/CLScheduler.h" - -using namespace arm_compute; - -CLDistribution1D::CLDistribution1D(size_t num_bins, int32_t offset, uint32_t range) - : ICLDistribution1D(num_bins, offset, range), _mem(CLScheduler::get().context(), CL_MEM_ALLOC_HOST_PTR | CL_MEM_READ_WRITE, num_bins * sizeof(int32_t)) -{ -} - -void CLDistribution1D::map(bool blocking) -{ - ICLDistribution1D::map(CLScheduler::get().queue(), blocking); -} - -void CLDistribution1D::unmap() -{ - ICLDistribution1D::unmap(CLScheduler::get().queue()); -} - -uint32_t *CLDistribution1D::do_map(cl::CommandQueue &q, bool blocking) -{ - ARM_COMPUTE_ERROR_ON(_mem.get() == nullptr); - return static_cast(q.enqueueMapBuffer(_mem, blocking ? CL_TRUE : CL_FALSE, CL_MAP_READ | CL_MAP_WRITE, 0, size())); -} - -void CLDistribution1D::do_unmap(cl::CommandQueue &q) -{ - ARM_COMPUTE_ERROR_ON(_mem.get() == nullptr); - q.enqueueUnmapMemObject(_mem, _mapping); -} - -cl::Buffer &CLDistribution1D::cl_buffer() -{ - return _mem; -} diff --git a/src/runtime/CL/CLHOG.cpp b/src/runtime/CL/CLHOG.cpp deleted file mode 100644 index 6a02d8ff44..0000000000 --- a/src/runtime/CL/CLHOG.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2017-2018 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "arm_compute/runtime/CL/CLHOG.h" - -#include "arm_compute/core/CL/OpenCL.h" -#include "arm_compute/core/Error.h" -#include "arm_compute/runtime/CL/CLScheduler.h" - -using namespace arm_compute; - -CLHOG::CLHOG() - : _info(), _buffer() -{ -} - -void CLHOG::init(const HOGInfo &input) -{ - ARM_COMPUTE_ERROR_ON(_buffer.get() != nullptr); - _info = input; - _buffer = cl::Buffer(CLScheduler::get().context(), CL_MEM_ALLOC_HOST_PTR | CL_MEM_READ_WRITE, info()->descriptor_size() * sizeof(float)); -} - -void CLHOG::free() -{ - ARM_COMPUTE_ERROR_ON(_buffer.get() == nullptr); - - _buffer = cl::Buffer(); -} - -const HOGInfo *CLHOG::info() const -{ - return &_info; -} - -const cl::Buffer &CLHOG::cl_buffer() const -{ - return _buffer; -} - -void CLHOG::map(bool blocking) -{ - ARM_COMPUTE_ERROR_ON(descriptor() != nullptr); - ICLHOG::map(CLScheduler::get().queue(), blocking); -} - -void CLHOG::unmap() -{ - ARM_COMPUTE_ERROR_ON(descriptor() == nullptr); - ICLHOG::unmap(CLScheduler::get().queue()); -} - -uint8_t *CLHOG::do_map(cl::CommandQueue &q, bool blocking) -{ - ARM_COMPUTE_ERROR_ON(_buffer.get() == nullptr); - return static_cast(q.enqueueMapBuffer(_buffer, blocking ? CL_TRUE : CL_FALSE, CL_MAP_READ | CL_MAP_WRITE, 0, info()->descriptor_size() * sizeof(float))); -} - -void CLHOG::do_unmap(cl::CommandQueue &q) -{ - ARM_COMPUTE_ERROR_ON(_buffer.get() == nullptr); - q.enqueueUnmapMemObject(_buffer, descriptor()); -} diff --git a/src/runtime/CL/CLLut.cpp b/src/runtime/CL/CLLut.cpp deleted file mode 100644 index eb9422cc37..0000000000 --- a/src/runtime/CL/CLLut.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2016, 2017 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/CLLut.h" - -#include "arm_compute/runtime/CL/CLScheduler.h" - -#include - -using namespace arm_compute; - -CLLut::CLLut() - : _allocator() -{ -} - -CLLut::CLLut(size_t num_elements, DataType data_type) - : _allocator() -{ - _allocator.init(num_elements, data_type); -} - -size_t CLLut::num_elements() const -{ - return _allocator.num_elements(); -} - -uint32_t CLLut::index_offset() const -{ - return (DataType::S16 == _allocator.type()) ? num_elements() / 2 : 0; -} - -size_t CLLut::size_in_bytes() const -{ - return _allocator.size(); -} - -DataType CLLut::type() const -{ - return _allocator.type(); -} - -const cl::Buffer &CLLut::cl_buffer() const -{ - return _allocator.cl_data(); -} - -void CLLut::clear() -{ - cl::CommandQueue &q = CLScheduler::get().queue(); - uint8_t *data = _allocator.map(q, true /* blocking */); - std::memset(data, 0, size_in_bytes()); - _allocator.unmap(q, data); -} - -ILutAllocator *CLLut::allocator() -{ - return &_allocator; -} - -void CLLut::map(bool blocking) -{ - ICLLut::map(CLScheduler::get().queue(), blocking); -} - -void CLLut::unmap() -{ - ICLLut::unmap(CLScheduler::get().queue()); -} - -uint8_t *CLLut::do_map(cl::CommandQueue &q, bool blocking) -{ - return _allocator.map(q, blocking); -} - -void CLLut::do_unmap(cl::CommandQueue &q) -{ - _allocator.unmap(q, buffer()); -} diff --git a/src/runtime/CL/CLLutAllocator.cpp b/src/runtime/CL/CLLutAllocator.cpp deleted file mode 100644 index d690cf2f1d..0000000000 --- a/src/runtime/CL/CLLutAllocator.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2016, 2017 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/CLLutAllocator.h" - -#include "arm_compute/core/Error.h" -#include "arm_compute/runtime/CL/CLScheduler.h" - -using namespace arm_compute; - -CLLutAllocator::CLLutAllocator() - : _buffer(), _mapping(nullptr) -{ -} - -uint8_t *CLLutAllocator::data() -{ - return _mapping; -} - -const cl::Buffer &CLLutAllocator::cl_data() const -{ - return _buffer; -} - -uint8_t *CLLutAllocator::map(cl::CommandQueue &q, bool blocking) -{ - ARM_COMPUTE_ERROR_ON(_buffer.get() == nullptr); - return static_cast(q.enqueueMapBuffer(_buffer, blocking ? CL_TRUE : CL_FALSE, CL_MAP_READ | CL_MAP_WRITE, 0, size())); -} - -void CLLutAllocator::unmap(cl::CommandQueue &q, uint8_t *mapping) -{ - ARM_COMPUTE_ERROR_ON(_buffer.get() == nullptr); - q.enqueueUnmapMemObject(_buffer, mapping); -} - -void CLLutAllocator::allocate() -{ - _buffer = cl::Buffer(CLScheduler::get().context(), CL_MEM_ALLOC_HOST_PTR | CL_MEM_READ_WRITE, size()); -} - -uint8_t *CLLutAllocator::lock() -{ - ARM_COMPUTE_ERROR_ON(_mapping != nullptr); - cl::CommandQueue q = CLScheduler::get().queue(); - _mapping = map(q, true); - return _mapping; -} - -void CLLutAllocator::unlock() -{ - ARM_COMPUTE_ERROR_ON(_mapping == nullptr); - cl::CommandQueue q = CLScheduler::get().queue(); - unmap(q, _mapping); - _mapping = nullptr; -} diff --git a/src/runtime/CL/CLMultiHOG.cpp b/src/runtime/CL/CLMultiHOG.cpp deleted file mode 100644 index 28a802ca1e..0000000000 --- a/src/runtime/CL/CLMultiHOG.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2017-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/CLMultiHOG.h" - -#include "arm_compute/core/CL/ICLHOG.h" -#include "arm_compute/core/Error.h" - -using namespace arm_compute; - -CLMultiHOG::CLMultiHOG(size_t num_models) - : _num_models(num_models), _model() -{ - _model.resize(_num_models); -} - -size_t CLMultiHOG::num_models() const -{ - return _num_models; -} - -ICLHOG *CLMultiHOG::cl_model(size_t index) -{ - ARM_COMPUTE_ERROR_ON(index >= _num_models); - return (&_model[index]); -} - -const ICLHOG *CLMultiHOG::cl_model(size_t index) const -{ - ARM_COMPUTE_ERROR_ON(index >= _num_models); - return (&_model[index]); -} diff --git a/src/runtime/CL/CLMultiImage.cpp b/src/runtime/CL/CLMultiImage.cpp deleted file mode 100644 index 28b3f854f2..0000000000 --- a/src/runtime/CL/CLMultiImage.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (c) 2016-2018 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/CLMultiImage.h" - -#include "arm_compute/core/Error.h" -#include "arm_compute/core/TensorInfo.h" -#include "arm_compute/core/Utils.h" -#include "arm_compute/runtime/ITensorAllocator.h" - -using namespace arm_compute; - -CLMultiImage::CLMultiImage() - : _info(), _plane() -{ -} - -const MultiImageInfo *CLMultiImage::info() const -{ - return &_info; -} - -void CLMultiImage::init(unsigned int width, unsigned int height, Format format) -{ - internal_init(width, height, format, false); -} - -void CLMultiImage::init_auto_padding(unsigned int width, unsigned int height, Format format) -{ - internal_init(width, height, format, true); -} - -void CLMultiImage::internal_init(unsigned int width, unsigned int height, Format format, bool auto_padding) -{ - TensorShape shape = adjust_odd_shape(TensorShape{ width, height }, format); - TensorInfo info(shape, Format::U8); - - if(auto_padding) - { - info.auto_padding(); - } - - switch(format) - { - case Format::U8: - case Format::S16: - case Format::U16: - case Format::S32: - case Format::F16: - case Format::F32: - case Format::U32: - case Format::RGB888: - case Format::RGBA8888: - case Format::YUYV422: - case Format::UYVY422: - { - TensorInfo info_full(shape, format); - - if(auto_padding) - { - info_full.auto_padding(); - } - - std::get<0>(_plane).allocator()->init(info_full); - break; - } - case Format::NV12: - case Format::NV21: - { - const TensorShape shape_uv88 = calculate_subsampled_shape(shape, Format::UV88); - TensorInfo info_uv88(shape_uv88, Format::UV88); - - if(auto_padding) - { - info_uv88.auto_padding(); - } - - std::get<0>(_plane).allocator()->init(info); - std::get<1>(_plane).allocator()->init(info_uv88); - break; - } - case Format::IYUV: - { - const TensorShape shape_sub2 = calculate_subsampled_shape(shape, Format::IYUV); - TensorInfo info_sub2(shape_sub2, Format::U8); - - if(auto_padding) - { - info_sub2.auto_padding(); - } - - std::get<0>(_plane).allocator()->init(info); - std::get<1>(_plane).allocator()->init(info_sub2); - std::get<2>(_plane).allocator()->init(info_sub2); - break; - } - case Format::YUV444: - std::get<0>(_plane).allocator()->init(info); - std::get<1>(_plane).allocator()->init(info); - std::get<2>(_plane).allocator()->init(info); - break; - default: - ARM_COMPUTE_ERROR("Not supported"); - break; - } - - _info.init(shape.x(), shape.y(), format); -} - -void CLMultiImage::allocate() -{ - switch(_info.format()) - { - case Format::U8: - case Format::S16: - case Format::U16: - case Format::S32: - case Format::F16: - case Format::F32: - case Format::U32: - case Format::RGB888: - case Format::RGBA8888: - case Format::YUYV422: - case Format::UYVY422: - std::get<0>(_plane).allocator()->allocate(); - break; - case Format::NV12: - case Format::NV21: - std::get<0>(_plane).allocator()->allocate(); - std::get<1>(_plane).allocator()->allocate(); - break; - case Format::IYUV: - case Format::YUV444: - std::get<0>(_plane).allocator()->allocate(); - std::get<1>(_plane).allocator()->allocate(); - std::get<2>(_plane).allocator()->allocate(); - break; - default: - ARM_COMPUTE_ERROR("Not supported"); - break; - } -} - -CLImage *CLMultiImage::cl_plane(unsigned int index) -{ - return &_plane[index]; -} - -const CLImage *CLMultiImage::cl_plane(unsigned int index) const -{ - return &_plane[index]; -} diff --git a/src/runtime/CL/CLPyramid.cpp b/src/runtime/CL/CLPyramid.cpp deleted file mode 100644 index dfa542e73c..0000000000 --- a/src/runtime/CL/CLPyramid.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/CLPyramid.h" - -#include "arm_compute/core/Error.h" -#include "arm_compute/core/PyramidInfo.h" -#include "arm_compute/core/TensorInfo.h" -#include "arm_compute/core/TensorShape.h" - -#include -#include - -using namespace arm_compute; - -CLPyramid::CLPyramid() - : _info(), _pyramid() -{ -} - -void CLPyramid::init(const PyramidInfo &info) -{ - internal_init(info, false); -} - -void CLPyramid::init_auto_padding(const PyramidInfo &info) -{ - internal_init(info, true); -} - -void CLPyramid::internal_init(const PyramidInfo &info, bool auto_padding) -{ - _info = info; - _pyramid.resize(_info.num_levels()); - - size_t w = _info.width(); - size_t h = _info.height(); - size_t ref_w = w; - size_t ref_h = h; - const bool is_orb_scale = (SCALE_PYRAMID_ORB == _info.scale()); - TensorShape tensor_shape = _info.tensor_shape(); - - // Note: Look-up table used by the OpenVX sample implementation - const std::array c_orbscale = - { - { - 0.5f, - SCALE_PYRAMID_ORB, - SCALE_PYRAMID_ORB * SCALE_PYRAMID_ORB, - SCALE_PYRAMID_ORB *SCALE_PYRAMID_ORB * SCALE_PYRAMID_ORB - } - }; - - for(size_t i = 0; i < _info.num_levels(); ++i) - { - TensorInfo tensor_info(tensor_shape, _info.format()); - - if(auto_padding) - { - tensor_info.auto_padding(); - } - - _pyramid[i].allocator()->init(tensor_info); - - if(is_orb_scale) - { - const float orb_scale = c_orbscale[(i + 1) % 4]; - w = std::ceil(ref_w * orb_scale); - h = std::ceil(ref_h * orb_scale); - - if(0 == ((i + 1) % 4)) - { - ref_w = w; - ref_h = h; - } - } - else - { - w = (w + 1) * _info.scale(); - h = (h + 1) * _info.scale(); - } - - // Update tensor_shape - tensor_shape.set(0, w); - tensor_shape.set(1, h); - } -} - -void CLPyramid::allocate() -{ - for(size_t i = 0; i < _info.num_levels(); ++i) - { - _pyramid[i].allocator()->allocate(); - } -} - -const PyramidInfo *CLPyramid::info() const -{ - return &_info; -} - -CLTensor *CLPyramid::get_pyramid_level(size_t index) const -{ - ARM_COMPUTE_ERROR_ON(index >= _info.num_levels()); - - return &_pyramid[index]; -} diff --git a/src/runtime/Distribution1D.cpp b/src/runtime/Distribution1D.cpp deleted file mode 100644 index c19862ce62..0000000000 --- a/src/runtime/Distribution1D.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/Distribution1D.h" - -#include "arm_compute/core/Error.h" - -#include - -using namespace arm_compute; - -Distribution1D::Distribution1D(size_t num_bins, int32_t offset, uint32_t range) - : IDistribution1D(num_bins, offset, range), _data(num_bins) -{ -} - -uint32_t *Distribution1D::buffer() const -{ - return _data.data(); -} diff --git a/src/runtime/HOG.cpp b/src/runtime/HOG.cpp deleted file mode 100644 index 74922767f9..0000000000 --- a/src/runtime/HOG.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/HOG.h" - -#include "arm_compute/core/Error.h" - -using namespace arm_compute; - -HOG::HOG() - : IHOG(), _info(), _descriptor() -{ -} - -void HOG::init(const HOGInfo &input) -{ - _info = input; - _descriptor.resize(_info.descriptor_size()); -} - -float *HOG::descriptor() const -{ - return _descriptor.data(); -} - -const HOGInfo *HOG::info() const -{ - return &_info; -} diff --git a/src/runtime/ILutAllocator.cpp b/src/runtime/ILutAllocator.cpp deleted file mode 100644 index 8ffb0744ed..0000000000 --- a/src/runtime/ILutAllocator.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2016, 2017 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/ILutAllocator.h" - -#include "arm_compute/core/Utils.h" - -using namespace arm_compute; - -ILutAllocator::ILutAllocator() - : _num_elements(0), _data_type(DataType::U8) -{ -} - -void ILutAllocator::init(size_t num_elements, DataType data_type) -{ - // Init internal metadata - _num_elements = num_elements; - _data_type = data_type; - - // Allocate the image's memory - allocate(); -} - -size_t ILutAllocator::num_elements() const -{ - return _num_elements; -} - -DataType ILutAllocator::type() const -{ - return _data_type; -} - -size_t ILutAllocator::size() const -{ - return data_size_from_type(_data_type) * num_elements(); -} diff --git a/src/runtime/Lut.cpp b/src/runtime/Lut.cpp deleted file mode 100644 index 9c3d2d384d..0000000000 --- a/src/runtime/Lut.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2016, 2017 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/Lut.h" - -#include - -using namespace arm_compute; - -Lut::Lut() - : _allocator() -{ -} - -Lut::Lut(size_t num_elements, DataType data_type) - : _allocator() -{ - _allocator.init(num_elements, data_type); -} - -size_t Lut::num_elements() const -{ - return _allocator.num_elements(); -} - -uint32_t Lut::index_offset() const -{ - return (DataType::S16 == _allocator.type()) ? num_elements() / 2 : 0; -} - -size_t Lut::size_in_bytes() const -{ - return _allocator.size(); -} - -DataType Lut::type() const -{ - return _allocator.type(); -} - -uint8_t *Lut::buffer() const -{ - return _allocator.data(); -} - -void Lut::clear() -{ - ARM_COMPUTE_ERROR_ON(this->buffer() == nullptr); - std::memset(this->buffer(), 0, this->size_in_bytes()); -} - -ILutAllocator *Lut::allocator() -{ - return &_allocator; -} diff --git a/src/runtime/LutAllocator.cpp b/src/runtime/LutAllocator.cpp deleted file mode 100644 index cc0c24f89b..0000000000 --- a/src/runtime/LutAllocator.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/LutAllocator.h" - -using namespace arm_compute; - -LutAllocator::LutAllocator() - : _buffer() -{ -} - -uint8_t *LutAllocator::data() const -{ - return _buffer.data(); -} - -void LutAllocator::allocate() -{ - _buffer.resize(size()); -} - -uint8_t *LutAllocator::lock() -{ - return _buffer.data(); -} - -void LutAllocator::unlock() -{ -} diff --git a/src/runtime/MultiHOG.cpp b/src/runtime/MultiHOG.cpp deleted file mode 100644 index d68b755b27..0000000000 --- a/src/runtime/MultiHOG.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/MultiHOG.h" - -#include "arm_compute/core/Error.h" -#include "arm_compute/core/IMultiHOG.h" - -using namespace arm_compute; - -MultiHOG::MultiHOG(size_t num_models) - : _num_models(num_models), _model() -{ - _model.resize(_num_models); -} - -size_t MultiHOG::num_models() const -{ - return _num_models; -} - -IHOG *MultiHOG::model(size_t index) -{ - ARM_COMPUTE_ERROR_ON(index >= _num_models); - return (&_model[index]); -} - -const IHOG *MultiHOG::model(size_t index) const -{ - ARM_COMPUTE_ERROR_ON(index >= _num_models); - return (&_model[index]); -} diff --git a/src/runtime/MultiImage.cpp b/src/runtime/MultiImage.cpp deleted file mode 100644 index 66e67ed8ba..0000000000 --- a/src/runtime/MultiImage.cpp +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright (c) 2016-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/MultiImage.h" - -#include "arm_compute/core/Error.h" -#include "arm_compute/core/TensorInfo.h" -#include "arm_compute/core/Utils.h" -#include "arm_compute/runtime/TensorAllocator.h" - -using namespace arm_compute; - -MultiImage::MultiImage() - : _info(), _plane() -{ -} - -const MultiImageInfo *MultiImage::info() const -{ - return &_info; -} - -void MultiImage::init(unsigned int width, unsigned int height, Format format) -{ - internal_init(width, height, format, false); -} - -void MultiImage::init_auto_padding(unsigned int width, unsigned int height, Format format) -{ - internal_init(width, height, format, true); -} - -void MultiImage::internal_init(unsigned int width, unsigned int height, Format format, bool auto_padding) -{ - TensorShape shape = adjust_odd_shape(TensorShape{ width, height }, format); - TensorInfo info(shape, Format::U8); - - if(auto_padding) - { - info.auto_padding(); - } - - switch(format) - { - case Format::U8: - case Format::S16: - case Format::U16: - case Format::S32: - case Format::F16: - case Format::F32: - case Format::U32: - case Format::RGB888: - case Format::RGBA8888: - case Format::YUYV422: - case Format::UYVY422: - { - TensorInfo info_full(shape, format); - - if(auto_padding) - { - info_full.auto_padding(); - } - - std::get<0>(_plane).allocator()->init(info_full); - break; - } - case Format::NV12: - case Format::NV21: - { - const TensorShape shape_uv88 = calculate_subsampled_shape(shape, Format::UV88); - TensorInfo info_uv88(shape_uv88, Format::UV88); - - if(auto_padding) - { - info_uv88.auto_padding(); - } - - std::get<0>(_plane).allocator()->init(info); - std::get<1>(_plane).allocator()->init(info_uv88); - break; - } - case Format::IYUV: - { - const TensorShape shape_sub2 = calculate_subsampled_shape(shape, Format::IYUV); - TensorInfo info_sub2(shape_sub2, Format::U8); - - if(auto_padding) - { - info_sub2.auto_padding(); - } - - std::get<0>(_plane).allocator()->init(info); - std::get<1>(_plane).allocator()->init(info_sub2); - std::get<2>(_plane).allocator()->init(info_sub2); - break; - } - case Format::YUV444: - std::get<0>(_plane).allocator()->init(info); - std::get<1>(_plane).allocator()->init(info); - std::get<2>(_plane).allocator()->init(info); - break; - default: - ARM_COMPUTE_ERROR("Not supported"); - break; - } - - _info.init(shape.x(), shape.y(), format); -} - -void MultiImage::allocate() -{ - switch(_info.format()) - { - case Format::U8: - case Format::S16: - case Format::U16: - case Format::S32: - case Format::F16: - case Format::F32: - case Format::U32: - case Format::RGB888: - case Format::RGBA8888: - case Format::YUYV422: - case Format::UYVY422: - std::get<0>(_plane).allocator()->allocate(); - break; - case Format::NV12: - case Format::NV21: - std::get<0>(_plane).allocator()->allocate(); - std::get<1>(_plane).allocator()->allocate(); - break; - case Format::IYUV: - case Format::YUV444: - std::get<0>(_plane).allocator()->allocate(); - std::get<1>(_plane).allocator()->allocate(); - std::get<2>(_plane).allocator()->allocate(); - break; - default: - ARM_COMPUTE_ERROR("Not supported"); - break; - } -} - -void MultiImage::create_subimage(MultiImage *image, const Coordinates &coords, unsigned int width, unsigned int height) -{ - arm_compute::Format format = image->info()->format(); - TensorInfo info(width, height, Format::U8); - - switch(format) - { - case Format::U8: - case Format::S16: - case Format::U16: - case Format::S32: - case Format::F32: - case Format::F16: - case Format::U32: - case Format::RGB888: - case Format::RGBA8888: - case Format::YUYV422: - case Format::UYVY422: - { - TensorInfo info_full(width, height, format); - std::get<0>(_plane).allocator()->init(*dynamic_cast(image->plane(0))->allocator(), coords, info_full); - break; - } - case Format::NV12: - case Format::NV21: - { - TensorInfo info_uv88(width / 2, height / 2, Format::UV88); - std::get<0>(_plane).allocator()->init(*dynamic_cast(image->plane(0))->allocator(), coords, info); - std::get<1>(_plane).allocator()->init(*dynamic_cast(image->plane(1))->allocator(), coords, info_uv88); - break; - } - case Format::IYUV: - { - TensorInfo info_sub2(width / 2, height / 2, Format::U8); - std::get<0>(_plane).allocator()->init(*dynamic_cast(image->plane(0))->allocator(), coords, info); - std::get<1>(_plane).allocator()->init(*dynamic_cast(image->plane(1))->allocator(), coords, info_sub2); - std::get<2>(_plane).allocator()->init(*dynamic_cast(image->plane(2))->allocator(), coords, info_sub2); - break; - } - case Format::YUV444: - std::get<0>(_plane).allocator()->init(*dynamic_cast(image->plane(0))->allocator(), coords, info); - std::get<1>(_plane).allocator()->init(*dynamic_cast(image->plane(0))->allocator(), coords, info); - std::get<2>(_plane).allocator()->init(*dynamic_cast(image->plane(0))->allocator(), coords, info); - break; - default: - ARM_COMPUTE_ERROR("Not supported"); - break; - } - - _info.init(width, height, format); -} - -Image *MultiImage::plane(unsigned int index) -{ - return &_plane[index]; -} - -const Image *MultiImage::plane(unsigned int index) const -{ - return &_plane[index]; -} diff --git a/src/runtime/Pyramid.cpp b/src/runtime/Pyramid.cpp deleted file mode 100644 index 5664b5f899..0000000000 --- a/src/runtime/Pyramid.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2016-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/Pyramid.h" - -#include "arm_compute/core/Error.h" -#include "arm_compute/core/PyramidInfo.h" -#include "arm_compute/core/TensorInfo.h" -#include "arm_compute/core/TensorShape.h" - -#include - -using namespace arm_compute; - -void Pyramid::init(const PyramidInfo &info) -{ - internal_init(info, false); -} - -void Pyramid::init_auto_padding(const PyramidInfo &info) -{ - internal_init(info, true); -} - -void Pyramid::internal_init(const PyramidInfo &info, bool auto_padding) -{ - _info = info; - _pyramid.resize(_info.num_levels()); - - size_t w = _info.width(); - size_t h = _info.height(); - size_t ref_w = w; - size_t ref_h = h; - bool is_orb_scale = (SCALE_PYRAMID_ORB == _info.scale()); - TensorShape tensor_shape = _info.tensor_shape(); - - // Note: Look-up table used by the OpenVX sample implementation - const std::array c_orbscale = { 0.5f, - SCALE_PYRAMID_ORB, - SCALE_PYRAMID_ORB * SCALE_PYRAMID_ORB, - SCALE_PYRAMID_ORB *SCALE_PYRAMID_ORB * SCALE_PYRAMID_ORB - }; - - for(size_t i = 0; i < _info.num_levels(); ++i) - { - TensorInfo tensor_info(tensor_shape, _info.format()); - - if(auto_padding) - { - tensor_info.auto_padding(); - } - - _pyramid[i].allocator()->init(tensor_info); - - if(is_orb_scale) - { - float orb_scale = c_orbscale[(i + 1) % 4]; - w = static_cast(std::ceil(static_cast(ref_w) * orb_scale)); - h = static_cast(std::ceil(static_cast(ref_h) * orb_scale)); - - if(0 == ((i + 1) % 4)) - { - ref_w = w; - ref_h = h; - } - } - else - { - w = (w + 1) * _info.scale(); - h = (h + 1) * _info.scale(); - } - - // Update tensor_shape - tensor_shape.set(0, w); - tensor_shape.set(1, h); - } -} - -void Pyramid::allocate() -{ - for(size_t i = 0; i < _info.num_levels(); ++i) - { - _pyramid[i].allocator()->allocate(); - } -} - -const PyramidInfo *Pyramid::info() const -{ - return &_info; -} - -Tensor *Pyramid::get_pyramid_level(size_t index) const -{ - ARM_COMPUTE_ERROR_ON(index >= _info.num_levels()); - - return &_pyramid[index]; -} diff --git a/tests/CL/CLHOGAccessor.h b/tests/CL/CLHOGAccessor.h deleted file mode 100644 index 2b594955f6..0000000000 --- a/tests/CL/CLHOGAccessor.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2018-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_CLHOGACCESSOR_H -#define ARM_COMPUTE_TEST_CLHOGACCESSOR_H - -#include "arm_compute/runtime/CL/CLHOG.h" -#include "tests/IHOGAccessor.h" - -namespace arm_compute -{ -namespace test -{ -/** Accessor implementation for @ref CLHOG objects. */ -class CLHOGAccessor : public IHOGAccessor -{ -public: - /** Create an accessor for the given @p CLHOG. */ - CLHOGAccessor(CLHOG &hog) - : _hog{ hog } - { - _hog.map(); - } - - /** Destructor that unmaps the CL memory. */ - ~CLHOGAccessor() - { - _hog.unmap(); - } - - /** Prevent instances of this class from being copied (As this class contains references). */ - CLHOGAccessor(const CLHOGAccessor &) = delete; - /** Prevent instances of this class from being copied (As this class contains references). */ - CLHOGAccessor &operator=(const CLHOGAccessor &) = delete; - - /** Pointer to the first element of the array which stores the linear SVM coefficients of HOG descriptor - * - * @return A pointer to the first element of the array which stores the linear SVM coefficients of HOG descriptor - */ - float *descriptor() const override - { - return _hog.descriptor(); - } - -private: - CLHOG &_hog; -}; -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_CLHOGACCESSOR_H */ diff --git a/tests/CL/CLLutAccessor.h b/tests/CL/CLLutAccessor.h deleted file mode 100644 index 78cd85d405..0000000000 --- a/tests/CL/CLLutAccessor.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_CL_CLLUTACCESSOR_H -#define ARM_COMPUTE_TEST_CL_CLLUTACCESSOR_H - -#include "tests/ILutAccessor.h" - -#include "arm_compute/runtime/CL/CLLut.h" - -namespace arm_compute -{ -namespace test -{ -/** Accessor implementation for @ref CLLut objects. */ -template -class CLLutAccessor : public ILutAccessor -{ -public: - /** Create an accessor for the given @p CLLut. - */ - CLLutAccessor(CLLut &lut) - : _lut{ lut } - { - _lut.map(true); - } - /** Default destructor */ - ~CLLutAccessor() - { - _lut.unmap(); - } - - /** Prevent instances of this class from being copy constructed */ - CLLutAccessor(const CLLutAccessor &) = delete; - /** Prevent instances of this class from being copied */ - CLLutAccessor &operator=(const CLLutAccessor &) = delete; - /** Allow instances of this class to be move constructed */ - CLLutAccessor(CLLutAccessor &&) = default; - /** Allow instance of this class to be moved */ - CLLutAccessor &operator=(CLLutAccessor &&) = default; - - int num_elements() const override - { - return _lut.num_elements(); - } - - const T &operator[](T input_value) const override - { - auto lut = reinterpret_cast(_lut.buffer()); - int32_t real_index = _lut.index_offset() + static_cast(input_value); - - if(0 <= real_index && real_index < num_elements()) - { - return lut[real_index]; - } - ARM_COMPUTE_ERROR("Error index not in range."); - } - - T &operator[](T input_value) override - { - auto lut = reinterpret_cast(_lut.buffer()); - int32_t real_index = _lut.index_offset() + static_cast(input_value); - - if(0 <= real_index && real_index < num_elements()) - { - return lut[real_index]; - } - ARM_COMPUTE_ERROR("Error index not in range."); - } - -private: - CLLut &_lut; -}; -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_CL_CLLUTACCESSOR_H */ diff --git a/tests/IHOGAccessor.h b/tests/IHOGAccessor.h deleted file mode 100644 index f1c137c2ed..0000000000 --- a/tests/IHOGAccessor.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2018-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_IHOGACCESSOR_H -#define ARM_COMPUTE_TEST_IHOGACCESSOR_H - -namespace arm_compute -{ -namespace test -{ -/** Common interface to access HOG structure */ -class IHOGAccessor -{ -public: - /** Virtual destructor. */ - virtual ~IHOGAccessor() = default; - - /** Pointer to the first element of the array which stores the linear SVM coefficients of HOG descriptor - * - * @note Other elements of the array can be accessed using descriptor()[idx] for idx=[0, descriptor_size() - 1] - * - * @return A pointer to the first element of the array which stores the linear SVM coefficients of HOG descriptor - */ - virtual float *descriptor() const = 0; -}; -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_IHOGACCESSOR_H */ diff --git a/tests/ILutAccessor.h b/tests/ILutAccessor.h deleted file mode 100644 index 39fa202d2c..0000000000 --- a/tests/ILutAccessor.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_ILUTACCESSOR_H -#define ARM_COMPUTE_TEST_ILUTACCESSOR_H - -#include "arm_compute/core/Coordinates.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -/** Common interface to provide information and access to Lut like - * structures. - */ -template -class ILutAccessor -{ -public: - /** Lut value type */ - using value_type = T; - - /** Pure virtual destructor. */ - virtual ~ILutAccessor() = default; - - /** Number of elements of the Lut. - * - * @return the number of elements. - */ - virtual int num_elements() const = 0; - - /** Read access to the specified element. - * - * @param[in] input_value Lut input value, from numericlimits:min to numericlimits:max. - * - * @return Output desired element. - */ - virtual const T &operator[](T input_value) const = 0; - - /** Write access to the specified element. - * - * @param[in] input_value Lut input value, from numericlimits:min to numericlimits:max. - * - * @return Output desired element. - */ - virtual T &operator[](T input_value) = 0; -}; - -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_ILUTACCESSOR_H */ diff --git a/tests/NEON/HOGAccessor.h b/tests/NEON/HOGAccessor.h deleted file mode 100644 index 735abb08d3..0000000000 --- a/tests/NEON/HOGAccessor.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2018-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_HOGACCESSOR_H -#define ARM_COMPUTE_TEST_HOGACCESSOR_H - -#include "arm_compute/runtime/HOG.h" -#include "tests/IHOGAccessor.h" - -namespace arm_compute -{ -namespace test -{ -/** Accessor implementation for @ref HOG objects. */ -class HOGAccessor : public IHOGAccessor -{ -public: - /** Create an accessor for the given @p HOG. - */ - HOGAccessor(HOG &hog) - : _hog{ hog } - { - } - - /** Prevent instances of this class from being copied (As this class contains references). */ - HOGAccessor(const HOGAccessor &) = delete; - /** Prevent instances of this class from being copied (As this class contains references). */ - HOGAccessor &operator=(const HOGAccessor &) = delete; - - /** Pointer to the first element of the array which stores the linear SVM coefficients of HOG descriptor - * - * @return A pointer to the first element of the array which stores the linear SVM coefficients of HOG descriptor - */ - float *descriptor() const override - { - return _hog.descriptor(); - } - -private: - HOG &_hog; -}; -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_HOGACCESSOR_H */ diff --git a/tests/NEON/LutAccessor.h b/tests/NEON/LutAccessor.h deleted file mode 100644 index 5204d0640c..0000000000 --- a/tests/NEON/LutAccessor.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_NEON_LUTACCESSOR_H -#define ARM_COMPUTE_TEST_NEON_LUTACCESSOR_H - -#include "tests/ILutAccessor.h" - -#include "arm_compute/runtime/Lut.h" - -namespace arm_compute -{ -namespace test -{ -/** Accessor implementation for @ref Lut objects. */ -template -class LutAccessor : public ILutAccessor -{ -public: - /** Create an accessor for the given @p Lut. - */ - LutAccessor(Lut &lut) - : _lut{ lut } - { - } - - /** Prevent instances of this class from being copy constructed */ - LutAccessor(const LutAccessor &) = delete; - /** Prevent instances of this class from being copied */ - LutAccessor &operator=(const LutAccessor &) = delete; - /** Allow instances of this class to be move constructed */ - LutAccessor(LutAccessor &&) = default; - /** Allow instances of this class to be moved */ - LutAccessor &operator=(LutAccessor &&) = default; - - int num_elements() const override - { - return _lut.num_elements(); - } - - const T &operator[](T input_value) const override - { - auto lut = reinterpret_cast(_lut.buffer()); - int32_t real_index = _lut.index_offset() + static_cast(input_value); - - if(0 <= real_index && real_index < num_elements()) - { - return lut[real_index]; - } - ARM_COMPUTE_ERROR("Error index not in range."); - } - - T &operator[](T input_value) override - { - auto lut = reinterpret_cast(_lut.buffer()); - int32_t real_index = _lut.index_offset() + static_cast(input_value); - - if(0 <= real_index && real_index < num_elements()) - { - return lut[real_index]; - } - ARM_COMPUTE_ERROR("Error index not in range."); - } - -private: - ILut &_lut; -}; -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_NEON_LUTACCESSOR_H */ diff --git a/tests/RawLutAccessor.h b/tests/RawLutAccessor.h deleted file mode 100644 index 4318fb2dcc..0000000000 --- a/tests/RawLutAccessor.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_RAWLUTACCESSOR_H -#define ARM_COMPUTE_TEST_RAWLUTACCESSOR_H - -#include "ILutAccessor.h" - -#include - -namespace arm_compute -{ -namespace test -{ -/** Accessor implementation for std::map-lut objects. */ -template -class RawLutAccessor : public ILutAccessor -{ -public: - /** Create an accessor for the given @p std::map. - */ - RawLutAccessor(std::map &lut) - : _lut{ lut } - { - } - - /** Prevent instances of this class from being copy constructed */ - RawLutAccessor(const RawLutAccessor &) = delete; - /** Prevent instances of this class from being copied */ - RawLutAccessor &operator=(const RawLutAccessor &) = delete; - /** Allow instances of this class to be move constructed */ - RawLutAccessor(RawLutAccessor &&) = default; - /** Allow instances of this class to be moved */ - RawLutAccessor &operator=(RawLutAccessor &&) = default; - - int num_elements() const override - { - return _lut.size(); - } - - const T &operator[](T input_value) const override - { - return _lut[input_value]; - } - - T &operator[](T input_value) override - { - return _lut[input_value]; - } - -private: - std::map &_lut; -}; - -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_RAWLUTACCESSOR_H */ diff --git a/tests/TypePrinter.h b/tests/TypePrinter.h deleted file mode 100644 index 612360d4f0..0000000000 --- a/tests/TypePrinter.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_TYPE_PRINTER_H -#define ARM_COMPUTE_TEST_TYPE_PRINTER_H - -#include "tests/Types.h" - -namespace arm_compute -{ -/** Formatted output of the GradientDimension type. - * - * @param[out] os Output stream - * @param[in] dim Type to output - * - * @return Modified output stream. - */ -inline ::std::ostream &operator<<(::std::ostream &os, const GradientDimension &dim) -{ - switch(dim) - { - case GradientDimension::GRAD_X: - os << "GRAD_X"; - break; - case GradientDimension::GRAD_Y: - os << "GRAD_Y"; - break; - case GradientDimension::GRAD_XY: - os << "GRAD_XY"; - break; - default: - ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); - } - - return os; -} - -/** Formatted output of the GradientDimension type. - * - * @param[in] type Type to output - * - * @return Formatted string. - */ -inline std::string to_string(const arm_compute::GradientDimension &type) -{ - std::stringstream str; - str << type; - return str.str(); -} - -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_TYPE_PRINTER_H */ diff --git a/tests/Types.h b/tests/Types.h index c8e9a755a7..5d5a8207d5 100644 --- a/tests/Types.h +++ b/tests/Types.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 Arm Limited. + * Copyright (c) 2017-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -30,14 +30,6 @@ namespace arm_compute { -/** Gradient dimension type. */ -enum class GradientDimension -{ - GRAD_X, /**< x gradient dimension */ - GRAD_Y, /**< y gradient dimension */ - GRAD_XY, /**< x and y gradient dimension */ -}; - /** Min and max values and locations */ template struct MinMaxLocationValues @@ -47,37 +39,5 @@ struct MinMaxLocationValues std::vector min_loc{}; /**< Min value location */ std::vector max_loc{}; /**< Max value location */ }; - -/** Parameters of Optical Flow algorithm. */ -struct OpticalFlowParameters -{ - OpticalFlowParameters(Termination termination, - float epsilon, - size_t num_iterations, - size_t window_dimension, - bool use_initial_estimate) - : termination{ std::move(termination) }, - epsilon{ std::move(epsilon) }, - num_iterations{ std::move(num_iterations) }, - window_dimension{ std::move(window_dimension) }, - use_initial_estimate{ std::move(use_initial_estimate) } - { - } - - Termination termination; - float epsilon; - size_t num_iterations; - size_t window_dimension; - bool use_initial_estimate; -}; - -/** Internal keypoint class for Lucas-Kanade Optical Flow */ -struct InternalKeyPoint -{ - float x{ 0.f }; /**< x coordinate of the keypoint */ - float y{ 0.f }; /**< y coordinate of the keypoint */ - bool tracking_status{ false }; /**< the tracking status of the keypoint */ -}; - } // namespace arm_compute #endif /* ARM_COMPUTE_TEST_TYPES_H */ diff --git a/tests/Utils.h b/tests/Utils.h index fe9fe712cf..b62ad4a677 100644 --- a/tests/Utils.h +++ b/tests/Utils.h @@ -26,8 +26,6 @@ #include "arm_compute/core/Coordinates.h" #include "arm_compute/core/Error.h" -#include "arm_compute/core/HOGInfo.h" -#include "arm_compute/core/PyramidInfo.h" #include "arm_compute/core/Size2D.h" #include "arm_compute/core/TensorInfo.h" #include "arm_compute/core/TensorShape.h" @@ -241,101 +239,6 @@ inline ValidRegion shape_to_valid_region(const TensorShape &a_shape, bool border return valid_region; } -/** Create a valid region for Gaussian Pyramid Half based on tensor shape and valid region at level "i - 1" and border mode - * - * @note The border size is 2 in case of Gaussian Pyramid Half - * - * @param[in] a_shape Shape used at level "i - 1" of Gaussian Pyramid Half - * @param[in] a_valid_region Valid region used at level "i - 1" of Gaussian Pyramid Half - * @param[in] border_undefined (Optional) Boolean indicating if the border mode is undefined. - * - * return The valid region for the level "i" of Gaussian Pyramid Half - */ -inline ValidRegion shape_to_valid_region_gaussian_pyramid_half(const TensorShape &a_shape, const ValidRegion &a_valid_region, bool border_undefined = false) -{ - constexpr int border_size = 2; - - ValidRegion valid_region{ Coordinates(), a_shape }; - - Coordinates &anchor = valid_region.anchor; - TensorShape &shape = valid_region.shape; - - // Compute tensor shape for level "i" of Gaussian Pyramid Half - // dst_width = (src_width + 1) * 0.5f - // dst_height = (src_height + 1) * 0.5f - shape.set(0, (a_shape[0] + 1) * 0.5f); - shape.set(1, (a_shape[1] + 1) * 0.5f); - - if(border_undefined) - { - ARM_COMPUTE_ERROR_ON(shape.num_dimensions() < 2); - - // Compute the left and top invalid borders - float invalid_border_left = static_cast(a_valid_region.anchor.x() + border_size) / 2.0f; - float invalid_border_top = static_cast(a_valid_region.anchor.y() + border_size) / 2.0f; - - // For the new anchor point we can have 2 cases: - // 1) If the width/height of the tensor shape is odd, we have to take the ceil value of (a_valid_region.anchor.x() + border_size) / 2.0f or (a_valid_region.anchor.y() + border_size / 2.0f - // 2) If the width/height of the tensor shape is even, we have to take the floor value of (a_valid_region.anchor.x() + border_size) / 2.0f or (a_valid_region.anchor.y() + border_size) / 2.0f - // In this manner we should be able to propagate correctly the valid region along all levels of the pyramid - invalid_border_left = (a_shape[0] % 2) ? std::ceil(invalid_border_left) : std::floor(invalid_border_left); - invalid_border_top = (a_shape[1] % 2) ? std::ceil(invalid_border_top) : std::floor(invalid_border_top); - - // Set the anchor point - anchor.set(0, static_cast(invalid_border_left)); - anchor.set(1, static_cast(invalid_border_top)); - - // Compute shape - // Calculate the right and bottom invalid borders at the previous level of the pyramid - const float prev_invalid_border_right = static_cast(a_shape[0] - (a_valid_region.anchor.x() + a_valid_region.shape[0])); - const float prev_invalid_border_bottom = static_cast(a_shape[1] - (a_valid_region.anchor.y() + a_valid_region.shape[1])); - - // Calculate the right and bottom invalid borders at the current level of the pyramid - const float invalid_border_right = std::ceil((prev_invalid_border_right + static_cast(border_size)) / 2.0f); - const float invalid_border_bottom = std::ceil((prev_invalid_border_bottom + static_cast(border_size)) / 2.0f); - - const int valid_shape_x = std::max(0, static_cast(shape.x()) - static_cast(invalid_border_left) - static_cast(invalid_border_right)); - const int valid_shape_y = std::max(0, static_cast(shape.y()) - static_cast(invalid_border_top) - static_cast(invalid_border_bottom)); - - shape.set(0, valid_shape_x); - shape.set(1, valid_shape_y); - } - - return valid_region; -} - -/** Create a valid region for Laplacian Pyramid based on tensor shape and valid region at level "i - 1" and border mode - * - * @note The border size is 2 in case of Laplacian Pyramid - * - * @param[in] a_shape Shape used at level "i - 1" of Laplacian Pyramid - * @param[in] a_valid_region Valid region used at level "i - 1" of Laplacian Pyramid - * @param[in] border_undefined (Optional) Boolean indicating if the border mode is undefined. - * - * return The valid region for the level "i" of Laplacian Pyramid - */ -inline ValidRegion shape_to_valid_region_laplacian_pyramid(const TensorShape &a_shape, const ValidRegion &a_valid_region, bool border_undefined = false) -{ - ValidRegion valid_region = shape_to_valid_region_gaussian_pyramid_half(a_shape, a_valid_region, border_undefined); - - if(border_undefined) - { - const BorderSize gaussian5x5_border(2); - - auto border_left = static_cast(gaussian5x5_border.left); - auto border_right = static_cast(gaussian5x5_border.right); - auto border_top = static_cast(gaussian5x5_border.top); - auto border_bottom = static_cast(gaussian5x5_border.bottom); - - valid_region.anchor.set(0, valid_region.anchor[0] + border_left); - valid_region.anchor.set(1, valid_region.anchor[1] + border_top); - valid_region.shape.set(0, std::max(0, static_cast(valid_region.shape[0]) - border_right - border_left)); - valid_region.shape.set(1, std::max(0, static_cast(valid_region.shape[1]) - border_top - border_bottom)); - } - - return valid_region; -} - /** Write the value after casting the pointer according to @p data_type. * * @warning The type of the value must match the specified data type. @@ -566,110 +469,6 @@ inline T create_tensor(const TensorShape &shape, Format format, IRuntimeContext return create_tensor(info, ctx); } -/** Create and initialize a multi-image of the given type. - * - * @param[in] shape Tensor shape. - * @param[in] format Format type. - * - * @return Initialized tensor of given type. - */ -template -inline T create_multi_image(const TensorShape &shape, Format format) -{ - T multi_image; - multi_image.init(shape.x(), shape.y(), format); - - return multi_image; -} - -/** Create and initialize a HOG (Histogram of Oriented Gradients) of the given type. - * - * @param[in] hog_info HOGInfo object - * - * @return Initialized HOG of given type. - */ -template -inline T create_HOG(const HOGInfo &hog_info) -{ - T hog; - hog.init(hog_info); - - return hog; -} - -/** Create and initialize a Pyramid of the given type. - * - * @param[in] pyramid_info The PyramidInfo object. - * - * @return Initialized Pyramid of given type. - */ -template -inline T create_pyramid(const PyramidInfo &pyramid_info) -{ - T pyramid; - pyramid.init_auto_padding(pyramid_info); - - return pyramid; -} - -/** Initialize a convolution matrix. - * - * @param[in, out] conv The input convolution matrix. - * @param[in] width The width of the convolution matrix. - * @param[in] height The height of the convolution matrix. - * @param[in] seed The random seed to be used. - */ -inline void init_conv(int16_t *conv, unsigned int width, unsigned int height, std::random_device::result_type seed) -{ - std::mt19937 gen(seed); - std::uniform_int_distribution distribution_int16(-32768, 32767); - - for(unsigned int i = 0; i < width * height; ++i) - { - conv[i] = distribution_int16(gen); - } -} - -/** Initialize a separable convolution matrix. - * - * @param[in, out] conv The input convolution matrix. - * @param[in] width The width of the convolution matrix. - * @param[in] height The height of the convolution matrix. - * @param[in] seed The random seed to be used. - */ -inline void init_separable_conv(int16_t *conv, unsigned int width, unsigned int height, std::random_device::result_type seed) -{ - std::mt19937 gen(seed); - // Set it between -128 and 127 to ensure the matrix does not overflow - std::uniform_int_distribution distribution_int16(-128, 127); - - int16_t *conv_row = new int16_t[width]; - int16_t *conv_col = new int16_t[height]; - - conv_row[0] = conv_col[0] = 1; - for(unsigned int i = 1; i < width; ++i) - { - conv_row[i] = distribution_int16(gen); - } - - for(unsigned int i = 1; i < height; ++i) - { - conv_col[i] = distribution_int16(gen); - } - - // Multiply two matrices - for(unsigned int i = 0; i < width; ++i) - { - for(unsigned int j = 0; j < height; ++j) - { - conv[i * width + j] = conv_col[i] * conv_row[j]; - } - } - - delete[] conv_row; - delete[] conv_col; -} - /** Create a vector with a uniform distribution of floating point values across the specified range. * * @param[in] num_values The number of values to be created. @@ -694,44 +493,6 @@ inline std::vector generate_random_real(unsigned int num_values, T min, T max return v; } -/** Create a vector of random keypoints for pyramid representation. - * - * @param[in] shape The shape of the input tensor. - * @param[in] num_keypoints The number of keypoints to be created. - * @param[in] seed The random seed to be used. - * @param[in] num_levels The number of pyramid levels. - * - * @return A vector that contains the requested number of random keypoints - */ -inline std::vector generate_random_keypoints(const TensorShape &shape, size_t num_keypoints, std::random_device::result_type seed, size_t num_levels = 1) -{ - std::vector keypoints; - std::mt19937 gen(seed); - - // Calculate distribution bounds - const auto min = static_cast(std::pow(2, num_levels)); - const auto max_width = static_cast(shape.x()); - const auto max_height = static_cast(shape.y()); - - ARM_COMPUTE_ERROR_ON(min > max_width || min > max_height); - - // Create distributions - std::uniform_int_distribution<> dist_w(min, max_width); - std::uniform_int_distribution<> dist_h(min, max_height); - - for(unsigned int i = 0; i < num_keypoints; i++) - { - KeyPoint keypoint; - keypoint.x = dist_w(gen); - keypoint.y = dist_h(gen); - keypoint.tracking_status = 1; - - keypoints.push_back(keypoint); - } - - return keypoints; -} - template inline void fill_array(ArrayAccessor_T &&array, const std::vector &v) { diff --git a/tests/framework/datasets/ContainerDataset.h b/tests/framework/datasets/ContainerDataset.h index 3987e8f1b8..de77cb24d6 100644 --- a/tests/framework/datasets/ContainerDataset.h +++ b/tests/framework/datasets/ContainerDataset.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2020 Arm Limited. + * Copyright (c) 2017-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -26,7 +26,6 @@ #include "Dataset.h" #include "support/StringSupport.h" -#include "tests/TypePrinter.h" #include #include diff --git a/tests/validation/CL/BoundingBoxTransform.cpp b/tests/validation/CL/BoundingBoxTransform.cpp index 2a7f1667d6..2584b1a5b6 100644 --- a/tests/validation/CL/BoundingBoxTransform.cpp +++ b/tests/validation/CL/BoundingBoxTransform.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020 Arm Limited. + * Copyright (c) 2018-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -24,7 +24,6 @@ #include "arm_compute/runtime/CL/CLScheduler.h" #include "arm_compute/runtime/CL/functions/CLBoundingBoxTransform.h" #include "tests/CL/CLAccessor.h" -#include "tests/CL/CLArrayAccessor.h" #include "tests/Globals.h" #include "tests/framework/Macros.h" #include "tests/framework/datasets/Datasets.h" diff --git a/tests/validation/Helpers.cpp b/tests/validation/Helpers.cpp index eb8bdcf5a7..7ff2ab6219 100644 --- a/tests/validation/Helpers.cpp +++ b/tests/validation/Helpers.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2020 Arm Limited. + * Copyright (c) 2017-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -32,82 +32,6 @@ namespace test { namespace validation { -void fill_mask_from_pattern(uint8_t *mask, int cols, int rows, MatrixPattern pattern) -{ - unsigned int v = 0; - std::mt19937 gen(library->seed()); - std::bernoulli_distribution dist(0.5); - - for(int r = 0; r < rows; ++r) - { - for(int c = 0; c < cols; ++c, ++v) - { - uint8_t val = 0; - - switch(pattern) - { - case MatrixPattern::BOX: - val = 255; - break; - case MatrixPattern::CROSS: - val = ((r == (rows / 2)) || (c == (cols / 2))) ? 255 : 0; - break; - case MatrixPattern::DISK: - val = (((r - rows / 2.0f + 0.5f) * (r - rows / 2.0f + 0.5f)) / ((rows / 2.0f) * (rows / 2.0f)) + ((c - cols / 2.0f + 0.5f) * (c - cols / 2.0f + 0.5f)) / ((cols / 2.0f) * - (cols / 2.0f))) <= 1.0f ? 255 : 0; - break; - case MatrixPattern::OTHER: - val = (dist(gen) ? 0 : 255); - break; - default: - return; - } - - mask[v] = val; - } - } - - if(pattern == MatrixPattern::OTHER) - { - std::uniform_int_distribution distribution_u8(0, ((cols * rows) - 1)); - mask[distribution_u8(gen)] = 255; - } -} - -HarrisCornersParameters harris_corners_parameters() -{ - HarrisCornersParameters params; - - std::mt19937 gen(library->seed()); - std::uniform_real_distribution threshold_dist(0.f, 0.001f); - std::uniform_real_distribution sensitivity(0.04f, 0.15f); - std::uniform_real_distribution euclidean_distance(0.f, 30.f); - std::uniform_int_distribution int_dist(0, 255); - - params.threshold = threshold_dist(gen); - params.sensitivity = sensitivity(gen); - params.min_dist = euclidean_distance(gen); - params.constant_border_value = int_dist(gen); - - return params; -} - -CannyEdgeParameters canny_edge_parameters() -{ - CannyEdgeParameters params; - - std::mt19937 gen(library->seed()); - std::uniform_int_distribution int_dist(0, 255); - std::uniform_int_distribution threshold_dist(2, 255); - - params.constant_border_value = int_dist(gen); - params.upper_thresh = threshold_dist(gen); // upper_threshold >= 2 - threshold_dist = std::uniform_int_distribution(1, params.upper_thresh - 1); - params.lower_thresh = threshold_dist(gen); // lower_threshold >= 1 && lower_threshold < upper_threshold - - return params; -} - template <> SimpleTensor convert_from_asymmetric(const SimpleTensor &src) { diff --git a/tests/validation/Helpers.h b/tests/validation/Helpers.h index 604840b33e..30ec14e716 100644 --- a/tests/validation/Helpers.h +++ b/tests/validation/Helpers.h @@ -111,15 +111,6 @@ std::pair get_activation_layer_test_bounds(ActivationLayerInfo::Activation return bounds; } -/** Fill mask with the corresponding given pattern. - * - * @param[in,out] mask Mask to be filled according to pattern - * @param[in] cols Columns (width) of mask - * @param[in] rows Rows (height) of mask - * @param[in] pattern Pattern to fill the mask according to - */ -void fill_mask_from_pattern(uint8_t *mask, int cols, int rows, MatrixPattern pattern); - /** Calculate output tensor shape give a vector of input tensor to concatenate * * @param[in] input_shapes Shapes of the tensors to concatenate across depth. @@ -137,46 +128,6 @@ TensorShape calculate_depth_concatenate_shape(const std::vector &in */ TensorShape calculate_concatenate_shape(const std::vector &input_shapes, size_t axis); -/** Parameters of Harris Corners algorithm. */ -struct HarrisCornersParameters -{ - float threshold{ 0.f }; /**< Threshold */ - float sensitivity{ 0.f }; /**< Sensitivity */ - float min_dist{ 0.f }; /**< Minimum distance */ - uint8_t constant_border_value{ 0 }; /**< Border value */ -}; - -/** Generate parameters for Harris Corners algorithm. */ -HarrisCornersParameters harris_corners_parameters(); - -/** Parameters of Canny edge algorithm. */ -struct CannyEdgeParameters -{ - int32_t upper_thresh{ 255 }; - int32_t lower_thresh{ 0 }; - uint8_t constant_border_value{ 0 }; -}; - -/** Generate parameters for Canny edge algorithm. */ -CannyEdgeParameters canny_edge_parameters(); - -/** Helper function to fill the Lut random by a ILutAccessor. - * - * @param[in,out] table Accessor at the Lut. - * - */ -template -void fill_lookuptable(T &&table) -{ - std::mt19937 generator(library->seed()); - std::uniform_int_distribution distribution(std::numeric_limits::min(), std::numeric_limits::max()); - - for(int i = std::numeric_limits::min(); i <= std::numeric_limits::max(); i++) - { - table[i] = distribution(generator); - } -} - /** Convert an asymmetric quantized simple tensor into float using tensor quantization information. * * @param[in] src Quantized tensor. diff --git a/tests/validation/Validation.h b/tests/validation/Validation.h index d356f05b70..c2df1c31c0 100644 --- a/tests/validation/Validation.h +++ b/tests/validation/Validation.h @@ -267,16 +267,6 @@ void validate(std::vector classified_labels, std::vector> bool validate(T target, T reference, U tolerance = AbsoluteTolerance()); -/** Validate key points. */ -template > -void validate_keypoints(T target_first, T target_last, U reference_first, U reference_last, V tolerance = AbsoluteTolerance(), - float allowed_missing_percentage = 5.f, float allowed_mismatch_percentage = 5.f); - -/** Validate detection windows. */ -template > -void validate_detection_windows(T target_first, T target_last, U reference_first, U reference_last, V tolerance = AbsoluteTolerance(), - float allowed_missing_percentage = 5.f, float allowed_mismatch_percentage = 5.f); - template struct compare_base { @@ -687,210 +677,6 @@ void validate_min_max_loc(const MinMaxLocationValues &target, const MinMaxLoc ARM_COMPUTE_EXPECT(same_coords != reference.max_loc.end(), framework::LogLevel::ERRORS); } } - -/** Check which keypoints from [first1, last1) are missing in [first2, last2) */ -template -std::pair compare_keypoints(T first1, T last1, U first2, U last2, V tolerance, bool check_mismatches = true) -{ - /* Keypoint (x,y) should have similar strength (within tolerance) and other properties in both reference and target */ - const auto compare_props_eq = [&](const KeyPoint & lhs, const KeyPoint & rhs) - { - return compare(lhs.strength, rhs.strength, tolerance) - && lhs.tracking_status == rhs.tracking_status - && lhs.scale == rhs.scale - && lhs.orientation == rhs.orientation - && lhs.error == rhs.error; - }; - - /* Used to sort KeyPoints by coordinates (x, y) */ - const auto compare_coords_lt = [](const KeyPoint & lhs, const KeyPoint & rhs) - { - return std::tie(lhs.x, lhs.y) < std::tie(rhs.x, rhs.y); - }; - - std::sort(first1, last1, compare_coords_lt); - std::sort(first2, last2, compare_coords_lt); - - if(check_mismatches) - { - ARM_COMPUTE_TEST_INFO("Checking for mismatches: ref count = " << std::distance(first1, last1) << " target count = " << std::distance(first2, last2)); - } - - int64_t num_missing = 0; - int64_t num_mismatches = 0; - bool rest_missing = false; - - while(first1 != last1) - { - if(first2 == last2) - { - rest_missing = true; - break; - } - - if(compare_coords_lt(*first1, *first2)) - { - ++num_missing; - ARM_COMPUTE_TEST_INFO("Key point not found"); - ARM_COMPUTE_TEST_INFO("keypoint1 = " << *first1++); - framework::ARM_COMPUTE_PRINT_INFO(); - } - else - { - if(!compare_coords_lt(*first2, *first1)) // Equal coordinates - { - if(check_mismatches && !compare_props_eq(*first1, *first2)) // Check other properties - { - ++num_mismatches; - ARM_COMPUTE_TEST_INFO("Mismatching keypoint"); - ARM_COMPUTE_TEST_INFO("keypoint1 [ref] = " << *first1); - ARM_COMPUTE_TEST_INFO("keypoint2 [tgt] = " << *first2); - framework::ARM_COMPUTE_PRINT_INFO(); - } - ++first1; - } - ++first2; - } - } - - if(rest_missing) - { - while(first1 != last1) - { - ++num_missing; - ARM_COMPUTE_TEST_INFO("Key point not found"); - ARM_COMPUTE_TEST_INFO("keypoint1 = " << *first1++); - framework::ARM_COMPUTE_PRINT_INFO(); - } - } - - return std::make_pair(num_missing, num_mismatches); -} - -template -void validate_keypoints(T target_first, T target_last, U reference_first, U reference_last, V tolerance, float allowed_missing_percentage, float allowed_mismatch_percentage) -{ - if(framework::Framework::get().configure_only() && framework::Framework::get().new_fixture_call()) - { - return; - } - - const int64_t num_elements_target = std::distance(target_first, target_last); - const int64_t num_elements_reference = std::distance(reference_first, reference_last); - - int64_t num_missing = 0; - int64_t num_mismatches = 0; - - if(num_elements_reference > 0) - { - std::tie(num_missing, num_mismatches) = compare_keypoints(reference_first, reference_last, target_first, target_last, tolerance); - - const float percent_missing = static_cast(num_missing) / num_elements_reference * 100.f; - const float percent_mismatches = static_cast(num_mismatches) / num_elements_reference * 100.f; - - ARM_COMPUTE_TEST_INFO(num_missing << " keypoints (" << std::fixed << std::setprecision(2) << percent_missing << "%) in ref are missing from target"); - ARM_COMPUTE_TEST_INFO("Missing (not in tgt): " << num_missing << "/" << num_elements_reference << " = " << std::fixed << std::setprecision(2) << percent_missing - << "% \tMax allowed: " << allowed_missing_percentage << "%"); - ARM_COMPUTE_EXPECT(percent_missing <= allowed_missing_percentage, framework::LogLevel::ERRORS); - - ARM_COMPUTE_TEST_INFO(num_mismatches << " keypoints (" << std::fixed << std::setprecision(2) << percent_mismatches << "%) mismatched"); - ARM_COMPUTE_TEST_INFO("Mismatched keypoints: " << num_mismatches << "/" << num_elements_reference << " = " << std::fixed << std::setprecision(2) << percent_mismatches - << "% \tMax allowed: " << allowed_mismatch_percentage << "%"); - ARM_COMPUTE_EXPECT(percent_mismatches <= allowed_mismatch_percentage, framework::LogLevel::ERRORS); - } - - if(num_elements_target > 0) - { - // Note: no need to check for mismatches a second time (last argument is 'false') - std::tie(num_missing, num_mismatches) = compare_keypoints(target_first, target_last, reference_first, reference_last, tolerance, false); - - const float percent_missing = static_cast(num_missing) / num_elements_target * 100.f; - - ARM_COMPUTE_TEST_INFO(num_missing << " keypoints (" << std::fixed << std::setprecision(2) << percent_missing << "%) in target are missing from ref"); - ARM_COMPUTE_TEST_INFO("Missing (not in ref): " << num_missing << "/" << num_elements_target << " = " << std::fixed << std::setprecision(2) << percent_missing - << "% \tMax allowed: " << allowed_missing_percentage << "%"); - ARM_COMPUTE_EXPECT(percent_missing <= allowed_missing_percentage, framework::LogLevel::ERRORS); - } -} - -/** Check which detection windows from [first1, last1) are missing in [first2, last2) */ -template -std::pair compare_detection_windows(T first1, T last1, U first2, U last2, V tolerance) -{ - int64_t num_missing = 0; - int64_t num_mismatches = 0; - - while(first1 != last1) - { - const auto window = std::find_if(first2, last2, [&](DetectionWindow window) - { - return window.x == first1->x && window.y == first1->y && window.width == first1->width && window.height == first1->height && window.idx_class == first1->idx_class; - }); - - if(window == last2) - { - ++num_missing; - ARM_COMPUTE_TEST_INFO("Detection window not found " << *first1) - framework::ARM_COMPUTE_PRINT_INFO(); - } - else - { - if(!compare(window->score, first1->score, tolerance)) - { - ++num_mismatches; - ARM_COMPUTE_TEST_INFO("Mismatching detection window") - ARM_COMPUTE_TEST_INFO("detection window 1= " << *first1) - ARM_COMPUTE_TEST_INFO("detection window 2= " << *window) - framework::ARM_COMPUTE_PRINT_INFO(); - } - } - - ++first1; - } - - return std::make_pair(num_missing, num_mismatches); -} - -template -void validate_detection_windows(T target_first, T target_last, U reference_first, U reference_last, V tolerance, - float allowed_missing_percentage, float allowed_mismatch_percentage) -{ - if(framework::Framework::get().configure_only() && framework::Framework::get().new_fixture_call()) - { - return; - } - - const int64_t num_elements_target = std::distance(target_first, target_last); - const int64_t num_elements_reference = std::distance(reference_first, reference_last); - - int64_t num_missing = 0; - int64_t num_mismatches = 0; - - if(num_elements_reference > 0) - { - std::tie(num_missing, num_mismatches) = compare_detection_windows(reference_first, reference_last, target_first, target_last, tolerance); - - const float percent_missing = static_cast(num_missing) / num_elements_reference * 100.f; - const float percent_mismatches = static_cast(num_mismatches) / num_elements_reference * 100.f; - - ARM_COMPUTE_TEST_INFO(num_missing << " detection windows (" << std::fixed << std::setprecision(2) << percent_missing << "%) are missing in target"); - ARM_COMPUTE_EXPECT(percent_missing <= allowed_missing_percentage, framework::LogLevel::ERRORS); - - ARM_COMPUTE_TEST_INFO(num_mismatches << " detection windows (" << std::fixed << std::setprecision(2) << percent_mismatches << "%) mismatched"); - ARM_COMPUTE_EXPECT(percent_mismatches <= allowed_mismatch_percentage, framework::LogLevel::ERRORS); - } - - if(num_elements_target > 0) - { - std::tie(num_missing, num_mismatches) = compare_detection_windows(target_first, target_last, reference_first, reference_last, tolerance); - - const float percent_missing = static_cast(num_missing) / num_elements_target * 100.f; - - ARM_COMPUTE_TEST_INFO(num_missing << " detection windows (" << std::fixed << std::setprecision(2) << percent_missing << "%) are not part of target"); - ARM_COMPUTE_EXPECT(percent_missing <= allowed_missing_percentage, framework::LogLevel::ERRORS); - } -} - } // namespace validation } // namespace test } // namespace arm_compute diff --git a/tests/validation/fixtures/CropResizeFixture.h b/tests/validation/fixtures/CropResizeFixture.h index 4f6389155a..2e00ac368a 100644 --- a/tests/validation/fixtures/CropResizeFixture.h +++ b/tests/validation/fixtures/CropResizeFixture.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020 Arm Limited. + * Copyright (c) 2019-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -30,7 +30,6 @@ #include "tests/AssetsLibrary.h" #include "tests/Globals.h" #include "tests/IAccessor.h" -#include "tests/RawLutAccessor.h" #include "tests/framework/Asserts.h" #include "tests/framework/Fixture.h" #include "tests/validation/Helpers.h" diff --git a/tests/validation/fixtures/SliceOperationsFixtures.h b/tests/validation/fixtures/SliceOperationsFixtures.h index c1e046e427..68e8290882 100644 --- a/tests/validation/fixtures/SliceOperationsFixtures.h +++ b/tests/validation/fixtures/SliceOperationsFixtures.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Arm Limited. + * Copyright (c) 2018-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -30,7 +30,6 @@ #include "tests/AssetsLibrary.h" #include "tests/Globals.h" #include "tests/IAccessor.h" -#include "tests/RawLutAccessor.h" #include "tests/framework/Asserts.h" #include "tests/framework/Fixture.h" #include "tests/validation/Helpers.h" diff --git a/tests/validation/fixtures/SplitFixture.h b/tests/validation/fixtures/SplitFixture.h index 03ff41e993..8df78fa2b9 100644 --- a/tests/validation/fixtures/SplitFixture.h +++ b/tests/validation/fixtures/SplitFixture.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020 Arm Limited. + * Copyright (c) 2018-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -30,7 +30,6 @@ #include "tests/AssetsLibrary.h" #include "tests/Globals.h" #include "tests/IAccessor.h" -#include "tests/RawLutAccessor.h" #include "tests/framework/Asserts.h" #include "tests/framework/Fixture.h" #include "tests/validation/Helpers.h" diff --git a/tests/validation/reference/Box3x3.cpp b/tests/validation/reference/Box3x3.cpp deleted file mode 100644 index ccc7f1b3b9..0000000000 --- a/tests/validation/reference/Box3x3.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2017-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Helpers.h" - -#include "Box3x3.h" -#include "Utils.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor box3x3(const SimpleTensor &src, BorderMode border_mode, T constant_border_value) -{ - SimpleTensor dst(src.shape(), src.data_type()); - const std::array filter{ { 1, 1, 1, 1, 1, 1, 1, 1, 1 } }; - const float scale = 1.f / static_cast(filter.size()); - const uint32_t num_elements = src.num_elements(); -#if defined(_OPENMP) - #pragma omp parallel for -#endif /* _OPENMP */ - for(uint32_t element_idx = 0; element_idx < num_elements; ++element_idx) - { - const Coordinates id = index2coord(src.shape(), element_idx); - apply_2d_spatial_filter(id, src, dst, TensorShape(3U, 3U), filter.data(), scale, border_mode, constant_border_value); - } - return dst; -} - -template SimpleTensor box3x3(const SimpleTensor &src, BorderMode border_mode, uint8_t constant_border_value); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/reference/Box3x3.h b/tests/validation/reference/Box3x3.h deleted file mode 100644 index f377f280af..0000000000 --- a/tests/validation/reference/Box3x3.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_BOX3X3_H -#define ARM_COMPUTE_TEST_BOX3X3_H - -#include "tests/SimpleTensor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor box3x3(const SimpleTensor &src, BorderMode border_mode, T constant_border_value); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_BOX3X3_H */ diff --git a/tests/validation/reference/CannyEdgeDetector.cpp b/tests/validation/reference/CannyEdgeDetector.cpp deleted file mode 100644 index aa2351ddd8..0000000000 --- a/tests/validation/reference/CannyEdgeDetector.cpp +++ /dev/null @@ -1,254 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "CannyEdgeDetector.h" - -#include "Utils.h" -#include "support/ToolchainSupport.h" -#include "tests/validation/Helpers.h" -#include "tests/validation/reference/Magnitude.h" -#include "tests/validation/reference/NonMaximaSuppression.h" -#include "tests/validation/reference/Phase.h" -#include "tests/validation/reference/Sobel.h" - -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -namespace -{ -const auto MARK_ZERO = 0u; -const auto MARK_MAYBE = 127u; -const auto MARK_EDGE = 255u; - -template -void trace_edge(SimpleTensor &dst, const ValidRegion &valid_region) -{ - std::stack pixels_stack; - for(auto i = 0; i < dst.num_elements(); ++i) - { - if(dst[i] == MARK_EDGE) - { - pixels_stack.push(index2coord(dst.shape(), i)); - } - } - - while(!pixels_stack.empty()) - { - const Coordinates pixel_coord = pixels_stack.top(); - pixels_stack.pop(); - - std::array neighbours = - { - { - Coordinates(pixel_coord.x() - 1, pixel_coord.y() + 0), - Coordinates(pixel_coord.x() + 1, pixel_coord.y() + 0), - Coordinates(pixel_coord.x() - 1, pixel_coord.y() - 1), - Coordinates(pixel_coord.x() + 1, pixel_coord.y() + 1), - Coordinates(pixel_coord.x() + 0, pixel_coord.y() - 1), - Coordinates(pixel_coord.x() + 0, pixel_coord.y() + 1), - Coordinates(pixel_coord.x() + 1, pixel_coord.y() - 1), - Coordinates(pixel_coord.x() - 1, pixel_coord.y() + 1) - } - }; - - // Mark MAYBE neighbours as edges since they are next to an EDGE - std::for_each(neighbours.begin(), neighbours.end(), [&](Coordinates & coord) - { - if(is_in_valid_region(valid_region, coord)) - { - const size_t pixel_index = coord2index(dst.shape(), coord); - const T pixel = dst[pixel_index]; - if(pixel == MARK_MAYBE) - { - dst[pixel_index] = MARK_EDGE; - pixels_stack.push(coord); - } - } - }); - } - - // Mark all remaining MAYBE pixels as ZERO (not edges) - for(auto i = 0; i < dst.num_elements(); ++i) - { - if(dst[i] == MARK_MAYBE) - { - dst[i] = MARK_ZERO; - } - } -} - -template -SimpleTensor canny_edge_detector_impl(const SimpleTensor &src, int32_t upper, int32_t lower, int gradient_size, MagnitudeType norm_type, - BorderMode border_mode, T constant_border_value) -{ - ARM_COMPUTE_ERROR_ON(gradient_size != 3 && gradient_size != 5 && gradient_size != 7); - ARM_COMPUTE_ERROR_ON(lower < 0 || lower >= upper); - - // Output: T == uint8_t - SimpleTensor dst{ src.shape(), src.data_type() }; - ValidRegion valid_region = shape_to_valid_region(src.shape(), border_mode == BorderMode::UNDEFINED, BorderSize(gradient_size / 2 + 1)); - - // Sobel computation: U == int16_t or int32_t - SimpleTensor gx{}; - SimpleTensor gy{}; - std::tie(gx, gy) = sobel(src, gradient_size, border_mode, constant_border_value, GradientDimension::GRAD_XY); - - using unsigned_U = typename traits::make_unsigned_conditional_t::type; - using promoted_U = typename common_promoted_signed_type::intermediate_type; - - // Gradient magnitude and phase (edge direction) - const DataType mag_data_type = gx.data_type() == DataType::S16 ? DataType::U16 : DataType::U32; - SimpleTensor grad_mag{ gx.shape(), mag_data_type }; - SimpleTensor grad_dir{ gy.shape(), DataType::U8 }; - - for(auto i = 0; i < grad_mag.num_elements(); ++i) - { - double mag = 0.f; - - if(norm_type == MagnitudeType::L2NORM) - { - mag = support::cpp11::round(std::sqrt(static_cast(gx[i]) * gx[i] + static_cast(gy[i]) * gy[i])); - } - else // MagnitudeType::L1NORM - { - mag = static_cast(std::abs(gx[i])) + static_cast(std::abs(gy[i])); - } - - float angle = 180.f * std::atan2(static_cast(gy[i]), static_cast(gx[i])) / M_PI; - grad_dir[i] = support::cpp11::round(angle < 0.f ? 180 + angle : angle); - grad_mag[i] = saturate_cast(mag); - } - - /* - Quantise the phase into 4 directions - 0° dir=0 0.0 <= p < 22.5 or 157.5 <= p < 180 - 45° dir=1 22.5 <= p < 67.5 - 90° dir=2 67.5 <= p < 112.5 - 135° dir=3 112.5 <= p < 157.5 - */ - for(auto i = 0; i < grad_dir.num_elements(); ++i) - { - const auto direction = std::fabs(grad_dir[i]); - grad_dir[i] = (direction < 22.5 || direction >= 157.5) ? 0 : (direction < 67.5) ? 1 : (direction < 112.5) ? 2 : 3; - } - - // Non-maximum suppression - std::vector strong_edges; - const auto upper_thresh = static_cast(upper); - const auto lower_thresh = static_cast(lower); - - const auto pixel_at_offset = [&](const SimpleTensor &tensor, const Coordinates & coord, int xoffset, int yoffset) - { - return tensor_elem_at(tensor, Coordinates{ coord.x() + xoffset, coord.y() + yoffset }, border_mode, static_cast(constant_border_value)); - }; - - for(auto i = 0; i < dst.num_elements(); ++i) - { - const auto coord = index2coord(dst.shape(), i); - if(!is_in_valid_region(valid_region, coord) || grad_mag[i] <= lower_thresh) - { - dst[i] = MARK_ZERO; - continue; - } - - unsigned_U mag_90; - unsigned_U mag90; - switch(grad_dir[i]) - { - case 0: // North/South edge direction, compare against East/West pixels (left & right) - mag_90 = pixel_at_offset(grad_mag, coord, -1, 0); - mag90 = pixel_at_offset(grad_mag, coord, 1, 0); - break; - case 1: // NE/SW edge direction, compare against NW/SE pixels (top-left & bottom-right) - mag_90 = pixel_at_offset(grad_mag, coord, -1, -1); - mag90 = pixel_at_offset(grad_mag, coord, +1, +1); - break; - case 2: // East/West edge direction, compare against North/South pixels (top & bottom) - mag_90 = pixel_at_offset(grad_mag, coord, 0, -1); - mag90 = pixel_at_offset(grad_mag, coord, 0, +1); - break; - case 3: // NW/SE edge direction, compare against NE/SW pixels (top-right & bottom-left) - mag_90 = pixel_at_offset(grad_mag, coord, +1, -1); - mag90 = pixel_at_offset(grad_mag, coord, -1, +1); - break; - default: - ARM_COMPUTE_ERROR("Invalid gradient phase provided"); - break; - } - - // Potential edge if greater than both pixels at +/-90° on either side - if(grad_mag[i] > mag_90 && grad_mag[i] > mag90) - { - // Double thresholding and edge tracing - if(grad_mag[i] > upper_thresh) - { - dst[i] = MARK_EDGE; // Definite edge pixel - strong_edges.emplace_back(i); - } - else - { - dst[i] = MARK_MAYBE; - } - } - else - { - dst[i] = MARK_ZERO; // Since not greater than neighbours - } - } - - // Final edge tracing - trace_edge(dst, valid_region); - return dst; -} -} // namespace - -template -SimpleTensor canny_edge_detector(const SimpleTensor &src, - int32_t upper_thresh, int32_t lower_thresh, int gradient_size, MagnitudeType norm_type, - BorderMode border_mode, T constant_border_value) -{ - if(gradient_size < 7) - { - return canny_edge_detector_impl(src, upper_thresh, lower_thresh, gradient_size, norm_type, border_mode, constant_border_value); - } - else - { - return canny_edge_detector_impl(src, upper_thresh, lower_thresh, gradient_size, norm_type, border_mode, constant_border_value); - } -} - -template SimpleTensor canny_edge_detector(const SimpleTensor &src, - int32_t upper_thresh, int32_t lower_thresh, int gradient_size, MagnitudeType norm_type, - BorderMode border_mode, uint8_t constant_border_value); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/reference/CannyEdgeDetector.h b/tests/validation/reference/CannyEdgeDetector.h deleted file mode 100644 index e05895ab95..0000000000 --- a/tests/validation/reference/CannyEdgeDetector.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_CANNY_EDGE_DETECTOR_H -#define ARM_COMPUTE_TEST_CANNY_EDGE_DETECTOR_H - -#include "arm_compute/core/Types.h" -#include "tests/SimpleTensor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor canny_edge_detector(const SimpleTensor &src, - int32_t upper_thresh, int32_t lower_thresh, int gradient_size, MagnitudeType norm_type, - BorderMode border_mode, T constant_border_value = 0); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_CANNY_EDGE_DETECTOR_H */ diff --git a/tests/validation/reference/ChannelCombine.cpp b/tests/validation/reference/ChannelCombine.cpp deleted file mode 100644 index dcd4cf551b..0000000000 --- a/tests/validation/reference/ChannelCombine.cpp +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Copyright (c) 2017-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "ChannelCombine.h" - -#include "arm_compute/core/Types.h" -#include "tests/validation/Helpers.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -namespace -{ -template -inline std::vector> create_image_planes(const TensorShape &shape, Format format) -{ - TensorShape image_shape = adjust_odd_shape(shape, format); - - std::vector> image_planes; - - switch(format) - { - case Format::RGB888: - case Format::RGBA8888: - case Format::YUYV422: - case Format::UYVY422: - { - image_planes.emplace_back(image_shape, format); - break; - } - case Format::NV12: - case Format::NV21: - { - TensorShape shape_uv88 = calculate_subsampled_shape(image_shape, Format::UV88); - - image_planes.emplace_back(image_shape, Format::U8); - image_planes.emplace_back(shape_uv88, Format::UV88); - break; - } - case Format::IYUV: - { - TensorShape shape_sub2 = calculate_subsampled_shape(image_shape, Format::IYUV); - - image_planes.emplace_back(image_shape, Format::U8); - image_planes.emplace_back(shape_sub2, Format::U8); - image_planes.emplace_back(shape_sub2, Format::U8); - break; - } - case Format::YUV444: - { - image_planes.emplace_back(image_shape, Format::U8); - image_planes.emplace_back(image_shape, Format::U8); - image_planes.emplace_back(image_shape, Format::U8); - break; - } - default: - ARM_COMPUTE_ERROR("Not supported"); - break; - } - - return image_planes; -} -} // namespace - -template -std::vector> channel_combine(const TensorShape &shape, const std::vector> &image_planes, Format format) -{ - std::vector> dst = create_image_planes(shape, format); - -#if defined(_OPENMP) - #pragma omp parallel for -#endif /* _OPENMP */ - for(unsigned int plane_idx = 0; plane_idx < dst.size(); ++plane_idx) - { - SimpleTensor &dst_tensor = dst[plane_idx]; - const uint32_t num_elements = dst_tensor.num_elements(); - - for(uint32_t element_idx = 0; element_idx < num_elements; ++element_idx) - { - Coordinates coord = index2coord(dst_tensor.shape(), element_idx); - - switch(format) - { - case Format::RGB888: - case Format::RGBA8888: - { - // Copy R/G/B or A channel - for(int channel_idx = 0; channel_idx < dst_tensor.num_channels(); ++channel_idx) - { - const T &src_value = reinterpret_cast(image_planes[channel_idx](coord))[0]; - T &dst_value = reinterpret_cast(dst_tensor(coord))[channel_idx]; - - dst_value = src_value; - } - break; - } - case Format::YUYV422: - case Format::UYVY422: - { - // Find coordinates of the sub-sampled pixel - const Coordinates coord_hori(coord.x() / 2, coord.y()); - - const T &src0 = reinterpret_cast(image_planes[0](coord))[0]; - const T &src1 = reinterpret_cast(image_planes[1](coord_hori))[0]; - - const int shift = (Format::YUYV422 == format) ? 1 : 0; - T &dst0 = reinterpret_cast(dst_tensor(coord))[1 - shift]; - T &dst1 = reinterpret_cast(dst_tensor(coord))[0 + shift]; - - dst0 = src0; - dst1 = src1; - - Coordinates coord2 = index2coord(dst_tensor.shape(), ++element_idx); - - const T &src2 = reinterpret_cast(image_planes[0](coord2))[0]; - const T &src3 = reinterpret_cast(image_planes[2](coord_hori))[0]; - - T &dst2 = reinterpret_cast(dst_tensor(coord2))[1 - shift]; - T &dst3 = reinterpret_cast(dst_tensor(coord2))[0 + shift]; - - dst2 = src2; - dst3 = src3; - - break; - } - case Format::NV12: - case Format::NV21: - { - if(0U == plane_idx) - { - // Get and combine Y channel from plane0 of destination multi-image - dst_tensor[element_idx] = image_planes[0][element_idx]; - } - else - { - const int shift = (Format::NV12 == format) ? 0 : 1; - - // Get U channel from plane1 and V channel from plane2 of the source - const T &src_u0 = reinterpret_cast(image_planes[1](coord))[0]; - const T &src_v0 = reinterpret_cast(image_planes[2](coord))[0]; - - // Get U and V channel from plane1 of destination multi-image - T &dst_u0 = reinterpret_cast(dst_tensor(coord))[0 + shift]; - T &dst_v0 = reinterpret_cast(dst_tensor(coord))[1 - shift]; - - // Combine channel U and V - dst_u0 = src_u0; - dst_v0 = src_v0; - } - - break; - } - case Format::IYUV: - case Format::YUV444: - { - // Get Y/U/V element - const T &src = reinterpret_cast(image_planes[plane_idx](coord))[0]; - T &dst = reinterpret_cast(dst_tensor(coord))[0]; - - // Copy Y/U/V plane - dst = src; - - break; - } - default: - ARM_COMPUTE_ERROR("Not supported"); - break; - } - } - } - - return dst; -} - -template std::vector> channel_combine(const TensorShape &shape, const std::vector> &image_planes, Format format); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/reference/ChannelCombine.h b/tests/validation/reference/ChannelCombine.h deleted file mode 100644 index 315e2d4dd4..0000000000 --- a/tests/validation/reference/ChannelCombine.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_CHANNEL_COMBINE_H -#define ARM_COMPUTE_TEST_CHANNEL_COMBINE_H - -#include "tests/SimpleTensor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -std::vector> channel_combine(const TensorShape &shape, const std::vector> &image_planes, Format format); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_CHANNEL_COMBINE_H */ diff --git a/tests/validation/reference/ChannelExtract.cpp b/tests/validation/reference/ChannelExtract.cpp deleted file mode 100644 index 8674510269..0000000000 --- a/tests/validation/reference/ChannelExtract.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2017-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "ChannelExtract.h" - -#include "arm_compute/core/Types.h" -#include "tests/validation/Helpers.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor channel_extract(const TensorShape &shape, const std::vector> &tensor_planes, Format format, Channel channel) -{ - // Find plane and channel index - const unsigned int plane_idx = plane_idx_from_channel(format, channel); - const unsigned int channel_idx = channel_idx_from_format(format, channel); - - // Create dst and get src tensor - SimpleTensor src = tensor_planes[plane_idx]; - SimpleTensor dst{ calculate_subsampled_shape(shape, format, channel), Format::U8 }; - - // Single planar formats with subsampling require a double horizontal step - const int step_x = ((Format::YUYV422 == format || Format::UYVY422 == format) && Channel::Y != channel) ? 2 : 1; - const int width = dst.shape().x(); - const int height = dst.shape().y(); - - // Loop over each pixel and extract channel -#if defined(_OPENMP) - #pragma omp parallel for collapse(2) -#endif /* _OPENMP */ - for(int y = 0; y < height; ++y) - { - for(int x = 0; x < width; ++x) - { - const Coordinates src_coord{ x * step_x, y }; - const Coordinates dst_coord{ x, y }; - - const auto *src_pixel = reinterpret_cast(src(src_coord)); - auto *dst_pixel = reinterpret_cast(dst(dst_coord)); - - dst_pixel[0] = src_pixel[channel_idx]; // NOLINT - } - } - - return dst; -} - -template SimpleTensor channel_extract(const TensorShape &shape, const std::vector> &tensor_planes, Format format, Channel channel); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/reference/ChannelExtract.h b/tests/validation/reference/ChannelExtract.h deleted file mode 100644 index ce1e6732bd..0000000000 --- a/tests/validation/reference/ChannelExtract.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_CHANNEL_EXTRACT_H -#define ARM_COMPUTE_TEST_CHANNEL_EXTRACT_H - -#include "tests/SimpleTensor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor channel_extract(const TensorShape &shape, const std::vector> &tensor_planes, Format format, Channel channel); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_CHANNEL_EXTRACT_H */ diff --git a/tests/validation/reference/ColorConvert.cpp b/tests/validation/reference/ColorConvert.cpp deleted file mode 100644 index c6a4630999..0000000000 --- a/tests/validation/reference/ColorConvert.cpp +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "ColorConvert.h" - -#include "arm_compute/core/Types.h" -#include "tests/validation/Helpers.h" -#include "tests/validation/reference/ColorConvertHelper.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -namespace -{ -template -inline std::vector> create_image_planes(const TensorShape &shape, Format format) -{ - TensorShape image_shape = adjust_odd_shape(shape, format); - - std::vector> image_planes; - - switch(format) - { - case Format::U8: - case Format::RGB888: - case Format::RGBA8888: - case Format::YUYV422: - case Format::UYVY422: - { - image_planes.emplace_back(image_shape, format); - break; - } - case Format::NV12: - case Format::NV21: - { - TensorShape shape_uv88 = calculate_subsampled_shape(image_shape, Format::UV88); - - image_planes.emplace_back(image_shape, Format::U8); - image_planes.emplace_back(shape_uv88, Format::UV88); - break; - } - case Format::IYUV: - { - TensorShape shape_sub2 = calculate_subsampled_shape(image_shape, Format::IYUV); - - image_planes.emplace_back(image_shape, Format::U8); - image_planes.emplace_back(shape_sub2, Format::U8); - image_planes.emplace_back(shape_sub2, Format::U8); - break; - } - case Format::YUV444: - { - image_planes.emplace_back(image_shape, Format::U8); - image_planes.emplace_back(image_shape, Format::U8); - image_planes.emplace_back(image_shape, Format::U8); - break; - } - default: - ARM_COMPUTE_ERROR("Not supported"); - break; - } - - return image_planes; -} -} // namespace - -template -std::vector> color_convert(const TensorShape &shape, const std::vector> &tensor_planes, Format src_format, Format dst_format) -{ - std::vector> dst = create_image_planes(shape, dst_format); - - switch(src_format) - { - case Format::RGB888: - { - switch(dst_format) - { - case Format::RGBA8888: - colorconvert_helper::detail::colorconvert_rgb_to_rgbx(tensor_planes[0], dst[0]); - break; - case Format::U8: - colorconvert_helper::detail::colorconvert_rgb_to_u8(tensor_planes[0], dst[0]); - break; - case Format::NV12: - colorconvert_helper::detail::colorconvert_rgb_to_nv12(tensor_planes[0], dst); - break; - case Format::IYUV: - colorconvert_helper::detail::colorconvert_rgb_to_iyuv(tensor_planes[0], dst); - break; - case Format::YUV444: - colorconvert_helper::detail::colorconvert_rgb_to_yuv4(tensor_planes[0], dst); - break; - default: - ARM_COMPUTE_ERROR("Not Supported"); - break; - } - break; - } - case Format::RGBA8888: - { - switch(dst_format) - { - case Format::RGB888: - colorconvert_helper::detail::colorconvert_rgbx_to_rgb(tensor_planes[0], dst[0]); - break; - case Format::NV12: - colorconvert_helper::detail::colorconvert_rgb_to_nv12(tensor_planes[0], dst); - break; - case Format::IYUV: - colorconvert_helper::detail::colorconvert_rgb_to_iyuv(tensor_planes[0], dst); - break; - case Format::YUV444: - colorconvert_helper::detail::colorconvert_rgb_to_yuv4(tensor_planes[0], dst); - break; - default: - ARM_COMPUTE_ERROR("Not Supported"); - break; - } - break; - } - case Format::UYVY422: - case Format::YUYV422: - { - switch(dst_format) - { - case Format::RGB888: - case Format::RGBA8888: - colorconvert_helper::detail::colorconvert_yuyv_to_rgb(tensor_planes[0], src_format, dst[0]); - break; - case Format::NV12: - colorconvert_helper::detail::colorconvert_yuyv_to_nv12(tensor_planes[0], src_format, dst); - break; - case Format::IYUV: - colorconvert_helper::detail::colorconvert_yuyv_to_iyuv(tensor_planes[0], src_format, dst); - break; - default: - ARM_COMPUTE_ERROR("Not Supported"); - break; - } - break; - } - case Format::IYUV: - { - switch(dst_format) - { - case Format::RGB888: - case Format::RGBA8888: - colorconvert_helper::detail::colorconvert_iyuv_to_rgb(tensor_planes, dst[0]); - break; - default: - ARM_COMPUTE_ERROR("Not Supported"); - break; - } - break; - } - case Format::NV12: - case Format::NV21: - { - switch(dst_format) - { - case Format::RGB888: - case Format::RGBA8888: - colorconvert_helper::detail::colorconvert_nv12_to_rgb(src_format, tensor_planes, dst[0]); - break; - case Format::IYUV: - colorconvert_helper::detail::colorconvert_nv_to_iyuv(tensor_planes, src_format, dst); - break; - case Format::YUV444: - colorconvert_helper::detail::colorconvert_nv_to_yuv4(tensor_planes, src_format, dst); - break; - default: - ARM_COMPUTE_ERROR("Not Supported"); - break; - } - break; - } - default: - ARM_COMPUTE_ERROR("Not supported"); - break; - } - return dst; -} - -template std::vector> color_convert(const TensorShape &shape, const std::vector> &tensor_planes, Format src_format, Format dst_format); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/reference/ColorConvert.h b/tests/validation/reference/ColorConvert.h deleted file mode 100644 index 28776cb85f..0000000000 --- a/tests/validation/reference/ColorConvert.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_COLOR_CONVERT_H -#define ARM_COMPUTE_TEST_COLOR_CONVERT_H - -#include "tests/SimpleTensor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -std::vector> color_convert(const TensorShape &shape, const std::vector> &tensor_planes, Format src_format, Format dst_format); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_COLOR_CONVERT_H */ diff --git a/tests/validation/reference/Derivative.cpp b/tests/validation/reference/Derivative.cpp deleted file mode 100644 index c65ebcada5..0000000000 --- a/tests/validation/reference/Derivative.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2017-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "Derivative.h" - -#include "Utils.h" -#include "tests/Types.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -namespace -{ -const std::array derivative_3_x{ { 0, 0, 0, -1, 0, 1, 0, 0, 0 } }; -const std::array derivative_3_y{ { 0, -1, 0, 0, 0, 0, 0, 1, 0 } }; - -template -struct data_type; - -template <> -struct data_type -{ - const static DataType value = DataType::S16; -}; -} // namespace - -template -std::pair, SimpleTensor> derivative(const SimpleTensor &src, BorderMode border_mode, uint8_t constant_border_value, GradientDimension gradient_dimension) -{ - const unsigned int filter_size = 3; - - SimpleTensor dst_x(src.shape(), data_type::value, src.num_channels()); - SimpleTensor dst_y(src.shape(), data_type::value, src.num_channels()); - - ValidRegion valid_region = shape_to_valid_region(src.shape(), border_mode == BorderMode::UNDEFINED, BorderSize(filter_size / 2)); - - const uint32_t num_elements = src.num_elements(); -#if defined(_OPENMP) - #pragma omp parallel for -#endif /* _OPENMP */ - for(uint32_t i = 0; i < num_elements; ++i) - { - Coordinates coord = index2coord(src.shape(), i); - - if(!is_in_valid_region(valid_region, coord)) - { - continue; - } - - switch(gradient_dimension) - { - case GradientDimension::GRAD_X: - apply_2d_spatial_filter(coord, src, dst_x, TensorShape{ filter_size, filter_size }, derivative_3_x.data(), 1.f, border_mode, - constant_border_value); - break; - case GradientDimension::GRAD_Y: - apply_2d_spatial_filter(coord, src, dst_y, TensorShape{ filter_size, filter_size }, derivative_3_y.data(), 1.f, border_mode, - constant_border_value); - break; - case GradientDimension::GRAD_XY: - apply_2d_spatial_filter(coord, src, dst_x, TensorShape{ filter_size, filter_size }, derivative_3_x.data(), 1.f, border_mode, - constant_border_value); - apply_2d_spatial_filter(coord, src, dst_y, TensorShape{ filter_size, filter_size }, derivative_3_y.data(), 1.f, border_mode, - constant_border_value); - break; - default: - ARM_COMPUTE_ERROR("Gradient dimension not supported"); - } - } - - return std::make_pair(dst_x, dst_y); -} - -template std::pair, SimpleTensor> derivative(const SimpleTensor &src, BorderMode border_mode, uint8_t constant_border_value, - GradientDimension gradient_dimension); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/reference/Derivative.h b/tests/validation/reference/Derivative.h deleted file mode 100644 index 16f764e90e..0000000000 --- a/tests/validation/reference/Derivative.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_DERIVATIVE_H -#define ARM_COMPUTE_TEST_DERIVATIVE_H - -#include "tests/SimpleTensor.h" -#include "tests/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -std::pair, SimpleTensor> derivative(const SimpleTensor &src, BorderMode border_mode, uint8_t constant_border_value, GradientDimension gradient_dimension); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_DERIVATIVE_H */ diff --git a/tests/validation/reference/Dilate.cpp b/tests/validation/reference/Dilate.cpp deleted file mode 100644 index be8ccb6f3a..0000000000 --- a/tests/validation/reference/Dilate.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2017-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "Dilate.h" - -#include "Utils.h" -#include "tests/validation/Helpers.h" - -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor dilate(const SimpleTensor &src, BorderMode border_mode, T constant_border_value) -{ - /* - -1 x +1 - -1 [tl][tc][tr] -1 - y [ml][xy][mr] y - +1 [bl][bc][br] +1 - -1 x +1 - dilate: - dst(x, y) = max[ src(x', y') for x-1<=x'<=x+1, y-1<=y'<=y+1 ] = max({tl, tc, tr, ml, xy, mr, bl, bc, br}) - */ - SimpleTensor dst(src.shape(), src.data_type()); - const uint32_t num_elements = src.num_elements(); - -#if defined(_OPENMP) - #pragma omp parallel for -#endif /* _OPENMP */ - for(uint32_t i = 0; i < num_elements; ++i) - { - Coordinates coord = index2coord(src.shape(), i); - const int x = coord.x(); - const int y = coord.y(); - - std::array neighbours = { { 0 } }; - for(int row = y - 1, j = 0; row <= y + 1; ++row) - { - for(int col = x - 1; col <= x + 1; ++col, ++j) - { - coord.set(0, col); - coord.set(1, row); - neighbours[j] = tensor_elem_at(src, coord, border_mode, constant_border_value); - } - } - - dst[i] = *std::max_element(neighbours.cbegin(), neighbours.cend()); - } - - return dst; -} - -template SimpleTensor dilate(const SimpleTensor &src, BorderMode border_mode, uint8_t constant_border_value); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/reference/Dilate.h b/tests/validation/reference/Dilate.h deleted file mode 100644 index 640bc9dd73..0000000000 --- a/tests/validation/reference/Dilate.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_DILATE_H -#define ARM_COMPUTE_TEST_DILATE_H - -#include "tests/SimpleTensor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor dilate(const SimpleTensor &src, BorderMode border_mode, T constant_border_value = 0); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_DILATE_H */ diff --git a/tests/validation/reference/EqualizeHistogram.cpp b/tests/validation/reference/EqualizeHistogram.cpp deleted file mode 100644 index 8a957d7085..0000000000 --- a/tests/validation/reference/EqualizeHistogram.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2017-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "EqualizeHistogram.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor equalize_histogram(const SimpleTensor &src) -{ - const size_t num_bins = 256; // 0-255 inclusive - - std::vector lut(num_bins); - std::vector hist(num_bins); - std::vector cd(num_bins); // cumulative distribution - - SimpleTensor dst(src.shape(), src.data_type()); - - // Create the histogram - for(int element_idx = 0; element_idx < src.num_elements(); ++element_idx) - { - hist[src[element_idx]]++; - } - - // Calculate cumulative distribution - std::partial_sum(hist.begin(), hist.end(), cd.begin()); - - // Get the number of pixels that have the lowest non-zero value - const uint32_t cd_min = *std::find_if(hist.begin(), hist.end(), [](const uint32_t &x) - { - return x > 0; - }); - - const size_t total_num_pixels = cd.back(); - - // Single color - create linear distribution - if(total_num_pixels == cd_min) - { - std::iota(lut.begin(), lut.end(), 0); - } - else - { - const float diff = total_num_pixels - cd_min; - - for(size_t i = 0; i < num_bins; ++i) - { - lut[i] = lround((cd[i] - cd_min) / diff * 255.f); - } - } - - // Fill output tensor with equalized values -#if defined(_OPENMP) - #pragma omp parallel for -#endif /* _OPENMP */ - for(int i = 0; i < src.num_elements(); ++i) - { - dst[i] = lut[src[i]]; - } - - return dst; -} - -template SimpleTensor equalize_histogram(const SimpleTensor &src); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/reference/EqualizeHistogram.h b/tests/validation/reference/EqualizeHistogram.h deleted file mode 100644 index c79b2131aa..0000000000 --- a/tests/validation/reference/EqualizeHistogram.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_EQUALIZE_HISTOGRAM_H -#define ARM_COMPUTE_TEST_EQUALIZE_HISTOGRAM_H - -#include "tests/SimpleTensor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor equalize_histogram(const SimpleTensor &src); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_EQUALIZE_HISTOGRAM_H */ diff --git a/tests/validation/reference/FastCorners.cpp b/tests/validation/reference/FastCorners.cpp deleted file mode 100644 index 25fbf1b6f2..0000000000 --- a/tests/validation/reference/FastCorners.cpp +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "FastCorners.h" - -#include "Utils.h" -#include "tests/validation/Helpers.h" -#include "tests/validation/reference/NonMaximaSuppression.h" - -#include "tests/framework/Asserts.h" -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -namespace -{ -constexpr unsigned int bresenham_radius = 3; -constexpr unsigned int bresenham_count = 16; - -/* - Offsets of the 16 pixels in the Bresenham circle of radius 3 centered on P - . . . . . . . . . - . . . F 0 1 . . . - . . E . . . 2 . . - . D . . . . . 3 . - . C . . P . . 4 . - . B . . . . . 5 . - . . A . . . 6 . . - . . . 9 8 7 . . . - . . . . . . . . . -*/ -const std::array, 16> circle_offsets = -{ - { - { { 0, -3 } }, // 0 - pixel #1 - { { 1, -3 } }, // 1 - pixel #2 - { { 2, -2 } }, // 2 - pixel #3 - { { 3, -1 } }, // 3 - pixel #4 - { { 3, 0 } }, // 4 - pixel #5 - { { 3, 1 } }, // 5 - pixel #6 - { { 2, 2 } }, // 6 - pixel #7 - { { 1, 3 } }, // 7 - pixel #8 - { { 0, 3 } }, // 8 - pixel #9 - { { -1, 3 } }, // 9 - pixel #10 - { { -2, 2 } }, // A - pixel #11 - { { -3, 1 } }, // B - pixel #12 - { { -3, 0 } }, // C - pixel #13 - { { -3, -1 } }, // D - pixel #14 - { { -2, -2 } }, // E - pixel #15 - { { -1, -3 } } // F - pixel #16 - } -}; - -/* - FAST-9 bit masks for consecutive points surrounding a corner candidate - Rejection of non-corners is expedited by checking pixels 1, 9, then 5, 13... -*/ -const std::array fast9_masks = -{ - { - 0x01FF, // 0000 0001 1111 1111 - 0x03FE, // 0000 0011 1111 1110 - 0x07FC, // 0000 0111 1111 1100 - 0x0FF8, // 0000 1111 1111 1000 - 0x1FF0, // 0001 1111 1111 0000 - 0x3FE0, // 0011 1111 1110 0000 - 0x7FC0, // 0111 1111 1100 0000 - 0xFF80, // 1111 1111 1000 0000 - 0xFF01, // 1111 1111 0000 0001 - 0xFE03, // 1111 1110 0000 0011 - 0xFC07, // 1111 1100 0000 0111 - 0xF80F, // 1111 1000 0000 1111 - 0xF01F, // 1111 0000 0001 1111 - 0xE03F, // 1110 0000 0011 1111 - 0xC07F, // 1100 0000 0111 1111 - 0x80FF // 1000 0000 1111 1111 - } -}; - -inline bool in_range(const uint8_t low, const uint8_t high, const uint8_t val) -{ - return low <= val && val <= high; -} - -template -bool is_a_corner(const Coordinates &candidate, const SimpleTensor &src, uint8_t threshold, BorderMode border_mode, T constant_border_value, F intensity_at) -{ - const auto intensity_p = tensor_elem_at(src, candidate, border_mode, constant_border_value); - const auto thresh_bright = intensity_p + threshold; - const auto thresh_dark = intensity_p - threshold; - - // Quicker rejection of non-corner points by checking pixels 1, 9 then 5, 13 around the candidate - const auto p1 = intensity_at(candidate, 0); - const auto p9 = intensity_at(candidate, 8); - const auto p5 = intensity_at(candidate, 4); - const auto p13 = intensity_at(candidate, 12); - - if((in_range(thresh_dark, thresh_bright, p1) && in_range(thresh_dark, thresh_bright, p9)) - || (in_range(thresh_dark, thresh_bright, p5) && in_range(thresh_dark, thresh_bright, p13))) - { - return false; - } - - uint16_t mask_bright = 0; - uint16_t mask_dark = 0; - - // Set bits of the brighter/darker pixels mask accordingly - for(unsigned int n = 0; n < bresenham_count; ++n) - { - T intensity_n = intensity_at(candidate, n); - mask_bright |= (intensity_n > thresh_bright) << n; - mask_dark |= (intensity_n < thresh_dark) << n; - } - - // Mark as corner candidate if brighter/darker pixel sequence satisfies any one of the FAST-9 masks - const auto found = std::find_if(fast9_masks.begin(), fast9_masks.end(), [&](decltype(fast9_masks[0]) mask) - { - return (mask_bright & mask) == mask || (mask_dark & mask) == mask; - }); - - return found != fast9_masks.end(); -} -} // namespace - -template -std::vector fast_corners(const SimpleTensor &src, float input_thresh, bool suppress_nonmax, BorderMode border_mode, T constant_border_value) -{ - // Get intensity of pixel at given index on the Bresenham circle around a candidate point - const auto intensity_at = [&](const Coordinates & point, const unsigned int idx) - { - const auto offset = circle_offsets[idx]; - Coordinates px{ point.x() + offset[0], point.y() + offset[1] }; - return tensor_elem_at(src, px, border_mode, constant_border_value); - }; - - const auto threshold = static_cast(input_thresh); - std::vector corners; - - // 1. Detect potential corners (the segment test) - std::vector corner_candidates; - SimpleTensor scores(src.shape(), DataType::U8); - ValidRegion valid_region = shape_to_valid_region(src.shape(), BorderMode::UNDEFINED == border_mode, BorderSize(bresenham_radius)); - - const uint32_t num_elements = src.num_elements(); - for(uint32_t i = 0; i < num_elements; ++i) - { - Coordinates candidate = index2coord(src.shape(), i); - scores[i] = 0; - if(!is_in_valid_region(valid_region, candidate)) - { - continue; - } - - if(is_a_corner(candidate, src, threshold, border_mode, constant_border_value, intensity_at)) - { - corner_candidates.emplace_back(candidate); - scores[i] = 1; - } - } - - // 2. Calculate corner scores if necessary - if(suppress_nonmax) - { - for(const auto &candidate : corner_candidates) - { - const auto index = coord2index(scores.shape(), candidate); - uint8_t thresh_max = UINT8_MAX; - uint8_t thresh_min = threshold; - uint8_t response = (thresh_min + thresh_max) / 2; - - // Corner score (response) is the largest threshold for which the pixel remains a corner - while(thresh_max - thresh_min > 1) - { - response = (thresh_min + thresh_max) / 2; - if(is_a_corner(candidate, src, response, border_mode, constant_border_value, intensity_at)) - { - thresh_min = response; // raise threshold - } - else - { - thresh_max = response; // lower threshold - } - } - scores[index] = thresh_min; - } - - scores = non_maxima_suppression(scores, border_mode, constant_border_value); - valid_region = shape_to_valid_region(scores.shape(), BorderMode::UNDEFINED == border_mode, BorderSize(bresenham_radius + 1)); - } - - for(const auto &candidate : corner_candidates) - { - const auto index = coord2index(scores.shape(), candidate); - if(scores[index] > 0.f && is_in_valid_region(valid_region, candidate)) - { - KeyPoint corner; - corner.x = candidate.x(); - corner.y = candidate.y(); - corner.strength = scores[index]; - corner.tracking_status = 1; - corner.scale = 0.f; - corner.orientation = 0.f; - corner.error = 0.f; - corners.emplace_back(corner); - } - } - - return corners; -} - -template std::vector fast_corners(const SimpleTensor &src, float threshold, bool suppress_nonmax, BorderMode border_mode, uint8_t constant_border_value); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/reference/FastCorners.h b/tests/validation/reference/FastCorners.h deleted file mode 100644 index 2c4506de5c..0000000000 --- a/tests/validation/reference/FastCorners.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_FAST_CORNERS_H -#define ARM_COMPUTE_TEST_FAST_CORNERS_H - -#include "arm_compute/core/Types.h" -#include "tests/SimpleTensor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -std::vector fast_corners(const SimpleTensor &src, float input_thresh, bool suppress_nonmax, BorderMode border_mode, T constant_border_value = 0); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_FAST_CORNERS_H */ diff --git a/tests/validation/reference/Gaussian3x3.cpp b/tests/validation/reference/Gaussian3x3.cpp deleted file mode 100644 index 2e307e8152..0000000000 --- a/tests/validation/reference/Gaussian3x3.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2017-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Helpers.h" - -#include "Gaussian3x3.h" -#include "Utils.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor gaussian3x3(const SimpleTensor &src, BorderMode border_mode, T constant_border_value) -{ - SimpleTensor dst(src.shape(), src.data_type()); - const std::array filter{ { 1, 2, 1, 2, 4, 2, 1, 2, 1 } }; - const float scale = 1.f / 16.f; - const uint32_t num_elements = src.num_elements(); - -#if defined(_OPENMP) - #pragma omp parallel for -#endif /* _OPENMP */ - for(uint32_t element_idx = 0; element_idx < num_elements; ++element_idx) - { - const Coordinates id = index2coord(src.shape(), element_idx); - apply_2d_spatial_filter(id, src, dst, TensorShape(3U, 3U), filter.data(), scale, border_mode, constant_border_value); - } - return dst; -} - -template SimpleTensor gaussian3x3(const SimpleTensor &src, BorderMode border_mode, uint8_t constant_border_value); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/reference/Gaussian3x3.h b/tests/validation/reference/Gaussian3x3.h deleted file mode 100644 index a433db6693..0000000000 --- a/tests/validation/reference/Gaussian3x3.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_GAUSSIAN3X3_H -#define ARM_COMPUTE_TEST_GAUSSIAN3X3_H - -#include "tests/SimpleTensor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor gaussian3x3(const SimpleTensor &src, BorderMode border_mode, T constant_border_value); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_GAUSSIAN3X3_H */ diff --git a/tests/validation/reference/Gaussian5x5.cpp b/tests/validation/reference/Gaussian5x5.cpp deleted file mode 100644 index 2133d8980e..0000000000 --- a/tests/validation/reference/Gaussian5x5.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2017-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Helpers.h" - -#include "Gaussian5x5.h" -#include "Utils.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor gaussian5x5(const SimpleTensor &src, BorderMode border_mode, T constant_border_value) -{ - SimpleTensor dst(src.shape(), src.data_type()); - const std::array filter{ { - 1, 4, 6, 4, 1, - 4, 16, 24, 16, 4, - 6, 24, 36, 24, 6, - 4, 16, 24, 16, 4, - 1, 4, 6, 4, 1 - } }; - const float scale = 1.f / 256.f; - const uint32_t num_elements = src.num_elements(); - -#if defined(_OPENMP) - #pragma omp parallel for -#endif /* _OPENMP */ - for(uint32_t element_idx = 0; element_idx < num_elements; ++element_idx) - { - const Coordinates id = index2coord(src.shape(), element_idx); - apply_2d_spatial_filter(id, src, dst, TensorShape(5U, 5U), filter.data(), scale, border_mode, constant_border_value); - } - return dst; -} - -template SimpleTensor gaussian5x5(const SimpleTensor &src, BorderMode border_mode, uint8_t constant_border_value); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/reference/Gaussian5x5.h b/tests/validation/reference/Gaussian5x5.h deleted file mode 100644 index 42920bd4c0..0000000000 --- a/tests/validation/reference/Gaussian5x5.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_GAUSSIAN5X5_H -#define ARM_COMPUTE_TEST_GAUSSIAN5X5_H - -#include "tests/SimpleTensor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor gaussian5x5(const SimpleTensor &src, BorderMode border_mode, T constant_border_value); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_GAUSSIAN5X5_H */ diff --git a/tests/validation/reference/GaussianPyramidHalf.cpp b/tests/validation/reference/GaussianPyramidHalf.cpp deleted file mode 100644 index 5bddd853a0..0000000000 --- a/tests/validation/reference/GaussianPyramidHalf.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2017-2018 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "GaussianPyramidHalf.h" - -#include "arm_compute/core/Helpers.h" - -#include "Gaussian5x5.h" -#include "Scale.h" -#include "Utils.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -std::vector> gaussian_pyramid_half(const SimpleTensor &src, BorderMode border_mode, uint8_t constant_border_value, size_t num_levels) -{ - std::vector> dst; - - // Level0 is equal to src - dst.push_back(src); - - for(size_t i = 1; i < num_levels; ++i) - { - // Gaussian Filter - const SimpleTensor out_gaus5x5 = reference::gaussian5x5(dst[i - 1], border_mode, constant_border_value); - - // Scale down by 2 with nearest interpolation - const SimpleTensor out = reference::scale(out_gaus5x5, SCALE_PYRAMID_HALF, SCALE_PYRAMID_HALF, InterpolationPolicy::NEAREST_NEIGHBOR, border_mode, constant_border_value, SamplingPolicy::CENTER, - true); - - dst.push_back(out); - } - - return dst; -} - -template std::vector> gaussian_pyramid_half(const SimpleTensor &src, BorderMode border_mode, uint8_t constant_border_value, size_t num_levels); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/reference/GaussianPyramidHalf.h b/tests/validation/reference/GaussianPyramidHalf.h deleted file mode 100644 index 225ef00727..0000000000 --- a/tests/validation/reference/GaussianPyramidHalf.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_GAUSSIAN_PYRAMID_HALF_H -#define ARM_COMPUTE_TEST_GAUSSIAN_PYRAMID_HALF_H - -#include "tests/SimpleTensor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -std::vector> gaussian_pyramid_half(const SimpleTensor &src, BorderMode border_mode, uint8_t constant_border_value, size_t num_levels); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_GAUSSIAN_PYRAMID_HALF_H */ \ No newline at end of file diff --git a/tests/validation/reference/HOGDescriptor.cpp b/tests/validation/reference/HOGDescriptor.cpp deleted file mode 100644 index e00beaf5d7..0000000000 --- a/tests/validation/reference/HOGDescriptor.cpp +++ /dev/null @@ -1,264 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "HOGDescriptor.h" - -#include "Derivative.h" -#include "Magnitude.h" -#include "Phase.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -namespace -{ -template -void hog_orientation_compute(const SimpleTensor &mag, const SimpleTensor &phase, std::vector &bins, const HOGInfo &hog_info) -{ - const Size2D &cell_size = hog_info.cell_size(); - const size_t num_bins = hog_info.num_bins(); - - float phase_scale = (PhaseType::SIGNED == hog_info.phase_type() ? num_bins / 360.0f : num_bins / 180.0f); - phase_scale *= (PhaseType::SIGNED == hog_info.phase_type() ? 360.0f / 255.0f : 1.0f); - - int row_idx = 0; - for(size_t yc = 0; yc < cell_size.height; ++yc) - { - for(size_t xc = 0; xc < cell_size.width; xc++) - { - const float mag_value = mag[(row_idx + xc)]; - const float phase_value = phase[(row_idx + xc)] * phase_scale + 0.5f; - const float w1 = phase_value - floor(phase_value); - - // The quantised phase is the histogram index [0, num_bins - 1] - // Check limit of histogram index. If hidx == num_bins, hidx = 0 - const auto hidx = static_cast(phase_value) % num_bins; - - // Weighted vote between 2 bins - bins[hidx] += mag_value * (1.0f - w1); - bins[(hidx + 1) % num_bins] += mag_value * w1; - } - - row_idx += cell_size.width; - } -} - -template -void hog_block_normalization_compute(SimpleTensor &block, SimpleTensor &desc, const HOGInfo &hog_info, uint32_t block_idx) -{ - const int num_bins_per_block = desc.num_channels(); - const HOGNormType norm_type = hog_info.normalization_type(); - const Coordinates id = index2coord(desc.shape(), block_idx); - - float sum = 0.0f; - - // Calculate sum - for(int i = 0; i < num_bins_per_block; ++i) - { - const float val = block[i]; - sum += (norm_type == HOGNormType::L1_NORM) ? std::fabs(val) : val * val; - } - - // Calculate normalization scale - float scale = 1.0f / (std::sqrt(sum) + num_bins_per_block * 0.1f); - - if(norm_type == HOGNormType::L2HYS_NORM) - { - // Reset sum - sum = 0.0f; - for(int i = 0; i < num_bins_per_block; ++i) - { - float val = block[i] * scale; - - // Clip scaled input_value if over l2_hyst_threshold - val = fmin(val, hog_info.l2_hyst_threshold()); - sum += val * val; - block[i] = val; - } - - // We use the same constants of OpenCV - scale = 1.0f / (std::sqrt(sum) + 1e-3f); - } - - for(int i = 0; i < num_bins_per_block; ++i) - { - block[i] *= scale; - reinterpret_cast(desc(id))[i] = block[i]; - } -} -} // namespace - -template -void hog_orientation_binning(const SimpleTensor &mag, const SimpleTensor &phase, SimpleTensor &hog_space, const HOGInfo &hog_info) -{ - const Size2D &cell_size = hog_info.cell_size(); - - const size_t num_bins = hog_info.num_bins(); - const size_t shape_width = hog_space.shape().x() * hog_info.cell_size().width; - const size_t shape_height = hog_space.shape().y() * hog_info.cell_size().height; - - TensorShape cell_shape(cell_size.width, cell_size.height); - - SimpleTensor mag_cell(cell_shape, DataType::F32); - SimpleTensor phase_cell(cell_shape, DataType::F32); - - int cell_idx = 0; - int y_offset = 0; - - // Traverse shape - for(auto sy = cell_size.height; sy <= shape_height; sy += cell_size.height) - { - int x_offset = 0; - for(auto sx = cell_size.width; sx <= shape_width; sx += cell_size.width) - { - int row_idx = 0; - int elem_idx = 0; - - // Traverse cell - for(auto y = 0u; y < cell_size.height; ++y) - { - for(auto x = 0u; x < cell_size.width; ++x) - { - int shape_idx = x + row_idx + x_offset + y_offset; - mag_cell[elem_idx] = mag[shape_idx]; - phase_cell[elem_idx] = phase[shape_idx]; - elem_idx++; - } - - row_idx += shape_width; - } - - // Partition magnitude values into bins based on phase values - std::vector bins(num_bins); - hog_orientation_compute(mag_cell, phase_cell, bins, hog_info); - - for(size_t i = 0; i < num_bins; ++i) - { - hog_space[cell_idx * num_bins + i] = bins[i]; - } - - x_offset += cell_size.width; - cell_idx++; - } - - y_offset += (cell_size.height * shape_width); - } -} - -template -void hog_block_normalization(SimpleTensor &desc, const SimpleTensor &hog_space, const HOGInfo &hog_info) -{ - const Size2D cells_per_block = hog_info.num_cells_per_block(); - const Size2D cells_per_block_stride = hog_info.num_cells_per_block_stride(); - const Size2D &block_size = hog_info.block_size(); - const Size2D &block_stride = hog_info.block_stride(); - const size_t num_bins = hog_info.num_bins(); - - const size_t shape_width = hog_space.shape().x() * hog_info.cell_size().width; - const size_t shape_height = hog_space.shape().y() * hog_info.cell_size().height; - const size_t num_bins_per_block_x = cells_per_block.width * num_bins; - - // Tensor representing single block - SimpleTensor block(TensorShape{ 1u, 1u }, DataType::F32, cells_per_block.area() * num_bins); - - uint32_t block_idx = 0; - int block_y_offset = 0; - - // Traverse shape - for(auto sy = block_size.height; sy <= shape_height; sy += block_stride.height) - { - int block_x_offset = 0; - for(auto sx = block_size.width; sx <= shape_width; sx += block_stride.width) - { - int cell_y_offset = 0; - int elem_idx = 0; - - // Traverse block - for(auto y = 0u; y < cells_per_block.height; ++y) - { - for(auto x = 0u; x < num_bins_per_block_x; ++x) - { - int idx = x + cell_y_offset + block_x_offset + block_y_offset; - block[elem_idx] = hog_space[idx]; - elem_idx++; - } - - cell_y_offset += hog_space.shape().x() * num_bins; - } - - // Normalize block and write to descriptor - hog_block_normalization_compute(block, desc, hog_info, block_idx); - - block_x_offset += cells_per_block_stride.width * num_bins; - block_idx++; - } - - block_y_offset += cells_per_block_stride.height * num_bins * hog_space.shape().x(); - } -} - -template -SimpleTensor hog_descriptor(const SimpleTensor &src, BorderMode border_mode, U constant_border_value, const HOGInfo &hog_info) -{ - SimpleTensor grad_x; - SimpleTensor grad_y; - - // Create tensor info for HOG descriptor - TensorInfo desc_info(hog_info, src.shape().x(), src.shape().y()); - SimpleTensor desc(desc_info.tensor_shape(), DataType::F32, desc_info.num_channels()); - - // Create HOG space tensor (num_cells_x, num_cells_y) - TensorShape hog_space_shape(src.shape().x() / hog_info.cell_size().width, - src.shape().y() / hog_info.cell_size().height); - - // For each cell a histogram with a num_bins is created - TensorInfo info_hog_space(hog_space_shape, hog_info.num_bins(), DataType::F32); - SimpleTensor hog_space(info_hog_space.tensor_shape(), DataType::F32, info_hog_space.num_channels()); - - // Calculate derivative - std::tie(grad_x, grad_y) = derivative(src, border_mode, constant_border_value, GradientDimension::GRAD_XY); - - // For each cell create histogram based on magnitude and phase - hog_orientation_binning(magnitude(grad_x, grad_y, MagnitudeType::L2NORM), - phase(grad_x, grad_y, hog_info.phase_type()), - hog_space, - hog_info); - - // Normalize histograms based on block size - hog_block_normalization(desc, hog_space, hog_info); - - return desc; -} - -template void hog_orientation_binning(const SimpleTensor &mag, const SimpleTensor &phase, SimpleTensor &hog_space, const HOGInfo &hog_info); -template void hog_block_normalization(SimpleTensor &desc, const SimpleTensor &hog_space, const HOGInfo &hog_info); -template SimpleTensor hog_descriptor(const SimpleTensor &src, BorderMode border_mode, uint8_t constant_border_value, const HOGInfo &hog_info); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/reference/HOGDescriptor.h b/tests/validation/reference/HOGDescriptor.h deleted file mode 100644 index dffeb655b2..0000000000 --- a/tests/validation/reference/HOGDescriptor.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_HOG_DESCRIPTOR_H -#define ARM_COMPUTE_TEST_HOG_DESCRIPTOR_H - -#include "tests/SimpleTensor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -void hog_orientation_binning(const SimpleTensor &mag, const SimpleTensor &phase, SimpleTensor &hog_space, const HOGInfo &hog_info); - -template -void hog_block_normalization(SimpleTensor &desc, const SimpleTensor &hog_space, const HOGInfo &hog_info); - -template -SimpleTensor hog_descriptor(const SimpleTensor &src, BorderMode border_mode, U constant_border_value, const HOGInfo &hog_info); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_HOG_DESCRIPTOR_H */ diff --git a/tests/validation/reference/HOGDetector.cpp b/tests/validation/reference/HOGDetector.cpp deleted file mode 100644 index 798c3fc142..0000000000 --- a/tests/validation/reference/HOGDetector.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2018-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "HOGDetector.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -namespace -{ -/** Computes the number of detection windows to iterate over in the feature vector. */ -Size2D num_detection_windows(const TensorShape &shape, const Size2D &window_step, const HOGInfo &hog_info) -{ - const size_t num_block_strides_width = hog_info.detection_window_size().width / hog_info.block_stride().width; - const size_t num_block_strides_height = hog_info.detection_window_size().height / hog_info.block_stride().height; - - return Size2D{ floor_to_multiple(shape.x() - num_block_strides_width, window_step.width) + window_step.width, - floor_to_multiple(shape.y() - num_block_strides_height, window_step.height) + window_step.height }; -} -} // namespace - -template -std::vector hog_detector(const SimpleTensor &src, const std::vector &descriptor, unsigned int max_num_detection_windows, - const HOGInfo &hog_info, const Size2D &detection_window_stride, float threshold, uint16_t idx_class) -{ - ARM_COMPUTE_ERROR_ON_MSG((detection_window_stride.width % hog_info.block_stride().width != 0), - "Detection window stride width must be multiple of block stride width"); - ARM_COMPUTE_ERROR_ON_MSG((detection_window_stride.height % hog_info.block_stride().height != 0), - "Detection window stride height must be multiple of block stride height"); - - // Create vector for identifying each detection window - std::vector windows; - - // Calculate detection window step - const Size2D window_step(detection_window_stride.width / hog_info.block_stride().width, - detection_window_stride.height / hog_info.block_stride().height); - - // Calculate number of detection windows - const Size2D num_windows = num_detection_windows(src.shape(), window_step, hog_info); - - // Calculate detection window and row offsets in feature vector - const size_t src_offset_x = window_step.width * hog_info.num_bins() * hog_info.num_cells_per_block().area(); - const size_t src_offset_y = window_step.height * hog_info.num_bins() * hog_info.num_cells_per_block().area() * src.shape().x(); - const size_t src_offset_row = src.num_channels() * src.shape().x(); - - // Calculate detection window attributes - const Size2D num_block_positions_per_detection_window = hog_info.num_block_positions_per_image(hog_info.detection_window_size()); - const unsigned int num_bins_per_descriptor_x = num_block_positions_per_detection_window.width * src.num_channels(); - const unsigned int num_blocks_per_descriptor_y = num_block_positions_per_detection_window.height; - - ARM_COMPUTE_ERROR_ON((num_bins_per_descriptor_x * num_blocks_per_descriptor_y + 1) != hog_info.descriptor_size()); - - size_t win_id = 0; - - // Traverse feature vector in detection window steps - for(auto win_y = 0u, offset_y = 0u; win_y < num_windows.height; win_y += window_step.height, offset_y += src_offset_y) - { - for(auto win_x = 0u, offset_x = 0u; win_x < num_windows.width; win_x += window_step.width, offset_x += src_offset_x) - { - // Reset the score - float score = 0.0f; - - // Traverse detection window - for(auto y = 0u, offset_row = 0u; y < num_blocks_per_descriptor_y; ++y, offset_row += src_offset_row) - { - const int bin_offset = y * num_bins_per_descriptor_x; - - for(auto x = 0u; x < num_bins_per_descriptor_x; ++x) - { - // Compute Linear SVM - const float a = src[x + offset_x + offset_y + offset_row]; - const float b = descriptor[x + bin_offset]; - score += a * b; - } - } - - // Add the bias. The bias is located at the position (descriptor_size() - 1) - score += descriptor[num_bins_per_descriptor_x * num_blocks_per_descriptor_y]; - - if(score > threshold) - { - DetectionWindow window; - - if(win_id++ < max_num_detection_windows) - { - window.x = win_x * hog_info.block_stride().width; - window.y = win_y * hog_info.block_stride().height; - window.width = hog_info.detection_window_size().width; - window.height = hog_info.detection_window_size().height; - window.idx_class = idx_class; - window.score = score; - - windows.push_back(window); - } - } - } - } - - return windows; -} - -template std::vector hog_detector(const SimpleTensor &src, const std::vector &descriptor, unsigned int max_num_detection_windows, - const HOGInfo &hog_info, const Size2D &detection_window_stride, float threshold, uint16_t idx_class); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/reference/HOGDetector.h b/tests/validation/reference/HOGDetector.h deleted file mode 100644 index 9809ae384f..0000000000 --- a/tests/validation/reference/HOGDetector.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2018-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_HOG_DETECTOR_H -#define ARM_COMPUTE_TEST_HOG_DETECTOR_H - -#include "arm_compute/core/Types.h" -#include "arm_compute/core/Utils.h" -#include "tests/SimpleTensor.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -std::vector hog_detector(const SimpleTensor &src, const std::vector &descriptor, unsigned int max_num_detection_windows, - const HOGInfo &hog_info, const Size2D &detection_window_stride, float threshold = 0.0f, uint16_t idx_class = 0); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_HOG_DETECTOR_H */ diff --git a/tests/validation/reference/HOGMultiDetection.cpp b/tests/validation/reference/HOGMultiDetection.cpp deleted file mode 100644 index 50d846c0be..0000000000 --- a/tests/validation/reference/HOGMultiDetection.cpp +++ /dev/null @@ -1,279 +0,0 @@ -/* - * Copyright (c) 2017-2018 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "HOGMultiDetection.h" - -#include "Derivative.h" -#include "HOGDescriptor.h" -#include "HOGDetector.h" -#include "Magnitude.h" -#include "Phase.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -namespace -{ -void validate_models(const std::vector &models) -{ - ARM_COMPUTE_ERROR_ON(0 == models.size()); - - for(size_t i = 1; i < models.size(); ++i) - { - ARM_COMPUTE_ERROR_ON_MSG(models[0].phase_type() != models[i].phase_type(), - "All HOG parameters must have the same phase type"); - - ARM_COMPUTE_ERROR_ON_MSG(models[0].normalization_type() != models[i].normalization_type(), - "All HOG parameters must have the same normalization_type"); - - ARM_COMPUTE_ERROR_ON_MSG((models[0].l2_hyst_threshold() != models[i].l2_hyst_threshold()) && (models[0].normalization_type() == arm_compute::HOGNormType::L2HYS_NORM), - "All HOG parameters must have the same l2 hysteresis threshold if you use L2 hysteresis normalization type"); - } -} -} // namespace - -void detection_windows_non_maxima_suppression(std::vector &multi_windows, float min_distance) -{ - const size_t num_candidates = multi_windows.size(); - size_t num_detections = 0; - - // Sort by idx_class first and by score second - std::sort(multi_windows.begin(), multi_windows.end(), [](const DetectionWindow & lhs, const DetectionWindow & rhs) - { - if(lhs.idx_class < rhs.idx_class) - { - return true; - } - if(rhs.idx_class < lhs.idx_class) - { - return false; - } - - // idx_classes are equal so compare by score - if(lhs.score > rhs.score) - { - return true; - } - if(rhs.score > lhs.score) - { - return false; - } - - return false; - }); - - const float min_distance_pow2 = min_distance * min_distance; - - // Euclidean distance - for(size_t i = 0; i < num_candidates; ++i) - { - if(0.0f != multi_windows.at(i).score) - { - DetectionWindow cur; - cur.x = multi_windows.at(i).x; - cur.y = multi_windows.at(i).y; - cur.width = multi_windows.at(i).width; - cur.height = multi_windows.at(i).height; - cur.idx_class = multi_windows.at(i).idx_class; - cur.score = multi_windows.at(i).score; - - // Store window - multi_windows.at(num_detections) = cur; - ++num_detections; - - const float xc = cur.x + cur.width * 0.5f; - const float yc = cur.y + cur.height * 0.5f; - - for(size_t k = i + 1; k < (num_candidates) && (cur.idx_class == multi_windows.at(k).idx_class); ++k) - { - const float xn = multi_windows.at(k).x + multi_windows.at(k).width * 0.5f; - const float yn = multi_windows.at(k).y + multi_windows.at(k).height * 0.5f; - - const float dx = std::fabs(xn - xc); - const float dy = std::fabs(yn - yc); - - if(dx < min_distance && dy < min_distance) - { - const float d = dx * dx + dy * dy; - - if(d < min_distance_pow2) - { - // Invalidate detection window - multi_windows.at(k).score = 0.0f; - } - } - } - } - } - - multi_windows.resize(num_detections); -} - -template -std::vector hog_multi_detection(const SimpleTensor &src, BorderMode border_mode, T constant_border_value, - const std::vector &models, std::vector> descriptors, - unsigned int max_num_detection_windows, float threshold, bool non_maxima_suppression, float min_distance) -{ - ARM_COMPUTE_ERROR_ON(descriptors.size() != models.size()); - validate_models(models); - - const size_t width = src.shape().x(); - const size_t height = src.shape().y(); - const size_t num_models = models.size(); - - // Initialize previous values - size_t prev_num_bins = models[0].num_bins(); - Size2D prev_cell_size = models[0].cell_size(); - Size2D prev_block_size = models[0].block_size(); - Size2D prev_block_stride = models[0].block_stride(); - - std::vector input_orient_bin; - std::vector input_hog_detect; - std::vector> input_block_norm; - - input_orient_bin.push_back(0); - input_hog_detect.push_back(0); - input_block_norm.emplace_back(0, 0); - - // Iterate through the number of models and check if orientation binning - // and block normalization steps can be skipped - for(size_t i = 1; i < num_models; ++i) - { - size_t cur_num_bins = models[i].num_bins(); - Size2D cur_cell_size = models[i].cell_size(); - Size2D cur_block_size = models[i].block_size(); - Size2D cur_block_stride = models[i].block_stride(); - - // Check if binning and normalization steps are required - if((cur_num_bins != prev_num_bins) || (cur_cell_size.width != prev_cell_size.width) || (cur_cell_size.height != prev_cell_size.height)) - { - prev_num_bins = cur_num_bins; - prev_cell_size = cur_cell_size; - prev_block_size = cur_block_size; - prev_block_stride = cur_block_stride; - - // Compute orientation binning and block normalization. Update input to process - input_orient_bin.push_back(i); - input_block_norm.emplace_back(i, input_orient_bin.size() - 1); - } - else if((cur_block_size.width != prev_block_size.width) || (cur_block_size.height != prev_block_size.height) || (cur_block_stride.width != prev_block_stride.width) - || (cur_block_stride.height != prev_block_stride.height)) - { - prev_block_size = cur_block_size; - prev_block_stride = cur_block_stride; - - // Compute block normalization. Update input to process - input_block_norm.emplace_back(i, input_orient_bin.size() - 1); - } - - // Update input to process for hog detector - input_hog_detect.push_back(input_block_norm.size() - 1); - } - - size_t num_orient_bin = input_orient_bin.size(); - size_t num_block_norm = input_block_norm.size(); - size_t num_hog_detect = input_hog_detect.size(); - - std::vector> hog_spaces(num_orient_bin); - std::vector> hog_norm_spaces(num_block_norm); - - // Calculate derivative - SimpleTensor grad_x; - SimpleTensor grad_y; - std::tie(grad_x, grad_y) = derivative(src, border_mode, constant_border_value, GradientDimension::GRAD_XY); - - // Calculate magnitude and phase - SimpleTensor _mag = magnitude(grad_x, grad_y, MagnitudeType::L2NORM); - SimpleTensor _phase = phase(grad_x, grad_y, models[0].phase_type()); - - // Calculate Tensors for the HOG space and orientation binning - for(size_t i = 0; i < num_orient_bin; ++i) - { - const size_t idx_multi_hog = input_orient_bin[i]; - - const size_t num_bins = models[idx_multi_hog].num_bins(); - const size_t num_cells_x = width / models[idx_multi_hog].cell_size().width; - const size_t num_cells_y = height / models[idx_multi_hog].cell_size().height; - - // TensorShape of hog space - TensorShape hog_space_shape(num_cells_x, num_cells_y); - - // Initialise HOG space - TensorInfo info_hog_space(hog_space_shape, num_bins, DataType::F32); - hog_spaces.at(i) = SimpleTensor(info_hog_space.tensor_shape(), DataType::F32, info_hog_space.num_channels()); - - // For each cell create histogram based on magnitude and phase - hog_orientation_binning(_mag, _phase, hog_spaces[i], models[idx_multi_hog]); - } - - // Calculate Tensors for the normalized HOG space and block normalization - for(size_t i = 0; i < num_block_norm; ++i) - { - const size_t idx_multi_hog = input_block_norm[i].first; - const size_t idx_orient_bin = input_block_norm[i].second; - - // Create tensor info for HOG descriptor - TensorInfo tensor_info(models[idx_multi_hog], src.shape().x(), src.shape().y()); - hog_norm_spaces.at(i) = SimpleTensor(tensor_info.tensor_shape(), DataType::F32, tensor_info.num_channels()); - - // Normalize histograms based on block size - hog_block_normalization(hog_norm_spaces[i], hog_spaces[idx_orient_bin], models[idx_multi_hog]); - } - - std::vector multi_windows; - - // Calculate Detection Windows for HOG detector - for(size_t i = 0; i < num_hog_detect; ++i) - { - const size_t idx_block_norm = input_hog_detect[i]; - - // NOTE: Detection window stride fixed to block stride - const Size2D detection_window_stride = models[i].block_stride(); - - std::vector windows = hog_detector(hog_norm_spaces[idx_block_norm], descriptors[i], - max_num_detection_windows, models[i], detection_window_stride, threshold, i); - - multi_windows.insert(multi_windows.end(), windows.begin(), windows.end()); - } - - // Suppress Non-maxima detection windows - if(non_maxima_suppression) - { - detection_windows_non_maxima_suppression(multi_windows, min_distance); - } - - return multi_windows; -} - -template std::vector hog_multi_detection(const SimpleTensor &src, BorderMode border_mode, uint8_t constant_border_value, - const std::vector &models, std::vector> descriptors, - unsigned int max_num_detection_windows, float threshold, bool non_maxima_suppression, float min_distance); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/reference/HOGMultiDetection.h b/tests/validation/reference/HOGMultiDetection.h deleted file mode 100644 index 7194af70c7..0000000000 --- a/tests/validation/reference/HOGMultiDetection.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2018-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_HOG_MULTI_DETECTION_H -#define ARM_COMPUTE_TEST_HOG_MULTI_DETECTION_H - -#include "arm_compute/core/Types.h" -#include "tests/SimpleTensor.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -std::vector hog_multi_detection(const SimpleTensor &src, BorderMode border_mode, T constant_border_value, - const std::vector &models, std::vector> descriptors, - unsigned int max_num_detection_windows, float threshold = 0.0f, bool non_maxima_suppression = false, float min_distance = 1.0f); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_HOG_MULTI_DETECTION_H */ diff --git a/tests/validation/reference/HarrisCornerDetector.cpp b/tests/validation/reference/HarrisCornerDetector.cpp deleted file mode 100644 index 6c46b3de5d..0000000000 --- a/tests/validation/reference/HarrisCornerDetector.cpp +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright (c) 2017 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "HarrisCornerDetector.h" - -#include "Utils.h" -#include "tests/validation/Helpers.h" -#include "tests/validation/reference/NonMaximaSuppression.h" -#include "tests/validation/reference/Sobel.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -namespace -{ -template -std::tuple, SimpleTensor, float> compute_sobel(const SimpleTensor &src, int gradient_size, int block_size, BorderMode border_mode, uint8_t constant_border_value) -{ - SimpleTensor grad_x; - SimpleTensor grad_y; - float norm_factor = 0.f; - - std::tie(grad_x, grad_y) = sobel(src, gradient_size, border_mode, constant_border_value, GradientDimension::GRAD_XY); - - switch(gradient_size) - { - case 3: - norm_factor = 1.f / (4 * 255 * block_size); - break; - case 5: - norm_factor = 1.f / (16 * 255 * block_size); - break; - case 7: - norm_factor = 1.f / (64 * 255 * block_size); - break; - default: - ARM_COMPUTE_ERROR("Gradient size not supported."); - } - - return std::make_tuple(grad_x, grad_y, norm_factor); -} - -template -std::vector harris_corner_detector_impl(const SimpleTensor &src, float threshold, float min_dist, float sensitivity, int gradient_size, int block_size, BorderMode border_mode, - U constant_border_value) -{ - ARM_COMPUTE_ERROR_ON(block_size != 3 && block_size != 5 && block_size != 7); - - SimpleTensor grad_x; - SimpleTensor grad_y; - float norm_factor = 0.f; - - // Sobel - std::tie(grad_x, grad_y, norm_factor) = compute_sobel(src, gradient_size, block_size, border_mode, constant_border_value); - - SimpleTensor scores(src.shape(), DataType::F32); - ValidRegion scores_region = shape_to_valid_region(scores.shape(), border_mode == BorderMode::UNDEFINED, BorderSize(gradient_size / 2 + block_size / 2)); - - // Calculate scores - for(int i = 0; i < scores.num_elements(); ++i) - { - Coordinates src_coord = index2coord(src.shape(), i); - Coordinates block_top_left{ src_coord.x() - block_size / 2, src_coord.y() - block_size / 2 }; - Coordinates block_bottom_right{ src_coord.x() + block_size / 2, src_coord.y() + block_size / 2 }; - - if(!is_in_valid_region(scores_region, src_coord)) - { - scores[i] = 0.f; - continue; - } - - float Gx2 = 0.f; - float Gy2 = 0.f; - float Gxy = 0.f; - - // Calculate Gx^2, Gy^2 and Gxy within the given window - for(int y = block_top_left.y(); y <= block_bottom_right.y(); ++y) - { - for(int x = block_top_left.x(); x <= block_bottom_right.x(); ++x) - { - Coordinates block_coord(x, y); - - const float norm_x = tensor_elem_at(grad_x, block_coord, border_mode, static_cast(constant_border_value)) * norm_factor; - const float norm_y = tensor_elem_at(grad_y, block_coord, border_mode, static_cast(constant_border_value)) * norm_factor; - - Gx2 += std::pow(norm_x, 2); - Gy2 += std::pow(norm_y, 2); - Gxy += norm_x * norm_y; - } - } - - const float trace2 = std::pow(Gx2 + Gy2, 2); - const float det = Gx2 * Gy2 - std::pow(Gxy, 2); - const float response = det - sensitivity * trace2; - - if(response > threshold) - { - scores[i] = response; - } - else - { - scores[i] = 0.f; - } - } - - // Suppress non-maxima candidates - SimpleTensor suppressed_scores = non_maxima_suppression(scores, border_mode != BorderMode::UNDEFINED ? BorderMode::CONSTANT : BorderMode::UNDEFINED, 0.f); - ValidRegion suppressed_scores_region = shape_to_valid_region(suppressed_scores.shape(), border_mode == BorderMode::UNDEFINED, BorderSize(gradient_size / 2 + block_size / 2 + 1)); - - // Create vector of candidate corners - std::vector corner_candidates; - - for(int i = 0; i < suppressed_scores.num_elements(); ++i) - { - Coordinates coord = index2coord(suppressed_scores.shape(), i); - - if(is_in_valid_region(suppressed_scores_region, coord) && suppressed_scores[i] != 0.f) - { - KeyPoint corner; - corner.x = coord.x(); - corner.y = coord.y(); - corner.tracking_status = 1; - corner.strength = suppressed_scores[i]; - corner.scale = 0.f; - corner.orientation = 0.f; - corner.error = 0.f; - - corner_candidates.emplace_back(corner); - } - } - - // Sort descending by strength - std::sort(corner_candidates.begin(), corner_candidates.end(), [](const KeyPoint & a, const KeyPoint & b) - { - return a.strength > b.strength; - }); - - std::vector corners; - corners.reserve(corner_candidates.size()); - - // Only add corner if there is no stronger within min_dist - for(const KeyPoint &point : corner_candidates) - { - const auto strongest = std::find_if(corners.begin(), corners.end(), [&](const KeyPoint & other) - { - return std::sqrt((std::pow(point.x - other.x, 2) + std::pow(point.y - other.y, 2))) < min_dist; - }); - - if(strongest == corners.end()) - { - corners.emplace_back(point); - } - } - - corners.shrink_to_fit(); - - return corners; -} -} // namespace - -template -std::vector harris_corner_detector(const SimpleTensor &src, float threshold, float min_dist, float sensitivity, int gradient_size, int block_size, BorderMode border_mode, - T constant_border_value) -{ - if(gradient_size < 7) - { - return harris_corner_detector_impl(src, threshold, min_dist, sensitivity, gradient_size, block_size, border_mode, constant_border_value); - } - else - { - return harris_corner_detector_impl(src, threshold, min_dist, sensitivity, gradient_size, block_size, border_mode, constant_border_value); - } -} - -template std::vector harris_corner_detector(const SimpleTensor &src, float threshold, float min_dist, float sensitivity, int gradient_size, int block_size, BorderMode border_mode, - uint8_t constant_border_value); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/reference/HarrisCornerDetector.h b/tests/validation/reference/HarrisCornerDetector.h deleted file mode 100644 index 2f464749f6..0000000000 --- a/tests/validation/reference/HarrisCornerDetector.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_HARRIS_CORNER_DETECTOR_H -#define ARM_COMPUTE_TEST_HARRIS_CORNER_DETECTOR_H - -#include "arm_compute/core/Types.h" -#include "tests/SimpleTensor.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -std::vector harris_corner_detector(const SimpleTensor &src, - float threshold, float min_dist, float sensitivity, int gradient_size, int block_size, - BorderMode border_mode, T constant_border_value = 0); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_HARRIS_CORNER_DETECTOR_H */ diff --git a/tests/validation/reference/Histogram.cpp b/tests/validation/reference/Histogram.cpp deleted file mode 100644 index f9c77108e1..0000000000 --- a/tests/validation/reference/Histogram.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2017 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "Histogram.h" - -#include "Utils.h" -#include "arm_compute/core/Helpers.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor histogram(const SimpleTensor &src, size_t num_bins, int32_t offset, uint32_t range) -{ - SimpleTensor dst(TensorShape(num_bins), DataType::U32); - - // Clear the distribution - for(size_t element_idx = 0; element_idx < num_bins; ++element_idx) - { - dst[element_idx] = 0; - } - - // Create the histogram - for(int element_idx = 0; element_idx < src.num_elements(); ++element_idx) - { - if((offset <= src[element_idx]) && (src[element_idx] < (offset + range))) - { - const int index = (src[element_idx] - offset) * num_bins / range; - dst[index]++; - } - } - - return dst; -} - -template SimpleTensor histogram(const SimpleTensor &src, size_t num_bins, int32_t offset, uint32_t range); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/reference/Histogram.h b/tests/validation/reference/Histogram.h deleted file mode 100644 index 5f6c7d27a2..0000000000 --- a/tests/validation/reference/Histogram.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_HISTOGRAM_H -#define ARM_COMPUTE_TEST_HISTOGRAM_H - -#include "tests/SimpleTensor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor histogram(const SimpleTensor &src, size_t num_bins, int32_t offset, uint32_t range); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_HISTOGRAM_H */ diff --git a/tests/validation/reference/IntegralImage.cpp b/tests/validation/reference/IntegralImage.cpp deleted file mode 100644 index 0f6a7504fe..0000000000 --- a/tests/validation/reference/IntegralImage.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2017 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "IntegralImage.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor integral_image(const SimpleTensor &src) -{ - SimpleTensor dst(src.shape(), DataType::U32); - - // Length of dimensions - const size_t width = src.shape().x(); - const size_t height = src.shape().y(); - const size_t depth = src.shape().total_size_upper(2); - - const size_t image_size = width * height; - - for(size_t z = 0; z < depth; ++z) - { - size_t current_image = z * image_size; - - //First element of each image - dst[current_image] = src[current_image]; - - // First row of each image (add only pixel on the left) - for(size_t x = 1; x < width; ++x) - { - dst[current_image + x] = static_cast(src[current_image + x]) + dst[current_image + x - 1]; - } - - // Subsequent rows - for(size_t y = 1; y < height; ++y) - { - size_t current_row = current_image + (width * y); - - // First element of each row (add only pixel up) - dst[current_row] = static_cast(src[current_row]) + dst[current_row - width]; - - // Following row elements - for(size_t x = 1; x < width; ++x) - { - size_t current_pixel = current_row + x; - - // out = in + up(out) + left(out) - up_left(out) - dst[current_pixel] = static_cast(src[current_pixel]) + dst[current_pixel - 1] - + dst[current_pixel - width] - dst[current_pixel - width - 1]; - } - } - } - - return dst; -} - -template SimpleTensor integral_image(const SimpleTensor &src); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/reference/IntegralImage.h b/tests/validation/reference/IntegralImage.h deleted file mode 100644 index 2c9b96a1d6..0000000000 --- a/tests/validation/reference/IntegralImage.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_INTEGRAL_IMAGE_H -#define ARM_COMPUTE_TEST_INTEGRAL_IMAGE_H - -#include "tests/SimpleTensor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor integral_image(const SimpleTensor &src); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_INTEGRAL_IMAGE_H */ diff --git a/tests/validation/reference/LaplacianPyramid.cpp b/tests/validation/reference/LaplacianPyramid.cpp deleted file mode 100644 index 904b8403b3..0000000000 --- a/tests/validation/reference/LaplacianPyramid.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2018 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "LaplacianPyramid.h" - -#include "tests/validation/reference/ArithmeticOperations.h" -#include "tests/validation/reference/DepthConvertLayer.h" -#include "tests/validation/reference/Gaussian5x5.h" -#include "tests/validation/reference/GaussianPyramidHalf.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -std::vector> laplacian_pyramid(const SimpleTensor &src, SimpleTensor &dst, size_t num_levels, BorderMode border_mode, uint8_t constant_border_value) -{ - std::vector> pyramid_conv; - std::vector> pyramid_dst; - - // First, a Gaussian pyramid with SCALE_PYRAMID_HALF is created - std::vector> gaussian_level_pyramid = reference::gaussian_pyramid_half(src, border_mode, constant_border_value, num_levels); - - // For each level i, the corresponding image Ii is blurred with Gaussian 5x5 - // filter, and the difference between the two images is the corresponding - // level Li of the Laplacian pyramid - for(size_t i = 0; i < num_levels; ++i) - { - const SimpleTensor level_filtered = reference::gaussian5x5(gaussian_level_pyramid[i], border_mode, constant_border_value); - pyramid_conv.push_back(level_filtered); - - const SimpleTensor level_filtered_converted = depth_convert(level_filtered, DataType::S16, ConvertPolicy::WRAP, 0); - const SimpleTensor gaussian_level_converted = depth_convert(gaussian_level_pyramid[i], DataType::S16, ConvertPolicy::WRAP, 0); - - const SimpleTensor level_sub = reference::arithmetic_operation(reference::ArithmeticOperation::SUB, gaussian_level_converted, level_filtered_converted, dst.data_type(), ConvertPolicy::WRAP); - pyramid_dst.push_back(level_sub); - } - - // Return the lowest resolution image and the pyramid - dst = depth_convert(pyramid_conv[num_levels - 1], DataType::S16, ConvertPolicy::WRAP, 0); - - return pyramid_dst; -} - -template std::vector> laplacian_pyramid(const SimpleTensor &src, SimpleTensor &dst, size_t num_levels, BorderMode border_mode, uint8_t constant_border_value); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/reference/LaplacianPyramid.h b/tests/validation/reference/LaplacianPyramid.h deleted file mode 100644 index 0596b81648..0000000000 --- a/tests/validation/reference/LaplacianPyramid.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2018-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_LAPLACIAN_PYRAMID_H -#define ARM_COMPUTE_TEST_LAPLACIAN_PYRAMID_H - -#include "tests/SimpleTensor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -std::vector> laplacian_pyramid(const SimpleTensor &src, SimpleTensor &dst, size_t num_levels, BorderMode border_mode, uint8_t constant_border_value); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_LAPLACIAN_PYRAMID_H */ diff --git a/tests/validation/reference/LaplacianReconstruct.cpp b/tests/validation/reference/LaplacianReconstruct.cpp deleted file mode 100644 index 2a0fcc2a65..0000000000 --- a/tests/validation/reference/LaplacianReconstruct.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2018 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "LaplacianReconstruct.h" - -#include "arm_compute/core/Types.h" -#include "tests/validation/reference/ArithmeticOperations.h" -#include "tests/validation/reference/DepthConvertLayer.h" -#include "tests/validation/reference/Scale.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor laplacian_reconstruct(const std::vector> &pyramid, const SimpleTensor &low_res, BorderMode border_mode, T constant_border_value) -{ - std::vector> tmp_pyramid(pyramid); - - const size_t last_level = pyramid.size() - 1; - const DataType data_type = low_res.data_type(); - - // input + L(n-1) - tmp_pyramid[last_level] = reference::arithmetic_operation(reference::ArithmeticOperation::ADD, low_res, pyramid[last_level], data_type, ConvertPolicy::SATURATE); - - // Scale levels n-1 to 1, and add levels n-2 to 0 - for(size_t i = last_level; i-- > 0;) - { - const float scale_x = static_cast(tmp_pyramid[i].shape().x()) / tmp_pyramid[i + 1].shape().x(); - const float scale_y = static_cast(tmp_pyramid[i].shape().y()) / tmp_pyramid[i + 1].shape().y(); - - tmp_pyramid[i] = reference::scale(tmp_pyramid[i + 1], scale_x, scale_y, InterpolationPolicy::NEAREST_NEIGHBOR, - border_mode, constant_border_value, SamplingPolicy::CENTER, false); - - tmp_pyramid[i] = reference::arithmetic_operation(reference::ArithmeticOperation::ADD, tmp_pyramid[i], pyramid[i], data_type, ConvertPolicy::SATURATE); - } - - return reference::depth_convert(tmp_pyramid[0], DataType::U8, ConvertPolicy::SATURATE, 0); -} - -template SimpleTensor laplacian_reconstruct(const std::vector> &pyramid, const SimpleTensor &low_res, BorderMode border_mode, int16_t constant_border_value); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/reference/LaplacianReconstruct.h b/tests/validation/reference/LaplacianReconstruct.h deleted file mode 100644 index 8820c92983..0000000000 --- a/tests/validation/reference/LaplacianReconstruct.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2018-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_LAPLACIAN_RECONSTRUCT_H -#define ARM_COMPUTE_TEST_LAPLACIAN_RECONSTRUCT_H - -#include "tests/SimpleTensor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor laplacian_reconstruct(const std::vector> &pyramid, const SimpleTensor &low_res, BorderMode border_mode, T constant_border_value); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_LAPLACIAN_RECONSTRUCT_H */ diff --git a/tests/validation/reference/Magnitude.cpp b/tests/validation/reference/Magnitude.cpp deleted file mode 100644 index 390aaa5d48..0000000000 --- a/tests/validation/reference/Magnitude.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2017 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "Magnitude.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor magnitude(const SimpleTensor &gx, const SimpleTensor &gy, MagnitudeType magnitude_type) -{ - SimpleTensor mag(gx.shape(), gx.data_type()); - - using intermediate_type = typename common_promoted_unsigned_type::intermediate_type; - - for(int i = 0; i < gx.num_elements(); ++i) - { - double val = 0.f; - - if(magnitude_type == MagnitudeType::L1NORM) - { - val = static_cast(std::abs(gx[i])) + static_cast(std::abs(gy[i])); - } - else // MagnitudeType::L2NORM - { - // Note: kernel saturates to uint32_t instead of intermediate_type for S32 format - auto sum = static_cast(gx[i] * gx[i]) + static_cast(gy[i] * gy[i]); - val = std::sqrt(sum) + 0.5f; - } - - mag[i] = saturate_cast(val); - } - - return mag; -} - -template SimpleTensor magnitude(const SimpleTensor &gx, const SimpleTensor &gy, MagnitudeType magnitude_type); -template SimpleTensor magnitude(const SimpleTensor &gx, const SimpleTensor &gy, MagnitudeType magnitude_type); -template SimpleTensor magnitude(const SimpleTensor &gx, const SimpleTensor &gy, MagnitudeType magnitude_type); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/reference/Magnitude.h b/tests/validation/reference/Magnitude.h deleted file mode 100644 index 81db27de20..0000000000 --- a/tests/validation/reference/Magnitude.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_MAGNITUDE_H -#define ARM_COMPUTE_TEST_MAGNITUDE_H - -#include "tests/SimpleTensor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor magnitude(const SimpleTensor &gx, const SimpleTensor &gy, MagnitudeType magnitude_type); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_MAGNITUDE_H */ diff --git a/tests/validation/reference/Median3x3.cpp b/tests/validation/reference/Median3x3.cpp deleted file mode 100644 index 55f5f62292..0000000000 --- a/tests/validation/reference/Median3x3.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Helpers.h" - -#include "Median3x3.h" -#include "Utils.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -namespace -{ -constexpr unsigned int filter_size = 3; /* Size of the kernel/filter in number of elements. */ -constexpr BorderSize border_size(filter_size / 2); /* Border size of the kernel/filter around its central element. */ -} // namespace - -template -SimpleTensor median3x3(const SimpleTensor &src, BorderMode border_mode, T constant_border_value) -{ - SimpleTensor dst(src.shape(), src.data_type()); - const int size_tot_filter = filter_size * filter_size; - const uint32_t num_elements = src.num_elements(); - - for(uint32_t src_idx = 0; src_idx < num_elements; ++src_idx) - { - std::array filter_elems = { { 0 } }; - Coordinates id = index2coord(src.shape(), src_idx); - const int x = id.x(); - const int y = id.y(); - - for(int j = y - static_cast(border_size.top), index = 0; j <= y + static_cast(border_size.bottom); ++j) - { - for(int i = x - static_cast(border_size.left); i <= x + static_cast(border_size.right); ++i, ++index) - { - id.set(0, i); - id.set(1, j); - filter_elems[index] = tensor_elem_at(src, id, border_mode, constant_border_value); - } - } - std::sort(filter_elems.begin(), filter_elems.end()); - dst[src_idx] = filter_elems[size_tot_filter / 2]; - } - - return dst; -} - -template SimpleTensor median3x3(const SimpleTensor &src, BorderMode border_mode, uint8_t constant_border_value); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/reference/Median3x3.h b/tests/validation/reference/Median3x3.h deleted file mode 100644 index a10f428d0c..0000000000 --- a/tests/validation/reference/Median3x3.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_MEDIAN3X3_H -#define ARM_COMPUTE_TEST_MEDIAN3X3_H - -#include "tests/SimpleTensor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor median3x3(const SimpleTensor &src, BorderMode border_mode, T constant_border_value); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_MEDIAN3X3_H */ diff --git a/tests/validation/reference/NonLinearFilter.cpp b/tests/validation/reference/NonLinearFilter.cpp deleted file mode 100644 index ada8286927..0000000000 --- a/tests/validation/reference/NonLinearFilter.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "NonLinearFilter.h" -#include "Utils.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor non_linear_filter(const SimpleTensor &src, NonLinearFilterFunction function, unsigned int mask_size, MatrixPattern pattern, const uint8_t *mask, BorderMode border_mode, - uint8_t constant_border_value) -{ - SimpleTensor dst(src.shape(), src.data_type()); - - ARM_COMPUTE_ERROR_ON(pattern == MatrixPattern::OTHER && mask == nullptr); - ARM_COMPUTE_UNUSED(pattern); - - using intermediate_type = typename common_promoted_signed_type::intermediate_type; - - const int sq_mask_size = mask_size * mask_size; - const int half_mask_size = mask_size / 2; - std::vector vals(sq_mask_size); - intermediate_type current_value = 0; - - const ValidRegion valid_region = shape_to_valid_region(src.shape(), border_mode == BorderMode::UNDEFINED, BorderSize(half_mask_size)); - const uint32_t num_elements = src.num_elements(); - - for(uint32_t element_idx = 0, count = 0, index = 0; element_idx < num_elements; ++element_idx, count = 0, index = 0) - { - Coordinates id = index2coord(src.shape(), element_idx); - if(is_in_valid_region(valid_region, id)) - { - int idx = id.x(); - int idy = id.y(); - for(int y = idy - half_mask_size; y <= idy + half_mask_size; ++y) - { - for(int x = idx - half_mask_size; x <= idx + half_mask_size; ++x, ++index) - { - id.set(0, x); - id.set(1, y); - current_value = tensor_elem_at(src, id, border_mode, constant_border_value); - - if(mask[index] == 255) - { - vals[count] = static_cast(current_value); - ++count; - } - } - } - std::sort(vals.begin(), vals.begin() + count); - - ARM_COMPUTE_ERROR_ON(count == 0); - - switch(function) - { - case NonLinearFilterFunction::MIN: - dst[element_idx] = saturate_cast(vals[0]); - break; - case NonLinearFilterFunction::MAX: - dst[element_idx] = saturate_cast(vals[count - 1]); - break; - case NonLinearFilterFunction::MEDIAN: - dst[element_idx] = saturate_cast(vals[count / 2]); - break; - default: - ARM_COMPUTE_ERROR("Unsupported NonLinearFilter function."); - } - } - } - - return dst; -} - -template SimpleTensor non_linear_filter(const SimpleTensor &src, NonLinearFilterFunction function, unsigned int mask_size, MatrixPattern pattern, const uint8_t *mask, - BorderMode border_mode, uint8_t constant_border_value); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/reference/NonLinearFilter.h b/tests/validation/reference/NonLinearFilter.h deleted file mode 100644 index ecf6563a15..0000000000 --- a/tests/validation/reference/NonLinearFilter.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_BITWISE_NOT_H -#define ARM_COMPUTE_TEST_BITWISE_NOT_H - -#include "tests/SimpleTensor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor non_linear_filter(const SimpleTensor &src, NonLinearFilterFunction function, unsigned int mask_size, MatrixPattern pattern, const uint8_t *mask, BorderMode border_mode, - uint8_t constant_border_value); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_BITWISE_NOT_H */ diff --git a/tests/validation/reference/OpticalFlow.cpp b/tests/validation/reference/OpticalFlow.cpp deleted file mode 100644 index 0a04214045..0000000000 --- a/tests/validation/reference/OpticalFlow.cpp +++ /dev/null @@ -1,404 +0,0 @@ -/* - * Copyright (c) 2018 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "OpticalFlow.h" - -#include "GaussianPyramidHalf.h" -#include "Scharr.h" -#include "Utils.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -namespace -{ -using KeyPointArray = std::vector; -using InternalKeyPointArray = std::vector; - -// Constants used for Lucas-Kanade Algorithm -constexpr int W_BITS = 14; -constexpr float D0 = 1 << W_BITS; -constexpr float DETERMINANT_THRESHOLD = 1.0e-07f; -constexpr float EIGENVALUE_THRESHOLD = 1.0e-04f; -constexpr float FLT_SCALE = 1.0f / (1 << 20); - -// Creates an InternalKeyPointArray for tracking non-integral pixel coordinates -InternalKeyPointArray create_internal_keypoints(const KeyPointArray &keypoints) -{ - InternalKeyPointArray internal_keypoints; - - for(auto keypoint : keypoints) - { - InternalKeyPoint internal_keypoint; - - internal_keypoint.x = static_cast(keypoint.x); - internal_keypoint.y = static_cast(keypoint.y); - internal_keypoint.tracking_status = static_cast(keypoint.tracking_status); - - internal_keypoints.push_back(internal_keypoint); - } - - return internal_keypoints; -} - -// Scale tracked points based on Pyramid level -void scale_tracked_points(size_t level, size_t num_levels, bool use_initial_estimate, - InternalKeyPointArray &old_points_internal, InternalKeyPointArray &new_points_internal, - const KeyPointArray &old_points, const KeyPointArray &new_points_estimates) -{ - if(level == num_levels - 1) // lowest resolution - { - const float scale = std::pow(SCALE_PYRAMID_HALF, level); - - for(size_t i = 0; i < old_points.size(); ++i) - { - old_points_internal.at(i).x = old_points.at(i).x * scale; - old_points_internal.at(i).y = old_points.at(i).y * scale; - old_points_internal.at(i).tracking_status = true; - - InternalKeyPoint keypoint_to_track; - - if(use_initial_estimate) - { - keypoint_to_track.x = new_points_estimates.at(i).x * scale; - keypoint_to_track.y = new_points_estimates.at(i).y * scale; - keypoint_to_track.tracking_status = (new_points_estimates.at(i).tracking_status == 1); - } - else - { - keypoint_to_track.x = old_points_internal.at(i).x; - keypoint_to_track.y = old_points_internal.at(i).y; - keypoint_to_track.tracking_status = true; - } - - new_points_internal.at(i) = keypoint_to_track; - } - } - else - { - for(size_t i = 0; i < old_points.size(); ++i) - { - old_points_internal.at(i).x /= SCALE_PYRAMID_HALF; - old_points_internal.at(i).y /= SCALE_PYRAMID_HALF; - new_points_internal.at(i).x /= SCALE_PYRAMID_HALF; - new_points_internal.at(i).y /= SCALE_PYRAMID_HALF; - } - } -} - -bool is_invalid_keypoint(const InternalKeyPoint &keypoint, const ValidRegion &valid_region, size_t window_dimension) -{ - const int half_window = window_dimension / 2; - const int x = std::floor(keypoint.x); - const int y = std::floor(keypoint.y); - - return (x - half_window < valid_region.start(0)) || (x + half_window >= valid_region.end(0) - 1) || (y - half_window < valid_region.start(1)) || (y + half_window >= valid_region.end(1) - 1); -} - -template -constexpr int INT_ROUND(T x, int n) -{ - return (x + (1 << (n - 1))) >> n; -} - -// Return the bilinear value at a specified coordinate with different border modes -template -int bilinear_interpolate(const SimpleTensor &in, Coordinates id, float wx, float wy, BorderMode border_mode, T constant_border_value, int scale) -{ - const int level = id.x(); - const int idy = id.y(); - - const float dx = wx; - const float dy = wy; - const float dx_1 = 1.0f - dx; - const float dy_1 = 1.0f - dy; - - const T border_value = constant_border_value; - - id.set(0, level); - id.set(1, idy); - const T tl = tensor_elem_at(in, id, border_mode, border_value); - id.set(0, level + 1); - id.set(1, idy); - const T tr = tensor_elem_at(in, id, border_mode, border_value); - id.set(0, level); - id.set(1, idy + 1); - const T bl = tensor_elem_at(in, id, border_mode, border_value); - id.set(0, level + 1); - id.set(1, idy + 1); - const T br = tensor_elem_at(in, id, border_mode, border_value); - - // weights - const int w00 = roundf(dx_1 * dy_1 * D0); - const int w01 = roundf(dx * dy_1 * D0); - const int w10 = roundf(dx_1 * dy * D0); - const int w11 = D0 - w00 - w01 - w10; - - return static_cast(INT_ROUND(tl * w00 + tr * w01 + bl * w10 + br * w11, scale)); -} - -template -std::vector compute_derivative(const SimpleTensor &input, const InternalKeyPoint &keypoint, - BorderMode border_mode, uint8_t constant_border_value, size_t window_dimension, int scale) -{ - std::vector bilinear_values; - - const int half_window = window_dimension / 2; - - float keypoint_int_x = 0; - float keypoint_int_y = 0; - - const float wx = std::modf(keypoint.x, &keypoint_int_x); - const float wy = std::modf(keypoint.y, &keypoint_int_y); - - Coordinates tl_window(static_cast(keypoint_int_x) - half_window, static_cast(keypoint_int_y) - half_window); - Coordinates br_window(static_cast(keypoint_int_x) + half_window, static_cast(keypoint_int_y) + half_window); - - for(int y = tl_window.y(); y <= br_window.y(); ++y) - { - for(int x = tl_window.x(); x <= br_window.x(); ++x) - { - bilinear_values.push_back(bilinear_interpolate(input, Coordinates(x, y), wx, wy, border_mode, static_cast(constant_border_value), scale)); - } - } - - return bilinear_values; -} - -std::tuple compute_spatial_gradient_matrix(const std::vector &bilinear_ix, const std::vector &bilinear_iy) -{ - ARM_COMPUTE_ERROR_ON(bilinear_ix.size() != bilinear_iy.size()); - - int iA11 = 0; - int iA12 = 0; - int iA22 = 0; - - for(size_t i = 0; i < bilinear_ix.size(); ++i) - { - int ixval = bilinear_ix[i]; - int iyval = bilinear_iy[i]; - - iA11 += ixval * ixval; - iA12 += ixval * iyval; - iA22 += iyval * iyval; - } - - return std::make_tuple(iA11 * FLT_SCALE, iA12 * FLT_SCALE, iA22 * FLT_SCALE); -} - -std::tuple compute_temporal_gradient_vector(const std::vector &bilinear_it_old, - const std::vector &bilinear_it_new, - const std::vector &bilinear_ix, - const std::vector &bilinear_iy) -{ - ARM_COMPUTE_ERROR_ON(bilinear_ix.size() != bilinear_iy.size()); - ARM_COMPUTE_ERROR_ON(bilinear_it_old.size() != bilinear_it_new.size()); - - int ib1 = 0; - int ib2 = 0; - - for(size_t i = 0; i < bilinear_ix.size(); ++i) - { - int ixval = bilinear_ix[i]; - int iyval = bilinear_iy[i]; - int ival = bilinear_it_old[i]; - int jval = bilinear_it_new[i]; - - const int diff = jval - ival; - - ib1 += diff * ixval; - ib2 += diff * iyval; - } - - const double b1 = ib1 * FLT_SCALE; - const double b2 = ib2 * FLT_SCALE; - - return std::make_tuple(b1, b2); -} -} // namespace - -template -std::vector optical_flow(const SimpleTensor &old_input, const SimpleTensor &new_input, - const OpticalFlowParameters ¶ms, size_t num_levels, - const std::vector &old_points, const std::vector &new_points_estimates, - BorderMode border_mode, uint8_t constant_border_value) -{ - const int filter_size = 3; // scharr filter size - const size_t max_iterations = 1000; // fixed by kernel - const size_t window_dimension = params.window_dimension; - const size_t num_iterations = (params.termination == Termination::TERM_CRITERIA_EPSILON) ? max_iterations : params.num_iterations; - - KeyPointArray new_points(old_points.size()); - - InternalKeyPointArray old_points_internal = create_internal_keypoints(old_points); - InternalKeyPointArray new_points_internal = create_internal_keypoints(new_points_estimates); - - SimpleTensor scharr_gx; - SimpleTensor scharr_gy; - - // Create pyramids - std::vector> old_pyramid = gaussian_pyramid_half(old_input, border_mode, constant_border_value, num_levels); - std::vector> new_pyramid = gaussian_pyramid_half(new_input, border_mode, constant_border_value, num_levels); - - // Iterate over each level of the pyramid - for(size_t idx = num_levels; idx > 0; --idx) - { - const size_t level = idx - 1; - - // Calculate scharr gradients - std::tie(scharr_gx, scharr_gy) = scharr(old_pyramid[level], filter_size, border_mode, constant_border_value, GradientDimension::GRAD_XY); - - scale_tracked_points(level, num_levels, params.use_initial_estimate, old_points_internal, new_points_internal, old_points, new_points_estimates); - - // Calculate valid region based on image dimensions of current pyramid level - const ValidRegion valid_region = shape_to_valid_region(old_pyramid[level].shape(), (border_mode == BorderMode::UNDEFINED), BorderSize(filter_size / 2)); - - for(size_t i = 0; i < old_points.size(); ++i) - { - InternalKeyPoint &old_keypoint = old_points_internal.at(i); - InternalKeyPoint &new_keypoint = new_points_internal.at(i); - - // Helper function for untracking keypoints when on the lowest pyramid level (high resolution) - const auto untrack_keypoint = [&](bool predicate) - { - if(predicate && (level == 0)) - { - new_keypoint.tracking_status = false; - return true; - } - return predicate; - }; - - if(!old_keypoint.tracking_status) - { - continue; - } - - // Check if tracked coordinate is outside image coordinate - if(untrack_keypoint(is_invalid_keypoint(old_keypoint, valid_region, window_dimension))) - { - continue; - } - - // Compute spatial derivative - std::vector bilinear_ix = compute_derivative(scharr_gx, old_keypoint, border_mode, constant_border_value, window_dimension, W_BITS); - std::vector bilinear_iy = compute_derivative(scharr_gy, old_keypoint, border_mode, constant_border_value, window_dimension, W_BITS); - - float A11 = 0.f; - float A12 = 0.f; - float A22 = 0.f; - std::tie(A11, A12, A22) = compute_spatial_gradient_matrix(bilinear_ix, bilinear_iy); - - // Calculate criteria for lost tracking : Matrix A is invertible - // 1. The determinant of the matrix is less than DETERMINANT_THRESHOLD - // 2. The minimum eigenvalue of the matrix is less than EIGENVALUE_THRESHOLD - const float trace_A = A11 + A22; - const float determinant = A11 * A22 - A12 * A12; - const float discriminant = (trace_A * trace_A) - 4.0f * (determinant); - const float eigenvalue_A = (trace_A - std::sqrt(discriminant)) / 2.0f; - - // Divide by window_dimension squared to reduce the floating point accummulation error - const float eigenvalue = eigenvalue_A / (window_dimension * window_dimension); - - // Check if it is a good point to track - if(untrack_keypoint(eigenvalue < EIGENVALUE_THRESHOLD || determinant < DETERMINANT_THRESHOLD)) - { - continue; - } - - float prev_delta_x = 0.f; - float prev_delta_y = 0.f; - - for(size_t j = 0; j < num_iterations; ++j) - { - // Check if tracked coordinate is outside image coordinate - if(untrack_keypoint(is_invalid_keypoint(new_keypoint, valid_region, window_dimension))) - { - break; - } - - // Compute temporal derivative - std::vector bilinear_it_old = compute_derivative(old_pyramid[level], old_keypoint, border_mode, constant_border_value, window_dimension, W_BITS - 5); - std::vector bilinear_it_new = compute_derivative(new_pyramid[level], new_keypoint, border_mode, constant_border_value, window_dimension, W_BITS - 5); - - double b1 = 0.f; - double b2 = 0.f; - std::tie(b1, b2) = compute_temporal_gradient_vector(bilinear_it_old, bilinear_it_new, bilinear_ix, bilinear_iy); - - // Compute motion vector -> A^-1 * -b - const float delta_x = (A12 * b2 - A22 * b1) / determinant; - const float delta_y = (A12 * b1 - A11 * b2) / determinant; - - // Update the new position - new_keypoint.x += delta_x; - new_keypoint.y += delta_y; - - const float magnitude_squared = delta_x * delta_x + delta_y * delta_y; - - // Check if termination criteria is EPSILON and if it is satisfied - if(magnitude_squared <= params.epsilon && (params.termination == Termination::TERM_CRITERIA_EPSILON || params.termination == Termination::TERM_CRITERIA_BOTH)) - { - break; - } - - // Check convergence analyzing the previous delta - if(j > 0 && (std::fabs(delta_x + prev_delta_x) < 0.01f && std::fabs(delta_y + prev_delta_y) < 0.01f)) - { - new_keypoint.x -= delta_x * SCALE_PYRAMID_HALF; - new_keypoint.y -= delta_y * SCALE_PYRAMID_HALF; - - break; - } - - prev_delta_x = delta_x; - prev_delta_y = delta_y; - } - } - } - - // Copy optical flow coordinates to output vector - for(size_t i = 0; i < old_points.size(); ++i) - { - const InternalKeyPoint &new_keypoint = new_points_internal.at(i); - - new_points.at(i).x = roundf(new_keypoint.x); - new_points.at(i).y = roundf(new_keypoint.y); - new_points.at(i).tracking_status = new_keypoint.tracking_status ? 1 : 0; - } - - return new_points; -} - -template std::vector optical_flow(const SimpleTensor &old_input, const SimpleTensor &new_input, - const OpticalFlowParameters ¶ms, size_t num_levels, - const std::vector &old_points, const std::vector &new_points_estimates, - BorderMode border_mode, uint8_t constant_border_value); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/reference/OpticalFlow.h b/tests/validation/reference/OpticalFlow.h deleted file mode 100644 index 1bc367ab6a..0000000000 --- a/tests/validation/reference/OpticalFlow.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2018-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_OPTICAL_FLOW_H -#define ARM_COMPUTE_TEST_OPTICAL_FLOW_H - -#include "tests/SimpleTensor.h" -#include "tests/Types.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -std::vector optical_flow(const SimpleTensor &old_input, const SimpleTensor &new_input, - const OpticalFlowParameters ¶ms, size_t num_levels, - const std::vector &old_points, const std::vector &new_points_estimates, - BorderMode border_mode, uint8_t constant_border_value); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_OPTICAL_FLOW_H */ diff --git a/tests/validation/reference/Phase.cpp b/tests/validation/reference/Phase.cpp deleted file mode 100644 index 228f73bb37..0000000000 --- a/tests/validation/reference/Phase.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2017 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "Phase.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor phase(const SimpleTensor &gx, const SimpleTensor &gy, PhaseType phase_type) -{ - const float PI = std::atan(1) * 4; - SimpleTensor phase(gx.shape(), DataType::U8); - - if(phase_type == PhaseType::UNSIGNED) // unsigned: map to [0-255) - { - for(int i = 0; i < gx.num_elements(); ++i) - { - float angle_deg = (std::atan2(float(gy[i]), float(gx[i])) / PI) * 180.0f; - phase[i] = (angle_deg < 0.0f) ? 180.f + angle_deg : angle_deg; - } - } - else // signed: map to [0-180) degrees - { - for(int i = 0; i < gx.num_elements(); ++i) - { - float angle_pi = std::atan2(gy[i], gx[i]) / PI; - angle_pi = (angle_pi < 0.0f) ? 2 + angle_pi : angle_pi; - phase[i] = lround(angle_pi * 128) & 0xFFu; - } - } - - return phase; -} - -template SimpleTensor phase(const SimpleTensor &gx, const SimpleTensor &gy, PhaseType phase_type); -template SimpleTensor phase(const SimpleTensor &gx, const SimpleTensor &gy, PhaseType phase_type); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/reference/Phase.h b/tests/validation/reference/Phase.h deleted file mode 100644 index 436c280f0a..0000000000 --- a/tests/validation/reference/Phase.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_PHASE_H -#define ARM_COMPUTE_TEST_PHASE_H - -#include "tests/SimpleTensor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor phase(const SimpleTensor &gx, const SimpleTensor &gy, PhaseType phase_type); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_PHASE_H */ diff --git a/tests/validation/reference/Scharr.cpp b/tests/validation/reference/Scharr.cpp deleted file mode 100644 index e9fbb73d49..0000000000 --- a/tests/validation/reference/Scharr.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "Scharr.h" - -#include "Utils.h" -#include "tests/validation/Helpers.h" - -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -namespace -{ -const std::array scharr_3_x{ { -3, 0, 3, -10, 0, 10, -3, 0, 3 } }; -const std::array scharr_3_y{ { -3, -10, -3, 0, 0, 0, 3, 10, 3 } }; - -const std::map> masks -{ - { 3, { scharr_3_x.data(), scharr_3_y.data() } } -}; - -template -struct data_type; - -template <> -struct data_type -{ - const static DataType value = DataType::S16; -}; -} // namespace - -template -std::pair, SimpleTensor> scharr(const SimpleTensor &src, int filter_size, BorderMode border_mode, uint8_t constant_border_value, GradientDimension gradient_dimension) -{ - const auto shape_size = static_cast(filter_size); - - SimpleTensor dst_x(src.shape(), data_type::value, src.num_channels()); - SimpleTensor dst_y(src.shape(), data_type::value, src.num_channels()); - - ValidRegion valid_region = shape_to_valid_region(src.shape(), border_mode == BorderMode::UNDEFINED, BorderSize(filter_size / 2)); - - const uint32_t num_elements = src.num_elements(); - for(uint32_t i = 0; i < num_elements; ++i) - { - Coordinates coord = index2coord(src.shape(), i); - - if(!is_in_valid_region(valid_region, coord)) - { - continue; - } - - switch(gradient_dimension) - { - case GradientDimension::GRAD_X: - apply_2d_spatial_filter(coord, src, dst_x, TensorShape{ shape_size, shape_size }, masks.at(filter_size).first, 1.f, border_mode, constant_border_value); - break; - case GradientDimension::GRAD_Y: - apply_2d_spatial_filter(coord, src, dst_y, TensorShape{ shape_size, shape_size }, masks.at(filter_size).second, 1.f, border_mode, constant_border_value); - break; - case GradientDimension::GRAD_XY: - apply_2d_spatial_filter(coord, src, dst_x, TensorShape{ shape_size, shape_size }, masks.at(filter_size).first, 1.f, border_mode, constant_border_value); - apply_2d_spatial_filter(coord, src, dst_y, TensorShape{ shape_size, shape_size }, masks.at(filter_size).second, 1.f, border_mode, constant_border_value); - break; - default: - ARM_COMPUTE_ERROR("Gradient dimension not supported"); - } - } - - return std::make_pair(dst_x, dst_y); -} - -template std::pair, SimpleTensor> scharr(const SimpleTensor &src, int filter_size, BorderMode border_mode, uint8_t constant_border_value, - GradientDimension gradient_dimension); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/reference/Scharr.h b/tests/validation/reference/Scharr.h deleted file mode 100644 index 42b3202d64..0000000000 --- a/tests/validation/reference/Scharr.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_SCHARR_H -#define ARM_COMPUTE_TEST_SCHARR_H - -#include "tests/SimpleTensor.h" -#include "tests/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -std::pair, SimpleTensor> scharr(const SimpleTensor &src, int filter_size, BorderMode border_mode, uint8_t constant_border_value, GradientDimension gradient_dimension); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_SCHARR_H */ diff --git a/tests/validation/reference/Sobel.cpp b/tests/validation/reference/Sobel.cpp deleted file mode 100644 index d9c2532add..0000000000 --- a/tests/validation/reference/Sobel.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "Sobel.h" - -#include "Utils.h" -#include "tests/validation/Helpers.h" - -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -namespace -{ -const std::array sobel_3_x{ { -1, 0, 1, -2, 0, 2, -1, 0, 1 } }; -const std::array sobel_3_y{ { -1, -2, -1, 0, 0, 0, 1, 2, 1 } }; - -const std::array sobel_5_x{ { - -1, -2, 0, 2, 1, - -4, -8, 0, 8, 4, - -6, -12, 0, 12, 6, - -4, -8, 0, 8, 4, - -1, -2, 0, 2, 1 - } }; - -const std::array sobel_5_y{ { - -1, -4, -6, -4, -1, - -2, -8, -12, -8, -2, - 0, 0, 0, 0, 0, - 2, 8, 12, 8, 2, - 1, 4, 6, 4, 1 - } }; - -const std::array sobel_7_x{ { - -1, -4, -5, 0, 5, 4, 1, - -6, -24, -30, 0, 30, 24, 6, - -15, -60, -75, 0, 75, 60, 15, - -20, -80, -100, 0, 100, 80, 20, - -15, -60, -75, 0, 75, 60, 15, - -6, -24, -30, 0, 30, 24, 6, - -1, -4, -5, 0, 5, 4, 1 - } }; - -const std::array sobel_7_y{ { - -1, -6, -15, -20, -15, -6, -1, - -4, -24, -60, -80, -60, -24, -4, - -5, -30, -75, -100, -75, -30, -5, - 0, 0, 0, 0, 0, 0, 0, - 5, 30, 75, 100, 75, 30, 5, - 4, 24, 60, 80, 60, 24, 4, - 1, 6, 15, 20, 15, 6, 1 - } }; - -const std::map> masks -{ - { 3, { sobel_3_x.data(), sobel_3_y.data() } }, - { 5, { sobel_5_x.data(), sobel_5_y.data() } }, - { 7, { sobel_7_x.data(), sobel_7_y.data() } }, -}; - -template -struct data_type; - -template <> -struct data_type -{ - const static DataType value = DataType::S16; -}; - -template <> -struct data_type -{ - const static DataType value = DataType::S32; -}; -} // namespace - -template -std::pair, SimpleTensor> sobel(const SimpleTensor &src, int filter_size, BorderMode border_mode, uint8_t constant_border_value, GradientDimension gradient_dimension) -{ - SimpleTensor dst_x(src.shape(), data_type::value, src.num_channels()); - SimpleTensor dst_y(src.shape(), data_type::value, src.num_channels()); - - ValidRegion valid_region = shape_to_valid_region(src.shape(), border_mode == BorderMode::UNDEFINED, BorderSize(filter_size / 2)); - - const uint32_t num_elements = src.num_elements(); - for(uint32_t i = 0; i < num_elements; ++i) - { - Coordinates coord = index2coord(src.shape(), i); - - if(!is_in_valid_region(valid_region, coord)) - { - continue; - } - switch(gradient_dimension) - { - case GradientDimension::GRAD_X: - apply_2d_spatial_filter(coord, src, dst_x, TensorShape{ static_cast(filter_size), static_cast(filter_size) }, masks.at(filter_size).first, 1.f, border_mode, - constant_border_value); - break; - case GradientDimension::GRAD_Y: - apply_2d_spatial_filter(coord, src, dst_y, TensorShape{ static_cast(filter_size), static_cast(filter_size) }, masks.at(filter_size).second, 1.f, border_mode, - constant_border_value); - break; - case GradientDimension::GRAD_XY: - apply_2d_spatial_filter(coord, src, dst_x, TensorShape{ static_cast(filter_size), static_cast(filter_size) }, masks.at(filter_size).first, 1.f, border_mode, - constant_border_value); - apply_2d_spatial_filter(coord, src, dst_y, TensorShape{ static_cast(filter_size), static_cast(filter_size) }, masks.at(filter_size).second, 1.f, border_mode, - constant_border_value); - break; - default: - ARM_COMPUTE_ERROR("Gradient dimension not supported"); - } - } - - return std::make_pair(dst_x, dst_y); -} - -template std::pair, SimpleTensor> sobel(const SimpleTensor &src, int filter_size, BorderMode border_mode, uint8_t constant_border_value, - GradientDimension gradient_dimension); -template std::pair, SimpleTensor> sobel(const SimpleTensor &src, int filter_size, BorderMode border_mode, uint8_t constant_border_value, - GradientDimension gradient_dimension); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/reference/Sobel.h b/tests/validation/reference/Sobel.h deleted file mode 100644 index 86d6d0bc11..0000000000 --- a/tests/validation/reference/Sobel.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_SOBEL_H -#define ARM_COMPUTE_TEST_SOBEL_H - -#include "arm_compute/core/Types.h" -#include "tests/SimpleTensor.h" -#include "tests/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -std::pair, SimpleTensor> sobel(const SimpleTensor &src, int filter_size, BorderMode border_mode, uint8_t constant_border_value, GradientDimension gradient_dimension); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_SOBEL_H */ diff --git a/tests/validation/reference/Threshold.cpp b/tests/validation/reference/Threshold.cpp deleted file mode 100644 index 6bc6cf0b4a..0000000000 --- a/tests/validation/reference/Threshold.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2017 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal src the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included src all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. src NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER src AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * dst OF OR src CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS src THE - * SOFTWARE. - */ -#include "Threshold.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor threshold(const SimpleTensor &src, T threshold, T false_value, T true_value, ThresholdType type, T upper) -{ - SimpleTensor dst(src.shape(), src.data_type()); - - switch(type) - { - case ThresholdType::BINARY: - for(int i = 0; i < src.num_elements(); ++i) - { - dst[i] = ((src[i] > threshold) ? true_value : false_value); - } - break; - case ThresholdType::RANGE: - for(int i = 0; i < src.num_elements(); ++i) - { - if(src[i] > upper) - { - dst[i] = false_value; - } - else if(src[i] < threshold) - { - dst[i] = false_value; - } - else - { - dst[i] = true_value; - } - } - break; - default: - ARM_COMPUTE_ERROR("Thresholding type not recognised"); - break; - } - - return dst; -} - -template SimpleTensor threshold(const SimpleTensor &src, uint8_t threshold, uint8_t false_value, uint8_t true_value, ThresholdType type, uint8_t upper); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/reference/Threshold.h b/tests/validation/reference/Threshold.h deleted file mode 100644 index bee9531351..0000000000 --- a/tests/validation/reference/Threshold.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_THRESHOLD_H -#define ARM_COMPUTE_TEST_THRESHOLD_H - -#include "tests/SimpleTensor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor threshold(const SimpleTensor &src, T threshold, T false_value, T true_value, ThresholdType type, T upper); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_THRESHOLD_H */ diff --git a/tests/validation/reference/Utils.h b/tests/validation/reference/Utils.h index 8e15faab8f..c83c6ea4b3 100644 --- a/tests/validation/reference/Utils.h +++ b/tests/validation/reference/Utils.h @@ -26,7 +26,6 @@ #include "arm_compute/core/Types.h" #include "tests/Globals.h" -#include "tests/ILutAccessor.h" #include "tests/Types.h" #include @@ -123,26 +122,6 @@ void apply_2d_spatial_filter(Coordinates coord, const SimpleTensor &src, Simp RawTensor transpose(const RawTensor &src, int chunk_width = 1); -/** Fill matrix random. - * - * @param[in,out] matrix Matrix - */ -template -inline void fill_warp_matrix(std::array &matrix) -{ - std::mt19937 gen(library.get()->seed()); - std::uniform_real_distribution dist(-1, 1); - for(auto &x : matrix) - { - x = dist(gen); - } - if(SIZE == 9) - { - // This is only used in Warp Perspective, we set M[3][3] = 1 so that Z0 is not 0 and we avoid division by 0. - matrix[8] = 1.f; - } -} - bool valid_bilinear_policy(float xn, float yn, int width, int height, BorderMode border_mode); } // namespace validation } // namespace test diff --git a/tests/validation/reference/WarpAffine.cpp b/tests/validation/reference/WarpAffine.cpp deleted file mode 100644 index 3580b75d43..0000000000 --- a/tests/validation/reference/WarpAffine.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "WarpAffine.h" - -#include "Utils.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -bool valid_bilinear_policy(float xn, float yn, int width, int height, BorderMode border_mode) -{ - if(border_mode != BorderMode::UNDEFINED) - { - return true; - } - if((0 <= yn + 1) && (yn + 1 < height) && (0 <= xn + 1) && (xn + 1 < width)) - { - return true; - } - return false; -} - -template -SimpleTensor warp_affine(const SimpleTensor &src, SimpleTensor &valid_mask, const float *matrix, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value) -{ - SimpleTensor dst(src.shape(), src.data_type()); - - // x0 = M00 * x + M01 * y + M02 - // y0 = M10 * x + M11 * y + M12 - const float M00 = matrix[0]; - const float M10 = matrix[1]; - const float M01 = matrix[0 + 1 * 2]; - const float M11 = matrix[1 + 1 * 2]; - const float M02 = matrix[0 + 2 * 2]; - const float M12 = matrix[1 + 2 * 2]; - - const int width = src.shape().x(); - const int height = src.shape().y(); - - const uint32_t num_elements = src.num_elements(); - for(uint32_t element_idx = 0; element_idx < num_elements; ++element_idx) - { - valid_mask[element_idx] = 1; - Coordinates id = index2coord(src.shape(), element_idx); - int idx = id.x(); - int idy = id.y(); - - float x0 = M00 * idx + M01 * idy + M02; - float y0 = M10 * idx + M11 * idy + M12; - - id.set(0, static_cast(std::floor(x0))); - id.set(1, static_cast(std::floor(y0))); - if((0 <= y0) && (y0 < height) && (0 <= x0) && (x0 < width)) - { - switch(policy) - { - case InterpolationPolicy::NEAREST_NEIGHBOR: - dst[element_idx] = tensor_elem_at(src, id, border_mode, constant_border_value); - break; - case InterpolationPolicy::BILINEAR: - (valid_bilinear_policy(x0, y0, width, height, border_mode)) ? dst[element_idx] = bilinear_policy(src, id, x0, y0, border_mode, constant_border_value) : - valid_mask[element_idx] = 0; - break; - case InterpolationPolicy::AREA: - default: - ARM_COMPUTE_ERROR("Interpolation not supported"); - } - } - else - { - if(border_mode == BorderMode::UNDEFINED) - { - valid_mask[element_idx] = 0; - } - else - { - switch(policy) - { - case InterpolationPolicy::NEAREST_NEIGHBOR: - if(border_mode == BorderMode::CONSTANT) - { - dst[element_idx] = constant_border_value; - } - else if(border_mode == BorderMode::REPLICATE) - { - id.set(0, std::max(0, std::min(static_cast(x0), width - 1))); - id.set(1, std::max(0, std::min(static_cast(y0), height - 1))); - dst[element_idx] = src[coord2index(src.shape(), id)]; - } - break; - case InterpolationPolicy::BILINEAR: - dst[element_idx] = bilinear_policy(src, id, x0, y0, border_mode, constant_border_value); - break; - case InterpolationPolicy::AREA: - default: - ARM_COMPUTE_ERROR("Interpolation not supported"); - } - } - } - } - - return dst; -} - -template SimpleTensor warp_affine(const SimpleTensor &src, SimpleTensor &valid_mask, const float *matrix, InterpolationPolicy policy, BorderMode border_mode, - uint8_t constant_border_value); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute \ No newline at end of file diff --git a/tests/validation/reference/WarpAffine.h b/tests/validation/reference/WarpAffine.h deleted file mode 100644 index 90f765c283..0000000000 --- a/tests/validation/reference/WarpAffine.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_WARP_AFFINE_H -#define ARM_COMPUTE_TEST_WARP_AFFINE_H - -#include "tests/SimpleTensor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor warp_affine(const SimpleTensor &src, SimpleTensor &valid_mask, const float *matrix, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_WARP_AFFINE_H */ diff --git a/tests/validation/reference/WarpPerspective.cpp b/tests/validation/reference/WarpPerspective.cpp deleted file mode 100644 index e35d75e6e2..0000000000 --- a/tests/validation/reference/WarpPerspective.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Helpers.h" - -#include "Utils.h" -#include "WarpPerspective.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor warp_perspective(const SimpleTensor &src, SimpleTensor &valid_mask, const float *matrix, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value) -{ - SimpleTensor dst(src.shape(), src.data_type()); - - // x0 = M00 * x + M01 * y + M02 - // y0 = M10 * x + M11 * y + M12 - // z0 = M20 * x + M21 * y + M22 - // xn = x0 / z0 - // yn = y0 / z0 - const float M00 = matrix[0]; - const float M10 = matrix[1]; - const float M20 = matrix[2]; - const float M01 = matrix[0 + 1 * 3]; - const float M11 = matrix[1 + 1 * 3]; - const float M21 = matrix[2 + 1 * 3]; - const float M02 = matrix[0 + 2 * 3]; - const float M12 = matrix[1 + 2 * 3]; - const float M22 = matrix[2 + 2 * 3]; - - const int width = src.shape().x(); - const int height = src.shape().y(); - - const uint32_t num_elements = src.num_elements(); - for(uint32_t element_idx = 0; element_idx < num_elements; ++element_idx) - { - valid_mask[element_idx] = 1; - Coordinates id = index2coord(src.shape(), element_idx); - const int idx = id.x(); - const int idy = id.y(); - const float z0 = M20 * idx + M21 * idy + M22; - - const float x0 = (M00 * idx + M01 * idy + M02); - const float y0 = (M10 * idx + M11 * idy + M12); - - const float xn = x0 / z0; - const float yn = y0 / z0; - id.set(0, static_cast(std::floor(xn))); - id.set(1, static_cast(std::floor(yn))); - if((0 <= yn) && (yn < height) && (0 <= xn) && (xn < width)) - { - switch(policy) - { - case InterpolationPolicy::NEAREST_NEIGHBOR: - dst[element_idx] = tensor_elem_at(src, id, border_mode, constant_border_value); - break; - case InterpolationPolicy::BILINEAR: - (valid_bilinear_policy(xn, yn, width, height, border_mode)) ? dst[element_idx] = bilinear_policy(src, id, xn, yn, border_mode, constant_border_value) : valid_mask[element_idx] = 0; - break; - case InterpolationPolicy::AREA: - default: - ARM_COMPUTE_ERROR("Interpolation not supported"); - break; - } - } - else - { - if(border_mode == BorderMode::UNDEFINED) - { - valid_mask[element_idx] = 0; - } - else - { - switch(policy) - { - case InterpolationPolicy::NEAREST_NEIGHBOR: - if(border_mode == BorderMode::CONSTANT) - { - dst[element_idx] = constant_border_value; - } - else if(border_mode == BorderMode::REPLICATE) - { - id.set(0, std::max(0, std::min(static_cast(xn), width - 1))); - id.set(1, std::max(0, std::min(static_cast(yn), height - 1))); - dst[element_idx] = src[coord2index(src.shape(), id)]; - } - break; - case InterpolationPolicy::BILINEAR: - dst[element_idx] = bilinear_policy(src, id, xn, yn, border_mode, constant_border_value); - break; - case InterpolationPolicy::AREA: - default: - ARM_COMPUTE_ERROR("Interpolation not supported"); - break; - } - } - } - } - return dst; -} - -template SimpleTensor warp_perspective(const SimpleTensor &src, SimpleTensor &valid_mask, const float *matrix, InterpolationPolicy policy, BorderMode border_mode, - uint8_t constant_border_value); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/reference/WarpPerspective.h b/tests/validation/reference/WarpPerspective.h deleted file mode 100644 index 7fcd5ddf7b..0000000000 --- a/tests/validation/reference/WarpPerspective.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_WARP_PERSPECTIVE_H -#define ARM_COMPUTE_TEST_WARP_PERSPECTIVE_H - -#include "tests/SimpleTensor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor warp_perspective(const SimpleTensor &src, SimpleTensor &valid_mask, const float *matrix, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_WARP_PERSPECTIVE_H */ diff --git a/tests/validation/reference/YOLOLayer.cpp b/tests/validation/reference/YOLOLayer.cpp deleted file mode 100644 index fbc81f1af9..0000000000 --- a/tests/validation/reference/YOLOLayer.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2018-2020 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "YOLOLayer.h" - -#include "ActivationLayer.h" - -#include "arm_compute/core/Types.h" -#include "tests/validation/Helpers.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template ::value, int>::type> -SimpleTensor yolo_layer(const SimpleTensor &src, const ActivationLayerInfo &info, int32_t num_classes) -{ - // Create reference - SimpleTensor dst{ src.shape(), src.data_type() }; - - // Compute reference - const T a(info.a()); - const T b(info.b()); - - const uint32_t num_elements = src.num_elements(); -#if defined(_OPENMP) - #pragma omp parallel for -#endif /* _OPENMP */ - for(uint32_t i = 0; i < num_elements; ++i) - { - const size_t z = index2coord(dst.shape(), i).z() % (num_classes + 5); - - if(z != 2 && z != 3) - { - dst[i] = activate_float(src[i], a, b, info.activation()); - } - else - { - dst[i] = src[i]; - } - } - - return dst; -} - -template <> -SimpleTensor yolo_layer(const SimpleTensor &src, const ActivationLayerInfo &info, int32_t num_classes) -{ - SimpleTensor src_tmp = convert_from_asymmetric(src); - SimpleTensor dst_tmp = yolo_layer(src_tmp, info, num_classes); - SimpleTensor dst = convert_to_asymmetric(dst_tmp, src.quantization_info()); - return dst; -} - -template SimpleTensor yolo_layer(const SimpleTensor &src, const ActivationLayerInfo &info, int32_t num_classes); -template SimpleTensor yolo_layer(const SimpleTensor &src, const ActivationLayerInfo &info, int32_t num_classes); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/reference/YOLOLayer.h b/tests/validation/reference/YOLOLayer.h deleted file mode 100644 index 33cf630aca..0000000000 --- a/tests/validation/reference/YOLOLayer.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2018-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_YOLO_LAYER_H -#define ARM_COMPUTE_TEST_YOLO_LAYER_H - -#include "tests/SimpleTensor.h" -#include "tests/validation/Helpers.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template ::value, int>::type = 0> -SimpleTensor yolo_layer(const SimpleTensor &src, const ActivationLayerInfo &info, int32_t num_classes); - -template ::value, int>::type = 0> -SimpleTensor yolo_layer(const SimpleTensor &src, const ActivationLayerInfo &info, int32_t num_classes); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_YOLO_LAYER_H */ diff --git a/utils/TypePrinter.h b/utils/TypePrinter.h index 53a8902dd4..e849edc092 100644 --- a/utils/TypePrinter.h +++ b/utils/TypePrinter.h @@ -28,7 +28,6 @@ #include "arm_compute/core/Dimensions.h" #include "arm_compute/core/Error.h" #include "arm_compute/core/GPUTarget.h" -#include "arm_compute/core/HOGInfo.h" #include "arm_compute/core/KernelDescriptors.h" #include "arm_compute/core/Size2D.h" #include "arm_compute/core/Strides.h" @@ -86,89 +85,6 @@ inline ::std::ostream &operator<<(::std::ostream &os, const Dimensions &dimen return os; } -/** Formatted output of the NonLinearFilterFunction type. - * - * @param[out] os Output stream. - * @param[in] function Type to output. - * - * @return Modified output stream. - */ -inline ::std::ostream &operator<<(::std::ostream &os, const NonLinearFilterFunction &function) -{ - switch(function) - { - case NonLinearFilterFunction::MAX: - os << "MAX"; - break; - case NonLinearFilterFunction::MEDIAN: - os << "MEDIAN"; - break; - case NonLinearFilterFunction::MIN: - os << "MIN"; - break; - default: - ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); - } - - return os; -} - -/** Formatted output of the NonLinearFilterFunction type. - * - * @param[in] function Type to output. - * - * @return Formatted string. - */ -inline std::string to_string(const NonLinearFilterFunction &function) -{ - std::stringstream str; - str << function; - return str.str(); -} - -/** Formatted output of the MatrixPattern type. - * - * @param[out] os Output stream. - * @param[in] pattern Type to output. - * - * @return Modified output stream. - */ -inline ::std::ostream &operator<<(::std::ostream &os, const MatrixPattern &pattern) -{ - switch(pattern) - { - case MatrixPattern::BOX: - os << "BOX"; - break; - case MatrixPattern::CROSS: - os << "CROSS"; - break; - case MatrixPattern::DISK: - os << "DISK"; - break; - case MatrixPattern::OTHER: - os << "OTHER"; - break; - default: - ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); - } - - return os; -} - -/** Formatted output of the MatrixPattern type. - * - * @param[in] pattern Type to output. - * - * @return Formatted string. - */ -inline std::string to_string(const MatrixPattern &pattern) -{ - std::stringstream str; - str << pattern; - return str.str(); -} - /** Formatted output of the RoundingPolicy type. * * @param[out] os Output stream. @@ -1083,8 +999,8 @@ inline ::std::ostream &operator<<(::std::ostream &os, const SamplingPolicy &poli */ inline ::std::ostream &operator<<(std::ostream &os, const ITensorInfo *info) { - const DataType data_type = info->data_type(); - const DataLayout data_layout = info->data_layout(); + const DataType data_type = info->data_type(); + const DataLayout data_layout = info->data_layout(); os << "Shape=" << info->tensor_shape() << "," << "DataLayout=" << string_from_data_layout(data_layout) << "," @@ -1109,7 +1025,7 @@ inline ::std::ostream &operator<<(std::ostream &os, const ITensorInfo *info) else { os << "(" << qinfo.uniform().scale << ", " - << qinfo.uniform().offset << ")"; + << qinfo.uniform().offset << ")"; } } return os; @@ -1125,7 +1041,7 @@ inline ::std::ostream &operator<<(std::ostream &os, const ITensorInfo *info) inline ::std::ostream &operator<<(::std::ostream &os, const TensorInfo &info) { os << &info; - return os; + return os; } /** Formatted output of the TensorInfo type. @@ -1803,140 +1719,6 @@ inline std::string to_string(const PriorBoxLayerInfo &info) return str.str(); } -/** Formatted output of the KeyPoint type. - * - * @param[out] os Output stream - * @param[in] point Type to output. - * - * @return Modified output stream. - */ -inline ::std::ostream &operator<<(::std::ostream &os, const KeyPoint &point) -{ - os << "{x=" << point.x << "," - << "y=" << point.y << "," - << "strength=" << point.strength << "," - << "scale=" << point.scale << "," - << "orientation=" << point.orientation << "," - << "tracking_status=" << point.tracking_status << "," - << "error=" << point.error << "}"; - - return os; -} - -/** Formatted output of the PhaseType type. - * - * @param[out] os Output stream - * @param[in] phase_type Type to output. - * - * @return Modified output stream. - */ -inline ::std::ostream &operator<<(::std::ostream &os, const PhaseType &phase_type) -{ - switch(phase_type) - { - case PhaseType::SIGNED: - os << "SIGNED"; - break; - case PhaseType::UNSIGNED: - os << "UNSIGNED"; - break; - default: - ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); - } - - return os; -} - -/** Formatted output of the PhaseType type. - * - * @param[in] type Type to output. - * - * @return Formatted string. - */ -inline std::string to_string(const arm_compute::PhaseType &type) -{ - std::stringstream str; - str << type; - return str.str(); -} - -/** Formatted output of the MagnitudeType type. - * - * @param[out] os Output stream - * @param[in] magnitude_type Type to output. - * - * @return Modified output stream. - */ -inline ::std::ostream &operator<<(::std::ostream &os, const MagnitudeType &magnitude_type) -{ - switch(magnitude_type) - { - case MagnitudeType::L1NORM: - os << "L1NORM"; - break; - case MagnitudeType::L2NORM: - os << "L2NORM"; - break; - default: - ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); - } - - return os; -} - -/** Formatted output of the MagnitudeType type. - * - * @param[in] type Type to output. - * - * @return Formatted string. - */ -inline std::string to_string(const arm_compute::MagnitudeType &type) -{ - std::stringstream str; - str << type; - return str.str(); -} - -/** Formatted output of the HOGNormType type. - * - * @param[out] os Output stream - * @param[in] norm_type Type to output - * - * @return Modified output stream. - */ -inline ::std::ostream &operator<<(::std::ostream &os, const HOGNormType &norm_type) -{ - switch(norm_type) - { - case HOGNormType::L1_NORM: - os << "L1_NORM"; - break; - case HOGNormType::L2_NORM: - os << "L2_NORM"; - break; - case HOGNormType::L2HYS_NORM: - os << "L2HYS_NORM"; - break; - default: - ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); - } - - return os; -} - -/** Formatted output of the HOGNormType type. - * - * @param[in] type Type to output - * - * @return Formatted string. - */ -inline std::string to_string(const HOGNormType &type) -{ - std::stringstream str; - str << type; - return str.str(); -} - /** Formatted output of the Size2D type. * * @param[out] os Output stream @@ -1964,40 +1746,6 @@ inline std::string to_string(const Size2D &type) return str.str(); } -/** Formatted output of the HOGInfo type. - * - * @param[out] os Output stream - * @param[in] hog_info Type to output - * - * @return Modified output stream. - */ -inline ::std::ostream &operator<<(::std::ostream &os, const HOGInfo &hog_info) -{ - os << "{CellSize=" << hog_info.cell_size() << "," - << "BlockSize=" << hog_info.block_size() << "," - << "DetectionWindowSize=" << hog_info.detection_window_size() << "," - << "BlockStride=" << hog_info.block_stride() << "," - << "NumBins=" << hog_info.num_bins() << "," - << "NormType=" << hog_info.normalization_type() << "," - << "L2HystThreshold=" << hog_info.l2_hyst_threshold() << "," - << "PhaseType=" << hog_info.phase_type() << "}"; - - return os; -} - -/** Formatted output of the HOGInfo type. - * - * @param[in] type Type to output - * - * @return Formatted string. - */ -inline std::string to_string(const HOGInfo &type) -{ - std::stringstream str; - str << type; - return str.str(); -} - /** Formatted output of the ConvolutionMethod type. * * @param[out] os Output stream @@ -2252,6 +2000,7 @@ inline std::string to_string(const DetectionPostProcessLayerInfo &detection_info str << detection_info; return str.str(); } + /** Formatted output of the DetectionWindow type. * * @param[in] detection_window Type to output @@ -2265,46 +2014,6 @@ inline std::string to_string(const DetectionWindow &detection_window) return str.str(); } -/** Formatted output of the Termination type. - * - * @param[out] os Output stream - * @param[in] termination Type to output - * - * @return Modified output stream. - */ -inline ::std::ostream &operator<<(::std::ostream &os, const Termination &termination) -{ - switch(termination) - { - case Termination::TERM_CRITERIA_EPSILON: - os << "TERM_CRITERIA_EPSILON"; - break; - case Termination::TERM_CRITERIA_ITERATIONS: - os << "TERM_CRITERIA_ITERATIONS"; - break; - case Termination::TERM_CRITERIA_BOTH: - os << "TERM_CRITERIA_BOTH"; - break; - default: - ARM_COMPUTE_ERROR("NOT_SUPPORTED!"); - } - - return os; -} - -/** Formatted output of the Termination type. - * - * @param[in] termination Type to output - * - * @return Formatted string. - */ -inline std::string to_string(const Termination &termination) -{ - std::stringstream str; - str << termination; - return str.str(); -} - /** Formatted output of the CPUModel type. * * @param[out] os Output stream diff --git a/utils/Utils.h b/utils/Utils.h index e9fbc134b2..d46fbc3633 100644 --- a/utils/Utils.h +++ b/utils/Utils.h @@ -42,7 +42,6 @@ #ifdef ARM_COMPUTE_CL #include "arm_compute/core/CL/OpenCL.h" -#include "arm_compute/runtime/CL/CLDistribution1D.h" #include "arm_compute/runtime/CL/CLTensor.h" #endif /* ARM_COMPUTE_CL */ @@ -245,25 +244,6 @@ inline void unmap(CLTensor &tensor) { tensor.unmap(); } - -/** Maps a distribution if needed - * - * @param[in] distribution Distribution to be mapped - * @param[in] blocking Specified if map is blocking or not - */ -inline void map(CLDistribution1D &distribution, bool blocking) -{ - distribution.map(blocking); -} - -/** Unmaps a distribution if needed - * - * @param distribution Distribution to be unmapped - */ -inline void unmap(CLDistribution1D &distribution) -{ - distribution.unmap(); -} #endif /* ARM_COMPUTE_CL */ /** Specialized class to generate random non-zero FP16 values. -- cgit v1.2.1