Compute Library
 22.11
upsample_layer.cl File Reference
#include "helpers.h"

Go to the source code of this file.

Functions

__kernel void upsample_layer_nchw (__global uchar *src_ptr, uint src_stride_x, uint src_step_x, uint src_stride_y, uint src_step_y, uint src_stride_z, uint src_step_z, uint src_offset_first_element_in_bytes, __global uchar *dst_ptr, uint dst_stride_x, uint dst_step_x, uint dst_stride_y, uint dst_step_y, uint dst_stride_z, uint dst_step_z, uint dst_offset_first_element_in_bytes)
 This function applies upsample on an input image. More...
 

Function Documentation

◆ upsample_layer_nchw()

__kernel void upsample_layer_nchw ( __global uchar *  src_ptr,
uint  src_stride_x,
uint  src_step_x,
uint  src_stride_y,
uint  src_step_y,
uint  src_stride_z,
uint  src_step_z,
uint  src_offset_first_element_in_bytes,
__global uchar *  dst_ptr,
uint  dst_stride_x,
uint  dst_step_x,
uint  dst_stride_y,
uint  dst_step_y,
uint  dst_stride_z,
uint  dst_step_z,
uint  dst_offset_first_element_in_bytes 
)

This function applies upsample on an input image.

(NCHW)

Attention
The following variables must be passed at compile time:
  1. -DDATA_TYPE = Tensor data type. Supported data types: All
  2. -DVEC_SIZE_IN = Input vector size
  3. -DVEC_SIZE_OUT = Output vector size
  4. -DLAST_ACCESSED_X_IN = The input element that is on the X border (threads trying to set this, might need to step back a bit)
  5. -DLAST_ACCESSED_X_OUT = The output element that is on the X border (threads trying to set this, might need to step back a bit)
Parameters
[in]src_ptrPointer to the source image. Supported data types: All
[in]src_stride_xStride of the source image in X dimension (in bytes)
[in]src_step_xsrc_stride_x * number of elements along X processed per workitem(in bytes)
[in]src_stride_yStride of the source image in Y dimension (in bytes)
[in]src_step_ysrc_stride_y * number of elements along Y processed per workitem(in bytes)
[in]src_stride_zStride of the source tensor in Z dimension (in bytes)
[in]src_step_zsrc_stride_z * number of elements along Z processed per workitem(in bytes)
[in]src_offset_first_element_in_bytesThe offset of the first element in the source image
[out]dst_ptrPointer to the destination image. Supported data types: same as src_ptr
[in]dst_stride_xStride of the destination image in X dimension (in bytes)
[in]dst_step_xdst_stride_x * number of elements along X processed per workitem(in bytes)
[in]dst_stride_yStride of the destination image in Y dimension (in bytes)
[in]dst_step_ydst_stride_y * number of elements along Y processed per workitem(in bytes)
[in]dst_stride_zStride of the source tensor in Z dimension (in bytes)
[in]dst_step_zdst_stride_z * number of elements along Z processed per workitem(in bytes)
[in]dst_offset_first_element_in_bytesThe offset of the first element in the destination image

Definition at line 52 of file upsample_layer.cl.

References CONVERT_TO_TENSOR3D_STRUCT, arm_compute::test::validation::dst, Tensor3D::ptr, arm_compute::test::validation::src, tensor3D_offset(), and VEC_DATA_TYPE.

55 {
58 
59 #if defined(VEC_SIZE_IN) && defined(VEC_SIZE_OUT) && defined(LAST_ACCESSED_X_IN) && defined(LAST_ACCESSED_X_OUT)
60  // Check if access on width gets out of bounds
61  // If it does shift access vector to access elements within bounds
62  const int xi_in = (int)(get_global_id(0) * VEC_SIZE_IN);
63  const int xi_out = (int)(get_global_id(0) * VEC_SIZE_OUT);
64  src.ptr -= max(xi_in - (int)LAST_ACCESSED_X_IN, 0) * src_stride_x;
65  dst.ptr -= max(xi_out - (int)LAST_ACCESSED_X_OUT, 0) * dst_stride_x;
66 
67  VEC_DATA_TYPE(DATA_TYPE, 8)
68  data = vload8(0, (__global DATA_TYPE *)src.ptr);
69 
70  VEC_DATA_TYPE(DATA_TYPE, 16)
71  data_out = (VEC_DATA_TYPE(DATA_TYPE, 16))(data.s0, data.s0, data.s1, data.s1, data.s2, data.s2, data.s3, data.s3, data.s4, data.s4, data.s5, data.s5, data.s6, data.s6, data.s7, data.s7);
72 
73  vstore16(data_out, 0, (__global DATA_TYPE *)dst.ptr);
74  vstore16(data_out, 0, (__global DATA_TYPE *)tensor3D_offset(&dst, 0, 1, 0));
75 #else // !defined(VEC_SIZE_IN) && defined(VEC_SIZE_OUT) && defined(LAST_ACCESSED_X_IN) && defined(LAST_ACCESSED_X_OUT)
76  *((__global DATA_TYPE *)tensor3D_offset(&dst, 0, 0, 0)) = *((__global DATA_TYPE *)src.ptr);
77  *((__global DATA_TYPE *)tensor3D_offset(&dst, 0, 1, 0)) = *((__global DATA_TYPE *)src.ptr);
78 #endif // defined(VEC_SIZE_IN) && defined(VEC_SIZE_OUT) && defined(LAST_ACCESSED_X_IN) && defined(LAST_ACCESSED_X_OUT)
79 }
Structure to hold 3D tensor information.
Definition: helpers.h:906
SimpleTensor< float > src
Definition: DFT.cpp:155
#define CONVERT_TO_TENSOR3D_STRUCT(name)
Definition: helpers.h:870
__global uchar * ptr
Pointer to the starting postion of the buffer.
Definition: helpers.h:908
__global const uchar * tensor3D_offset(const Tensor3D *tensor, int x, int y, int z)
Get the pointer position of a Tensor3D.
Definition: helpers.h:1096
#define VEC_DATA_TYPE(type, size)
Definition: helpers.h:728