MMALIB User Guide
MMALIB_CNN_tensor_convert_ixX_oxX

Introduction

Kernel for converting tensors of various datatypes and formats.

Data Structures

struct  MMALIB_CNN_tensor_convert_ixX_oxX_InitArgs
 Structure containing the parameters initialization of tensor convert function. More...
 
struct  MMALIB_CNN_tensor_convert_ixX_oxX_ExecInArgs
 This structure holds all the runtime input parameters for tensor convert kernel. More...
 
struct  MMALIB_CNN_tensor_convert_ixX_oxX_ExecOutArgs
 This structure holds all the runtime output parameters for tensor convert kernel. More...
 

Functions

int32_t MMALIB_CNN_tensor_convert_ixX_oxX_getHandleSize (MMALIB_CNN_tensor_convert_ixX_oxX_InitArgs *pKerInitArgs)
 This is a query function to calculate the size of internal handle. More...
 
MMALIB_STATUS MMALIB_CNN_tensor_convert_ixX_oxX_init (MMALIB_kernelHandle handle, const MMALIB_bufParams3D_t *src_addr, const MMALIB_bufParams1D_t *scale_addr, const MMALIB_bufParams3D_t *dst_addr, const MMALIB_CNN_tensor_convert_ixX_oxX_InitArgs *pKerInitArgs)
 This function call is required to initialize the handle. In this function, most of the one-time operations are performed and results are stored in handle. More...
 
MMALIB_STATUS MMALIB_CNN_tensor_convert_ixX_oxX_init_checkParams (MMALIB_kernelHandle handle, const MMALIB_bufParams3D_t *src_addr, const MMALIB_bufParams1D_t *scale_addr, const MMALIB_bufParams3D_t *dst_addr, const MMALIB_CNN_tensor_convert_ixX_oxX_InitArgs *pKerInitArgs)
 This function checks the validity of the input parameters. More...
 
MMALIB_STATUS MMALIB_CNN_tensor_convert_ixX_oxX_exec (MMALIB_kernelHandle handle, const void *src, const void *scale, const uint8_t *shift, const void *q, void *dst, const MMALIB_CNN_tensor_convert_ixX_oxX_ExecInArgs *pKerInArgs, MMALIB_CNN_tensor_convert_ixX_oxX_ExecOutArgs *pKerOutArgs)
 This function is the main compute function, and performs the tensor datatype conversion. More...
 
MMALIB_STATUS MMALIB_CNN_tensor_convert_ixX_oxX_exec_checkParams (MMALIB_kernelHandle handle, const void *src, const void *scale, const uint8_t *shift, const void *q, void *dst, const MMALIB_CNN_tensor_convert_ixX_oxX_ExecInArgs *pKerInArgs, MMALIB_CNN_tensor_convert_ixX_oxX_ExecOutArgs *pKerOutArgs)
 This function checks the parameters and should be called before kernel executuon. It can be called once. More...
 
void MMALIB_CNN_tensor_convert_ixX_oxX_perfEst (MMALIB_kernelHandle handle, const MMALIB_bufParams3D_t *src_addr, const MMALIB_bufParams3D_t *dst_addr, uint64_t *idealCycles, uint64_t *archCycles, uint64_t *estCycles)
 This function estimates the kernel performance. More...
 

Function Documentation

◆ MMALIB_CNN_tensor_convert_ixX_oxX_getHandleSize()

int32_t MMALIB_CNN_tensor_convert_ixX_oxX_getHandleSize ( MMALIB_CNN_tensor_convert_ixX_oxX_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.

◆ MMALIB_CNN_tensor_convert_ixX_oxX_init()

MMALIB_STATUS MMALIB_CNN_tensor_convert_ixX_oxX_init ( MMALIB_kernelHandle  handle,
const MMALIB_bufParams3D_t src_addr,
const MMALIB_bufParams1D_t scale_addr,
const MMALIB_bufParams3D_t dst_addr,
const MMALIB_CNN_tensor_convert_ixX_oxX_InitArgs pKerInitArgs 
)

This function call is required to initialize the handle. In this function, most of the one-time operations are performed and results are stored in handle.

Parameters
[in]handle: Active handle to the kernel
[in]src_addr: Pointer to structure containing dimensional information of src (input tensor)
[in]scale_addr: Pointer to structure containing dimensional
[out]dst_addr: Pointer to structure containing dimensional information of dst (output tensor)
[in]pKerInitArgs: Pointer to structure holding init parameters
Returns
Status of success or Error with Error Codes
Remarks
Application is expected to do provide valid handle

◆ MMALIB_CNN_tensor_convert_ixX_oxX_init_checkParams()

MMALIB_STATUS MMALIB_CNN_tensor_convert_ixX_oxX_init_checkParams ( MMALIB_kernelHandle  handle,
const MMALIB_bufParams3D_t src_addr,
const MMALIB_bufParams1D_t scale_addr,
const MMALIB_bufParams3D_t dst_addr,
const MMALIB_CNN_tensor_convert_ixX_oxX_InitArgs pKerInitArgs 
)

This function checks the validity of the input parameters.

Parameters
[in]handle: Active handle to the kernel
[in]src_addr: Pointer to structure containing dimensional information of src (input tensor)
[in]scale_addr: Pointer to structure containing dimensional information of scale
[out]dst_addr: Pointer to structure containing dimensional information of dst (output tensor)
[in]pKerInitArgs: Pointer to structure holding init parameters
Returns
Status of success or Error with Error Codes
Remarks
Application is expected to do provide valid handle

◆ MMALIB_CNN_tensor_convert_ixX_oxX_exec()

MMALIB_STATUS MMALIB_CNN_tensor_convert_ixX_oxX_exec ( MMALIB_kernelHandle  handle,
const void *  src,
const void *  scale,
const uint8_t *  shift,
const void *  q,
void *  dst,
const MMALIB_CNN_tensor_convert_ixX_oxX_ExecInArgs pKerInArgs,
MMALIB_CNN_tensor_convert_ixX_oxX_ExecOutArgs pKerOutArgs 
)

This function is the main compute function, and performs the tensor datatype conversion.

TBD

Parameters
[in]handle: Active handle to the kernel
[in]src[]: Pointer to buffer holding input tensor
[in]scale[]: Pointer to buffer holding scale
[in]shift[]: Pointer to buffer holding shift
[in]q[]: Pointer to buffer holding quantization parameter
[out]dst[]: Pointer to buffer holding output tensor
[in]pKerInArgs: Pointer to structure holding args used during kernel execution
[out]pKerOutArgs: Pointer to structure holding args generated during kernel execution (unused for now)
Returns
Status of success or Error with Error Codes
Assumptions:
  • I/O buffer pointers are assumed to be not aliased.
Performance Considerations:
  • TBD
Remarks
Application is expected to do call of checkParams function prior to this function as it avoids check of paramaters for each invocation for optimization

◆ MMALIB_CNN_tensor_convert_ixX_oxX_exec_checkParams()

MMALIB_STATUS MMALIB_CNN_tensor_convert_ixX_oxX_exec_checkParams ( MMALIB_kernelHandle  handle,
const void *  src,
const void *  scale,
const uint8_t *  shift,
const void *  q,
void *  dst,
const MMALIB_CNN_tensor_convert_ixX_oxX_ExecInArgs pKerInArgs,
MMALIB_CNN_tensor_convert_ixX_oxX_ExecOutArgs pKerOutArgs 
)

This function checks the parameters and should be called before kernel executuon. It can be called once.

Parameters
[in]handle: Active handle to the kernel
[in]src[]: Pointer to buffer holding input tensor
[in]scale[]: Pointer to buffer holding scale
[in]shift[]: Pointer to buffer holding shift
[in]q[]: Pointer to buffer holding quantization parameter
[out]dst[]: Pointer to buffer holding output tensor
[in]pKerInArgs: Pointer to structure holding args used during kernel execution
[out]pKerOutArgs: Pointer to structure holding args generated during kernel execution (unused for now)
Returns
Status of success or Error with Error Codes
Remarks
None

◆ MMALIB_CNN_tensor_convert_ixX_oxX_perfEst()

void MMALIB_CNN_tensor_convert_ixX_oxX_perfEst ( MMALIB_kernelHandle  handle,
const MMALIB_bufParams3D_t src_addr,
const MMALIB_bufParams3D_t dst_addr,
uint64_t *  idealCycles,
uint64_t *  archCycles,
uint64_t *  estCycles 
)

This function estimates the kernel performance.

Parameters
[in]handle: Active handle to the kernel
[in]src_addr: Pointer to structure containing dimensional information of src (input tensor)
[in]dst_addr: Pointer to structure containing dimensional information of dst (output tensor)
[out]idealCycles: TBD
[out]archCycles: TBD
[out]estCycles: Cycles estimated for the compute, startup, teardown and any associated overhead
Remarks
This function is only a crude estimation Performance of interger to integer conversion can degrade by 2x due to unaligned memory accesses