VXLIB User Guide
VXLIB_convolve

Introduction

Kernel for applying filterHeight x filterWidth convolution filter on input image, scaled by constant, and saturating the output to the output datatype numeric limits.

Performs a filterHeight x filterWidth convolution filter on an input * image. Filter dimensions are configured by passing accepted filter dimension through init args. Similarly, padded configuration can be set via init args (Padding = 0 * supported only for now). For non-padded implementation, user must set input image dimensions greater than or equal filter size. Output images will have the following dimensions: (inputHeight - filterHeight + 1, inputWidth - filterWidth + 1) Scale factor should be set to a positive power of 2. 3x3, 5x5, 7x7, 9x9 filter sizes have optimized performance The following datatype combinations are supported by this function:

Case Input Filter Output
0 uint8_t int16_t uint8_t
1 uint8_t int16_t int16_t
Method
 3x3 convolution Filter: dst(x,y) =
 (src(x+0,y+0)*f(0,0) + src(x+1,y+0)*f(0,1) + src(x+2,y+0)*f(0,2) +
  src(x+0,y+1)*f(1,0) + src(x+1,y+1)*f(1,1) + src(x+2,y+1)*f(1,2) +
  src(x+0,y+2)*f(2,0) + src(x+1,y+2)*f(2,1) + src(x+2,y+2)*f(2,2)) / scale

Data Structures

struct  VXLIB_convolve_InitArgs
 Structure containing the parameters to initialize the kernel. More...
 

Functions

int32_t VXLIB_convolve_getHandleSize (VXLIB_convolve_InitArgs *pKerInitArgs)
 This is a query function to calculate the size of internal handle. More...
 
VXLIB_STATUS VXLIB_convolve_init (VXLIB_kernelHandle handle, VXLIB_bufParams2D_t *bufParamsIn, VXLIB_bufParams2D_t *bufParamsFilter, VXLIB_bufParams2D_t *bufParamsOut, const VXLIB_convolve_InitArgs *pKerInitArgs)
 This function should be called before the VXLIB_convolve_exec function is called. This function takes care of any one-time operations such as setting up the configuration of required hardware resources such as the streaming engine. The results of these operations are stored in the handle. More...
 
VXLIB_STATUS VXLIB_convolve_init_checkParams (VXLIB_kernelHandle handle, const VXLIB_bufParams2D_t *bufParamsIn, const VXLIB_bufParams2D_t *bufParamsFilter, const VXLIB_bufParams2D_t *bufParamsOut, const VXLIB_convolve_InitArgs *pKerInitArgs)
 This function checks the validity of the parameters passed to VXLIB_convolve_init function. This function is called with the same parameters as the VXLIB_convolve_init, and this function must be called before the VXLIB_convolve_init is called. More...
 
VXLIB_STATUS VXLIB_convolve_exec_checkParams (VXLIB_kernelHandle handle, const void *restrict pIn, const void *restrict pFilter, const void *restrict pOut)
 This function checks the validity of the parameters passed to VXLIB_convolve_exec function. This function is called with the same parameters as the VXLIB_convolve_init, and this function must be called before the VXLIB_convolve_init is called. More...
 
VXLIB_STATUS VXLIB_convolve_exec (VXLIB_kernelHandle handle, void *restrict pIn, void *restrict pFilter, void *restrict pOut)
 This function is the main kernel compute function. More...
 
void VXLIB_convolve_perfEst (VXLIB_kernelHandle handle, size_t *archCycles, size_t *estCycles)
 

Function Documentation

◆ VXLIB_convolve_getHandleSize()

int32_t VXLIB_convolve_getHandleSize ( VXLIB_convolve_InitArgs pKerInitArgs)

This is a query function to calculate the size of internal handle.

Parameters
[in]pKerInitArgs: Pointer to structure holding init parameters
Returns
Size of the buffer in bytes
Remarks
Application is expected to allocate buffer of the requested size and provide it as input to other functions requiring it.

Definition at line 52 of file VXLIB_convolve.cpp.

◆ VXLIB_convolve_init()

VXLIB_STATUS VXLIB_convolve_init ( VXLIB_kernelHandle  handle,
VXLIB_bufParams2D_t bufParamsIn,
VXLIB_bufParams2D_t bufParamsFilter,
VXLIB_bufParams2D_t bufParamsOut,
const VXLIB_convolve_InitArgs pKerInitArgs 
)

This function should be called before the VXLIB_convolve_exec function is called. This function takes care of any one-time operations such as setting up the configuration of required hardware resources such as the streaming engine. The results of these operations are stored in the handle.

Parameters
[in]handle: Active handle to the kernel
[in]bufParamsIn: Pointer to the structure containing dimensional information of input image
[in]bufParamsFilter: Pointer to the structure containing dimensional information of the convolution filter
[out]bufParamsOut: Pointer to the structure containing dimensional information of output image
[in]pKerInitArgs: Pointer to the structure holding init parameters
Returns
Status value indicating success or failure. Refer to VXLIB_STATUS.
Remarks
Application is expected to provide a valid handle.

Definition at line 171 of file VXLIB_convolve.cpp.

◆ VXLIB_convolve_init_checkParams()

VXLIB_STATUS VXLIB_convolve_init_checkParams ( VXLIB_kernelHandle  handle,
const VXLIB_bufParams2D_t bufParamsIn,
const VXLIB_bufParams2D_t bufParamsFilter,
const VXLIB_bufParams2D_t bufParamsOut,
const VXLIB_convolve_InitArgs pKerInitArgs 
)

This function checks the validity of the parameters passed to VXLIB_convolve_init function. This function is called with the same parameters as the VXLIB_convolve_init, and this function must be called before the VXLIB_convolve_init is called.

Parameters
[in]handle: Active handle to the kernel
[in]bufParamsIn: Pointer to the structure containing dimensional information of input image
[in]bufParamsFilter: Pointer to the structure containing dimensional information of the convolution filter
[out]bufParamsOut: Pointer to the structure containing dimensional information of output image
[in]pKerInitArgs: Pointer to the structure holding init parameters
Returns
Status value indicating success or failure. Refer to VXLIB_STATUS.
Remarks
None

Definition at line 66 of file VXLIB_convolve.cpp.

◆ VXLIB_convolve_exec_checkParams()

VXLIB_STATUS VXLIB_convolve_exec_checkParams ( VXLIB_kernelHandle  handle,
const void *restrict  pIn,
const void *restrict  pFilter,
const void *restrict  pOut 
)

This function checks the validity of the parameters passed to VXLIB_convolve_exec function. This function is called with the same parameters as the VXLIB_convolve_init, and this function must be called before the VXLIB_convolve_init is called.

Parameters
[in]handle: Active handle to the kernel
[in]pIn: Pointer to the structure input image
[in]pFilterPointer to the structure input filter
[out]pOut: Pointer to the output image
Returns
Status value indicating success or failure. Refer to VXLIB_STATUS.
Remarks
None

Definition at line 144 of file VXLIB_convolve.cpp.

◆ VXLIB_convolve_exec()

VXLIB_STATUS VXLIB_convolve_exec ( VXLIB_kernelHandle  handle,
void *restrict  pIn,
void *restrict  pFilter,
void *restrict  pOut 
)

This function is the main kernel compute function.

Please refer to details under VXLIB_convolve_exec

Parameters
[in]handle: Active handle to the kernel
[in]pIn: Pointer to the structure input image
[in]pFilterPointer to the structure input filter
[out]pOut: Pointer to the output image
Returns
Status value indicating success or failure. Refer to VXLIB_STATUS.
Assumptions:
  • None
Performance Considerations:
For best performance,
  • the input and output data image are expected to be in L2 memory
  • the buffer pointers are assumed to be 64-byte aligned
Remarks
Before calling this function, application is expected to call VXLIB_convolve_init and VXLIB_convolve_exec_checkParams functions. This ensures resource configuration and error checks are done only once for several invocations of this function.

Definition at line 249 of file VXLIB_convolve.cpp.

◆ VXLIB_convolve_perfEst()

void VXLIB_convolve_perfEst ( VXLIB_kernelHandle  handle,
size_t *  archCycles,
size_t *  estCycles 
)

Definition at line 1838 of file VXLIB_convolve_ci.cpp.