aboutsummaryrefslogtreecommitdiff
path: root/src/core/CL/cl_kernels/pooling_layer.cl
diff options
context:
space:
mode:
authorGeorgios Pinitas <georgios.pinitas@arm.com>2018-10-29 20:07:15 +0000
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:55:45 +0000
commit89d71731d8922bc302ac57046126cdaedcf6e96b (patch)
tree7ab9d6b3eea59b49f992dc84fa960aa2926ddc2c /src/core/CL/cl_kernels/pooling_layer.cl
parentf718ce255508f74729bab40fe30c5dab0f3a978b (diff)
downloadComputeLibrary-89d71731d8922bc302ac57046126cdaedcf6e96b.tar.gz
COMPMID-1704: Collapse the 4th dimension in CLPoolingLayerKernel
Change-Id: I76e57af6608b55b6f59a5d06aecc30063ee4c3cc Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/155733 Tested-by: bsgcomp <bsgcomp@arm.com> Reviewed-by: Michele DiGiorgio <michele.digiorgio@arm.com> Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Diffstat (limited to 'src/core/CL/cl_kernels/pooling_layer.cl')
-rw-r--r--src/core/CL/cl_kernels/pooling_layer.cl39
1 files changed, 31 insertions, 8 deletions
diff --git a/src/core/CL/cl_kernels/pooling_layer.cl b/src/core/CL/cl_kernels/pooling_layer.cl
index 080835348d..7d15d100e9 100644
--- a/src/core/CL/cl_kernels/pooling_layer.cl
+++ b/src/core/CL/cl_kernels/pooling_layer.cl
@@ -489,7 +489,11 @@ DATA_TYPE calculate_avg_scale_nhwc(const int pool_size_x, const int pool_size_y,
const int pad_x, const int pad_y, const int stride_x, const int stride_y)
{
int start_x = get_global_id(1) * stride_x - pad_x;
+#if defined(DST_DEPTH)
+ int start_y = (get_global_id(2) % DST_DEPTH) * stride_y - pad_y;
+#else /* defined(DST_DEPTH) */
int start_y = get_global_id(2) * stride_y - pad_y;
+#endif /* defined(DST_DEPTH) */
#if !defined(EXCLUDE_PADDING)
upper_bound_w += pad_x;
@@ -522,30 +526,43 @@ DATA_TYPE calculate_avg_scale_nhwc(const int pool_size_x, const int pool_size_y,
* @param[in] input_step_y input_stride_y * number of elements along Y processed per workitem(in bytes)
* @param[in] input_stride_z Stride of the source tensor in Z dimension (in bytes)
* @param[in] input_step_z input_stride_z * number of elements along Z processed per workitem(in bytes)
+ * @param[in] input_stride_w Stride of the source tensor in W dimension (in bytes)
+ * @param[in] input_step_w input_stride_w * number of elements along W processed per workitem(in bytes)
* @param[in] input_offset_first_element_in_bytes The offset of the first element in the source image
* @param[out] output_ptr Pointer to the destination image. Supported data types: same as @p input_ptr
- * @param[in] output_stride_x Stride of the destination image in X dimension (in bytes)
+ * @param[in] output_stride_x Stride of the destination tensor in X dimension (in bytes)
* @param[in] output_step_x output_stride_x * number of elements along X processed per workitem(in bytes)
- * @param[in] output_stride_y Stride of the destination image in Y dimension (in bytes)
+ * @param[in] output_stride_y Stride of the destination tensor in Y dimension (in bytes)
* @param[in] output_step_y output_stride_y * number of elements along Y processed per workitem(in bytes)
- * @param[in] output_stride_z Stride of the source tensor in Z dimension (in bytes)
+ * @param[in] output_stride_z Stride of the destination tensor in Z dimension (in bytes)
* @param[in] output_step_z output_stride_z * number of elements along Z processed per workitem(in bytes)
+ * @param[in] output_stride_w Stride of the destination tensor in W dimension (in bytes)
+ * @param[in] output_step_w output_stride_w * number of elements along W processed per workitem(in bytes)
* @param[in] output_offset_first_element_in_bytes The offset of the first element in the destination image
*/
__kernel void pooling_layer_MxN_nhwc(
- TENSOR3D_DECLARATION(input),
- TENSOR3D_DECLARATION(output))
+ TENSOR4D_DECLARATION(input),
+ TENSOR4D_DECLARATION(output))
{
// Get pixels pointer
- Tensor3D input = CONVERT_TO_TENSOR3D_STRUCT(input);
- Tensor3D output = CONVERT_TO_TENSOR3D_STRUCT(output);
+#if defined(DST_DEPTH)
+ Tensor4D input = CONVERT_TO_TENSOR4D_STRUCT(input, DST_DEPTH);
+ Tensor4D output = CONVERT_TO_TENSOR4D_STRUCT(output, DST_DEPTH);
+#else /* defined(DST_DEPTH) */
+ Tensor3D input = CONVERT_TO_TENSOR3D_STRUCT(input);
+ Tensor3D output = CONVERT_TO_TENSOR3D_STRUCT(output);
+#endif /* defined(DST_DEPTH) */
VEC_DATA_TYPE(DATA_TYPE, 8)
vdata = INITIAL_VALUE;
DATA_TYPE sdata = INITIAL_VALUE;
- const int idx_width = get_global_id(1) * STRIDE_X;
+ const int idx_width = get_global_id(1) * STRIDE_X;
+#if defined(DST_DEPTH)
+ const int idx_height = (get_global_id(2) % DST_DEPTH) * STRIDE_Y;
+#else /* defined(DST_DEPTH) */
const int idx_height = get_global_id(2) * STRIDE_Y;
+#endif /* defined(DST_DEPTH) */
for(int y = 0; y < POOL_SIZE_Y; ++y)
{
@@ -555,8 +572,14 @@ __kernel void pooling_layer_MxN_nhwc(
int x1 = select(x, PAD_X - idx_width - 1, x + idx_width - PAD_X < 0 || x + idx_width - PAD_X >= MAX_WIDTH);
x1 = select(x1, PAD_X - idx_width - 1, y != y1);
+#if defined(DST_DEPTH)
+ VEC_DATA_TYPE(DATA_TYPE, 8)
+ data0 = vload8(0, (__global DATA_TYPE *)tensor4D_offset(&input, 0, x1 - PAD_X, y1 - PAD_Y, 0));
+#else /* defined(DST_DEPTH) */
VEC_DATA_TYPE(DATA_TYPE, 8)
data0 = vload8(0, (__global DATA_TYPE *)tensor3D_offset(&input, 0, x1 - PAD_X, y1 - PAD_Y));
+#endif /* defined(DST_DEPTH) */
+
#if defined(POOL_L2)
// Raise to power of 2 for L2 Pooling
data0 *= data0;