MMALIB User Guide
MMALIB_CNN_convolve_row_ixX_ixX_oxX.h
Go to the documentation of this file.
1 /******************************************************************************
2 * *
3 * module name :MMALIB *
4 * *
5 * module descripton :Matrix Multiply Accelerator Library module for C7x+MMA *
6 * *
7 * Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/ *
8 * ALL RIGHTS RESERVED *
9 * *
10 ******************************************************************************/
23 #ifndef MMALIB_CNN_CONVOLVE_ROW_IXX_IXX_OXX_H_
24 #define MMALIB_CNN_CONVOLVE_ROW_IXX_IXX_OXX_H_
25 
26 #include "../../common/MMALIB_types.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
63 /* @{ */
64 
68 typedef enum
69 {
73 
74 
79 typedef struct
80 {
82  int8_t funcStyle;
84  int32_t No;
87  int32_t inChOffset;
108  int32_t validColsIn;
116  int32_t validRowsIn;
125  int32_t inWidth;
128  int32_t pad;
130  int32_t maxHeight;
144  int32_t subMChannels;
149  int32_t shift;
151  int32_t Fr;
153  int32_t Fc;
155  int32_t strideX;
157  int32_t strideY;
159  int32_t dilationX;
161  int32_t dilationY;
163  int32_t bias;
165  uint8_t activationType;
168  uint8_t mode;
175  int32_t numBiasVals;
176 
178 
184 typedef struct
185 {
191  int32_t validColsIn;
201  int32_t validRowsIn;
205  int32_t pad;
208  int32_t subMChannels;
214  int32_t bufferReset;
215 
217 
223 typedef struct
224 {
225  int32_t dataType;
226  int32_t Ni;
227  int32_t No;
228  int32_t Fr;
229  int32_t Fc;
230  int32_t strideX;
231  int32_t strideY;
232  int32_t dilationX;
233  int32_t dilationY;
234  int32_t numBiasVals;
235  int32_t subMChannels;
236  int32_t inWidth;
237  int32_t pad;
238  int32_t validColsIn;
241 
246 typedef struct
247 {
255  int32_t validColsOut;
263  int32_t validRowsOut;
265 
266 
277 
278 
299  MMALIB_kernelHandle handle,
300  const MMALIB_bufParams2D_t * src0_addr,
301  const MMALIB_bufParams2D_t * src1_addr,
302  const MMALIB_bufParams3D_t * dst_addr ,
304 
325  MMALIB_kernelHandle handle,
326  const MMALIB_bufParams2D_t * src0_addr,
327  const MMALIB_bufParams2D_t * src1_addr,
328  const MMALIB_bufParams3D_t * dst_addr,
330 
379  MMALIB_kernelHandle handle,
380  const void *src0,
381  const void *src1,
382  void *dst,
385 
386 
403  MMALIB_kernelHandle handle,
404  const void *src0,
405  const void *src1,
406  void *dst,
408 
428  MMALIB_kernelHandle handle,
429  int32_t inputWidth,
430  int32_t pad,
431  int32_t inputHeight,
432  int32_t mmaWidth,
433  int32_t MChannels,
434  int32_t subMChannels);
435 
451  int32_t inputWidth,
452  int32_t pad,
453  int32_t inputHeight,
454  int32_t mmaWidth,
455  int32_t MChannels,
456  int32_t subMChannels);
457 
458 
459 /******************************************************************************/
476 /******************************************************************************/
477 
479  const void *restrict pWeights,
480  void *restrict pReorderWeights,
481  void *restrict pBias,
482  const MMALIB_bufParams2D_t * src0_addr,
483  const MMALIB_bufParams2D_t * src2_addr,
486 
487 /******************************************************************************/
498 
499 /******************************************************************************/
511 /******************************************************************************/
512 
514  MMALIB_bufParams2D_t * src0_addr,
517 
526 
546  const MMALIB_bufParams2D_t *src0_addr,
547  const MMALIB_bufParams2D_t *src1_addr,
548  const MMALIB_bufParams3D_t *dst_addr,
552  int32_t iterN,
553  uint64_t *archCycles,
554  uint64_t *estCycles);
555 
557 #ifdef __cplusplus
558 }
559 #endif
560 #endif /* _MMALIB_CNN_CONVOLVE_ROW_IXX_IXX_OXX_H_ */
561 
562 /* ======================================================================== */
563 /* End of file: MMALIB_CNN_convolve_row_ixX_ixX_oxX.h */
564 /* ======================================================================== */
565 
int32_t MMALIB_CNN_seamPredicateRegistersSizeDefault()
This function generates the predicate registers once per layer.
void MMA_CNNLIB_convolveBiasReLUCompute_ixX_ixX_oxX_perfEst(const MMALIB_bufParams2D_t *src0_addr, const MMALIB_bufParams2D_t *src1_addr, const MMALIB_bufParams3D_t *dst_addr, MMALIB_CNN_convolve_row_ixX_ixX_oxX_InitArgs *pKerInitArgs, const MMALIB_CNN_convolve_row_ixX_ixX_oxX_ExecInArgs *pKerInArgs, MMALIB_CNN_convolve_row_ixX_ixX_oxX_ExecOutArgs *pKerOutArgs, int32_t iterN, uint64_t *archCycles, uint64_t *estCycles)
This function generates the performance of MMALIB kernels.
int32_t MMALIB_CNN_convolve_row_reorderWeightsBufferSize(MMALIB_bufParams2D_t *src0_addr, MMALIB_CNN_convolve_row_ixX_ixX_oxX_reorderWeights_Args *reorderWeights, const MMALIB_CNN_convolve_row_ixX_ixX_oxX_InitArgs *pKerInitArgs)
This function return the buffer size for M < 1 and K < 1 cases.
int32_t MMALIB_CNN_seamPredicateRegistersSize(int32_t inputWidth, int32_t pad, int32_t inputHeight, int32_t mmaWidth, int32_t MChannels, int32_t subMChannels)
This function provides total bytes needed for seam insertion buffer.
MMALIB_STATUS MMALIB_CNN_convolve_row_ixX_ixX_oxX_exec_checkParams(MMALIB_kernelHandle handle, const void *src0, const void *src1, void *dst, const MMALIB_CNN_convolve_row_ixX_ixX_oxX_ExecInArgs *pKerInArgs)
This function checks the parameters and should be called before kernel executuon. It can be called on...
MMALIB_STATUS MMALIB_CNN_convolve_row_ixX_ixX_oxX_exec(MMALIB_kernelHandle handle, const void *src0, const void *src1, void *dst, const MMALIB_CNN_convolve_row_ixX_ixX_oxX_ExecInArgs *pKerInArgs, MMALIB_CNN_convolve_row_ixX_ixX_oxX_ExecOutArgs *pKerOutArgs)
This function is the main compute function, and performs the convolution primitive (conv + ReLU) for ...
int32_t MMALIB_CNN_convolve_row_reorderWeights(const void *restrict pWeights, void *restrict pReorderWeights, void *restrict pBias, const MMALIB_bufParams2D_t *src0_addr, const MMALIB_bufParams2D_t *src2_addr, MMALIB_CNN_convolve_row_ixX_ixX_oxX_reorderWeights_Args *reorderWeights, const MMALIB_CNN_convolve_row_ixX_ixX_oxX_InitArgs *pKerInitArgs)
This function reorder the weights for M < 1 and K < 1 cases.
int32_t MMALIB_CNN_generateFillSeamPredicateRegisters(MMALIB_kernelHandle handle, int32_t inputWidth, int32_t pad, int32_t inputHeight, int32_t mmaWidth, int32_t MChannels, int32_t subMChannels)
This function generates the predicate registers once per layer Predicate buffers are create to identi...
MMALIB_STATUS MMALIB_CNN_convolve_row_ixX_ixX_oxX_init_checkParams(MMALIB_kernelHandle handle, const MMALIB_bufParams2D_t *src0_addr, const MMALIB_bufParams2D_t *src1_addr, const MMALIB_bufParams3D_t *dst_addr, const MMALIB_CNN_convolve_row_ixX_ixX_oxX_InitArgs *pKerInitArgs)
This function call is required to initialize the handle. In this function most of the one time operat...
int32_t MMALIB_CNN_convolve_row_reorderWeightsFlag(MMALIB_CNN_convolve_row_ixX_ixX_oxX_reorderWeights_Args *reorderWeights)
This function return the flag for M < 1 and K < 1 cases.
MMALIB_STATUS MMALIB_CNN_convolve_row_ixX_ixX_oxX_init(MMALIB_kernelHandle handle, const MMALIB_bufParams2D_t *src0_addr, const MMALIB_bufParams2D_t *src1_addr, const MMALIB_bufParams3D_t *dst_addr, const MMALIB_CNN_convolve_row_ixX_ixX_oxX_InitArgs *pKerInitArgs)
This function call is required to initialize the handle. In this function most of the one time operat...
int32_t MMALIB_CNN_convolve_row_ixX_ixX_oxX_getHandleSize(MMALIB_CNN_convolve_row_ixX_ixX_oxX_InitArgs *pKerInitArgs)
This is a query function to calculate the size of internal handle.
MMALIB_CNN_CONVOLVE_ROW_IXX_IXX_OXX_STATUS_NAME
Enum to define the error codes.
@ MMALIB_CNN_CONVOLVE_ROW_IXX_IXX_OXX_ERR_MAX
@ MMALIB_CNN_CONVOLVE_ROW_IXX_IXX_OXX_ERR_SMALL_K
MMALIB_STATUS_NAME
The enumeration of all status codes.
Definition: MMALIB_types.h:176
@ MMALIB_ERROR_MAX
Definition: MMALIB_types.h:190
void * MMALIB_kernelHandle
Handle type for MMALIB operations.
Definition: MMALIB_types.h:279
Structure containing the parameters for input to the execute phase of CNN convolution computation.
int32_t bufferReset
Reset the buffers so that handle is not reloaded 0: no reset 1: reset. SE, SA, MMA and Predicate buff...
int32_t subMChannels
Number of output channels per kernel call in execute phase This parameter is not used,...
int32_t validColsPerRowIn
Valid columns in a row of input feature maps for one call of processing of the kernel for strided con...
int32_t validRowsIn
Valid input rows of input feature maps for one call of processing of the kernel for strided convoluti...
int32_t pad
Pad of each row of input feature map, specify pad only on one side in execute phase....
int32_t validColsIn
Valid columns in a row of input feature maps for one call of processing of the kernel for non strided...
Structure containing the parameters for output from the execute phase of CNN convolution computation.
int32_t validRowsOut
Valid output rows of output feature maps for one call of processing of the kernel for strided convolu...
int32_t validColsOut
Valid columns out in a row of output feature maps for one call of processing of the kernel for non st...
int32_t validColsPerRowOut
Valid columns in a row of output feature maps for one call of processing of the kernel for strided co...
Structure containing the parameters initialization of CNN convolution computation.
int32_t validColsPerRowIn
Valid columns in a row of input feature maps for one call of processing of the kernel for strided con...
int8_t funcStyle
Variant of the function refer to MMALIB_FUNCTION_STYLE
int32_t pad
Pad of each row of input feature map, specify pad only on one side and for strided flow the Pad is on...
int32_t bias
bias value in B matrix same as data type of B matrix
uint8_t mode
mode for input feature map in Circular or Linear mode in B matrix
int32_t dilationX
dilation of coefficients of columns
int32_t subMChannels
Number of output channels per kernel call.
int32_t validColsIn
Valid columns of input feature maps in B matrix for one call of processing of the kernel for non stri...
int32_t inputPitchPerRow
Valid pitch for each input rows of input feature maps for strided convolution. This is in units of by...
uint8_t weightReorderFlag
MChannel < mma width and NiFrFc < mma width for non strided cases blocks processing > 2,...
int32_t numGroupsPerKernel
number of groups per kernel call > 1 will enable processing when No <= MMA size for non strided kerne...
int32_t outputPitchPerRow
Valid output pitch for each output rows of output feature maps for strided convolution....
int32_t numBiasVals
Number of elements used for the bias (cols in weights, rows in feature maps)
uint8_t activationType
activation RELU, SAT or none for output
int32_t validRowsIn
Valid input rows of input feature maps for one call of processing of the kernel for strided convoluti...
int32_t inChOffset
offset of the input feature maps in B matrix. This is power of 2 for circular buffer and atleast 64 b...
int32_t maxHeight
Height of the input feature map in units of data type
int32_t inWidth
Width of each row of input feature map in units of data type
This structure holds all the input parameters for reordering CNN filter weights for row convolution k...
int32_t numBiasVals
Number of elements used for the bias (cols in weights, rows in feature maps)
int32_t dataType
Data type must be a member of MMALIB_data_type_e.
int32_t numGroupsPerKernel
Number of groups to be processed in kernel call.
A structure for a 2 dimensional buffer descriptor.
A structure for a 3 dimensional buffer descriptor.