Compute Library  18.03
derivative.cl File Reference
#include "helpers.h"

Go to the source code of this file.

Functions

__kernel void derivative (__global uchar *src_ptr, uint src_stride_x, uint src_step_x, uint src_stride_y, uint src_step_y, uint src_offset_first_element_in_bytes, __global uchar *dst_gx_ptr, uint dst_gx_stride_x, uint dst_gx_step_x, uint dst_gx_stride_y, uint dst_gx_step_y, uint dst_gx_offset_first_element_in_bytes, __global uchar *dst_gy_ptr, uint dst_gy_stride_x, uint dst_gy_step_x, uint dst_gy_stride_y, uint dst_gy_step_y, uint dst_gy_offset_first_element_in_bytes)
 This OpenCL kernel that computes the first-order derivative. More...
 

Function Documentation

__kernel void derivative ( __global uchar *  src_ptr,
uint  src_stride_x,
uint  src_step_x,
uint  src_stride_y,
uint  src_step_y,
uint  src_offset_first_element_in_bytes,
__global uchar *  dst_gx_ptr,
uint  dst_gx_stride_x,
uint  dst_gx_step_x,
uint  dst_gx_stride_y,
uint  dst_gx_step_y,
uint  dst_gx_offset_first_element_in_bytes,
__global uchar *  dst_gy_ptr,
uint  dst_gy_stride_x,
uint  dst_gy_step_x,
uint  dst_gy_stride_y,
uint  dst_gy_step_y,
uint  dst_gy_offset_first_element_in_bytes 
)

This OpenCL kernel that computes the first-order derivative.

Attention
To enable computation of the X gradient -DGRAD_X must be passed at compile time, while computation of the Y gradient is performed when -DGRAD_Y is used. You can use both when computation of both gradients is required.
Parameters
[in]src_ptrPointer to the source image. Supported data types: U8
[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_offset_first_element_in_bytesThe offset of the first element in the source image
[out]dst_gx_ptrPointer to the destination image. Supported data types: S16
[in]dst_gx_stride_xStride of the destination image in X dimension (in bytes)
[in]dst_gx_step_xdst_gx_stride_x * number of elements along X processed per workitem(in bytes)
[in]dst_gx_stride_yStride of the destination image in Y dimension (in bytes)
[in]dst_gx_step_ydst_gx_stride_y * number of elements along Y processed per workitem(in bytes)
[in]dst_gx_offset_first_element_in_bytesThe offset of the first element in the destination image
[out]dst_gy_ptrPointer to the destination image. Supported data types: S16
[in]dst_gy_stride_xStride of the destination image in X dimension (in bytes)
[in]dst_gy_step_xdst_gy_stride_x * number of elements along X processed per workitem(in bytes)
[in]dst_gy_stride_yStride of the destination image in Y dimension (in bytes)
[in]dst_gy_step_ydst_gy_stride_y * number of elements along Y processed per workitem(in bytes)
[in]dst_gy_offset_first_element_in_bytesThe offset of the first element in the destination image

Definition at line 50 of file derivative.cl.

References CONVERT_TO_IMAGE_STRUCT, offset(), Image::ptr, and arm_compute::test::validation::src.

Referenced by arm_compute::test::validation::DATA_TEST_CASE(), and DerivativeValidationFixture< TensorType, AccessorType, FunctionType, T, U >::setup().

61 {
63 #ifdef GRAD_X
64  Image dst_gx = CONVERT_TO_IMAGE_STRUCT(dst_gx);
65 #endif /* GRAD_X */
66 #ifdef GRAD_Y
67  Image dst_gy = CONVERT_TO_IMAGE_STRUCT(dst_gy);
68 #endif /* GRAD_Y */
69 
70 #ifdef GRAD_X
71  short16 l_data = convert_short16(vload16(0, offset(&src, -1, 0)));
72  short16 r_data = convert_short16(vload16(0, offset(&src, 1, 0)));
73  vstore16(r_data - l_data, 0, ((__global short *)dst_gx.ptr));
74 #endif /* GRAD_X */
75 #ifdef GRAD_Y
76  short16 t_data = convert_short16(vload16(0, offset(&src, 0, -1)));
77  short16 b_data = convert_short16(vload16(0, offset(&src, 0, 1)));
78  vstore16(b_data - t_data, 0, ((__global short *)dst_gy.ptr));
79 #endif /* GRAD_Y */
80 }
__global uchar * offset(const Image *img, int x, int y)
Get the pointer position of a Image.
Definition: helpers.h:301
#define CONVERT_TO_IMAGE_STRUCT(name)
Definition: helpers.h:102
Structure to hold Image information.
Definition: helpers.h:140
__global uchar * ptr
Pointer to the starting postion of the buffer.
Definition: helpers.h:142
convolution configure & src