Compute Library  18.05
helpers.h File Reference

Go to the source code of this file.

Data Structures

struct  Vector
 Structure to hold Vector information. More...
 
struct  Image
 Structure to hold Image information. More...
 
struct  Tensor3D
 Structure to hold 3D tensor information. More...
 
struct  Tensor4D
 Structure to hold 4D tensor information. More...
 

Macros

#define EXPAND(x)   x
 
#define CLAMP(x, min_val, max_val)   min(max(x, min_val), max_val)
 
#define VLOAD_STR(size)   vload##size
 
#define VLOAD(size)   VLOAD_STR(size)
 
#define VSTORE_STR(size)   vstore##size
 
#define VSTORE(size)   VSTORE_STR(size)
 
#define VEC_DATA_TYPE_STR(type, size)   type##size
 
#define VEC_DATA_TYPE(type, size)   VEC_DATA_TYPE_STR(type, size)
 
#define CL_VEC_DATA_TYPE_STR(type, size)   type##size
 
#define CL_VEC_DATA_TYPE(type, size)   CL_VEC_DATA_TYPE_STR(type, size)
 
#define CONVERT_STR(x, type)   (convert_##type((x)))
 
#define CONVERT(x, type)   CONVERT_STR(x, type)
 
#define CONVERT_SAT_STR(x, type)   (convert_##type##_sat((x)))
 
#define CONVERT_SAT(x, type)   CONVERT_SAT_STR(x, type)
 
#define CONVERT_SAT_ROUND_STR(x, type, round)   (convert_##type##_sat_##round((x)))
 
#define CONVERT_SAT_ROUND(x, type, round)   CONVERT_SAT_ROUND_STR(x, type, round)
 
#define VECTOR_DECLARATION(name)
 
#define IMAGE_DECLARATION(name)
 
#define TENSOR3D_DECLARATION(name)
 
#define TENSOR4D_DECLARATION(name)
 
#define CONVERT_TO_VECTOR_STRUCT(name)   update_vector_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, name##_step_x)
 
#define CONVERT_TO_VECTOR_STRUCT_NO_STEP(name)   update_vector_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, 0)
 
#define CONVERT_TO_IMAGE_STRUCT(name)   update_image_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, name##_step_x, name##_stride_y, name##_step_y)
 
#define CONVERT_TO_IMAGE_STRUCT_NO_STEP(name)   update_image_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, 0, name##_stride_y, 0)
 
#define CONVERT_TENSOR3D_TO_IMAGE_STRUCT(name)   update_image_from_tensor3D_workitem_ptr(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)
 
#define CONVERT_TENSOR3D_TO_IMAGE_STRUCT_NO_STEP(name)   update_image_from_tensor3D_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, 0, name##_stride_y, 0, name##_stride_z, name##_step_z)
 
#define CONVERT_TENSOR3D_TO_IMAGE_STRUCT(name)   update_image_from_tensor3D_workitem_ptr(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)
 
#define CONVERT_TO_TENSOR3D_STRUCT(name)
 
#define CONVERT_TO_TENSOR3D_STRUCT_NO_STEP(name)   update_tensor3D_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, 0, name##_stride_y, 0, name##_stride_z, 0)
 
#define CONVERT_TO_TENSOR4D_STRUCT(name, mod_size)
 
#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)
 

Typedefs

typedef struct Vector Vector
 Structure to hold Vector information. More...
 
typedef struct Image Image
 Structure to hold Image information. More...
 
typedef struct Tensor3D Tensor3D
 Structure to hold 3D tensor information. More...
 
typedef struct Tensor4D Tensor4D
 Structure to hold 4D tensor information. More...
 

Functions

Vector update_vector_workitem_ptr (__global uchar *ptr, uint offset_first_element_in_bytes, uint stride_x, uint step_x)
 Wrap vector information into an Vector structure, and make the pointer point at this workitem's data. More...
 
Image update_image_workitem_ptr (__global uchar *ptr, uint offset_first_element_in_bytes, uint stride_x, uint step_x, uint stride_y, uint step_y)
 Wrap image information into an Image structure, and make the pointer point at this workitem's data. More...
 
Image update_image_from_tensor3D_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)
 Wrap 3D tensor information into an image structure, and make the pointer point at this workitem's data. More...
 
Tensor3D update_tensor3D_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)
 Wrap 3D tensor information into an tensor structure, and make the pointer point at this workitem's data. More...
 
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)
 
__global const uchar * vector_offset (const Vector *vec, int x)
 Get the pointer position of a Vector. More...
 
__global uchar * offset (const Image *img, int x, int y)
 Get the pointer position of a Image. More...
 
__global const uchar * tensor3D_offset (const Tensor3D *tensor, int x, int y, int z)
 Get the pointer position of a Tensor3D. More...
 
__global const uchar * tensor4D_offset (const Tensor4D *tensor, int x, int y, int z, int w)
 Get the pointer position of a Tensor4D. More...
 

Macro Definition Documentation

#define CL_VEC_DATA_TYPE (   type,
  size 
)    CL_VEC_DATA_TYPE_STR(type, size)

Definition at line 51 of file helpers.h.

Referenced by softmax_layer_max_shift_exp_sum_serial().

#define CL_VEC_DATA_TYPE_STR (   type,
  size 
)    type##size

Definition at line 50 of file helpers.h.

#define CLAMP (   x,
  min_val,
  max_val 
)    min(max(x, min_val), max_val)

Definition at line 39 of file helpers.h.

#define CONVERT (   x,
  type 
)    CONVERT_STR(x, type)

Definition at line 54 of file helpers.h.

#define CONVERT_SAT (   x,
  type 
)    CONVERT_SAT_STR(x, type)

Definition at line 57 of file helpers.h.

#define CONVERT_SAT_ROUND (   x,
  type,
  round 
)    CONVERT_SAT_ROUND_STR(x, type, round)

Definition at line 60 of file helpers.h.

Referenced by combine_gradients_L2().

#define CONVERT_SAT_ROUND_STR (   x,
  type,
  round 
)    (convert_##type##_sat_##round((x)))

Definition at line 59 of file helpers.h.

#define CONVERT_SAT_STR (   x,
  type 
)    (convert_##type##_sat((x)))

Definition at line 56 of file helpers.h.

#define CONVERT_STR (   x,
  type 
)    (convert_##type((x)))

Definition at line 53 of file helpers.h.

#define CONVERT_TENSOR3D_TO_IMAGE_STRUCT (   name)    update_image_from_tensor3D_workitem_ptr(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)
#define CONVERT_TENSOR3D_TO_IMAGE_STRUCT (   name)    update_image_from_tensor3D_workitem_ptr(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)

Definition at line 116 of file helpers.h.

#define CONVERT_TENSOR3D_TO_IMAGE_STRUCT_NO_STEP (   name)    update_image_from_tensor3D_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, 0, name##_stride_y, 0, name##_stride_z, name##_step_z)
#define CONVERT_TO_IMAGE_STRUCT (   name)    update_image_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, name##_step_x, name##_stride_y, name##_step_y)

Definition at line 104 of file helpers.h.

Referenced by absdiff(), accumulate(), accumulate_squared(), accumulate_weighted(), bitwise_and(), bitwise_not(), bitwise_or(), bitwise_xor(), channel_combine_NV(), channel_combine_RGB888(), channel_combine_RGBA8888(), channel_combine_UYVY422(), channel_combine_YUYV422(), channel_extract_NV12(), channel_extract_NV21(), channel_extract_RGB888(), channel_extract_RGBA8888(), channel_extract_UYVY422(), channel_extract_YUYV422(), combine_gradients_L1(), combine_gradients_L2(), convert_depth_down(), convert_depth_up(), convolution3x3_static(), convolution5x5_static(), convolution7x7_static(), convolution9x9_static(), convolution_rectangle(), convolution_separable1x5_static(), convolution_separable1x7_static(), convolution_separable1x9_static(), convolution_separable5x1_static(), convolution_separable7x1_static(), convolution_separable9x1_static(), copy_plane(), copy_planes_3p(), copy_to_keypoint(), deconvolution_upsample(), derivative(), dilate(), erode(), fast_corners(), gaussian1x5_sub_x(), gaussian5x1_sub_y(), harris_score_3x3(), harris_score_5x5(), harris_score_7x7(), hist_border_kernel(), hist_border_kernel_fixed(), hist_local_kernel(), hist_local_kernel_fixed(), integral_horizontal(), integral_vertical(), IYUV_to_NV12_bt709(), IYUV_to_RGB888_bt709(), IYUV_to_RGBA8888_bt709(), IYUV_to_YUV444_bt709(), magnitude_phase(), mean_stddev_accumulate(), minmax(), minmaxloc(), non_linear_filter_box3x3(), non_linear_filter_box5x5(), non_linear_filter_cross3x3(), non_linear_filter_cross5x5(), non_linear_filter_disk3x3(), non_linear_filter_disk5x5(), non_max_suppression(), NV12_to_IYUV_bt709(), NV12_to_RGB888_bt709(), NV12_to_RGBA8888_bt709(), NV12_to_YUV444_bt709(), NV21_to_IYUV_bt709(), NV21_to_RGB888_bt709(), NV21_to_RGBA8888_bt709(), NV21_to_YUV444_bt709(), reduction_operation(), remap_bilinear(), remap_nearest_neighbour(), RGB888_to_IYUV_bt709(), RGB888_to_NV12_bt709(), RGB888_to_RGBA8888_bt709(), RGB888_to_YUV444_bt709(), RGBA8888_to_IYUV_bt709(), RGBA8888_to_NV12_bt709(), RGBA8888_to_RGB888_bt709(), RGBA8888_to_YUV444_bt709(), scale_bilinear(), scale_nearest_neighbour(), scharr3x3(), sobel3x3(), sobel_separable1x5(), sobel_separable1x7(), sobel_separable5x1(), sobel_separable7x1(), suppress_non_maximum(), tablelookup_S16(), tablelookup_U8(), threshold_binary(), threshold_range(), transpose(), UYVY422_to_IYUV_bt709(), UYVY422_to_NV12_bt709(), UYVY422_to_RGB888_bt709(), UYVY422_to_RGBA8888_bt709(), warp_affine_bilinear(), warp_affine_nearest_neighbour(), warp_perspective_bilinear(), warp_perspective_nearest_neighbour(), YUYV422_to_IYUV_bt709(), YUYV422_to_NV12_bt709(), YUYV422_to_RGB888_bt709(), and YUYV422_to_RGBA8888_bt709().

#define CONVERT_TO_IMAGE_STRUCT_NO_STEP (   name)    update_image_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, 0, name##_stride_y, 0)
#define CONVERT_TO_TENSOR3D_STRUCT (   name)
Value:
update_tensor3D_workitem_ptr(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)
Tensor3D update_tensor3D_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)
Wrap 3D tensor information into an tensor structure, and make the pointer point at this workitem's da...
Definition: helpers.h:255

Definition at line 119 of file helpers.h.

Referenced by arithmetic_add(), arithmetic_sub(), concatenate_depth(), concatenate_width(), dequantization_layer(), floor_layer(), normalization_layer_cross_map(), normalization_layer_in_map(), pixelwise_mul_float(), pixelwise_mul_int(), pooling_layer_2(), pooling_layer_3(), pooling_layer_MxN_nhwc(), pooling_layer_MxN_quantized_nchw(), pooling_layer_MxN_quantized_nhwc(), quantization_layer(), and reshape_layer().

#define CONVERT_TO_TENSOR3D_STRUCT_NO_STEP (   name)    update_tensor3D_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, 0, name##_stride_y, 0, name##_stride_z, 0)

Definition at line 123 of file helpers.h.

Referenced by reshape_layer(), and roi_pooling_layer().

#define CONVERT_TO_TENSOR4D_STRUCT (   name,
  mod_size 
)
Value:
update_tensor4D_workitem_ptr(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, name##_stride_w, name##_step_w, mod_size)
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)
Definition: helpers.h:269

Definition at line 126 of file helpers.h.

#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)

Definition at line 130 of file helpers.h.

#define CONVERT_TO_VECTOR_STRUCT (   name)    update_vector_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, name##_step_x)

Definition at line 98 of file helpers.h.

Referenced by copy_tensor(), dequantization_layer(), and l2_normalize().

#define CONVERT_TO_VECTOR_STRUCT_NO_STEP (   name)    update_vector_workitem_ptr(name##_ptr, name##_offset_first_element_in_bytes, name##_stride_x, 0)

Definition at line 101 of file helpers.h.

Referenced by output_stage_quantized(), and roi_pooling_layer().

#define EXPAND (   x)    x

Definition at line 37 of file helpers.h.

Referenced by softmax_layer_max_shift_exp_sum_serial().

#define IMAGE_DECLARATION (   name)
Value:
__global uchar *name##_ptr, \
uint name##_stride_x, \
uint name##_step_x, \
uint name##_stride_y, \
uint name##_step_y, \
uint name##_offset_first_element_in_bytes

Definition at line 68 of file helpers.h.

#define TENSOR3D_DECLARATION (   name)
Value:
__global uchar *name##_ptr, \
uint name##_stride_x, \
uint name##_step_x, \
uint name##_stride_y, \
uint name##_step_y, \
uint name##_stride_z, \
uint name##_step_z, \
uint name##_offset_first_element_in_bytes

Definition at line 76 of file helpers.h.

#define TENSOR4D_DECLARATION (   name)
Value:
__global uchar *name##_ptr, \
uint name##_stride_x, \
uint name##_step_x, \
uint name##_stride_y, \
uint name##_step_y, \
uint name##_stride_z, \
uint name##_step_z, \
uint name##_stride_w, \
uint name##_step_w, \
uint name##_offset_first_element_in_bytes

Definition at line 86 of file helpers.h.

#define VEC_DATA_TYPE (   type,
  size 
)    VEC_DATA_TYPE_STR(type, size)

Definition at line 48 of file helpers.h.

#define VEC_DATA_TYPE_STR (   type,
  size 
)    type##size

Definition at line 47 of file helpers.h.

#define VECTOR_DECLARATION (   name)
Value:
__global uchar *name##_ptr, \
uint name##_stride_x, \
uint name##_step_x, \
uint name##_offset_first_element_in_bytes

Definition at line 62 of file helpers.h.

#define VLOAD_STR (   size)    vload##size

Definition at line 41 of file helpers.h.

#define VSTORE_STR (   size)    vstore##size

Definition at line 44 of file helpers.h.

Typedef Documentation

typedef struct Image Image

Structure to hold Image information.

typedef struct Tensor3D Tensor3D

Structure to hold 3D tensor information.

typedef struct Tensor4D Tensor4D

Structure to hold 4D tensor information.

typedef struct Vector Vector

Structure to hold Vector information.

Function Documentation

__global uchar* offset ( const Image img,
int  x,
int  y 
)
inline

Get the pointer position of a Image.

Parameters
[in]imgPointer to the starting position of the buffer
[in]xRelative X position
[in]yRelative Y position

Definition at line 303 of file helpers.h.

References Image::ptr, Image::stride_x, and Image::stride_y.

Referenced by bilinear_interpolate_with_border(), channel_combine_NV(), convolution3x3(), convolution5x1(), convolution5x5(), convolution7x1(), convolution7x7(), convolution9x1(), convolution9x9(), convolution_rectangle(), convolution_separable1x5_static(), convolution_separable1x7_static(), convolution_separable1x9_static(), copy_planes_3p(), copy_to_keypoint(), arm_compute::test::validation::DATA_TEST_CASE(), derivative(), dilate(), erode(), arm_compute::test::validation::reference::fast_corners(), AssetsLibrary::fill(), fill_image_borders_constant(), fill_image_borders_replicate(), gaussian5x1_sub_y(), harris_score_1x5(), harris_score_1x7(), harris_score_3x3(), hist_border_kernel(), arm_compute::test::validation::reference::histogram(), hysteresis(), integral_horizontal(), integral_vertical(), lktracker_stage0(), lktracker_stage1(), mean_stddev_accumulate(), minmax(), non_linear_filter_box3x3(), non_linear_filter_box5x5(), non_linear_filter_cross3x3(), non_linear_filter_cross5x5(), non_linear_filter_disk3x3(), non_linear_filter_disk5x5(), non_max_suppression(), QuantizationInfo::operator==(), SimpleTensor< T >::operator[](), PaddingCalculator::PaddingCalculator(), RandomAccessor::RandomAccessor(), read_texels4(), reduction_operation(), scharr3x3(), PaddingCalculator::set_access_offset(), sobel1x5(), sobel3x3(), sobel5x1(), softmax_layer_max_shift_exp_sum_parallel(), softmax_layer_max_shift_exp_sum_serial(), softmax_layer_norm(), suppress_non_maximum(), transpose(), and arm_compute::test::validation::reference::widthconcatenate_layer().

304 {
305  return img->ptr + x * img->stride_x + y * img->stride_y;
306 }
__global uchar * ptr
Pointer to the starting postion of the buffer.
Definition: helpers.h:144
int stride_y
Stride of the image in Y dimension (in bytes)
Definition: helpers.h:147
int stride_x
Stride of the image in X dimension (in bytes)
Definition: helpers.h:146
__global const uchar* tensor3D_offset ( const Tensor3D tensor,
int  x,
int  y,
int  z 
)
inline

Get the pointer position of a Tensor3D.

Parameters
[in]tensorPointer to the starting position of the buffer
[in]xRelative X position
[in]yRelative Y position
[in]zRelative Z position

Definition at line 315 of file helpers.h.

References Tensor3D::ptr, Tensor3D::stride_x, Tensor3D::stride_y, and Tensor3D::stride_z.

Referenced by concatenate_depth(), normalization_layer_cross_map(), normalization_layer_in_map(), pooling_layer_2(), pooling_layer_3(), pooling_layer_MxN_nhwc(), pooling_layer_MxN_quantized_nchw(), pooling_layer_MxN_quantized_nhwc(), reshape_layer(), roi_pool_1x1(), and roi_pooling_layer().

316 {
317  return tensor->ptr + x * tensor->stride_x + y * tensor->stride_y + z * tensor->stride_z;
318 }
int stride_z
Stride of the image in Z dimension (in bytes)
Definition: helpers.h:157
int stride_x
Stride of the image in X dimension (in bytes)
Definition: helpers.h:155
__global uchar * ptr
Pointer to the starting postion of the buffer.
Definition: helpers.h:153
int stride_y
Stride of the image in Y dimension (in bytes)
Definition: helpers.h:156
__global const uchar* tensor4D_offset ( const Tensor4D tensor,
int  x,
int  y,
int  z,
int  w 
)
inline

Get the pointer position of a Tensor4D.

Parameters
[in]tensorPointer to the starting position of the buffer
[in]xRelative X position
[in]yRelative Y position
[in]zRelative Z position
[in]wRelative W position

Definition at line 328 of file helpers.h.

References Tensor4D::ptr, Tensor4D::stride_w, Tensor4D::stride_x, Tensor4D::stride_y, and Tensor4D::stride_z.

329 {
330  return tensor->ptr + x * tensor->stride_x + y * tensor->stride_y + z * tensor->stride_z + w * tensor->stride_w;
331 }
__global uchar * ptr
Pointer to the starting postion of the buffer.
Definition: helpers.h:163
int stride_w
Stride of the image in W dimension (in bytes)
Definition: helpers.h:168
int stride_y
Stride of the image in Y dimension (in bytes)
Definition: helpers.h:166
int stride_x
Stride of the image in X dimension (in bytes)
Definition: helpers.h:165
int stride_z
Stride of the image in Z dimension (in bytes)
Definition: helpers.h:167
Image update_image_from_tensor3D_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 
)
inline

Wrap 3D tensor information into an image structure, and make the pointer point at this workitem's data.

Parameters
[in]ptrPointer to the starting postion of the buffer
[in]offset_first_element_in_bytesThe offset of the first element in the source image
[in]stride_xStride of the image in X dimension (in bytes)
[in]step_xstride_x * number of elements along X processed per workitem(in bytes)
[in]stride_yStride of the image in Y dimension (in bytes)
[in]step_ystride_y * number of elements along Y processed per workitem(in bytes)
[in]stride_zStride of the image in Z dimension (in bytes)
[in]step_zstride_z * number of elements along Z processed per workitem(in bytes)
Returns
A 3D tensor object

Definition at line 229 of file helpers.h.

References Vector::offset_first_element_in_bytes, Image::offset_first_element_in_bytes, Vector::ptr, Image::ptr, and Vector::stride_x.

230 {
231  Image img =
232  {
233  .ptr = ptr,
234  .offset_first_element_in_bytes = offset_first_element_in_bytes,
235  .stride_x = stride_x,
236  .stride_y = stride_y
237  };
238  img.ptr += img.offset_first_element_in_bytes + get_global_id(0) * step_x + get_global_id(1) * step_y + get_global_id(2) * step_z;
239  return img;
240 }
int offset_first_element_in_bytes
The offset of the first element in the source image.
Definition: helpers.h:145
Structure to hold Image information.
Definition: helpers.h:142
__global uchar * ptr
Pointer to the starting postion of the buffer.
Definition: helpers.h:144
Image update_image_workitem_ptr ( __global uchar *  ptr,
uint  offset_first_element_in_bytes,
uint  stride_x,
uint  step_x,
uint  stride_y,
uint  step_y 
)
inline

Wrap image information into an Image structure, and make the pointer point at this workitem's data.

Parameters
[in]ptrPointer to the starting postion of the buffer
[in]offset_first_element_in_bytesThe offset of the first element in the source image
[in]stride_xStride of the image in X dimension (in bytes)
[in]step_xstride_x * number of elements along X processed per workitem(in bytes)
[in]stride_yStride of the image in Y dimension (in bytes)
[in]step_ystride_y * number of elements along Y processed per workitem(in bytes)
Returns
An image object

Definition at line 203 of file helpers.h.

References Vector::offset_first_element_in_bytes, Image::offset_first_element_in_bytes, Vector::ptr, Image::ptr, and Vector::stride_x.

204 {
205  Image img =
206  {
207  .ptr = ptr,
208  .offset_first_element_in_bytes = offset_first_element_in_bytes,
209  .stride_x = stride_x,
210  .stride_y = stride_y
211  };
212  img.ptr += img.offset_first_element_in_bytes + get_global_id(0) * step_x + get_global_id(1) * step_y;
213  return img;
214 }
int offset_first_element_in_bytes
The offset of the first element in the source image.
Definition: helpers.h:145
Structure to hold Image information.
Definition: helpers.h:142
__global uchar * ptr
Pointer to the starting postion of the buffer.
Definition: helpers.h:144
Tensor3D update_tensor3D_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 
)
inline

Wrap 3D tensor information into an tensor structure, and make the pointer point at this workitem's data.

Parameters
[in]ptrPointer to the starting postion of the buffer
[in]offset_first_element_in_bytesThe offset of the first element in the source image
[in]stride_xStride of the image in X dimension (in bytes)
[in]step_xstride_x * number of elements along X processed per workitem(in bytes)
[in]stride_yStride of the image in Y dimension (in bytes)
[in]step_ystride_y * number of elements along Y processed per workitem(in bytes)
[in]stride_zStride of the image in Z dimension (in bytes)
[in]step_zstride_z * number of elements along Z processed per workitem(in bytes)
Returns
A 3D tensor object

Definition at line 255 of file helpers.h.

References Vector::offset_first_element_in_bytes, Tensor3D::offset_first_element_in_bytes, Vector::ptr, Tensor3D::ptr, and Vector::stride_x.

256 {
257  Tensor3D tensor =
258  {
259  .ptr = ptr,
260  .offset_first_element_in_bytes = offset_first_element_in_bytes,
261  .stride_x = stride_x,
262  .stride_y = stride_y,
263  .stride_z = stride_z
264  };
265  tensor.ptr += tensor.offset_first_element_in_bytes + get_global_id(0) * step_x + get_global_id(1) * step_y + get_global_id(2) * step_z;
266  return tensor;
267 }
Structure to hold 3D tensor information.
Definition: helpers.h:151
__global uchar * ptr
Pointer to the starting postion of the buffer.
Definition: helpers.h:153
int offset_first_element_in_bytes
The offset of the first element in the source image.
Definition: helpers.h:154
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 
)
inline

Definition at line 269 of file helpers.h.

References Vector::offset_first_element_in_bytes, Tensor4D::offset_first_element_in_bytes, Vector::ptr, Tensor4D::ptr, and Vector::stride_x.

272 {
273  Tensor4D tensor =
274  {
275  .ptr = ptr,
276  .offset_first_element_in_bytes = offset_first_element_in_bytes,
277  .stride_x = stride_x,
278  .stride_y = stride_y,
279  .stride_z = stride_z,
280  .stride_w = stride_w
281  };
282 
283  tensor.ptr += tensor.offset_first_element_in_bytes + get_global_id(0) * step_x + get_global_id(1) * step_y + (get_global_id(2) % mod_size) * step_z + (get_global_id(2) / mod_size) * step_w;
284  return tensor;
285 }
__global uchar * ptr
Pointer to the starting postion of the buffer.
Definition: helpers.h:163
Structure to hold 4D tensor information.
Definition: helpers.h:161
int offset_first_element_in_bytes
The offset of the first element in the source image.
Definition: helpers.h:164
Vector update_vector_workitem_ptr ( __global uchar *  ptr,
uint  offset_first_element_in_bytes,
uint  stride_x,
uint  step_x 
)
inline

Wrap vector information into an Vector structure, and make the pointer point at this workitem's data.

Parameters
[in]ptrPointer to the starting postion of the buffer
[in]offset_first_element_in_bytesThe offset of the first element in the source vector
[in]stride_xStride of the vector in X dimension (in bytes)
[in]step_xstride_x * number of elements along X processed per workitem(in bytes)
Returns
An image object

Definition at line 180 of file helpers.h.

References Vector::offset_first_element_in_bytes, Vector::ptr, and Vector::stride_x.

181 {
182  Vector vector =
183  {
184  .ptr = ptr,
185  .offset_first_element_in_bytes = offset_first_element_in_bytes,
186  .stride_x = stride_x,
187  };
188  vector.ptr += vector.offset_first_element_in_bytes + get_global_id(0) * step_x;
189  return vector;
190 }
Structure to hold Vector information.
Definition: helpers.h:134
__global uchar * ptr
Pointer to the starting postion of the buffer.
Definition: helpers.h:136
int offset_first_element_in_bytes
The offset of the first element in the source image.
Definition: helpers.h:137
__global const uchar* vector_offset ( const Vector vec,
int  x 
)
inline

Get the pointer position of a Vector.

Parameters
[in]vecPointer to the starting position of the buffer
[in]xRelative X position

Definition at line 292 of file helpers.h.

References Vector::ptr, and Vector::stride_x.

Referenced by output_stage_quantized(), and roi_pooling_layer().

293 {
294  return vec->ptr + x * vec->stride_x;
295 }
int stride_x
Stride of the image in X dimension (in bytes)
Definition: helpers.h:138
__global uchar * ptr
Pointer to the starting postion of the buffer.
Definition: helpers.h:136