diff options
author | Gian Marco Iodice <gianmarco.iodice@arm.com> | 2020-07-14 15:05:31 +0100 |
---|---|---|
committer | Sheri Zhang <sheri.zhang@arm.com> | 2020-08-05 17:45:10 +0000 |
commit | 4d81d75de09bba2de17e849a3d46e3052d449ad8 (patch) | |
tree | d3bc5c3430e3d8cf70540be5e545914a54e93035 /src/core/CL/cl_kernels/helpers.h | |
parent | 801bbcb2f9a16633d0071b55aaf93b89870248ee (diff) | |
download | ComputeLibrary-4d81d75de09bba2de17e849a3d46e3052d449ad8.tar.gz |
COMPMID-2450: Implement CLMaxUnpoolingLayer
- Add OpenCL kernel for Max unpooling layer
- Add tests for validating the result
Change-Id: If7ca79566a1198e3141f880abf46738980a62c81
Signed-off-by: Gian Marco Iodice <gianmarco.iodice@arm.com>
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/3606
Reviewed-by: Pablo Marquez <pablo.tello@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/core/CL/cl_kernels/helpers.h')
-rw-r--r-- | src/core/CL/cl_kernels/helpers.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/core/CL/cl_kernels/helpers.h b/src/core/CL/cl_kernels/helpers.h index d3ede32bc9..7b08233029 100644 --- a/src/core/CL/cl_kernels/helpers.h +++ b/src/core/CL/cl_kernels/helpers.h @@ -516,6 +516,10 @@ #define CONVERT_TO_TENSOR4D_STRUCT_NO_STEP(name, mod_size) \ update_tensor4D_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, 0, name##_stride_y, 0, name##_stride_z, 0, name##_stride_w, 0, mod_size) +#define CONVERT_TO_TENSOR3D_STRUCT_NO_UPDATE_PTR(name) \ + tensor3D_ptr_no_update(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, name##_step_x, name##_stride_y, name##_step_y, \ + name##_stride_z, name##_step_z) + /** Structure to hold Vector information */ typedef struct Vector { @@ -652,6 +656,32 @@ inline Tensor3D update_tensor3D_workitem_ptr(__global uchar *ptr, uint offset_fi return tensor; } +/** Wrap 3D tensor information into an tensor structure. + * + * @param[in] ptr Pointer to the starting postion of the buffer + * @param[in] offset_first_element_in_bytes The offset of the first element in the source image + * @param[in] stride_x Stride of the image in X dimension (in bytes) + * @param[in] step_x stride_x * number of elements along X processed per workitem(in bytes) + * @param[in] stride_y Stride of the image in Y dimension (in bytes) + * @param[in] step_y stride_y * number of elements along Y processed per workitem(in bytes) + * @param[in] stride_z Stride of the image in Z dimension (in bytes) + * @param[in] step_z stride_z * number of elements along Z processed per workitem(in bytes) + * + * @return A 3D tensor object + */ +inline Tensor3D tensor3D_ptr_no_update(__global uchar *ptr, uint offset_first_element_in_bytes, uint stride_x, uint step_x, uint stride_y, uint step_y, uint stride_z, uint step_z) +{ + Tensor3D tensor = + { + .ptr = ptr, + .offset_first_element_in_bytes = offset_first_element_in_bytes, + .stride_x = stride_x, + .stride_y = stride_y, + .stride_z = stride_z + }; + return tensor; +} + inline Tensor4D update_tensor4D_workitem_ptr(__global uchar *ptr, uint offset_first_element_in_bytes, uint stride_x, uint step_x, uint stride_y, uint step_y, uint stride_z, uint step_z, uint stride_w, uint step_w, uint mod_size) @@ -716,4 +746,29 @@ inline __global const uchar *tensor4D_offset(const Tensor4D *tensor, int x, int return tensor->ptr + x * tensor->stride_x + y * tensor->stride_y + z * tensor->stride_z + w * tensor->stride_w; } +/** Get the offset for a given linear index of a Tensor3D + * + * @param[in] tensor Pointer to the starting position of the buffer + * @param[in] width Width of the input tensor + * @param[in] height Height of the input tensor + * @param[in] depth Depth of the input tensor + * @param[in] index Linear index + */ +inline __global const uchar *tensor3D_index2ptr(const Tensor3D *tensor, uint width, uint height, uint depth, uint index) +{ + uint num_elements = width * height; + + const uint z = index / num_elements; + + index %= num_elements; + + const uint y = index / width; + + index %= width; + + const uint x = index; + + return tensor->ptr + x * tensor->stride_x + y * tensor->stride_y + z * tensor->stride_z + tensor->offset_first_element_in_bytes; +} + #endif // _HELPER_H |