aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichele Di Giorgio <michele.digiorgio@arm.com>2020-06-01 13:39:52 +0100
committerMichele Di Giorgio <michele.digiorgio@arm.com>2020-06-02 14:29:06 +0000
commit7d6b5772c8854a470a08b3415eda1ceca531601d (patch)
tree7732a0079c3feaa50f2c84928cef16eca299d47f
parent1710133b05a9ed1fcc1cc68624c2ce0e09eae495 (diff)
downloadComputeLibrary-7d6b5772c8854a470a08b3415eda1ceca531601d.tar.gz
COMPMID-3365: Add support for U8 datatype to CropResize on CL
Change-Id: I5164db1fa4cef003875647ed01879c5dbdfb9b35 Signed-off-by: Michele Di Giorgio <michele.digiorgio@arm.com> Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/3286 Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
-rw-r--r--arm_compute/core/CL/kernels/CLCropKernel.h6
-rw-r--r--arm_compute/runtime/CL/functions/CLCropResize.h6
-rw-r--r--src/core/CL/cl_kernels/crop_tensor.cl6
-rw-r--r--src/core/CL/kernels/CLCropKernel.cpp2
-rw-r--r--tests/validation/CL/CropResize.cpp21
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 = CropResizeFixture<CLTensor, CLAccessor, CLCropResize
// clang-format off
DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(
framework::dataset::make("InputInfo", { TensorInfo(TensorShape(15U, 30U, 40U, 10U), 1, DataType::S32),
- TensorInfo(TensorShape(15U, 30U, 40U, 10U), 1, DataType::U8), // Invalid input data type.
TensorInfo(TensorShape(15U, 30U, 40U, 10U), 1, DataType::S32), // Invalid box_ind shape.
TensorInfo(TensorShape(15U, 30U, 40U, 10U), 1, DataType::S32), // Invalid output shape.
TensorInfo(TensorShape(15U, 30U, 40U, 10U), 1, DataType::S32), // Invalid output data type.
@@ -64,11 +63,9 @@ DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(
TensorInfo(TensorShape(4, 20), 1, DataType::F32),
TensorInfo(TensorShape(4, 20), 1, DataType::F32),
TensorInfo(TensorShape(4, 20), 1, DataType::F32),
- TensorInfo(TensorShape(4, 20), 1, DataType::F32),
TensorInfo(TensorShape(3, 20), 1, DataType::F32),
})),
framework::dataset::make("BoxIndInfo",{ TensorInfo(TensorShape(20), 1, DataType::S32),
- TensorInfo(TensorShape(20), 1, DataType::S32),
TensorInfo(TensorShape(10), 1, DataType::S32),
TensorInfo(TensorShape(20), 1, DataType::S32),
TensorInfo(TensorShape(20), 1, DataType::S32),
@@ -77,13 +74,12 @@ DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(
})),
framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(15U, 5, 5, 20U), 1, DataType::F32),
TensorInfo(TensorShape(15U, 5, 5, 20U), 1, DataType::F32),
- TensorInfo(TensorShape(15U, 5, 5, 20U), 1, DataType::F32),
TensorInfo(TensorShape(15U, 5, 5, 10U), 1, DataType::F32),
TensorInfo(TensorShape(15U, 5, 5, 20U), 1, DataType::S32),
TensorInfo(TensorShape(5U, 5, 5, 20U), 1, DataType::F32),
TensorInfo(TensorShape(15U, 5, 5, 20U), 1, DataType::F32),
})),
- framework::dataset::make("Expected", { true, false, false, false, false, false, false})),
+ framework::dataset::make("Expected", { true, false, false, false, false, false})),
input, boxes, box_ind, output, expected)
{
ARM_COMPUTE_EXPECT(bool(CLCropResize::validate(&input.clone()->set_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<uint8_t>,
+ 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<uint16_t>,