From 7d6b5772c8854a470a08b3415eda1ceca531601d Mon Sep 17 00:00:00 2001 From: Michele Di Giorgio Date: Mon, 1 Jun 2020 13:39:52 +0100 Subject: COMPMID-3365: Add support for U8 datatype to CropResize on CL Change-Id: I5164db1fa4cef003875647ed01879c5dbdfb9b35 Signed-off-by: Michele Di Giorgio Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/3286 Tested-by: Arm Jenkins Reviewed-by: Georgios Pinitas Comments-Addressed: Arm Jenkins --- arm_compute/core/CL/kernels/CLCropKernel.h | 6 +++--- arm_compute/runtime/CL/functions/CLCropResize.h | 6 +++--- src/core/CL/cl_kernels/crop_tensor.cl | 6 +++--- src/core/CL/kernels/CLCropKernel.cpp | 2 +- tests/validation/CL/CropResize.cpp | 21 +++++++++++++++------ 5 files changed, 25 insertions(+), 16 deletions(-) diff --git a/arm_compute/core/CL/kernels/CLCropKernel.h b/arm_compute/core/CL/kernels/CLCropKernel.h index a1c6f901eb..cbc2338940 100644 --- a/arm_compute/core/CL/kernels/CLCropKernel.h +++ b/arm_compute/core/CL/kernels/CLCropKernel.h @@ -49,7 +49,7 @@ public: * * @note Supported tensor rank: up to 4 * - * @param[in] input Source tensor. Data type supported: U16/S16/U32/S32/F16/F32. Data layouts supported: NHWC. + * @param[in] input Source tensor. Data type supported: All. Data layouts supported: NHWC. * @param[out] output Destination tensor. Data type supported: F32 * @param[in] start Coordinates of where to start cropping the image. * @param[in] end Coordinates of where to end cropping the image. @@ -63,7 +63,7 @@ public: * @note Supported tensor rank: up to 4 * * @param[in] compile_context The compile context to be used. - * @param[in] input Source tensor. Data type supported: U16/S16/U32/S32/F16/F32. Data layouts supported: NHWC. + * @param[in] input Source tensor. Data type supported: All. Data layouts supported: NHWC. * @param[out] output Destination tensor. Data type supported: F32 * @param[in] start Coordinates of where to start cropping the image. * @param[in] end Coordinates of where to end cropping the image. @@ -78,7 +78,7 @@ public: * * @note Supported tensor rank: up to 4 * - * @param[in] input Source tensor info. Data type supported: U16/S16/U32/S32/F16/F32. Data layouts supported: NHWC. + * @param[in] input Source tensor info. Data type supported: All. Data layouts supported: NHWC. * @param[in] output Destination tensor info. Data type supported: F32 * @param[in] start Coordinates of where to start cropping the image. * @param[in] end Coordinates of where to end cropping the image. diff --git a/arm_compute/runtime/CL/functions/CLCropResize.h b/arm_compute/runtime/CL/functions/CLCropResize.h index 86df0d46d1..ea50fe51c7 100644 --- a/arm_compute/runtime/CL/functions/CLCropResize.h +++ b/arm_compute/runtime/CL/functions/CLCropResize.h @@ -62,7 +62,7 @@ public: * @note Box indices may be outside of the bounds, in which case @p extrapolation_value is used. * @note Start and end indices of boxes are inclusive. * - * @param[in] input Source tensor containing N batches of 3D images to be cropped. Data type supported: : U16/S16/U32/S32/F16/F32 + * @param[in] input Source tensor containing N batches of 3D images to be cropped. Data type supported: All * @param[in] boxes Tensor containing the boxes used to crop the images. It has to be known before configuration. Data type supported: F32 * @param[in] box_ind One dimensional tensor containing the batch index of the 3D image in @p input that the corresponding * box in @p boxes will be applied to. It has to be known before configuration. Data type supported: F32 @@ -80,7 +80,7 @@ public: * @note Start and end indices of boxes are inclusive. * * @param[in] compile_context The compile context to be used. - * @param[in] input Source tensor containing N batches of 3D images to be cropped. Data type supported: U16/S16/U32/S32/F16/F32 + * @param[in] input Source tensor containing N batches of 3D images to be cropped. Data type supported: All * @param[in] boxes Tensor containing the boxes used to crop the images. It has to be known before configuration. Data type supported: F32 * @param[in] box_ind One dimensional tensor containing the batch index of the 3D image in @p input that the corresponding * box in @p boxes will be applied to. It has to be known before configuration. Data type supported: F32 @@ -98,7 +98,7 @@ public: * @note Box indices may be outside of the bounds, in which case @p extrapolation_value is used. * @note Start and end indices of boxes are inclusive. * - * @param[in] input Source tensor info containing N batches of 3D images to be cropped. Data type supported: U16/S16/U32/S32/F16/F32 + * @param[in] input Source tensor info containing N batches of 3D images to be cropped. Data type supported: All * @param[in] boxes Tensor info for the tensor containing the boxes used to crop the images. Data type supported: F32 * @param[in] box_ind Tensor info for the one dimensional tensor containing the batch index of the 3D image in @p input * that the corresponding box in @p boxes will be applied to. Data type supported: F32 diff --git a/src/core/CL/cl_kernels/crop_tensor.cl b/src/core/CL/cl_kernels/crop_tensor.cl index 55f8544a10..efc3eabc82 100644 --- a/src/core/CL/cl_kernels/crop_tensor.cl +++ b/src/core/CL/cl_kernels/crop_tensor.cl @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 ARM Limited. + * Copyright (c) 2019-2020 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -27,7 +27,7 @@ /** Performs a copy of input tensor to the output tensor. * - * @param[in] in_ptr Pointer to the source tensor. Supported data types: U16/S16/F16/U32/S32/F32 + * @param[in] in_ptr Pointer to the source tensor. Supported data types: All * @param[in] in_stride_x Stride of the source tensor in X dimension (in bytes) * @param[in] in_step_x input_stride_x * number of elements along X processed per workitem(in bytes) * @param[in] in_stride_y Stride of the source tensor in Y dimension (in bytes) @@ -35,7 +35,7 @@ * @param[in] in_stride_z Stride of the source tensor in Z dimension (in bytes) * @param[in] in_step_z input_stride_z * number of elements along Z processed per workitem(in bytes) * @param[in] in_offset_first_element_in_bytes The offset of the first element in the source tensor - * @param[out] out_ptr Pointer to the destination tensor. Supported data types: same as @p in_ptr + * @param[out] out_ptr Pointer to the destination tensor. Supported data types: F32 * @param[in] out_stride_x Stride of the destination tensor in X dimension (in bytes) * @param[in] out_step_x output_stride_x * number of elements along X processed per workitem(in bytes) * @param[in] out_stride_y Stride of the destination tensor in Y dimension (in bytes) diff --git a/src/core/CL/kernels/CLCropKernel.cpp b/src/core/CL/kernels/CLCropKernel.cpp index eb1ab7aebb..29a97bbfa4 100644 --- a/src/core/CL/kernels/CLCropKernel.cpp +++ b/src/core/CL/kernels/CLCropKernel.cpp @@ -99,7 +99,7 @@ Status CLCropKernel::validate(const ITensorInfo *input, const ITensorInfo *outpu { ARM_COMPUTE_UNUSED(extrapolation_value, output_window); ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(input); - ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U16, DataType::S16, DataType::F16, DataType::U32, DataType::S32, DataType::F32); + ARM_COMPUTE_RETURN_ERROR_ON(input->data_type() == DataType::UNKNOWN); ARM_COMPUTE_RETURN_ERROR_ON_DATA_LAYOUT_NOT_IN(input, DataLayout::NHWC); ARM_COMPUTE_RETURN_ERROR_ON(input->tensor_shape().num_dimensions() > 4); ARM_COMPUTE_RETURN_ERROR_ON(start.x < 0 || start.y < 0 || end.x < 0 || end.y < 0); diff --git a/tests/validation/CL/CropResize.cpp b/tests/validation/CL/CropResize.cpp index cacf405c96..379597ee67 100644 --- a/tests/validation/CL/CropResize.cpp +++ b/tests/validation/CL/CropResize.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 ARM Limited. + * Copyright (c) 2019-2020 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -52,7 +52,6 @@ using CLCropResizeFixture = CropResizeFixtureset_data_layout(DataLayout::NHWC).set_is_resizable(false), @@ -125,6 +121,19 @@ FIXTURE_DATA_TEST_CASE(RunSmall, TEST_SUITE_END() // F32 TEST_SUITE_END() // Float +TEST_SUITE(U8) +FIXTURE_DATA_TEST_CASE(RunSmall, + CLCropResizeFixture, + framework::DatasetMode::PRECOMMIT, + combine(datasets::SmallCropResizeDataset(), + combine(framework::dataset::make("IsOutOfBounds", { true, false }), + framework::dataset::make("DataType", DataType::U8)))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_fp32, 0.01); +} +TEST_SUITE_END() // U8 + TEST_SUITE(U16) FIXTURE_DATA_TEST_CASE(RunSmall, CLCropResizeFixture, -- cgit v1.2.1