Kernel for converting tensors of various datatypes and formats.
- Kernel requires input tensor ( \( X \)) to be available in memory
- The output tensor ( \( Y \)) is computed as shown below
- \(Y = (X - inZf) \times scale + outZf \\ \hspace{1.25ex} = X \times scale - (inZf \times scale + outZf) \\ \hspace{1.25ex} = X \times scale + q \)
- The quantization parameter ( \(q\)) is currently a scalar value similar to shift and scale
- When integer-to-integer conversion is involved:
- \(Y = ShiftAndRound(X \times scale + q \))
- Output pad (MMALIB_CNN_tensor_convert_ixX_oxX_InitArgs::outPad) is always zero if output tensor format is NHWC (MMALIB_HWC)
- Performance estimates is TBD, "Arch. Compute cyc." and "Est. Compute
cyc." are yet to be analyzed; right now printed as "0"
- Signedness of Scale: Scale is always signed and the same precision as the max precision involved in the conversion
- For example, scale is int16_t when converting from uint8_t to uint16_t
- Only the below conversion formats are supported
|
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...
|
|
◆ MMALIB_CNN_tensor_convert_ixX_oxX_getHandleSize()
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
◆ MMALIB_CNN_tensor_convert_ixX_oxX_init()
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
◆ MMALIB_CNN_tensor_convert_ixX_oxX_init_checkParams()
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
◆ MMALIB_CNN_tensor_convert_ixX_oxX_exec()
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:
-
◆ MMALIB_CNN_tensor_convert_ixX_oxX_exec_checkParams()
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
◆ MMALIB_CNN_tensor_convert_ixX_oxX_perfEst()
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 |