Compute Library  17.09
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
accumulate.cl File Reference
#include "helpers.h"

Go to the source code of this file.

Functions

__kernel void accumulate (__global uchar *input_ptr, uint input_stride_x, uint input_step_x, uint input_stride_y, uint input_step_y, uint input_offset_first_element_in_bytes, __global uchar *accu_ptr, uint accu_stride_x, uint accu_step_x, uint accu_stride_y, uint accu_step_y, uint accu_offset_first_element_in_bytes)
 This function accumulates an input image into output image. More...
 
__kernel void accumulate_weighted (__global uchar *input_ptr, uint input_stride_x, uint input_step_x, uint input_stride_y, uint input_step_y, uint input_offset_first_element_in_bytes, __global uchar *accu_ptr, uint accu_stride_x, uint accu_step_x, uint accu_stride_y, uint accu_step_y, uint accu_offset_first_element_in_bytes, const float alpha)
 This function accumulates a weighted value from an input image to an output image. More...
 
__kernel void accumulate_squared (__global uchar *input_ptr, uint input_stride_x, uint input_step_x, uint input_stride_y, uint input_step_y, uint input_offset_first_element_in_bytes, __global uchar *accu_ptr, uint accu_stride_x, uint accu_step_x, uint accu_stride_y, uint accu_step_y, uint accu_offset_first_element_in_bytes, const uint shift)
 This function accumulates a squared value from an input image to an output image. More...
 

Function Documentation

__kernel void accumulate ( __global uchar *  input_ptr,
uint  input_stride_x,
uint  input_step_x,
uint  input_stride_y,
uint  input_step_y,
uint  input_offset_first_element_in_bytes,
__global uchar *  accu_ptr,
uint  accu_stride_x,
uint  accu_step_x,
uint  accu_stride_y,
uint  accu_step_y,
uint  accu_offset_first_element_in_bytes 
)

This function accumulates an input image into output image.

Parameters
[in]input_ptrPointer to the source image. Supported data types: U8
[in]input_stride_xStride of the source image in X dimension (in bytes)
[in]input_step_xinput_stride_x * number of elements along X processed per workitem(in bytes)
[in]input_stride_yStride of the source image in Y dimension (in bytes)
[in]input_step_yinput_stride_y * number of elements along Y processed per workitem(in bytes)
[in]input_offset_first_element_in_bytesThe offset of the first element in the source image
[out]accu_ptrPointer to the destination image. Supported data types: S16
[in]accu_stride_xStride of the destination image in X dimension (in bytes)
[in]accu_step_xaccu_stride_x * number of elements along X processed per workitem(in bytes)
[in]accu_stride_yStride of the destination image in Y dimension (in bytes)
[in]accu_step_yaccu_stride_y * number of elements along Y processed per workitem(in bytes)
[in]accu_offset_first_element_in_bytesThe offset of the first element in the destination image

Definition at line 41 of file accumulate.cl.

References CONVERT_TO_IMAGE_STRUCT, and Image::ptr.

Referenced by arm_compute::calculate_matrix_scale(), Dimensions< size_t >::collapse(), arm_compute::data_type_for_convolution(), arm_compute::data_type_for_convolution_matrix(), arm_compute::test::join(), arm_compute::test::validation::reference::mean_and_standard_deviation(), arm_compute::pixel_area_c1u8_clamp(), JSONPrinter::print_measurements(), PrettyPrinter::print_measurements(), SimpleTensor< T >::size(), TensorShape::total_size(), TensorShape::total_size_lower(), and TensorShape::total_size_upper().

44 {
45  // Get pixels pointer
46  Image input = CONVERT_TO_IMAGE_STRUCT(input);
47  Image accu = CONVERT_TO_IMAGE_STRUCT(accu);
48 
49  // Load data
50  uchar16 in_data = vload16(0, input.ptr);
51  short16 accu_data = vload16(0, (__global short *)accu.ptr);
52 
53  // Perform accumulation
54  short16 res = add_sat(convert_short16(in_data), accu_data);
55 
56  // Store result
57  vstore16(res, 0, (__global short *)accu.ptr);
58 }
#define CONVERT_TO_IMAGE_STRUCT(name)
Definition: helpers.h:93
Structure to hold Image information.
Definition: helpers.h:131
__global uchar * ptr
Pointer to the starting postion of the buffer.
Definition: helpers.h:133
__kernel void accumulate_squared ( __global uchar *  input_ptr,
uint  input_stride_x,
uint  input_step_x,
uint  input_stride_y,
uint  input_step_y,
uint  input_offset_first_element_in_bytes,
__global uchar *  accu_ptr,
uint  accu_stride_x,
uint  accu_step_x,
uint  accu_stride_y,
uint  accu_step_y,
uint  accu_offset_first_element_in_bytes,
const uint  shift 
)

This function accumulates a squared value from an input image to an output image.

Parameters
[in]input_ptrPointer to the source image. Supported data types: U8
[in]input_stride_xStride of the source image in X dimension (in bytes)
[in]input_step_xinput_stride_x * number of elements along X processed per workitem(in bytes)
[in]input_stride_yStride of the source image in Y dimension (in bytes)
[in]input_step_yinput_stride_y * number of elements along Y processed per workitem(in bytes)
[in]input_offset_first_element_in_bytesThe offset of the first element in the source image
[out]accu_ptrPointer to the destination image. Supported data types: S16
[in]accu_stride_xStride of the destination image in X dimension (in bytes)
[in]accu_step_xaccu_stride_x * number of elements along X processed per workitem(in bytes)
[in]accu_stride_yStride of the destination image in Y dimension (in bytes)
[in]accu_step_yaccu_stride_y * number of elements along Y processed per workitem(in bytes)
[in]accu_offset_first_element_in_bytesThe offset of the first element in the destination image
[in]shiftThe U32 scalar value with a value in the range of 0 to 15

Definition at line 112 of file accumulate.cl.

References CONVERT_TO_IMAGE_STRUCT, and Image::ptr.

116 {
117  // Get pixels pointer
118  Image input = CONVERT_TO_IMAGE_STRUCT(input);
119  Image accu = CONVERT_TO_IMAGE_STRUCT(accu);
120 
121  // Load data
122  ushort16 in_data = convert_ushort16(vload16(0, input.ptr));
123  uint16 accu_data = convert_uint16(vload16(0, (__global short *)accu.ptr));
124 
125  // Calculate squared accumulation
126  short16 res = convert_short16_sat(accu_data + convert_uint16((in_data * in_data) >> shift));
127 
128  // Store result
129  vstore16(res, 0, (__global short *)accu.ptr);
130 }
#define CONVERT_TO_IMAGE_STRUCT(name)
Definition: helpers.h:93
Structure to hold Image information.
Definition: helpers.h:131
__global uchar * ptr
Pointer to the starting postion of the buffer.
Definition: helpers.h:133
__kernel void accumulate_weighted ( __global uchar *  input_ptr,
uint  input_stride_x,
uint  input_step_x,
uint  input_stride_y,
uint  input_step_y,
uint  input_offset_first_element_in_bytes,
__global uchar *  accu_ptr,
uint  accu_stride_x,
uint  accu_step_x,
uint  accu_stride_y,
uint  accu_step_y,
uint  accu_offset_first_element_in_bytes,
const float  alpha 
)

This function accumulates a weighted value from an input image to an output image.

Parameters
[in]input_ptrPointer to the source image. Supported data types: U8
[in]input_stride_xStride of the source image in X dimension (in bytes)
[in]input_step_xinput_stride_x * number of elements along X processed per workitem(in bytes)
[in]input_stride_yStride of the source image in Y dimension (in bytes)
[in]input_step_yinput_stride_y * number of elements along Y processed per workitem(in bytes)
[in]input_offset_first_element_in_bytesThe offset of the first element in the source image
[out]accu_ptrPointer to the destination image. Supported data types: S16
[in]accu_stride_xStride of the destination image in X dimension (in bytes)
[in]accu_step_xaccu_stride_x * number of elements along X processed per workitem(in bytes)
[in]accu_stride_yStride of the destination image in Y dimension (in bytes)
[in]accu_step_yaccu_stride_y * number of elements along Y processed per workitem(in bytes)
[in]accu_offset_first_element_in_bytesThe offset of the first element in the destination image
[in]alphaThe float scalar value with a value in the range of 0 to 1

Definition at line 76 of file accumulate.cl.

References CONVERT_TO_IMAGE_STRUCT, and Image::ptr.

80 {
81  // Get pixels pointer
82  Image input = CONVERT_TO_IMAGE_STRUCT(input);
83  Image accu = CONVERT_TO_IMAGE_STRUCT(accu);
84 
85  // Load data
86  const float16 in_data = convert_float16(vload16(0, input.ptr));
87  const float16 accu_data = convert_float16(vload16(0, accu.ptr));
88 
89  // Calculate weighted accumulation
90  const uchar16 res = convert_uchar16((1.0f - alpha) * accu_data + alpha * in_data);
91 
92  // Store result
93  vstore16(res, 0, accu.ptr);
94 }
#define CONVERT_TO_IMAGE_STRUCT(name)
Definition: helpers.h:93
Structure to hold Image information.
Definition: helpers.h:131
__global uchar * ptr
Pointer to the starting postion of the buffer.
Definition: helpers.h:133