Compute Library
 20.05
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

◆ accumulate()

__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.

44 {
45  // Get pixels pointer
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:311
uint8_t add_sat(const uint8_t &a, const uint8_t &b)
Definition: add.h:33
Structure to hold Image information.
Definition: helpers.h:349
__global uchar * ptr
Pointer to the starting postion of the buffer.
Definition: helpers.h:351

References arm_compute::wrapper::add_sat(), CONVERT_TO_IMAGE_STRUCT, arm_compute::test::validation::input, and Image::ptr.

Referenced by arm_compute::calculate_matrix_scale(), Dimensions< int >::collapse(), arm_compute::detail::convolve_3x3(), arm_compute::data_type_for_convolution(), arm_compute::data_type_for_convolution_matrix(), arm_compute::helpers::fft::digit_reverse_indices(), arm_compute::test::join(), arm_compute::test::validation::reference::mean_and_standard_deviation(), arm_compute::pixel_area_c1u8_clamp(), SimpleTensor< uint8_t >::size(), OpenCLMemoryUsage::test_measurements(), TensorShape::total_size(), TensorShape::total_size_lower(), and TensorShape::total_size_upper().

◆ accumulate_squared()

__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.

116 {
117  // Get pixels pointer
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:311
Structure to hold Image information.
Definition: helpers.h:349
__global uchar * ptr
Pointer to the starting postion of the buffer.
Definition: helpers.h:351

References CONVERT_TO_IMAGE_STRUCT, arm_compute::test::validation::input, Image::ptr, and arm_compute::test::validation::shift.

◆ accumulate_weighted()

__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.

80 {
81  // Get pixels pointer
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:311
Structure to hold Image information.
Definition: helpers.h:349
__global uchar * ptr
Pointer to the starting postion of the buffer.
Definition: helpers.h:351

References arm_compute::test::validation::alpha, CONVERT_TO_IMAGE_STRUCT, arm_compute::test::validation::input, and Image::ptr.