From dbf66147481e1b7d878eb161ce92439b218404e3 Mon Sep 17 00:00:00 2001 From: Adnan AlSinan Date: Fri, 4 Feb 2022 13:04:55 +0000 Subject: Remove deprecated remap functions. - Remove CLRemapKernel. - Remove NERemapKernel. Partially resolves COMPMID-4984 Signed-off-by: Adnan AlSinan Change-Id: Ia61f9ac7447695d81178701cf0e9b7625a91eccc Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/7056 Tested-by: Arm Jenkins Reviewed-by: Pablo Marquez Tello Comments-Addressed: Arm Jenkins --- Android.bp | 6 - SConscript | 2 - arm_compute/core/KernelDescriptors.h | 14 +- arm_compute/runtime/CL/CLFunctions.h | 3 +- arm_compute/runtime/CL/functions/CLRemap.h | 122 -------- arm_compute/runtime/NEON/NEFunctions.h | 3 +- arm_compute/runtime/NEON/functions/NERemap.h | 83 ------ docs/user_guide/release_version_and_change_log.dox | 6 +- filelist.json | 15 - src/core/CL/CLKernels.h | 3 +- src/core/CL/cl_kernels/nchw/remap.cl | 133 --------- src/core/CL/cl_kernels/nhwc/remap.cl | 180 ------------ src/core/CL/kernels/CLRemapKernel.cpp | 183 ------------ src/core/CL/kernels/CLRemapKernel.h | 88 ------ src/core/NEON/NEKernels.h | 3 +- src/core/NEON/kernels/NERemapKernel.cpp | 326 --------------------- src/core/NEON/kernels/NERemapKernel.h | 86 ------ src/gpu/cl/ClKernelLibrary.cpp | 12 - src/runtime/CL/functions/CLRemap.cpp | 68 ----- src/runtime/NEON/functions/NERemap.cpp | 55 ---- tests/validation/CL/Remap.cpp | 138 --------- tests/validation/NEON/Remap.cpp | 77 ----- tests/validation/fixtures/RemapFixture.h | 192 ------------ tests/validation/reference/Remap.cpp | 115 -------- tests/validation/reference/Remap.h | 44 --- 25 files changed, 8 insertions(+), 1949 deletions(-) delete mode 100644 arm_compute/runtime/CL/functions/CLRemap.h delete mode 100644 arm_compute/runtime/NEON/functions/NERemap.h delete mode 100644 src/core/CL/cl_kernels/nchw/remap.cl delete mode 100644 src/core/CL/cl_kernels/nhwc/remap.cl delete mode 100644 src/core/CL/kernels/CLRemapKernel.cpp delete mode 100644 src/core/CL/kernels/CLRemapKernel.h delete mode 100644 src/core/NEON/kernels/NERemapKernel.cpp delete mode 100644 src/core/NEON/kernels/NERemapKernel.h delete mode 100644 src/runtime/CL/functions/CLRemap.cpp delete mode 100644 src/runtime/NEON/functions/NERemap.cpp delete mode 100644 tests/validation/CL/Remap.cpp delete mode 100644 tests/validation/NEON/Remap.cpp delete mode 100644 tests/validation/fixtures/RemapFixture.h delete mode 100644 tests/validation/reference/Remap.cpp delete mode 100644 tests/validation/reference/Remap.h diff --git a/Android.bp b/Android.bp index 136714b260..6add3f3c2d 100644 --- a/Android.bp +++ b/Android.bp @@ -88,7 +88,6 @@ opencl_srcs = [ "src/core/CL/cl_kernels/nchw/normalize_planar_yuv_layer_quantized.cl", "src/core/CL/cl_kernels/nchw/pooling_layer.cl", "src/core/CL/cl_kernels/nchw/prior_box_layer.cl", - "src/core/CL/cl_kernels/nchw/remap.cl", "src/core/CL/cl_kernels/nchw/reorg_layer.cl", "src/core/CL/cl_kernels/nchw/scale.cl", "src/core/CL/cl_kernels/nchw/space_to_batch.cl", @@ -112,7 +111,6 @@ opencl_srcs = [ "src/core/CL/cl_kernels/nhwc/normalize_planar_yuv_layer_quantized.cl", "src/core/CL/cl_kernels/nhwc/pooling_layer.cl", "src/core/CL/cl_kernels/nhwc/pooling_layer_quantized.cl", - "src/core/CL/cl_kernels/nhwc/remap.cl", "src/core/CL/cl_kernels/nhwc/reorg_layer.cl", "src/core/CL/cl_kernels/nhwc/scale.cl", "src/core/CL/cl_kernels/nhwc/space_to_batch.cl", @@ -239,7 +237,6 @@ cc_library_static { "src/core/CL/kernels/CLROIPoolingLayerKernel.cpp", "src/core/CL/kernels/CLRangeKernel.cpp", "src/core/CL/kernels/CLReductionOperationKernel.cpp", - "src/core/CL/kernels/CLRemapKernel.cpp", "src/core/CL/kernels/CLReorgLayerKernel.cpp", "src/core/CL/kernels/CLReverseKernel.cpp", "src/core/CL/kernels/CLSelectKernel.cpp", @@ -291,7 +288,6 @@ cc_library_static { "src/core/NEON/kernels/NEROIPoolingLayerKernel.cpp", "src/core/NEON/kernels/NERangeKernel.cpp", "src/core/NEON/kernels/NEReductionOperationKernel.cpp", - "src/core/NEON/kernels/NERemapKernel.cpp", "src/core/NEON/kernels/NEReorgLayerKernel.cpp", "src/core/NEON/kernels/NEReverseKernel.cpp", "src/core/NEON/kernels/NESelectKernel.cpp", @@ -750,7 +746,6 @@ cc_library_static { "src/runtime/CL/functions/CLRange.cpp", "src/runtime/CL/functions/CLReduceMean.cpp", "src/runtime/CL/functions/CLReductionOperation.cpp", - "src/runtime/CL/functions/CLRemap.cpp", "src/runtime/CL/functions/CLReorgLayer.cpp", "src/runtime/CL/functions/CLReshapeLayer.cpp", "src/runtime/CL/functions/CLReverse.cpp", @@ -861,7 +856,6 @@ cc_library_static { "src/runtime/NEON/functions/NERange.cpp", "src/runtime/NEON/functions/NEReduceMean.cpp", "src/runtime/NEON/functions/NEReductionOperation.cpp", - "src/runtime/NEON/functions/NERemap.cpp", "src/runtime/NEON/functions/NEReorgLayer.cpp", "src/runtime/NEON/functions/NEReshapeLayer.cpp", "src/runtime/NEON/functions/NEReverse.cpp", diff --git a/SConscript b/SConscript index 74bd4f75f0..62ec9f8854 100644 --- a/SConscript +++ b/SConscript @@ -418,7 +418,6 @@ if env['opencl'] and env['embed_kernels']: 'src/core/CL/cl_kernels/nchw/normalize_planar_yuv_layer_quantized.cl', 'src/core/CL/cl_kernels/nchw/pooling_layer.cl', 'src/core/CL/cl_kernels/nchw/prior_box_layer.cl', - 'src/core/CL/cl_kernels/nchw/remap.cl', 'src/core/CL/cl_kernels/nchw/reorg_layer.cl', 'src/core/CL/cl_kernels/nchw/scale.cl', 'src/core/CL/cl_kernels/nchw/space_to_batch.cl', @@ -445,7 +444,6 @@ if env['opencl'] and env['embed_kernels']: 'src/core/CL/cl_kernels/nhwc/normalize_planar_yuv_layer_quantized.cl', 'src/core/CL/cl_kernels/nhwc/pooling_layer.cl', 'src/core/CL/cl_kernels/nhwc/pooling_layer_quantized.cl', - 'src/core/CL/cl_kernels/nhwc/remap.cl', 'src/core/CL/cl_kernels/nhwc/reorg_layer.cl', 'src/core/CL/cl_kernels/nhwc/scale.cl', 'src/core/CL/cl_kernels/nhwc/space_to_batch.cl', diff --git a/arm_compute/core/KernelDescriptors.h b/arm_compute/core/KernelDescriptors.h index bc6ec1f6c5..b1086494e4 100644 --- a/arm_compute/core/KernelDescriptors.h +++ b/arm_compute/core/KernelDescriptors.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021 Arm Limited. + * Copyright (c) 2019-2022 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -211,17 +211,5 @@ struct ScaleKernelInfo bool align_corners; /**< Align corners of input and output */ DataLayout data_layout; /**< Data layout to use */ }; - -struct RemapInfo -{ - RemapInfo() = default; - RemapInfo(InterpolationPolicy policy, BorderMode border_mode, PixelValue constant_border_value) - : policy(policy), border_mode(border_mode), constant_border_value(constant_border_value) - { - } - InterpolationPolicy policy; - BorderMode border_mode; - PixelValue constant_border_value; -}; } // namespace arm_compute #endif /* ARM_COMPUTE_CORE_KERNEL_DESCRIPTORS_H */ diff --git a/arm_compute/runtime/CL/CLFunctions.h b/arm_compute/runtime/CL/CLFunctions.h index 3dd635b14b..9f67f2e05b 100644 --- a/arm_compute/runtime/CL/CLFunctions.h +++ b/arm_compute/runtime/CL/CLFunctions.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2021 Arm Limited. + * Copyright (c) 2016-2022 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -94,7 +94,6 @@ #include "arm_compute/runtime/CL/functions/CLRange.h" #include "arm_compute/runtime/CL/functions/CLReduceMean.h" #include "arm_compute/runtime/CL/functions/CLReductionOperation.h" -#include "arm_compute/runtime/CL/functions/CLRemap.h" #include "arm_compute/runtime/CL/functions/CLReorgLayer.h" #include "arm_compute/runtime/CL/functions/CLReshapeLayer.h" #include "arm_compute/runtime/CL/functions/CLReverse.h" diff --git a/arm_compute/runtime/CL/functions/CLRemap.h b/arm_compute/runtime/CL/functions/CLRemap.h deleted file mode 100644 index ae75817d0e..0000000000 --- a/arm_compute/runtime/CL/functions/CLRemap.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2017-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_CLREMAP_H -#define ARM_COMPUTE_CLREMAP_H - -#include "arm_compute/core/PixelValue.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/ICLSimpleFunction.h" - -#include - -namespace arm_compute -{ -class CLCompileContext; -class ICLTensor; -class ITensorInfo; - -/** Basic function to execute remap. This function calls the following OpenCL kernels: - * - * -# @ref CLFillBorderKernel (executed if border_mode == CONSTANT or border_mode == REPLICATE) - * -# @ref CLRemapKernel - * - */ -class CLRemap : public ICLSimpleFunction -{ -public: - /** Initialise the function's sources, destination, interpolation policy and border mode. - * - * Valid data layouts: - * - All - * - * Valid data type configurations: - * |src0 |src1 |src2 |dst | - * |:------|:------|:------|:------| - * |U8 |F32 |F32 |U8 | - * |F16 |F32 |F32 |F16 | - * - * @param[in] compile_context The compile context to be used. - * @param[in,out] input Source tensor. Data types supported: U8. (Written to only for @p border_mode != UNDEFINED) - * @param[in] map_x Map for X coords. Data types supported: F32. - * @param[in] map_y Map for Y coords. Data types supported: F32. - * @param[out] output Output tensor. Data types supported: U8. - * @param[in] policy Interpolation policy to use. Only NEAREST and BILINEAR are supported. - * @param[in] border_mode Border mode to use on the input tensor. Only CONSTANT and UNDEFINED are supported. - * @param[in] constant_border_value (Optional) Constant value to use for borders if border_mode is set to CONSTANT. - * - * @deprecated This function is deprecated and is intended to be removed in 22.02 release - * - */ - ARM_COMPUTE_DEPRECATED_REL(21.08) - void configure(const CLCompileContext &compile_context, ICLTensor *input, const ICLTensor *map_x, const ICLTensor *map_y, ICLTensor *output, - InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value = 0); - - /** Initialise the function's sources, destination, interpolation policy and border mode. - * - * Similar to @ref CLRemap::configure(const CLCompileContext &compile_context, ICLTensor *input, const ICLTensor *map_x, const ICLTensor *map_y, ICLTensor *output, - InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value) - * - * @deprecated This function is deprecated and is intended to be removed in 22.02 release - * - */ - ARM_COMPUTE_DEPRECATED_REL(21.08) - void configure(ICLTensor *input, const ICLTensor *map_x, const ICLTensor *map_y, ICLTensor *output, - InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value = 0); - - /** Initialise the function's sources, destination, interpolation policy and border mode. - * - * @param[in] compile_context The compile context to be used. - * @param[in,out] input Source tensor. Data types supported: U8,(or F16 when layout is NHWC). (Written to only for @p border_mode != UNDEFINED) - * @param[in] map_x Map for X coords. Data types supported: F32. - * @param[in] map_y Map for Y coords. Data types supported: F32. - * @param[out] output Output tensor. Data types supported: Same as @p input. - * @param[in] policy Interpolation policy to use. Only NEAREST and BILINEAR are supported. - * @param[in] border_mode Border mode to use on the input tensor. Only CONSTANT and UNDEFINED are supported. - * @param[in] constant_border_value (Optional) Constant value to use for borders if border_mode is set to CONSTANT. - * - */ - void configure(const CLCompileContext &compile_context, ICLTensor *input, const ICLTensor *map_x, const ICLTensor *map_y, ICLTensor *output, - InterpolationPolicy policy, BorderMode border_mode, PixelValue constant_border_value = PixelValue{}); - - /** Initialise the function's sources, destination, interpolation policy and border mode. - * - * Similar to @ref CLRemap::configure(const CLCompileContext &compile_context, ICLTensor *input, const ICLTensor *map_x, const ICLTensor *map_y, ICLTensor *output, - InterpolationPolicy policy, BorderMode border_mode, PixelValue constant_border_value) - * - */ - void configure(ICLTensor *input, const ICLTensor *map_x, const ICLTensor *map_y, ICLTensor *output, - InterpolationPolicy policy, BorderMode border_mode, PixelValue constant_border_value = PixelValue{}); - - /** Checks if the kernel's input, output and border mode will lead to a valid configuration of @ref CLRemap - * - * Similar to @ref CLRemap::configure(const CLCompileContext &compile_context, ICLTensor *input, const ICLTensor *map_x, const ICLTensor *map_y, ICLTensor *output, - InterpolationPolicy policy, BorderMode border_mode, PixelValue constant_border_value) - * - * @return a Status - */ - static Status validate(const ITensorInfo *input, const ITensorInfo *map_x, const ITensorInfo *map_y, const ITensorInfo *output, - const InterpolationPolicy policy, const BorderMode border_mode, PixelValue constant_border_value = PixelValue{}); -}; -} -#endif /*ARM_COMPUTE_CLREMAP_H */ diff --git a/arm_compute/runtime/NEON/NEFunctions.h b/arm_compute/runtime/NEON/NEFunctions.h index 71009fb45a..562ade1d5a 100644 --- a/arm_compute/runtime/NEON/NEFunctions.h +++ b/arm_compute/runtime/NEON/NEFunctions.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2021 Arm Limited. + * Copyright (c) 2016-2022 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -90,7 +90,6 @@ #include "arm_compute/runtime/NEON/functions/NERange.h" #include "arm_compute/runtime/NEON/functions/NEReduceMean.h" #include "arm_compute/runtime/NEON/functions/NEReductionOperation.h" -#include "arm_compute/runtime/NEON/functions/NERemap.h" #include "arm_compute/runtime/NEON/functions/NEReorgLayer.h" #include "arm_compute/runtime/NEON/functions/NEReshapeLayer.h" #include "arm_compute/runtime/NEON/functions/NEReverse.h" diff --git a/arm_compute/runtime/NEON/functions/NERemap.h b/arm_compute/runtime/NEON/functions/NERemap.h deleted file mode 100644 index 5d50517b01..0000000000 --- a/arm_compute/runtime/NEON/functions/NERemap.h +++ /dev/null @@ -1,83 +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_NEREMAP_H -#define ARM_COMPUTE_NEREMAP_H - -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/INESimpleFunctionNoBorder.h" -#include "arm_compute/runtime/Tensor.h" - -#include - -namespace arm_compute -{ -class ITensor; - -/** Basic function to execute remap. This function calls the following kernels: - * - * -# @ref NERemapKernel - */ -class NERemap : public INESimpleFunctionNoBorder -{ -public: - /** Initialise the function's sources, destination, interpolation policy and border mode. - * - * Valid data layouts: - * - All - * - * Valid data type configurations: - * |src0 |src1 |src2 |dst | - * |:------|:------|:------|:------| - * |U8 |F32 |F32 |U 8 | - * - * @param[in, out] input Source tensor. Data type supported: U8. (Written to only for @p border_mode != UNDEFINED) - * @param[in] map_x Map for X coordinates. Data type supported: F32. - * @param[in] map_y Map for Y coordinates. Data type supported: F32. - * @param[out] output Output tensor. Data type supported: U8. - * @param[in] policy Interpolation policy to use. Only NEAREST and BILINEAR are supported. - * @param[in] border_mode Border mode to use on the input tensor. - * @param[in] constant_border_value (Optional) Constant value to use for borders if border_mode is set to CONSTANT. Defaults to 0. - * - * @deprecated This function is deprecated and is intended to be removed in 22.02 release - * - */ - ARM_COMPUTE_DEPRECATED_REL(21.08) - void configure(ITensor *input, const ITensor *map_x, const ITensor *map_y, ITensor *output, - InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value = 0); - /** Initialise the function's sources, destination, interpolation policy and border mode. - * - * @param[in, out] input Source tensor. Data type supported: U8. (Written to only for @p border_mode != UNDEFINED) - * @param[in] map_x Map for X coordinates. Data type supported: F32. - * @param[in] map_y Map for Y coordinates. Data type supported: F32. - * @param[out] output Output tensor. Data type supported: U8. - * @param[in] policy Interpolation policy to use. Only NEAREST and BILINEAR are supported. - * @param[in] border_mode Border mode to use on the input tensor. - * @param[in] constant_border_value Constant value to use for borders if border_mode is set to CONSTANT. - * - */ - void configure(ITensor *input, const ITensor *map_x, const ITensor *map_y, ITensor *output, - InterpolationPolicy policy, BorderMode border_mode, PixelValue constant_border_value); -}; -} -#endif /*ARM_COMPUTE_NEREMAP_H */ diff --git a/docs/user_guide/release_version_and_change_log.dox b/docs/user_guide/release_version_and_change_log.dox index a8805b4759..0e2c8427ad 100644 --- a/docs/user_guide/release_version_and_change_log.dox +++ b/docs/user_guide/release_version_and_change_log.dox @@ -75,7 +75,7 @@ v21.08 Public major release - Support fat binary build for arm8.2-a via fat_binary build flag - Add CPU discovery capabilities - Add data type f16 support for: - - @ref CLRemapKernel + - CLRemapKernel - Port the following functions to stateless API: - @ref CLConvolutionLayer - @ref CLFlattenLayer @@ -296,7 +296,7 @@ v20.11 Public major release - Removed padding from Arm® Neon™ kernels: - NEComplexPixelWiseMultiplicationKernel - NENonMaximaSuppression3x3Kernel - - @ref NERemapKernel + - NERemapKernel - NEGEMMInterleave4x4Kernel - NEDirectConvolutionLayerKernel - NEScaleKernel @@ -1443,7 +1443,7 @@ v17.02.1 Sources preview - CLLogits1DMaxKernel, CLLogits1DShiftExpSumKernel, CLLogits1DNormKernel / @ref CLSoftmaxLayer - CLPoolingLayerKernel / @ref CLPoolingLayer - CLIm2ColKernel, CLCol2ImKernel, CLConvolutionLayerWeightsReshapeKernel / CLConvolutionLayer - - @ref CLRemapKernel / @ref CLRemap + - CLRemapKernel / CLRemap - CLGaussianPyramidHorKernel, CLGaussianPyramidVertKernel / CLGaussianPyramid, CLGaussianPyramidHalf, CLGaussianPyramidOrb - CLMinMaxKernel, CLMinMaxLocationKernel / CLMinMaxLocation - CLNonLinearFilterKernel / CLNonLinearFilter diff --git a/filelist.json b/filelist.json index d6b6f47bb9..ba19321a50 100644 --- a/filelist.json +++ b/filelist.json @@ -662,13 +662,6 @@ ] } }, - "Remap": { - "files": { - "common": [ - "src/core/CL/kernels/CLRemapKernel.cpp", - "src/runtime/CL/functions/CLRemap.cpp"] - } - }, "Reorg": { "files": { "common": [ @@ -1797,14 +1790,6 @@ ] } }, - "Remap": { - "files": { - "common": [ - "src/core/NEON/kernels/NERemapKernel.cpp", - "src/runtime/NEON/functions/NERemap.cpp" - ] - } - }, "Reorg": { "files": { "common": [ diff --git a/src/core/CL/CLKernels.h b/src/core/CL/CLKernels.h index 0c295aae6a..63be7b1ea8 100644 --- a/src/core/CL/CLKernels.h +++ b/src/core/CL/CLKernels.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2021 Arm Limited. + * Copyright (c) 2016-2022 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -56,7 +56,6 @@ #include "src/core/CL/kernels/CLROIPoolingLayerKernel.h" #include "src/core/CL/kernels/CLRangeKernel.h" #include "src/core/CL/kernels/CLReductionOperationKernel.h" -#include "src/core/CL/kernels/CLRemapKernel.h" #include "src/core/CL/kernels/CLReorgLayerKernel.h" #include "src/core/CL/kernels/CLReverseKernel.h" #include "src/core/CL/kernels/CLSelectKernel.h" diff --git a/src/core/CL/cl_kernels/nchw/remap.cl b/src/core/CL/cl_kernels/nchw/remap.cl deleted file mode 100644 index fab88a1682..0000000000 --- a/src/core/CL/cl_kernels/nchw/remap.cl +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2017-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. - */ -#include "helpers.h" -#include "warp_helpers.h" - -#ifndef DEPTH_OUT -/** Performs a remapping of an input image to an output given two remapping image using nearest neighbor as interpolation. - * - * This kernel performs remapping with this method of pixel coordinate translation: - * out(x,y) = in(mapx(x,y), mapy(x,y)); - * - * @param[in] in_ptr Pointer to the source image. Supported data types: U8. - * @param[in] in_stride_x Stride of the source image in X dimension (in bytes) - * @param[in] in_step_x in_stride_x * number of elements along X processed per work item (in bytes) - * @param[in] in_stride_y Stride of the source image in Y dimension (in bytes) - * @param[in] in_step_y in_stride_y * number of elements along Y processed per work item (in bytes) - * @param[in] in_offset_first_element_in_bytes Offset of the first element in the source image - * @param[out] out_ptr Pointer to the destination image. Supported data types: U8. - * @param[in] out_stride_x Stride of the destination image in X dimension (in bytes) - * @param[in] out_step_x out_stride_x * number of elements along X processed per work item (in bytes) - * @param[in] out_stride_y Stride of the destination image in Y dimension (in bytes) - * @param[in] out_step_y out_stride_y * number of elements along Y processed per work item (in bytes) - * @param[in] out_offset_first_element_in_bytes Offset of the first element in the destination image - * @param[in] mapx_ptr Pointer to the x remapping image. Supported data types: F32. - * @param[in] mapx_stride_x Stride of the remapping image in X dimension (in bytes) - * @param[in] mapx_step_x mapx_stride_x * number of elements along X processed per work item (in bytes) - * @param[in] mapx_stride_y Stride of the remapping image in Y dimension (in bytes) - * @param[in] mapx_step_y mapy_stride_y * number of elements along Y processed per work item (in bytes) - * @param[in] mapx_offset_first_element_in_bytes Offset of the first element in the remapping image - * @param[in] mapy_ptr Pointer to the x remapping image. Supported data types: F32. - * @param[in] mapy_stride_x Stride of the remapping image in X dimension (in bytes) - * @param[in] mapy_step_x mapy_stride_x * number of elements along X processed per work item (in bytes) - * @param[in] mapy_stride_y Stride of the remapping image in Y dimension (in bytes) - * @param[in] mapy_step_y mapy_stride_y * number of elements along Y processed per work item (in bytes) - * @param[in] mapy_offset_first_element_in_bytes Offset of the first element in the remapping image - * @param[in] width Width of the input image - * @param[in] height Height of the input image - */ -__kernel void remap_nearest_neighbour_nchw( - IMAGE_DECLARATION(in), - IMAGE_DECLARATION(out), - IMAGE_DECLARATION(mapx), - IMAGE_DECLARATION(mapy), - const float width, - const float height) -{ - Image in = CONVERT_TO_IMAGE_STRUCT_NO_STEP(in); - Image out = CONVERT_TO_IMAGE_STRUCT(out); - Image mapx = CONVERT_TO_IMAGE_STRUCT(mapx); - Image mapy = CONVERT_TO_IMAGE_STRUCT(mapy); - - float4 mapx_coords = vload4(0, (__global float *)mapx.ptr); - float4 mapy_coords = vload4(0, (__global float *)mapy.ptr); - float8 map_coords = (float8)(mapx_coords.s0, mapy_coords.s0, mapx_coords.s1, mapy_coords.s1, - mapx_coords.s2, mapy_coords.s2, mapx_coords.s3, mapy_coords.s3); - - vstore4(read_texels4(&in, convert_int8(clamp_to_border(map_coords, width, height))), 0, out.ptr); -} - -/** Performs a remapping of an input image to an output given two remapping image using bilinear as interpolation. - * - * This kernel performs remapping with this method of pixel coordinate translation: - * out(x,y) = in(mapx(x,y), mapy(x,y)); - * - * @param[in] in_ptr Pointer to the source image. Supported data types: U8. - * @param[in] in_stride_x Stride of the source image in X dimension (in bytes) - * @param[in] in_step_x in_stride_x * number of elements along X processed per work item (in bytes) - * @param[in] in_stride_y Stride of the source image in Y dimension (in bytes) - * @param[in] in_step_y in_stride_y * number of elements along Y processed per work item (in bytes) - * @param[in] in_offset_first_element_in_bytes Offset of the first element in the source image - * @param[out] out_ptr Pointer to the destination image. Supported data types: U8. - * @param[in] out_stride_x Stride of the destination image in X dimension (in bytes) - * @param[in] out_step_x out_stride_x * number of elements along X processed per work item (in bytes) - * @param[in] out_stride_y Stride of the destination image in Y dimension (in bytes) - * @param[in] out_step_y out_stride_y * number of elements along Y processed per work item (in bytes) - * @param[in] out_offset_first_element_in_bytes Offset of the first element in the destination image - * @param[in] mapx_ptr Pointer to the x remapping image. Supported data types: F32. - * @param[in] mapx_stride_x Stride of the remapping image in X dimension (in bytes) - * @param[in] mapx_step_x mapx_stride_x * number of elements along X processed per work item (in bytes) - * @param[in] mapx_stride_y Stride of the remapping image in Y dimension (in bytes) - * @param[in] mapx_step_y mapy_stride_y * number of elements along Y processed per work item (in bytes) - * @param[in] mapx_offset_first_element_in_bytes Offset of the first element in the remapping image - * @param[in] mapy_ptr Pointer to the x remapping image. Supported data types: F32. - * @param[in] mapy_stride_x Stride of the remapping image in X dimension (in bytes) - * @param[in] mapy_step_x mapy_stride_x * number of elements along X processed per work item (in bytes) - * @param[in] mapy_stride_y Stride of the remapping image in Y dimension (in bytes) - * @param[in] mapy_step_y mapy_stride_y * number of elements along Y processed per work item (in bytes) - * @param[in] mapy_offset_first_element_in_bytes Offset of the first element in the remapping image - * @param[in] width Width of the input image - * @param[in] height Height of the input image - */ -__kernel void remap_bilinear_nchw( - IMAGE_DECLARATION(in), - IMAGE_DECLARATION(out), - IMAGE_DECLARATION(mapx), - IMAGE_DECLARATION(mapy), - const float width, - const float height) -{ - Image in = CONVERT_TO_IMAGE_STRUCT_NO_STEP(in); - Image out = CONVERT_TO_IMAGE_STRUCT(out); - Image mapx = CONVERT_TO_IMAGE_STRUCT(mapx); - Image mapy = CONVERT_TO_IMAGE_STRUCT(mapy); - - float4 mapx_coords = vload4(0, (__global float *)mapx.ptr); - float4 mapy_coords = vload4(0, (__global float *)mapy.ptr); - float8 map_coords = (float8)(mapx_coords.s0, mapy_coords.s0, mapx_coords.s1, mapy_coords.s1, - mapx_coords.s2, mapy_coords.s2, mapx_coords.s3, mapy_coords.s3); - - vstore4(bilinear_interpolate(&in, clamp_to_border(map_coords, width, height), width, height), 0, out.ptr); -} -#endif // DEPTH_OUT \ No newline at end of file diff --git a/src/core/CL/cl_kernels/nhwc/remap.cl b/src/core/CL/cl_kernels/nhwc/remap.cl deleted file mode 100644 index 0b629fe6c9..0000000000 --- a/src/core/CL/cl_kernels/nhwc/remap.cl +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (c) 2017-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. - */ -#include "helpers.h" -#include "warp_helpers.h" - -#ifdef DEPTH_OUT -/** Performs a remapping of an input image to an output given two remapping image using nearest neighbor as interpolation. - * Also applies constant border value, "border_val", if "CONSTANT_BORDER" is set. - * - * This kernel performs remapping with this method of pixel coordinate translation: - * out(x,y) = in(mapx(x,y), mapy(x,y)); - * - * @param[in] in_ptr Pointer to the source image. Supported data types: U8,F16. - * @param[in] in_stride_x Stride of the source image in X dimension (in bytes) - * @param[in] in_step_x in_stride_x * number of elements along X processed per work item (in bytes) - * @param[in] in_stride_y Stride of the source image in Y dimension (in bytes) - * @param[in] in_step_y in_stride_y * number of elements along Y processed per work item (in bytes) - * @param[in] in_offset_first_element_in_bytes Offset of the first element in the source image - * @param[out] out_ptr Pointer to the destination image. Supported data types: U8,F16. - * @param[in] out_stride_x Stride of the destination image in X dimension (in bytes) - * @param[in] out_step_x out_stride_x * number of elements along X processed per work item (in bytes) - * @param[in] out_stride_y Stride of the destination image in Y dimension (in bytes) - * @param[in] out_step_y out_stride_y * number of elements along Y processed per work item (in bytes) - * @param[in] out_offset_first_element_in_bytes Offset of the first element in the destination image - * @param[in] mapx_ptr Pointer to the x remapping image. Supported data types: F32. - * @param[in] mapx_stride_x Stride of the remapping image in X dimension (in bytes) - * @param[in] mapx_step_x mapx_stride_x * number of elements along X processed per work item (in bytes) - * @param[in] mapx_stride_y Stride of the remapping image in Y dimension (in bytes) - * @param[in] mapx_step_y mapy_stride_y * number of elements along Y processed per work item (in bytes) - * @param[in] mapx_offset_first_element_in_bytes Offset of the first element in the remapping image - * @param[in] mapy_ptr Pointer to the x remapping image. Supported data types: F32. - * @param[in] mapy_stride_x Stride of the remapping image in X dimension (in bytes) - * @param[in] mapy_step_x mapy_stride_x * number of elements along X processed per work item (in bytes) - * @param[in] mapy_stride_y Stride of the remapping image in Y dimension (in bytes) - * @param[in] mapy_step_y mapy_stride_y * number of elements along Y processed per work item (in bytes) - * @param[in] mapy_offset_first_element_in_bytes Offset of the first element in the remapping image - * @param[in] width Width of the input image - * @param[in] height Height of the input image - * @param[in] border_val Value to use for border around input tensor when in CONSTANT border is selected - */ -__kernel void remap_nearest_neighbour_nhwc( - TENSOR4D_DECLARATION(in), - TENSOR4D_DECLARATION(out), - TENSOR4D_DECLARATION(mapx), - TENSOR4D_DECLARATION(mapy), - const float width, - const float height -#ifdef CONSTANT_BORDER - , - const DATA_TYPE border_val -#endif // CONSTANT_BORDER -) -{ - Tensor4D in = CONVERT_TO_TENSOR4D_STRUCT_NO_STEP(in, 0); - Tensor4D out = CONVERT_TO_TENSOR4D_STRUCT(out, DEPTH_OUT); - Tensor4D mapx = CONVERT_TO_TENSOR4D_STRUCT(mapx, DEPTH_OUT); - Tensor4D mapy = CONVERT_TO_TENSOR4D_STRUCT(mapy, DEPTH_OUT); - - float mapx_coord = (float) * (__global float *)mapx.ptr; - float mapy_coord = (float) * (__global float *)mapy.ptr; - -#ifdef CONSTANT_BORDER - if(mapx_coord < 0 || mapx_coord > width - 1 || mapy_coord < 0 || mapy_coord > height - 1) - { - *((__global DATA_TYPE *)out.ptr) = border_val; - return; - } -#else // CONSTANT_BORDER - mapx_coord = clamp(mapx_coord, 0.0f, width - 1); - mapy_coord = clamp(mapy_coord, 0.0f, height - 1); -#endif // CONSTANT_BORDER - *((__global DATA_TYPE *)out.ptr) = *((__global DATA_TYPE *)tensor4D_offset(&in, get_global_id(0), convert_int(mapx_coord), convert_int(mapy_coord), (get_global_id(2) / DEPTH_OUT))); -} - -/** Performs a remapping of an input image to an output given two remapping image using bilinear as interpolation. - * Also applies constant border value, "border_val", if "CONSTANT_BORDER" is set. - * - * This kernel performs remapping with this method of pixel coordinate translation: - * out(x,y) = in(mapx(x,y), mapy(x,y)); - * - * @param[in] in_ptr Pointer to the source image. Supported data types: U8,F16. - * @param[in] in_stride_x Stride of the source image in X dimension (in bytes) - * @param[in] in_step_x in_stride_x * number of elements along X processed per work item (in bytes) - * @param[in] in_stride_y Stride of the source image in Y dimension (in bytes) - * @param[in] in_step_y in_stride_y * number of elements along Y processed per work item (in bytes) - * @param[in] in_offset_first_element_in_bytes Offset of the first element in the source image - * @param[out] out_ptr Pointer to the destination image. Supported data types: U8,F16. - * @param[in] out_stride_x Stride of the destination image in X dimension (in bytes) - * @param[in] out_step_x out_stride_x * number of elements along X processed per work item (in bytes) - * @param[in] out_stride_y Stride of the destination image in Y dimension (in bytes) - * @param[in] out_step_y out_stride_y * number of elements along Y processed per work item (in bytes) - * @param[in] out_offset_first_element_in_bytes Offset of the first element in the destination image - * @param[in] mapx_ptr Pointer to the x remapping image. Supported data types: F32. - * @param[in] mapx_stride_x Stride of the remapping image in X dimension (in bytes) - * @param[in] mapx_step_x mapx_stride_x * number of elements along X processed per work item (in bytes) - * @param[in] mapx_stride_y Stride of the remapping image in Y dimension (in bytes) - * @param[in] mapx_step_y mapy_stride_y * number of elements along Y processed per work item (in bytes) - * @param[in] mapx_offset_first_element_in_bytes Offset of the first element in the remapping image - * @param[in] mapy_ptr Pointer to the x remapping image. Supported data types: F32. - * @param[in] mapy_stride_x Stride of the remapping image in X dimension (in bytes) - * @param[in] mapy_step_x mapy_stride_x * number of elements along X processed per work item (in bytes) - * @param[in] mapy_stride_y Stride of the remapping image in Y dimension (in bytes) - * @param[in] mapy_step_y mapy_stride_y * number of elements along Y processed per work item (in bytes) - * @param[in] mapy_offset_first_element_in_bytes Offset of the first element in the remapping image - * @param[in] width Width of the input image - * @param[in] height Height of the input image - * @param[in] border_val Value to use for border around input tensor when in CONSTANT border is selected - */ -__kernel void remap_bilinear_nhwc( - TENSOR4D_DECLARATION(in), - TENSOR4D_DECLARATION(out), - TENSOR4D_DECLARATION(mapx), - TENSOR4D_DECLARATION(mapy), - const float width, - const float height -#ifdef CONSTANT_BORDER - , - const DATA_TYPE border_val -#endif // CONSTANT_BORDER -) -{ - Tensor4D in = CONVERT_TO_TENSOR4D_STRUCT_NO_STEP(in, 0); - Tensor4D out = CONVERT_TO_TENSOR4D_STRUCT(out, DEPTH_OUT); - Tensor4D mapx = CONVERT_TO_TENSOR4D_STRUCT(mapx, DEPTH_OUT); - Tensor4D mapy = CONVERT_TO_TENSOR4D_STRUCT(mapy, DEPTH_OUT); - - float mapx_coord = (float) * (__global float *)mapx.ptr; - float mapy_coord = (float) * (__global float *)mapy.ptr; - -#ifdef CONSTANT_BORDER - if(mapx_coord < 0 || mapx_coord > width - 1 || mapy_coord < 0 || mapy_coord > height - 1) - { - *((__global DATA_TYPE *)out.ptr) = border_val; - return; - } -#endif // CONSTANT_BORDER - - const float new_xf = floor(mapx_coord); - const float new_yf = floor(mapy_coord); - const float clamped_x = clamp(new_xf, 0.0f, width - 1); - const float clamped_x1 = clamp(new_xf + 1, 0.0f, width - 1); - const float clamped_y = clamp(new_yf, 0.0f, height - 1); - const float clamped_y1 = clamp(new_yf + 1, 0.0f, height - 1); - - float4 ins = (float4)(*((__global DATA_TYPE *)tensor4D_offset(&in, get_global_id(0), convert_int(clamped_x), convert_int(clamped_y), (get_global_id(2) / DEPTH_OUT))), - *((__global DATA_TYPE *)tensor4D_offset(&in, get_global_id(0), convert_int(clamped_x1), convert_int(clamped_y), (get_global_id(2) / DEPTH_OUT))), - *((__global DATA_TYPE *)tensor4D_offset(&in, get_global_id(0), convert_int(clamped_x), convert_int(clamped_y1), (get_global_id(2) / DEPTH_OUT))), - *((__global DATA_TYPE *)tensor4D_offset(&in, get_global_id(0), convert_int(clamped_x1), convert_int(clamped_y1), (get_global_id(2) / DEPTH_OUT)))); - - const float a = mapx_coord - new_xf; - const float b = 1.f - a; - const float a1 = mapy_coord - new_yf; - const float b1 = 1.f - a1; - const float fr = ((ins.s0 * b * b1) + (ins.s1 * a * b1) + (ins.s2 * b * a1) + (ins.s3 * a * a1)); - - *((__global DATA_TYPE *)out.ptr) = CONVERT(fr, DATA_TYPE); -} - -#endif // DEPTH_OUT \ No newline at end of file diff --git a/src/core/CL/kernels/CLRemapKernel.cpp b/src/core/CL/kernels/CLRemapKernel.cpp deleted file mode 100644 index ea3b637e8d..0000000000 --- a/src/core/CL/kernels/CLRemapKernel.cpp +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (c) 2017-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. - */ -#include "src/core/CL/kernels/CLRemapKernel.h" - -#include "arm_compute/core/CL/CLHelpers.h" -#include "arm_compute/core/CL/CLKernelLibrary.h" -#include "arm_compute/core/CL/ICLTensor.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" - -namespace arm_compute -{ -CLRemapKernel::CLRemapKernel() - : _input(nullptr), _output(nullptr), _map_x(nullptr), _map_y(nullptr), _data_layout(DataLayout::NCHW) -{ - _type = CLKernelType::ELEMENTWISE; -} - -BorderSize CLRemapKernel::border_size() const -{ - return _data_layout == DataLayout::NCHW ? BorderSize(1) : BorderSize(0); -} - -template -void CLRemapKernel::set_constant_border(unsigned int idx, const PixelValue &constant_border_value) -{ - T value; - constant_border_value.get(value); - ICLKernel::add_argument(idx, static_cast(value)); -} - -Status CLRemapKernel::validate(const ITensorInfo *input, const ITensorInfo *map_x, const ITensorInfo *map_y, const ITensorInfo *output, RemapInfo info) -{ - ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input, map_x, map_y, output); - if(input->data_layout() == DataLayout::NCHW) - { - ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8); - } - else - { - ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8, DataType::F16); - } - ARM_COMPUTE_RETURN_ERROR_ON_MSG(input->data_type() != output->data_type(), "Input/output have different data types"); - ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(map_x, 1, DataType::F32); - ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(map_y, 1, DataType::F32); - ARM_COMPUTE_RETURN_ERROR_ON_MSG(info.policy == InterpolationPolicy::AREA, "Area interpolation is not supported!"); - ARM_COMPUTE_RETURN_ERROR_ON_MSG(info.border_mode != BorderMode::CONSTANT && info.border_mode != BorderMode::UNDEFINED, "Border mode not supported"); - return Status{}; -} - -void CLRemapKernel::configure(const CLCompileContext &compile_context, const ICLTensor *input, const ICLTensor *map_x, const ICLTensor *map_y, ICLTensor *output, RemapInfo info) -{ - ARM_COMPUTE_ERROR_ON_NULLPTR(input, map_x, map_y, output); - ARM_COMPUTE_ERROR_THROW_ON(CLRemapKernel::validate(input->info(), map_x->info(), map_y->info(), output->info(), info)); - - _input = input; - _output = output; - _map_x = map_x; - _map_y = map_y; - _data_layout = input->info()->data_layout(); - - const bool is_nhwc = _data_layout == DataLayout::NHWC; - const bool is_constant_border = info.border_mode == BorderMode::CONSTANT; - - // Create kernel - CLBuildOptions build_opts; - build_opts.add_option(("-DDATA_TYPE=" + get_cl_type_from_data_type(input->info()->data_type()))); - build_opts.add_option_if(is_nhwc, "-DDEPTH_OUT=" + support::cpp11::to_string(output->info()->dimension(2))); - build_opts.add_option_if(is_constant_border, "-DCONSTANT_BORDER"); - - const std::string interpolation_name = lower_string(string_from_interpolation_policy(info.policy)); - const std::string kernel_name = "remap_" + interpolation_name + "_" + lower_string(string_from_data_layout(_data_layout)); - _kernel = create_kernel(compile_context, kernel_name, build_opts.options()); - - const unsigned int num_elems_processed_per_iteration = is_nhwc ? 1 : 4; - const int idx_height = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::HEIGHT); - const int idx_width = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::WIDTH); - const int input_height = input->info()->dimension(idx_height); - const int input_width = input->info()->dimension(idx_width); - - // Configure window - Window win = calculate_max_window(*_output->info(), Steps(num_elems_processed_per_iteration)); - - // Update padding in NCHW case - if(_data_layout == DataLayout::NCHW) - { - const int total_right = ceil_to_multiple(input_width, num_elems_processed_per_iteration); - const int access_right = total_right + (((total_right - input_width) == 0) ? border_size().right : 0); - AccessWindowStatic input_access(input->info(), -border_size().left, -border_size().top, access_right, input_height + border_size().bottom); - - AccessWindowHorizontal output_access(output->info(), 0, num_elems_processed_per_iteration); - - update_window_and_padding(win, input_access, output_access); - } - - ICLKernel::configure_internal(win); - - // Set static arguments - unsigned int idx = 4 * (is_nhwc ? num_arguments_per_4D_tensor() : num_arguments_per_2D_tensor()); - _kernel.setArg(idx++, input_width); - _kernel.setArg(idx++, input_height); - if(is_nhwc && is_constant_border) - { - switch(input->info()->data_type()) - { - case DataType::U8: - set_constant_border(idx, info.constant_border_value); - break; - case DataType::F16: - static_assert(sizeof(cl_half) == sizeof(half), "Half must be same size as cl_half"); - static_assert(sizeof(cl_half) == 2, "Half must be 16 bit"); - set_constant_border(idx, info.constant_border_value); - break; - default: - ARM_COMPUTE_ERROR("Data Type not handled"); - } - } -} - -void CLRemapKernel::run(const Window &window, cl::CommandQueue &queue) -{ - ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); - ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(ICLKernel::window(), window); - switch(_data_layout) - { - case DataLayout::NCHW: - { - Window slice = window.first_slice_window_2D(); - do - { - unsigned int idx = 0; - add_2D_tensor_argument(idx, _input, slice); - add_2D_tensor_argument(idx, _output, slice); - add_2D_tensor_argument(idx, _map_x, slice); - add_2D_tensor_argument(idx, _map_y, slice); - enqueue(queue, *this, slice, lws_hint()); - - } - while(window.slide_window_slice_2D(slice)); - break; - } - case DataLayout::NHWC: - { - Window collapsed = window.collapse(ICLKernel::window(), Window::DimZ); - Window slice = collapsed.first_slice_window_4D(); - - unsigned int idx = 0; - add_4D_tensor_argument(idx, _input, slice); - add_4D_tensor_argument(idx, _output, slice); - add_4D_tensor_argument(idx, _map_x, slice); - add_4D_tensor_argument(idx, _map_y, slice); - enqueue(queue, *this, slice, lws_hint()); - break; - } - default: - ARM_COMPUTE_ERROR("Invalid Data layout"); - } -} -} // namespace arm_compute diff --git a/src/core/CL/kernels/CLRemapKernel.h b/src/core/CL/kernels/CLRemapKernel.h deleted file mode 100644 index 93b0b4e660..0000000000 --- a/src/core/CL/kernels/CLRemapKernel.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2017-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_CLREMAPKERNEL_H -#define ARM_COMPUTE_CLREMAPKERNEL_H - -#include "arm_compute/core/KernelDescriptors.h" -#include "arm_compute/core/Types.h" -#include "src/core/CL/ICLKernel.h" - -namespace arm_compute -{ -class ICLTensor; - -/** OpenCL kernel to perform a remap on a tensor */ -class CLRemapKernel : public ICLKernel -{ -public: - /** Default constructor */ - CLRemapKernel(); - /** Prevent instances of this class from being copied (As this class contains pointers) */ - CLRemapKernel(const CLRemapKernel &) = delete; - /** Prevent instances of this class from being copied (As this class contains pointers) */ - CLRemapKernel &operator=(const CLRemapKernel &) = delete; - /** Allow instances of this class to be moved */ - CLRemapKernel(CLRemapKernel &&) = default; - /** Allow instances of this class to be moved */ - CLRemapKernel &operator=(CLRemapKernel &&) = default; - /** Initialize the kernel's input, output and border mode. - * - * @param[in] compile_context The compile context to be used. - * @param[in] input Source tensor. Data types supported: U8 (or F16 when layout is NHWC). - * @param[in] map_x Map for X coordinates. Data types supported: F32. - * @param[in] map_y Map for Y coordinates. Data types supported: F32. - * @param[out] output Destination tensor. Data types supported: Same as @p input. All but the lowest two dimensions must be the same size as in the input tensor, i.e. remapping is only performed within the XY-plane. - * @param[in] info RemapInfo struct: - * - policy Interpolation policy to use. Only NEAREST and BILINEAR are supported. - * - border_mode Border mode to use on the input tensor. Only CONSTANT and UNDEFINED are supported. - * - constant_border_value Constant value to use for borders if border_mode is set to CONSTANT. - */ - void configure(const CLCompileContext &compile_context, const ICLTensor *input, const ICLTensor *map_x, const ICLTensor *map_y, ICLTensor *output, RemapInfo info); - /** Checks if the kernel's input, output and border mode will lead to a valid configuration of @ref CLRemapKernel - * - * Similar to @ref CLRemapKernel::configure(const CLCompileContext &compile_context, const ICLTensor *input, const ICLTensor *map_x, const ICLTensor *map_y, ICLTensor *output, RemapInfo info) - * - */ - static Status validate(const ITensorInfo *input, const ITensorInfo *map_x, const ITensorInfo *map_y, const ITensorInfo *output, RemapInfo info); - /** Function to set the constant value on fill border kernel depending on type. - * - * @param[in] idx Index of the kernel argument to set. - * @param[in] constant_border_value Constant value to use for borders if border_mode is set to CONSTANT. - */ - template - void set_constant_border(unsigned int idx, const PixelValue &constant_border_value); - - // Inherited methods overridden: - void run(const Window &window, cl::CommandQueue &queue) override; - BorderSize border_size() const override; - -private: - const ICLTensor *_input; - ICLTensor *_output; - const ICLTensor *_map_x; - const ICLTensor *_map_y; - DataLayout _data_layout; -}; -} // namespace arm_compute -#endif /*ARM_COMPUTE_CLREMAPKERNEL_H */ diff --git a/src/core/NEON/NEKernels.h b/src/core/NEON/NEKernels.h index af301c8d16..cd01659c0d 100644 --- a/src/core/NEON/NEKernels.h +++ b/src/core/NEON/NEKernels.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2021 Arm Limited. + * Copyright (c) 2016-2022 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -55,7 +55,6 @@ #include "src/core/NEON/kernels/NEROIPoolingLayerKernel.h" #include "src/core/NEON/kernels/NERangeKernel.h" #include "src/core/NEON/kernels/NEReductionOperationKernel.h" -#include "src/core/NEON/kernels/NERemapKernel.h" #include "src/core/NEON/kernels/NEReorgLayerKernel.h" #include "src/core/NEON/kernels/NEReverseKernel.h" #include "src/core/NEON/kernels/NESelectKernel.h" diff --git a/src/core/NEON/kernels/NERemapKernel.cpp b/src/core/NEON/kernels/NERemapKernel.cpp deleted file mode 100644 index a1ba29e4c4..0000000000 --- a/src/core/NEON/kernels/NERemapKernel.cpp +++ /dev/null @@ -1,326 +0,0 @@ -/* - * Copyright (c) 2017-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. - */ -#include "src/core/NEON/kernels/NERemapKernel.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/ScaleHelpers.h" -#include "src/core/helpers/WindowHelpers.h" - -#include -#include -#include - -using namespace arm_compute::scale_helpers; - -namespace arm_compute -{ -class Coordinates; - -namespace -{ -inline int32_t num_out_of_tensor(const float *mapx_ptr, const float *mapy_ptr, const int32x4_t &width_1, const int32x4_t &height_1) -{ - const int32x4_t mapx_s32 = vcvtq_s32_f32(vld1q_f32(mapx_ptr)); - const int32x4_t mapy_s32 = vcvtq_s32_f32(vld1q_f32(mapy_ptr)); - - const int32x4_t outbx_s32 = vminq_s32(vmaxq_s32(vminq_s32(vsubq_s32(width_1, mapx_s32), mapx_s32), vdupq_n_s32(-1)), vdupq_n_s32(0)); // Contains -1 if out of border in x, 0 otherwise - const int32x4_t outby_s32 = vminq_s32(vmaxq_s32(vminq_s32(vsubq_s32(height_1, mapy_s32), mapy_s32), vdupq_n_s32(-1)), vdupq_n_s32(0)); // Contains -1 if out of border in y, 0 otherwise - - const int32x4_t out_of_tensor_v = vminq_s32(outbx_s32, outby_s32); -#if defined(__aarch64__) - // only AArch64 supports vaddv - return vaddvq_s32(out_of_tensor_v); -#else // __aarch64__ - return vgetq_lane_s32(out_of_tensor_v, 0) + vgetq_lane_s32(out_of_tensor_v, 1) + vgetq_lane_s32(out_of_tensor_v, 2) + vgetq_lane_s32(out_of_tensor_v, 3); -#endif // __aarch64__ -} - -inline void serial_remap_nearest_interpolation(const uint8_t *in_ptr, const float *mapx_ptr, const float *mapy_ptr, uint8_t *out_ptr, - int32_t width_val, int32_t height_val, int32_t in_stride_val, uint8_t constant_border_value) -{ - const auto x_s32 = static_cast(*mapx_ptr); - const auto y_s32 = static_cast(*mapy_ptr); - if(x_s32 < 0 || y_s32 < 0 || x_s32 >= width_val || y_s32 >= height_val) - { - *(out_ptr) = constant_border_value; - } - else - { - *(out_ptr) = in_ptr[x_s32 + y_s32 * in_stride_val]; - } -} - -inline int32x4_t offset_nearest_interpolation(const float *mapx_ptr, const float *mapy_ptr, const int32x4_t &stride) -{ - const int32x4_t mapx_s32 = vcvtq_s32_f32(vld1q_f32(mapx_ptr)); - const int32x4_t mapy_s32 = vcvtq_s32_f32(vld1q_f32(mapy_ptr)); - return vmlaq_s32(mapx_s32, mapy_s32, stride); -} - -inline uint8_t pixel_bilinear_c1_clamp(const uint8_t *pixel_ptr, int32_t stride, int32_t width, int32_t height, float x, float y, uint8_t constant_border_value) -{ - x = std::max(-1.f, std::min(x, static_cast(width))); - y = std::max(-1.f, std::min(y, static_cast(height))); - - const int32_t xi = static_cast(std::floor(x)); - const int32_t yi = static_cast(std::floor(y)); - - const float dx = x - static_cast(xi); - const float dy = y - static_cast(yi); - - // Calculating the address won't trigger a segfault in case the value is outside the tensor - // The ternary operator resolves the values in both conditions - const uint8_t *a00 = (xi < 0 || xi >= width || yi < 0 || yi >= height) ? &constant_border_value : (pixel_ptr + xi + yi * stride); - const uint8_t *a01 = (xi + 1 >= width || yi < 0 || yi >= height) ? &constant_border_value : (pixel_ptr + xi + 1 + yi * stride); - const uint8_t *a10 = (xi < 0 || xi >= width || yi + 1 >= height) ? &constant_border_value : (pixel_ptr + xi + yi * stride + stride); - const uint8_t *a11 = (xi + 1 >= width || yi + 1 >= height) ? &constant_border_value : (pixel_ptr + xi + 1 + yi * stride + stride); - - const float dx1 = 1.0f - dx; - const float dy1 = 1.0f - dy; - const float w1 = dx1 * dy1; - const float w2 = dx * dy1; - const float w3 = dx1 * dy; - const float w4 = dx * dy; - - return static_cast((*a00) * w1 + (*a01) * w2 + (*a10) * w3 + (*a11) * w4); -} -} // namespace - -NERemapKernel::NERemapKernel() - : _func(nullptr), _input(nullptr), _output(nullptr), _map_x(nullptr), _map_y(nullptr), _border_mode(BorderMode::UNDEFINED), _constant_border_value(0) -{ -} - -void NERemapKernel::configure(const ITensor *input, const ITensor *map_x, const ITensor *map_y, ITensor *output, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value) -{ - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8); - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(output, 1, DataType::U8); - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(map_x, 1, DataType::F32); - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(map_y, 1, DataType::F32); - - _input = input; - _output = output; - _map_x = map_x; - _map_y = map_y; - _border_mode = border_mode; - _constant_border_value = constant_border_value; - - switch(policy) - { - case InterpolationPolicy::NEAREST_NEIGHBOR: - { - _func = &NERemapKernel::remap_nearest; - break; - } - case InterpolationPolicy::BILINEAR: - { - _func = &NERemapKernel::remap_bilinear; - break; - } - default: - ARM_COMPUTE_ERROR("Unsupported interpolation mode"); - break; - } - - // Configure kernel window - Window win = calculate_max_window(*output->info(), Steps()); - INEKernel::configure(win); -} - -void NERemapKernel::remap_nearest(const Window &window) -{ - // Don't increment in X and Y direction for the input tensor - // A pointer to the start of this plane is needed as base for the precomputed offsets - Window win_in(window); - win_in.set(Window::DimX, Window::Dimension(0, 0, 0)); - win_in.set(Window::DimY, Window::Dimension(0, 0, 0)); - - const auto window_start_x = static_cast(window.x().start()); - const auto window_end_x = static_cast(window.x().end()); - const int32_t window_step_x = 8; - - // Don't increment in X direction for the output, mapx, mapy tensors - Window win(window); - win.set(Window::DimX, Window::Dimension(0, 1, 1)); - - Iterator in(_input, win_in); - Iterator out(_output, win); - Iterator mapx(_map_x, win); - Iterator mapy(_map_y, win); - - const int32_t width_val = static_cast(_input->info()->dimension(0)); - const int32_t height_val = static_cast(_input->info()->dimension(1)); - const int32_t in_stride_val = static_cast(_input->info()->strides_in_bytes()[1]); - const int32x4_t width_1 = vdupq_n_s32(width_val - 1); - const int32x4_t height_1 = vdupq_n_s32(height_val - 1); - const int32x4_t in_stride = vdupq_n_s32(in_stride_val); - - execute_window_loop(win, [&](const Coordinates &) - { - auto mapx_ptr = reinterpret_cast(mapx.ptr()); - auto mapy_ptr = reinterpret_cast(mapy.ptr()); - const uint8_t *in_ptr = in.ptr(); - uint8_t *out_ptr = out.ptr(); - int32_t x = window_start_x; - for(; x < window_end_x - window_step_x; x += window_step_x, mapx_ptr += window_step_x, mapy_ptr += window_step_x, out_ptr += window_step_x) - { - const int32_t out_of_tensor0 = num_out_of_tensor(mapx_ptr, mapy_ptr + 0, width_1, height_1); - const int32_t out_of_tensor1 = num_out_of_tensor(mapx_ptr + 4, mapy_ptr + 4, width_1, height_1); - const int32_t out_of_tensor = out_of_tensor0 + out_of_tensor1; - - if(out_of_tensor == -8) - { - // All elements are out of xy plane - uint8x8_t tmp = vdup_n_u8(_constant_border_value); - vst1_u8(out_ptr, tmp); - } - else if(out_of_tensor < 0) - { - // Some elements are out of xy plane - serial_remap_nearest_interpolation(in_ptr, mapx_ptr, mapy_ptr, out_ptr, width_val, height_val, in_stride_val, _constant_border_value); - serial_remap_nearest_interpolation(in_ptr, mapx_ptr + 1, mapy_ptr + 1, out_ptr + 1, width_val, height_val, in_stride_val, _constant_border_value); - serial_remap_nearest_interpolation(in_ptr, mapx_ptr + 2, mapy_ptr + 2, out_ptr + 2, width_val, height_val, in_stride_val, _constant_border_value); - serial_remap_nearest_interpolation(in_ptr, mapx_ptr + 3, mapy_ptr + 3, out_ptr + 3, width_val, height_val, in_stride_val, _constant_border_value); - serial_remap_nearest_interpolation(in_ptr, mapx_ptr + 4, mapy_ptr + 4, out_ptr + 4, width_val, height_val, in_stride_val, _constant_border_value); - serial_remap_nearest_interpolation(in_ptr, mapx_ptr + 5, mapy_ptr + 5, out_ptr + 5, width_val, height_val, in_stride_val, _constant_border_value); - serial_remap_nearest_interpolation(in_ptr, mapx_ptr + 6, mapy_ptr + 6, out_ptr + 6, width_val, height_val, in_stride_val, _constant_border_value); - serial_remap_nearest_interpolation(in_ptr, mapx_ptr + 7, mapy_ptr + 7, out_ptr + 7, width_val, height_val, in_stride_val, _constant_border_value); - } - else - { - // All elements are in xy plane - uint8x8_t tmp = vdup_n_u8(0); - const int32x4_t offset0 = offset_nearest_interpolation(mapx_ptr, mapy_ptr, in_stride); - const int32x4_t offset1 = offset_nearest_interpolation(mapx_ptr + 4, mapy_ptr + 4, in_stride); - tmp = vset_lane_u8(in_ptr[vgetq_lane_s32(offset0, 0)], tmp, 0); - tmp = vset_lane_u8(in_ptr[vgetq_lane_s32(offset0, 1)], tmp, 1); - tmp = vset_lane_u8(in_ptr[vgetq_lane_s32(offset0, 2)], tmp, 2); - tmp = vset_lane_u8(in_ptr[vgetq_lane_s32(offset0, 3)], tmp, 3); - tmp = vset_lane_u8(in_ptr[vgetq_lane_s32(offset1, 0)], tmp, 4); - tmp = vset_lane_u8(in_ptr[vgetq_lane_s32(offset1, 1)], tmp, 5); - tmp = vset_lane_u8(in_ptr[vgetq_lane_s32(offset1, 2)], tmp, 6); - tmp = vset_lane_u8(in_ptr[vgetq_lane_s32(offset1, 3)], tmp, 7); - vst1_u8(out_ptr, tmp); - } - } - for(; x < window_end_x; ++x, ++mapx_ptr, ++mapy_ptr, ++out_ptr) - { - serial_remap_nearest_interpolation(in_ptr, mapx_ptr, mapy_ptr, out_ptr, width_val, height_val, in_stride_val, _constant_border_value); - } - }, - in, out, mapx, mapy); -} - -void NERemapKernel::remap_bilinear(const Window &window) -{ - // Don't increment in X and Y direction for the input tensor - // A pointer to the start of this plane is needed as base for the precomputed offsets - Window win_in(window); - win_in.set(Window::DimX, Window::Dimension(0, 0, 0)); - win_in.set(Window::DimY, Window::Dimension(0, 0, 0)); - - const auto window_start_x = static_cast(window.x().start()); - const auto window_end_x = static_cast(window.x().end()); - const int32_t window_step_x = 8; - - // Don't increment in X direction for the output, mapx, mapy tensors - Window win(window); - win.set(Window::DimX, Window::Dimension(0, 1, 1)); - - Iterator in(_input, win_in); - Iterator out(_output, win); - Iterator mapx(_map_x, win); - Iterator mapy(_map_y, win); - - const int32_t width_val = static_cast(_input->info()->dimension(0)); - const int32_t height_val = static_cast(_input->info()->dimension(1)); - const int32x4_t width_2 = vdupq_n_s32(width_val - 2); - const int32x4_t height_2 = vdupq_n_s32(height_val - 2); - const int32_t in_stride_val = static_cast(_input->info()->strides_in_bytes()[1]); - - execute_window_loop(win, [&](const Coordinates &) - { - auto mapx_ptr = reinterpret_cast(mapx.ptr()); - auto mapy_ptr = reinterpret_cast(mapy.ptr()); - const uint8_t *in_ptr = in.ptr(); - uint8_t *out_ptr = out.ptr(); - int32_t x = window_start_x; - for(; x < window_end_x - window_step_x; x += window_step_x, mapx_ptr += window_step_x, mapy_ptr += window_step_x, out_ptr += window_step_x) - { - const int32_t out_of_tensor0 = num_out_of_tensor(mapx_ptr, mapy_ptr + 0, width_2, height_2); - const int32_t out_of_tensor1 = num_out_of_tensor(mapx_ptr + 4, mapy_ptr + 4, width_2, height_2); - const int32_t out_of_tensor = out_of_tensor0 + out_of_tensor1; - - if(out_of_tensor < 0) - { - // Elements are out of xy plane - *(out_ptr) = pixel_bilinear_c1_clamp(in_ptr, in_stride_val, width_val, height_val, mapx_ptr[0], mapy_ptr[0], _constant_border_value); - *(out_ptr + 1) = pixel_bilinear_c1_clamp(in_ptr, in_stride_val, width_val, height_val, mapx_ptr[1], mapy_ptr[1], _constant_border_value); - *(out_ptr + 2) = pixel_bilinear_c1_clamp(in_ptr, in_stride_val, width_val, height_val, mapx_ptr[2], mapy_ptr[2], _constant_border_value); - *(out_ptr + 3) = pixel_bilinear_c1_clamp(in_ptr, in_stride_val, width_val, height_val, mapx_ptr[3], mapy_ptr[3], _constant_border_value); - *(out_ptr + 4) = pixel_bilinear_c1_clamp(in_ptr, in_stride_val, width_val, height_val, mapx_ptr[4], mapy_ptr[4], _constant_border_value); - *(out_ptr + 5) = pixel_bilinear_c1_clamp(in_ptr, in_stride_val, width_val, height_val, mapx_ptr[5], mapy_ptr[5], _constant_border_value); - *(out_ptr + 6) = pixel_bilinear_c1_clamp(in_ptr, in_stride_val, width_val, height_val, mapx_ptr[6], mapy_ptr[6], _constant_border_value); - *(out_ptr + 7) = pixel_bilinear_c1_clamp(in_ptr, in_stride_val, width_val, height_val, mapx_ptr[7], mapy_ptr[7], _constant_border_value); - } - else - { - // All elements are in xy plane - uint8x8_t tmp = vdup_n_u8(0); - tmp = vset_lane_u8(pixel_bilinear_c1_clamp(in_ptr, in_stride_val, width_val, height_val, mapx_ptr[0], mapy_ptr[0], _constant_border_value), tmp, 0); - tmp = vset_lane_u8(pixel_bilinear_c1_clamp(in_ptr, in_stride_val, width_val, height_val, mapx_ptr[1], mapy_ptr[1], _constant_border_value), tmp, 1); - tmp = vset_lane_u8(pixel_bilinear_c1_clamp(in_ptr, in_stride_val, width_val, height_val, mapx_ptr[2], mapy_ptr[2], _constant_border_value), tmp, 2); - tmp = vset_lane_u8(pixel_bilinear_c1_clamp(in_ptr, in_stride_val, width_val, height_val, mapx_ptr[3], mapy_ptr[3], _constant_border_value), tmp, 3); - tmp = vset_lane_u8(pixel_bilinear_c1_clamp(in_ptr, in_stride_val, width_val, height_val, mapx_ptr[4], mapy_ptr[4], _constant_border_value), tmp, 4); - tmp = vset_lane_u8(pixel_bilinear_c1_clamp(in_ptr, in_stride_val, width_val, height_val, mapx_ptr[5], mapy_ptr[5], _constant_border_value), tmp, 5); - tmp = vset_lane_u8(pixel_bilinear_c1_clamp(in_ptr, in_stride_val, width_val, height_val, mapx_ptr[6], mapy_ptr[6], _constant_border_value), tmp, 6); - tmp = vset_lane_u8(pixel_bilinear_c1_clamp(in_ptr, in_stride_val, width_val, height_val, mapx_ptr[7], mapy_ptr[7], _constant_border_value), tmp, 7); - vst1_u8(out_ptr, tmp); - } - } - for(; x < window_end_x; ++x, ++mapx_ptr, ++mapy_ptr, ++out_ptr) - { - *(out_ptr) = pixel_bilinear_c1_clamp(in_ptr, in_stride_val, width_val, height_val, mapx_ptr[0], mapy_ptr[0], _constant_border_value); - } - }, - in, out, mapx, mapy); -} - -void NERemapKernel::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(_func == nullptr); - - (this->*_func)(window); -} -} // namespace arm_compute \ No newline at end of file diff --git a/src/core/NEON/kernels/NERemapKernel.h b/src/core/NEON/kernels/NERemapKernel.h deleted file mode 100644 index 33e929805a..0000000000 --- a/src/core/NEON/kernels/NERemapKernel.h +++ /dev/null @@ -1,86 +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_NEREMAPKERNEL_H -#define ARM_COMPUTE_NEREMAPKERNEL_H - -#include "arm_compute/core/Types.h" -#include "src/core/NEON/INEKernel.h" - -namespace arm_compute -{ -class ITensor; - -/** Kernel to perform a remap on a tensor */ -class NERemapKernel : public INEKernel -{ -public: - const char *name() const override - { - return "NERemapKernel"; - } - /** Default constructor */ - NERemapKernel(); - /** Prevent instances of this class from being copied (As this class contains pointers) */ - NERemapKernel(const NERemapKernel &) = delete; - /** Prevent instances of this class from being copied (As this class contains pointers) */ - NERemapKernel &operator=(const NERemapKernel &) = delete; - /** Allow instances of this class to be moved */ - NERemapKernel(NERemapKernel &&) = default; - /** Allow instances of this class to be moved */ - NERemapKernel &operator=(NERemapKernel &&) = default; - /** Default destructor */ - ~NERemapKernel() = default; - - /** Initialize the kernel's input, output and border mode. - * - * @param[in] input Source tensor. Data type supported: U8. - * @param[in] map_x Map for X coordinates. Data type supported: F32. - * @param[in] map_y Map for Y coordinates. Data type supported: F32. - * @param[out] output Destination tensor. Data types supported: U8. All but the lowest two dimensions must be the same size as in the input tensor, i.e. remapping is only performed within the XY-plane. - * @param[in] policy The interpolation type. - * @param[in] border_mode Border mode to use on the input tensor. - * @param[in] constant_border_value (Optional) Constant value to use for borders if border_mode is set to CONSTANT. Defaults to 0. - */ - void configure(const ITensor *input, const ITensor *map_x, const ITensor *map_y, ITensor *output, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value = 0); - - // Inherited methods overridden: - void run(const Window &window, const ThreadInfo &info) override; - -private: - /** function to perform nearest interpolation on the given window */ - void remap_nearest(const Window &window); - /** function to perform bilinear interpolation on the given window */ - void remap_bilinear(const Window &window); - /** Remap function to use for the particular interpolation type passed to configure() */ - void (NERemapKernel::*_func)(const Window &window); - - const ITensor *_input; /**< Input image */ - ITensor *_output; /**< Output image */ - const ITensor *_map_x; /**< Input remap x coordinates */ - const ITensor *_map_y; /**< Input remap y coordinates */ - BorderMode _border_mode; /**< Border mode */ - uint8_t _constant_border_value; /**< Border value to use */ -}; -} // namespace arm_compute -#endif /*ARM_COMPUTE_NEREMAPKERNEL_H */ \ No newline at end of file diff --git a/src/gpu/cl/ClKernelLibrary.cpp b/src/gpu/cl/ClKernelLibrary.cpp index 2c43a20908..bab5342168 100644 --- a/src/gpu/cl/ClKernelLibrary.cpp +++ b/src/gpu/cl/ClKernelLibrary.cpp @@ -378,8 +378,6 @@ const std::map ClKernelLibrary::_kernel_program_map = { "pooling_layer_MxN_nchw", "nchw/pooling_layer.cl" }, { "pooling_layer_2_nchw_indices", "nchw/pooling_layer.cl" }, { "prior_box_layer_nchw", "nchw/prior_box_layer.cl" }, - { "remap_nearest_neighbour_nchw", "nchw/remap.cl" }, - { "remap_bilinear_nchw", "nchw/remap.cl" }, { "reorg_layer_nchw", "nchw/reorg_layer.cl" }, { "scale_nearest_neighbour_nchw", "nchw/scale.cl" }, { "scale_bilinear_nchw", "nchw/scale.cl" }, @@ -439,8 +437,6 @@ const std::map ClKernelLibrary::_kernel_program_map = { "pooling_layer_MxN_nhwc", "nhwc/pooling_layer.cl" }, { "pooling_layer_2x2_nhwc", "nhwc/pooling_layer.cl" }, { "pooling_layer_MxN_quantized_nhwc", "nhwc/pooling_layer_quantized.cl" }, - { "remap_nearest_neighbour_nhwc", "nhwc/remap.cl" }, - { "remap_bilinear_nhwc", "nhwc/remap.cl" }, { "reorg_layer_nhwc", "nhwc/reorg_layer.cl" }, { "scale_nearest_neighbour_nhwc", "nhwc/scale.cl" }, { "scale_bilinear_nhwc", "nhwc/scale.cl" }, @@ -793,10 +789,6 @@ const std::map ClKernelLibrary::_program_source_map = { "nchw/prior_box_layer.cl", #include "./cl_kernels/nchw/prior_box_layer.clembed" - }, - { - "nchw/remap.cl", -#include "./cl_kernels/nchw/remap.clembed" }, { "nchw/reorg_layer.cl", @@ -892,10 +884,6 @@ const std::map ClKernelLibrary::_program_source_map = { "nhwc/pooling_layer_quantized.cl", #include "./cl_kernels/nhwc/pooling_layer_quantized.clembed" - }, - { - "nhwc/remap.cl", -#include "./cl_kernels/nhwc/remap.clembed" }, { "nhwc/reorg_layer.cl", diff --git a/src/runtime/CL/functions/CLRemap.cpp b/src/runtime/CL/functions/CLRemap.cpp deleted file mode 100644 index b9c62d8487..0000000000 --- a/src/runtime/CL/functions/CLRemap.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2017-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. - */ - -#include "arm_compute/runtime/CL/functions/CLRemap.h" -#include "arm_compute/core/CL/ICLTensor.h" -#include "arm_compute/core/Error.h" -#include "arm_compute/core/TensorInfo.h" -#include "arm_compute/core/Validate.h" -#include "src/core/CL/kernels/CLFillBorderKernel.h" -#include "src/core/CL/kernels/CLRemapKernel.h" - -#include "src/common/utils/Log.h" - -namespace arm_compute -{ -void CLRemap::configure(const CLCompileContext &compile_context, ICLTensor *input, const ICLTensor *map_x, const ICLTensor *map_y, ICLTensor *output, InterpolationPolicy policy, - BorderMode border_mode, uint8_t constant_border_value) -{ - configure(compile_context, input, map_x, map_y, output, policy, border_mode, PixelValue{ constant_border_value }); -} - -void CLRemap::configure(ICLTensor *input, const ICLTensor *map_x, const ICLTensor *map_y, ICLTensor *output, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, map_x, map_y, output, policy, border_mode, PixelValue{ constant_border_value }); -} - -void CLRemap::configure(ICLTensor *input, const ICLTensor *map_x, const ICLTensor *map_y, ICLTensor *output, InterpolationPolicy policy, BorderMode border_mode, PixelValue constant_border_value) -{ - configure(CLKernelLibrary::get().get_compile_context(), input, map_x, map_y, output, policy, border_mode, constant_border_value); -} - -void CLRemap::configure(const CLCompileContext &compile_context, ICLTensor *input, const ICLTensor *map_x, const ICLTensor *map_y, ICLTensor *output, InterpolationPolicy policy, - BorderMode border_mode, PixelValue constant_border_value) -{ - ARM_COMPUTE_LOG_PARAMS(input, map_x, map_y, output, policy, border_mode, constant_border_value); - auto k = std::make_unique(); - k->configure(compile_context, input, map_x, map_y, output, RemapInfo{ policy, border_mode, constant_border_value }); - _kernel = std::move(k); - _border_handler->configure(compile_context, input, _kernel->border_size(), border_mode, constant_border_value); -} - -Status CLRemap::validate(const ITensorInfo *input, const ITensorInfo *map_x, const ITensorInfo *map_y, const ITensorInfo *output, const InterpolationPolicy policy, const BorderMode border_mode, - PixelValue constant_border_value) -{ - return CLRemapKernel::validate(input, map_x, map_y, output, RemapInfo{ policy, border_mode, constant_border_value }); -} -} // namespace arm_compute diff --git a/src/runtime/NEON/functions/NERemap.cpp b/src/runtime/NEON/functions/NERemap.cpp deleted file mode 100644 index 154479aede..0000000000 --- a/src/runtime/NEON/functions/NERemap.cpp +++ /dev/null @@ -1,55 +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. - */ -#include "arm_compute/runtime/NEON/functions/NERemap.h" - -#include "arm_compute/core/Error.h" -#include "arm_compute/core/ITensor.h" -#include "arm_compute/core/TensorInfo.h" -#include "arm_compute/core/Validate.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "src/common/utils/Log.h" -#include "src/core/NEON/kernels/NERemapKernel.h" - -#include - -namespace arm_compute -{ -void NERemap::configure(ITensor *input, const ITensor *map_x, const ITensor *map_y, ITensor *output, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value) -{ - configure(input, map_x, map_y, output, policy, border_mode, PixelValue{ constant_border_value }); -} -void NERemap::configure(ITensor *input, const ITensor *map_x, const ITensor *map_y, ITensor *output, InterpolationPolicy policy, BorderMode border_mode, PixelValue constant_border_value) -{ - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8); - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(output, 1, DataType::U8); - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(map_x, 1, DataType::F32); - ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(map_y, 1, DataType::F32); - ARM_COMPUTE_ERROR_ON_MSG(policy == InterpolationPolicy::AREA, "Area interpolation is not supported"); - ARM_COMPUTE_LOG_PARAMS(input, map_x, map_y, output, policy, border_mode, constant_border_value); - - auto k = std::make_unique(); - k->configure(input, map_x, map_y, output, policy, border_mode, constant_border_value.get()); - _kernel = std::move(k); -} -} // namespace arm_compute diff --git a/tests/validation/CL/Remap.cpp b/tests/validation/CL/Remap.cpp deleted file mode 100644 index 7849d77394..0000000000 --- a/tests/validation/CL/Remap.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (c) 2017-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. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/functions/CLRemap.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets/BorderModeDataset.h" -#include "tests/datasets/ShapeDatasets.h" -#include "tests/framework/Asserts.h" -#include "tests/framework/Macros.h" -#include "tests/framework/datasets/Datasets.h" -#include "tests/validation/Validation.h" -#include "tests/validation/fixtures/RemapFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -constexpr AbsoluteTolerance tolerance_value(1); -} // namespace - -TEST_SUITE(CL) -TEST_SUITE(Remap) - -// *INDENT-OFF* -// clang-format off - -DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip( - framework::dataset::make("input", { TensorInfo(TensorShape(10U, 10U), 1, DataType::U8, DataLayout::NCHW), - TensorInfo(TensorShape(10U, 10U), 1, DataType::U8, DataLayout::NHWC), - TensorInfo(TensorShape(10U, 10U), 1, DataType::F16, DataLayout::NCHW), - TensorInfo(TensorShape(10U, 10U), 1, DataType::F16, DataLayout::NHWC) - }), - framework::dataset::make("map_x", { TensorInfo(TensorShape(10U, 10U), 1, DataType::F32, DataLayout::NCHW), - TensorInfo(TensorShape(10U, 10U), 1, DataType::F32, DataLayout::NHWC), - TensorInfo(TensorShape(10U, 10U), 1, DataType::F32, DataLayout::NCHW), - TensorInfo(TensorShape(10U, 10U), 1, DataType::F32, DataLayout::NHWC) - - })), - framework::dataset::make("map_y", { TensorInfo(TensorShape(10U, 10U), 1, DataType::F32, DataLayout::NCHW), - TensorInfo(TensorShape(10U, 10U), 1, DataType::F32, DataLayout::NHWC), - TensorInfo(TensorShape(10U, 10U), 1, DataType::F32, DataLayout::NCHW), - TensorInfo(TensorShape(10U, 10U), 1, DataType::F32, DataLayout::NHWC) - })), - framework::dataset::make("output", { TensorInfo(TensorShape(10U, 10U), 1, DataType::U8, DataLayout::NCHW), - TensorInfo(TensorShape(10U, 10U), 1, DataType::U8, DataLayout::NHWC), - TensorInfo(TensorShape(10U, 10U), 1, DataType::F16, DataLayout::NCHW), - TensorInfo(TensorShape(10U, 10U), 1, DataType::F16, DataLayout::NHWC) - })), - framework::dataset::make("policy",{ InterpolationPolicy::NEAREST_NEIGHBOR, - InterpolationPolicy::NEAREST_NEIGHBOR, - InterpolationPolicy::NEAREST_NEIGHBOR, - InterpolationPolicy::NEAREST_NEIGHBOR - })), - framework::dataset::make("border_mode",{ BorderMode::CONSTANT, - BorderMode::CONSTANT, - BorderMode::CONSTANT, - BorderMode::CONSTANT - })), - framework::dataset::make("Expected", { true, // NCHW, U8 - true, // NHWC, U8 - false, // NCHW, F16 - true // NHWC, F16 - })), - input, map_x, map_y, output, policy, border_mode, expected) -{ - ARM_COMPUTE_EXPECT(bool(CLRemap::validate(&input, &map_x, &map_y, &output, policy, border_mode, PixelValue{})) == expected, framework::LogLevel::ERRORS); -} -// clang-format on -// *INDENT-ON* -template -using CLRemapFixture = RemapValidationFixture; -template -using CLRemapLayoutFixture = RemapValidationMixedLayoutFixture; - -TEST_SUITE(U8) -FIXTURE_DATA_TEST_CASE(RunSmall, CLRemapLayoutFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(datasets::SmallShapes(), - framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), - framework::dataset::make("DataType", DataType::U8)), - framework::dataset::make("BorderModes", { BorderMode::UNDEFINED, BorderMode::CONSTANT })), - framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) -{ - // Validate output - validate(CLAccessor(_target), _reference, _valid_mask, tolerance_value); -} - -FIXTURE_DATA_TEST_CASE(RunLarge, CLRemapFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), - framework::dataset::make("DataType", DataType::U8)), - framework::dataset::make("BorderModes", { BorderMode::UNDEFINED, BorderMode::CONSTANT }))) -{ - // Validate output - validate(CLAccessor(_target), _reference, _valid_mask, tolerance_value); -} -TEST_SUITE_END() // U8 - -TEST_SUITE(F16) -FIXTURE_DATA_TEST_CASE(RunSmall, CLRemapLayoutFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(datasets::SmallShapes(), - framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), - framework::dataset::make("DataType", DataType::F16)), - framework::dataset::make("BorderModes", { BorderMode::UNDEFINED, BorderMode::CONSTANT })), - framework::dataset::make("DataLayout", DataLayout::NHWC))) -{ - // Validate output - validate(CLAccessor(_target), _reference, _valid_mask, tolerance_value); -} -TEST_SUITE_END() // F16 -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/NEON/Remap.cpp b/tests/validation/NEON/Remap.cpp deleted file mode 100644 index 3c02f8eece..0000000000 --- a/tests/validation/NEON/Remap.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2017-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. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NERemap.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets/BorderModeDataset.h" -#include "tests/datasets/ShapeDatasets.h" -#include "tests/framework/Asserts.h" -#include "tests/framework/Macros.h" -#include "tests/framework/datasets/Datasets.h" -#include "tests/validation/Validation.h" -#include "tests/validation/fixtures/RemapFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -constexpr AbsoluteTolerance tolerance_value(0); -constexpr float tolerance_number = 0.f; -} // namespace - -TEST_SUITE(NEON) -TEST_SUITE(Remap) - -template -using NERemapFixture = RemapValidationFixture; - -FIXTURE_DATA_TEST_CASE(RunSmall, NERemapFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), - framework::dataset::make("DataType", - DataType::U8)), - framework::dataset::make("BorderModes", { BorderMode::UNDEFINED, BorderMode::CONSTANT }))) -{ - // Validate output - validate(Accessor(_target), _reference, _valid_mask, tolerance_value, tolerance_number); -} - -FIXTURE_DATA_TEST_CASE(RunLarge, NERemapFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), - framework::dataset::make("DataType", - DataType::U8)), - framework::dataset::make("BorderModes", { BorderMode::UNDEFINED, BorderMode::CONSTANT }))) -{ - // Validate output - validate(Accessor(_target), _reference, _valid_mask, tolerance_value, tolerance_number); -} -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/fixtures/RemapFixture.h b/tests/validation/fixtures/RemapFixture.h deleted file mode 100644 index 03cb6aef42..0000000000 --- a/tests/validation/fixtures/RemapFixture.h +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright (c) 2017-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_TEST_REMAP_FIXTURE -#define ARM_COMPUTE_TEST_REMAP_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/framework/Asserts.h" -#include "tests/framework/Fixture.h" -#include "tests/validation/reference/Remap.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class RemapValidationGenericFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, InterpolationPolicy policy, DataType data_type, BorderMode border_mode, DataLayout data_layout = DataLayout::NCHW) - { - std::mt19937 gen(library->seed()); - std::uniform_int_distribution distribution(0, 255); - PixelValue constant_border_value{ static_cast(distribution(gen)) }; - - _data_layout = data_layout; - _target = compute_target(shape, policy, data_type, border_mode, constant_border_value); - _reference = compute_reference(shape, policy, data_type, border_mode, constant_border_value); - } - -protected: - template - void fill(U &&tensor, int i, int min, int max) - { - switch(tensor.data_type()) - { - case DataType::F32: - { - // map_x,y as integer values - std::uniform_int_distribution distribution(min, max); - library->fill(tensor, distribution, i); - break; - } - case DataType::F16: - { - arm_compute::utils::uniform_real_distribution_16bit distribution(static_cast(min), static_cast(max)); - library->fill(tensor, distribution, i); - break; - } - case DataType::U8: - { - std::uniform_int_distribution distribution(min, max); - library->fill(tensor, distribution, i); - break; - } - default: - ARM_COMPUTE_ERROR("DataType for Remap not supported"); - } - } - - TensorType compute_target(TensorShape shape, InterpolationPolicy policy, DataType data_type, BorderMode border_mode, PixelValue constant_border_value) - { - if(_data_layout == DataLayout::NHWC) - { - permute(shape, PermutationVector(2U, 0U, 1U)); - } - - // Create tensors - TensorType src = create_tensor(shape, data_type, 1, QuantizationInfo(), _data_layout); - TensorType map_x = create_tensor(shape, DataType::F32, 1, QuantizationInfo(), _data_layout); - TensorType map_y = create_tensor(shape, DataType::F32, 1, QuantizationInfo(), _data_layout); - TensorType dst = create_tensor(shape, data_type, 1, QuantizationInfo(), _data_layout); - - // Create and configure function - FunctionType remap; - remap.configure(&src, &map_x, &map_y, &dst, policy, border_mode, constant_border_value); - - ARM_COMPUTE_ASSERT(src.info()->is_resizable()); - ARM_COMPUTE_ASSERT(map_x.info()->is_resizable()); - ARM_COMPUTE_ASSERT(map_y.info()->is_resizable()); - ARM_COMPUTE_ASSERT(dst.info()->is_resizable()); - - // Allocate tensors - src.allocator()->allocate(); - map_x.allocator()->allocate(); - map_y.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_ASSERT(!src.info()->is_resizable()); - ARM_COMPUTE_ASSERT(!map_x.info()->is_resizable()); - ARM_COMPUTE_ASSERT(!map_y.info()->is_resizable()); - ARM_COMPUTE_ASSERT(!dst.info()->is_resizable()); - - // Fill tensors - int max_val = std::max({ shape.x(), shape.y(), shape.z() }); - - fill(AccessorType(src), 0, 0, 255); - fill(AccessorType(map_x), 1, -5, max_val); - fill(AccessorType(map_y), 2, -5, max_val); - - // Compute function - remap.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape shape, InterpolationPolicy policy, DataType data_type, BorderMode border_mode, PixelValue constant_border_value) - { - ARM_COMPUTE_ERROR_ON(data_type != DataType::U8 && data_type != DataType::F16); - - // Create reference - SimpleTensor src{ shape, data_type }; - SimpleTensor map_x{ shape, DataType::F32 }; - SimpleTensor map_y{ shape, DataType::F32 }; - T border_value{}; - constant_border_value.get(border_value); - - // Create the valid mask Tensor - _valid_mask = SimpleTensor { shape, data_type }; - - // Fill reference - int max_val = std::max({ shape.x(), shape.y(), shape.z() }); - - fill(src, 0, 0, 255); - fill(map_x, 1, -5, max_val); - fill(map_y, 2, -5, max_val); - - // Compute reference - return reference::remap(src, map_x, map_y, _valid_mask, policy, border_mode, border_value); - } - - TensorType _target{}; - SimpleTensor _reference{}; - SimpleTensor _valid_mask{}; - DataLayout _data_layout{}; -}; - -template -class RemapValidationFixture : public RemapValidationGenericFixture -{ -public: - template - void setup(TensorShape shape, InterpolationPolicy policy, DataType data_type, BorderMode border_mode) - { - RemapValidationGenericFixture::setup(shape, policy, data_type, border_mode); - } -}; - -template -class RemapValidationMixedLayoutFixture : public RemapValidationGenericFixture -{ -public: - template - void setup(TensorShape shape, InterpolationPolicy policy, DataType data_type, BorderMode border_mode, DataLayout data_layout) - { - RemapValidationGenericFixture::setup(shape, policy, data_type, border_mode, data_layout); - } -}; - -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_REMAP_FIXTURE */ diff --git a/tests/validation/reference/Remap.cpp b/tests/validation/reference/Remap.cpp deleted file mode 100644 index dfbe1aa12b..0000000000 --- a/tests/validation/reference/Remap.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2017-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. - */ -#include "Remap.h" - -#include "Utils.h" -#include "tests/validation/Helpers.h" - -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor remap(const SimpleTensor &in, SimpleTensor &map_x, SimpleTensor &map_y, SimpleTensor &valid_mask, InterpolationPolicy policy, BorderMode border_mode, - T constant_border_value) -{ - ARM_COMPUTE_ERROR_ON_MSG(border_mode == BorderMode::REPLICATE, "BorderMode not supported"); - SimpleTensor out(in.shape(), in.data_type()); - ARM_COMPUTE_ERROR_ON(out.num_elements() != map_x.num_elements()); - const int width = in.shape().x(); - const int height = in.shape().y(); - const uint32_t num_elements = out.num_elements(); - for(uint32_t idx = 0; idx < num_elements; idx++) - { - const Coordinates id_out = index2coord(out.shape(), idx); - valid_mask[idx] = 1; - Coordinates src_idx = id_out; // need to setup all coordinates and not just xy - if((0 <= map_y[idx]) && (map_y[idx] < height) && (0 <= map_x[idx]) && (map_x[idx] < width)) - { - switch(policy) - { - case InterpolationPolicy::NEAREST_NEIGHBOR: - { - src_idx.set(0, static_cast(std::floor(map_x[idx]))); - src_idx.set(1, static_cast(std::floor(map_y[idx]))); - out[idx] = in[coord2index(in.shape(), src_idx)]; - break; - } - case InterpolationPolicy::BILINEAR: - { - (valid_bilinear_policy(map_x[idx], map_y[idx], width, height, border_mode)) ? - out[idx] = bilinear_policy(in, src_idx, map_x[idx], map_y[idx], border_mode, constant_border_value) : - valid_mask[idx] = 0; - break; - } - case InterpolationPolicy::AREA: - default: - ARM_COMPUTE_ERROR("Interpolation not supported"); - break; - } - } - else - { - if(border_mode == BorderMode::UNDEFINED) - { - valid_mask[idx] = 0; - } - else - { - switch(policy) - { - case InterpolationPolicy::NEAREST_NEIGHBOR: - out[idx] = constant_border_value; - break; - case InterpolationPolicy::BILINEAR: - out[idx] = bilinear_policy(in, src_idx, map_x[idx], map_y[idx], border_mode, constant_border_value); - break; - case InterpolationPolicy::AREA: - default: - break; - } - } - } - } - return out; -} - -template SimpleTensor remap(const SimpleTensor &src, SimpleTensor &map_x, SimpleTensor &map_y, SimpleTensor &valid_mask, InterpolationPolicy policy, - BorderMode border_mode, - uint8_t constant_border_value); - -template SimpleTensor remap(const SimpleTensor &src, SimpleTensor &map_x, SimpleTensor &map_y, SimpleTensor &valid_mask, InterpolationPolicy policy, - BorderMode border_mode, - half constant_border_value); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/reference/Remap.h b/tests/validation/reference/Remap.h deleted file mode 100644 index 0726f75965..0000000000 --- a/tests/validation/reference/Remap.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_REMAP_H -#define ARM_COMPUTE_TEST_REMAP_H - -#include "tests/SimpleTensor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor remap(const SimpleTensor &in, SimpleTensor &map_x, SimpleTensor &map_y, SimpleTensor &valid_mask, InterpolationPolicy policy, BorderMode border_mode, - T constant_border_value = 0); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_REMAP_H */ -- cgit v1.2.1