PSOC E8XXGP Device Support Library

General Description

Functions

void Cy_NNLite_LeakyRelUPWLActivation (float alpha_scale, float unit_scale, cy_nn_act_intrpl_param_t *leakyRelU)
 Set PWL interpolation parameters for LeakyRElU activation. More...
 
cy_en_nnlite_status_t Cy_NNLite_Convolution (const int8_t *inputData, int8_t *outData, const cy_nn_dims_t *inputDims, const cy_nn_dims_t *outputDims, const cy_nn_dims_t *filterDims, const int8_t *filterData, const int32_t *biasData, cy_nn_conv_params_t *convParam, cy_en_nnlite_fused_activation_t actType, cy_nn_act_intrpl_param_t *intrplParam)
 2D Convolution CPU mode kernel API, API will configure nnlite and then start nnlite operation.API will work in blocking mode if callback function in Kernel config structure is NULL, if valid callback function is passed in Kernel config, API will be non-blocking and callback function will be called after completion of layer, caller need to wait for callback function before calling another Kernel API, else error will be for other function More...
 
cy_en_nnlite_status_t Cy_NNLite_ConvolutionDMA (const int8_t *inputData, int8_t *outData, const cy_nn_dims_t *inputDims, const cy_nn_dims_t *outputDims, const cy_nn_dims_t *filterDims, const int8_t *filterData, const int32_t *biasData, cy_nn_conv_params_t *convParam, cy_en_nnlite_fused_activation_t actType, cy_nn_act_intrpl_param_t *intrplParam)
 2D Convolution DMA mode kernel API, API will configure DMA descriptor pointing nnlite MEMIO configuration structure. More...
 
cy_en_nnlite_status_t Cy_NNLite_DepthwiseConvolution (const int8_t *inputData, int8_t *outData, const cy_nn_dims_t *inputDims, const cy_nn_dims_t *outputDims, const cy_nn_dims_t *filterDims, const int8_t *filterData, const int32_t *biasData, cy_nn_conv_params_t *convParam, cy_en_nnlite_fused_activation_t actType, cy_nn_act_intrpl_param_t *intrplParam)
 Depthwise Convolution CPU mode kernel API, API will work in blocking mode if callback function in Kernel config structure is NULL, if valid callback function is passed in Kernel config, API will be non-blocking and callback function will be called after completion of layer, caller need to wait for callback function before calling another Kernel API, else error will be for other function. More...
 
cy_en_nnlite_status_t Cy_NNLite_DepthwiseConvolutionDMA (const int8_t *inputData, int8_t *outData, const cy_nn_dims_t *inputDims, const cy_nn_dims_t *outputDims, const cy_nn_dims_t *filterDims, const int8_t *filterData, const int32_t *biasData, cy_nn_conv_params_t *convParam, cy_en_nnlite_fused_activation_t actType, cy_nn_act_intrpl_param_t *intrplParam)
 Depthwise DMA mode kernel API, API will configure DMA descriptor pointing nnlite MEMIO configuration structure. More...
 
cy_en_nnlite_status_t Cy_NNLite_FullyConnected (const int8_t *inputData, int8_t *outData, const cy_nn_dims_t *inputDims, const cy_nn_dims_t *outputDims, const cy_nn_dims_t *filterDims, const int8_t *filterData, const int32_t *biasData, cy_nn_fc_params_t *fcParam, cy_en_nnlite_fused_activation_t actType, cy_nn_act_intrpl_param_t *intrplParam)
 Fully connected CPU mode kernel API, API will configure nnlite and then start nnlite operation.API will work in blocking mode For case inputDims->dims[0] > 1,scratch buffer is required scratch buffer size in CPU should be calculated using Cy_NNLite_FC_ScratchBufSize API if callback function in Kernel config structure is NULL, if valid callback function is passed in Kernel config, API will be non-blocking and callback function will be called after completion of layer, caller need to wait for callback function before calling another Kernel API, else error will be for other function. More...
 
cy_en_nnlite_status_t Cy_NNLite_FullyConnectedDMA (const int8_t *inputData, int8_t *outData, const cy_nn_dims_t *inputDims, const cy_nn_dims_t *outputDims, const cy_nn_dims_t *filterDims, const int8_t *filterData, const int32_t *biasData, cy_nn_fc_params_t *fcParam, cy_en_nnlite_fused_activation_t actType, cy_nn_act_intrpl_param_t *intrplParam)
 Fully connected DMA mode kernel API, API will configure DMA descriptor pointing nnlite MEMIO configuration structure. More...
 
cy_en_nnlite_status_t Cy_NNLite_Avgpool (const int8_t *inputData, int8_t *outData, const cy_nn_dims_t *inputDims, const cy_nn_dims_t *outputDims, const cy_nn_dims_t *filterDims, cy_nn_pool_params_t *avgpoolParam)
 Average pool CPU mode kernel API, API will configure nnlite. More...
 
cy_en_nnlite_status_t Cy_NNLite_AvgpoolDMA (const int8_t *inputData, int8_t *outData, const cy_nn_dims_t *inputDims, const cy_nn_dims_t *outputDims, const cy_nn_dims_t *filterDims, cy_nn_pool_params_t *avgpoolParam)
 Average pool CPU mode kernel API, API will configure DMA descriptor pointing nnlite MEMIO configuration structure. More...
 
cy_en_nnlite_status_t Cy_NNLite_Maxpool (const int8_t *inputData, int8_t *outData, const cy_nn_dims_t *inputDims, const cy_nn_dims_t *outputDims, const cy_nn_dims_t *filterDims, cy_nn_pool_params_t *poolParam)
 Max pool CPU mode kernel API, API will configure nnlite. More...
 
cy_en_nnlite_status_t Cy_NNLite_MaxpoolDMA (const int8_t *inputData, int8_t *outData, const cy_nn_dims_t *inputDims, const cy_nn_dims_t *outputDims, const cy_nn_dims_t *filterDims, cy_nn_pool_params_t *poolParam)
 Max pool CPU mode kernel API, API will configure DMA descriptor pointing nnlite MEMIO configuration structure. More...
 
cy_en_nnlite_status_t Cy_NNLite_Scaling_Setup (cy_nn_scaling_t *ss, float lhs_scale, float rhs_scale, float output_scale, cy_en_nnlite_activation_size_t input_size, cy_en_nnlite_op_t op_type, cy_en_nnlite_fused_activation_t act_type)
 Precomputation of NPU scaling factor settings for NPU binary operations. More...
 
void Cy_NNLite_Scaling_Q_Setup (cy_nn_scaling_t *ss)
 Set scaling configuration to "no scaling" (fast) More...
 
cy_en_nnlite_status_t Cy_NNLite_AddSubMul (const int8_t *lhsData, const int8_t *rhsData, int8_t *outData, const cy_nn_dims_t *lhsDims, const cy_nn_dims_t *rhsOutDims, const cy_nn_pwise_binary_params_t *pwParams, cy_en_nnlite_op_t op_type, cy_en_nnlite_fused_activation_t act_type)
 Generic binary op CPU mode kernel API, API will configure nnlite. More...
 
cy_en_nnlite_status_t Cy_NNLite_AddSubMulDMA (const int8_t *lhsData, const int8_t *rhsData, int8_t *outData, const cy_nn_dims_t *lhsDims, const cy_nn_dims_t *rhsOutDims, const cy_nn_pwise_binary_params_t *pwParams, cy_en_nnlite_op_t op_type, cy_en_nnlite_fused_activation_t act_type)
 Generic binary op CPU mode kernel API, API will configure DMA descriptor pointing nnlite MEMIO configuration structure. More...
 
cy_en_nnlite_status_t Cy_NNLite_Add (const int8_t *lhsData, const int8_t *rhsData, int8_t *outData, const cy_nn_dims_t *lhsDims, const cy_nn_dims_t *rhsOutDims, const cy_nn_pwise_binary_params_t *pwParams)
 Pointwise addition operation. More...
 
cy_en_nnlite_status_t Cy_NNLite_AddDMA (const int8_t *lhsData, const int8_t *rhsData, int8_t *outData, const cy_nn_dims_t *lhsDims, const cy_nn_dims_t *rhsOutDims, const cy_nn_pwise_binary_params_t *pwParams)
 Pointwise addition operation. More...
 
cy_en_nnlite_status_t Cy_NNLite_Sub (const int8_t *lhsData, const int8_t *rhsData, int8_t *outData, const cy_nn_dims_t *lhsDims, const cy_nn_dims_t *rhsOutDims, const cy_nn_pwise_binary_params_t *pwParams, bool left_from_right)
 Pointwise addition operation. More...
 
cy_en_nnlite_status_t Cy_NNLite_SubDMA (const int8_t *lhsData, const int8_t *rhsData, int8_t *outData, const cy_nn_dims_t *lhsDims, const cy_nn_dims_t *rhsOutDims, const cy_nn_pwise_binary_params_t *pwParams, bool left_from_right)
 Pointwise addition operation. More...
 
cy_en_nnlite_status_t Cy_NNLite_Mul (const int8_t *lhsData, const int8_t *rhsData, int8_t *outData, const cy_nn_dims_t *lhsDims, const cy_nn_dims_t *rhsOutDims, const cy_nn_pwise_binary_params_t *pwParams)
 multiplication More...
 
cy_en_nnlite_status_t Cy_NNLite_MulDMA (const int8_t *lhsData, const int8_t *rhsData, int8_t *outData, const cy_nn_dims_t *lhsDims, const cy_nn_dims_t *rhsOutDims, const cy_nn_pwise_binary_params_t *pwParams)
 Pointwise multiplication with simple broadcast. More...
 
cy_en_nnlite_status_t Cy_NNLite_Activation (const int8_t *inData, int8_t *outData, const cy_nn_dims_t *inoutDims, const cy_nn_pwise_unary_params_t *actParams, cy_en_nnlite_fused_activation_t act_type, cy_nn_act_intrpl_param_t *intrplParam)
 Unfused Activation function CPU mode kernel API, API will configure nnlite and then start nnlite operation. More...
 
cy_en_nnlite_status_t Cy_NNLite_ActivationDMA (const int8_t *inData, int8_t *outData, const cy_nn_dims_t *inoutDims, const cy_nn_pwise_unary_params_t *actParams, cy_en_nnlite_fused_activation_t act_type, cy_nn_act_intrpl_param_t *intrplParam)
 Unfused Activation function DMA mode kernel API,API will configure DMA descriptor pointing nnlite MEMIO configuration structure. More...
 
cy_en_nnlite_status_t Cy_NNLite_LayerNorm (const int8_t *inputData, int8_t *outputData, const cy_nn_dims_t *inputDims, const cy_nn_dims_t *outputDims, const cy_nn_layernorm_params_t *lnParams)
 Compute composite LayerNorm operation. More...
 
uint32_t Cy_NNLite_LayerNormScratchBufSize (const cy_nn_dims_t *inputDims, cy_en_nnlite_activation_size_t inputSize)
 API will return scratch buffer size for LayerNorm kernel, buffer will be used for intermediate calculations.
 
cy_en_nnlite_status_t Cy_NNLite_Byte_Copy (const int8_t *inData, int8_t *outData, uint32_t count)
 Byte block copy using NNLite. More...
 
cy_en_nnlite_status_t Cy_NNLite_Q31Reciprocal (const uint32_t *inData, float *outData, const cy_nn_dims_t *inoutDims)
 Float reciprocal of (sums of) unsigned Q.31 values CPU mode kernel API. More...
 
cy_en_nnlite_status_t Cy_NNLite_LSTM_Int8 (cy_nn_lstm_context *scratch_buffers, const int8_t *input_data, const cy_nn_lstm_dims *lstm_dims, const int8_t *input_to_input_weights, const int8_t *input_to_forget_weights, const int8_t *input_to_cell_weights, const int8_t *input_to_output_weights, const int8_t *recurrent_to_input_weights, const int8_t *recurrent_to_forget_weights, const int8_t *recurrent_to_cell_weights, const int8_t *recurrent_to_output_weights, const int8_t *projection_weights, const cy_nn_lstm_params *lstm, int8_t *output_state, int16_t *cell_state, int8_t *output_data)
 LSTM unidirectional function with 8 bit input and output and 16 bit gate output Peephole connections, projection, clipping, combined input/forget gate and layer normalization are not supported. More...
 
uint32_t Cy_NNLite_SoftMax_ScratchBufSize (const cy_nn_dims_t *inoutDims, const cy_en_nnlite_activation_size_t act_size)
 Compute scratch buffer size needed to compute row-wise softmax of 2D input tensor. More...
 
uint32_t Cy_NNLite_FC_ScratchBufSize (const cy_nn_dims_t *inDims, const cy_nn_dims_t *outDims)
 Compute size scratch buffer required for FC op. More...
 
uint32_t Cy_NNLite_DMAModeScratchBufSize (void)
 Compute scratch buffer size needed for DMA mode API. More...
 
cy_en_nnlite_status_t Cy_NNLite_TriggerDMAQueue (void)
 Cy_NNLite_TriggerDMAQueue will trigger DMA transfer of Queued layer starting from first queued layer, callback function will be called after completion of all the Queued layer if valid callback function is passed in kernel context, API will work in blocking mode if callback function is NULL. More...
 
uint32_t Cy_NNLite_GetQueuedLayerCount (void)
 Cy_NNLite_GetQueuedLayerCount will return count of queued layer for DMA. More...
 
cy_en_nnlite_status_t Cy_NNLite_GetCurrDMAQueue (cy_nnlite_dma_queue_config_t *dmaQueue)
 Cy_NNLite_GetCurrDMAQueue API will copy current dma queue in to dmaQueue pointer, valid dmaQueue pointer should be passed. More...
 
cy_en_nnlite_status_t Cy_NNLite_RunDMAQueue (cy_nnlite_dma_queue_config_t *dmaQueue)
 Cy_NNLite_RunDMAQueue API will Trigger DMA dmaQueue queue valid dmaQueue pointer should be passed, DMA queue should return from Cy_NNLite_GetCurrDMAQueue queue will be in runnable state if Cy_NNLite_GetCurrDMAQueue called after queue created in Kernel DMA API such as Cy_NNLite_AvgpoolDMA and get executed by calling Cy_NNLite_TriggerDMAQueue. More...
 
cy_en_nnlite_status_t Cy_NNLite_SoftMax (const int8_t *inData, int8_t *outData, int8_t *expTempBuf, const cy_nn_dims_t *inoutDims, const cy_nn_pwise_unary_params_t *smParams)
 Compute row-wise softmax of 2D input tensor. More...
 
cy_en_nnlite_status_t Cy_NNLite_FFT (int32_t *ppBuf0, int32_t *ppBuf1, unsigned int fftStages)
 Compute Q1.15 complex FFT. More...
 
cy_en_nnlite_status_t Cy_NNLite_FFTDMA (int32_t *ppBuf0, int32_t *ppBuf1, unsigned int fftStages, void *scratchBuf)
 Compute Q1.15 complex FFT DMA mode API API will configure DMA descriptor pointing nnlite MEMIO configuration structure. More...
 
cy_en_nnlite_status_t Cy_NNLite_KernelInit (cy_kernel_config_t *kernelConfig)
 Kernel Init API, initialize PDL driver and setup IRQ handler, setup function pointers from kernelConfig argument. More...
 
cy_en_nnlite_status_t Cy_NNLite_KernelDeInit (void)
 Kernel Deinit API, de-initialize PDL driver and synchronization primitives. More...
 

Function Documentation

◆ Cy_NNLite_LeakyRelUPWLActivation()

void Cy_NNLite_LeakyRelUPWLActivation ( float  alpha_scale,
float  unit_scale,
cy_nn_act_intrpl_param_t leakyRelU 
)

Set PWL interpolation parameters for LeakyRElU activation.

[in] alpha_scale LeakyRelU scale for alpha parameter (may fold in a rescaling factor) [in] unit_scale LeakyRelU scale for unit gradient (may fold in a rescaling factor) [in] inParam Pointer to PWL activation struct to set for specified alpha

◆ Cy_NNLite_Convolution()

cy_en_nnlite_status_t Cy_NNLite_Convolution ( const int8_t *  inputData,
int8_t *  outData,
const cy_nn_dims_t inputDims,
const cy_nn_dims_t outputDims,
const cy_nn_dims_t filterDims,
const int8_t *  filterData,
const int32_t *  biasData,
cy_nn_conv_params_t convParam,
cy_en_nnlite_fused_activation_t  actType,
cy_nn_act_intrpl_param_t intrplParam 
)

2D Convolution CPU mode kernel API, API will configure nnlite and then start nnlite operation.API will work in blocking mode if callback function in Kernel config structure is NULL, if valid callback function is passed in Kernel config, API will be non-blocking and callback function will be called after completion of layer, caller need to wait for callback function before calling another Kernel API, else error will be for other function

filterData points to weights if sparse weight or non sparse based base on type of packing is used

Parameters
[in]inputDataactivation buffer pointer
[in]outDataoutput buffer pointer
[in]inputDimsactivation dimension pointer
[in]outputDimsoutput dimension pointer
[in]filterDimsfilter dimension pointer
[in]filterDatafilter pointer
[in]biasDatabias pointer
[in]convParamconvolution parameter structure pointer
[in]actTypeoutput activation type
[in]intrplParaminterpolation param for PWL actType output activation
Return values
Refercy_en_nnlite_status_t

2D Convolution CPU mode kernel API, API will configure nnlite and then start nnlite operation.API will work in blocking mode if callback function in Kernel config structure is NULL, if valid callback function is passed in Kernel config, API will be non-blocking and callback function will be called after completion of layer, caller need to wait for callback function before calling another Kernel API, else error will be for other function

Kernel config structure should point to valid callback function. filterData points to weights if sparsityBaseAddr is NULL otherwise weights pointer will be derived from sparsityBaseAddr and filterData will not be used. Valid scratch buffer should be passed in convParam, scratch buffer will be used for transpose operation (transpose scratch buffer and transpose DMA descriptors)for per axis convolution implementation, size of scratch buffer should be derived by calling function Cy_NNLite_ConvolutionScratchBufSize. Scratch buffer can be freed after receiving completion callback of API.

[in] inputData activation buffer pointer

[in] outData output buffer pointer

[in] inputDims activation dimension pointer

[in] outpututDims output dimension pointer

[in] filterDims filter dimension pointer

[in] filterData filter pointer

[in] biasData bias pointer

[in] sparsityBaseAddr sparsity map base pointer

[in] convParam convolution parameter structure pointer

[in] actType output activation type

[in] intrplParam interpolation param for PWL output activation, null = nothing set

◆ Cy_NNLite_ConvolutionDMA()

cy_en_nnlite_status_t Cy_NNLite_ConvolutionDMA ( const int8_t *  inputData,
int8_t *  outData,
const cy_nn_dims_t inputDims,
const cy_nn_dims_t outputDims,
const cy_nn_dims_t filterDims,
const int8_t *  filterData,
const int32_t *  biasData,
cy_nn_conv_params_t convParam,
cy_en_nnlite_fused_activation_t  actType,
cy_nn_act_intrpl_param_t intrplParam 
)

2D Convolution DMA mode kernel API, API will configure DMA descriptor pointing nnlite MEMIO configuration structure.

Valid scratch buffer should be passed in convParam, scratch buffer will be used for nnlite MEMIO configuration structure, size of scratch buffer should be value return from Cy_NNLite_ScratchBufSize. CY_NNLITE_OP_QUEUED will be the return value on success After queuing kernel, DMA needs to be triggered by calling API Cy_TriggerNNLiteDMAQueue

filterData points to weights if sparse weight or non sparse based base on type of packing is used

Parameters
[in]inputDataactivation buffer pointer
[in]outDataoutput buffer pointer
[in]inputDimsactivation dimension pointer
[in]outputDimsoutput dimension pointer
[in]filterDimsfilter dimension pointer
[in]filterDatafilter pointer
[in]biasDatabias pointer
[in]convParamconvolution parameter structure pointer
[in]actTypeoutput activation type
[in]intrplParaminterpolation param for PWL actType output activation
Return values
Refercy_en_nnlite_status_t

◆ Cy_NNLite_DepthwiseConvolution()

cy_en_nnlite_status_t Cy_NNLite_DepthwiseConvolution ( const int8_t *  inputData,
int8_t *  outData,
const cy_nn_dims_t inputDims,
const cy_nn_dims_t outputDims,
const cy_nn_dims_t filterDims,
const int8_t *  filterData,
const int32_t *  biasData,
cy_nn_conv_params_t convParam,
cy_en_nnlite_fused_activation_t  actType,
cy_nn_act_intrpl_param_t intrplParam 
)

Depthwise Convolution CPU mode kernel API, API will work in blocking mode if callback function in Kernel config structure is NULL, if valid callback function is passed in Kernel config, API will be non-blocking and callback function will be called after completion of layer, caller need to wait for callback function before calling another Kernel API, else error will be for other function.

depth multiplier considers as additional stacked channels rather than separate filter channel = input_channel * depth.

Note
sparse weight data is not supported in depth-wise convolution operation instead of normal “NHWC” special layout is used for depth-wise the layout depends on the number of weights being processed in parallel 'P' (depthMultiplier) P maximum is 4.
  • Bias buffer should be always 128 bit aligned, i.e. for 8-bit activations bias buffer should be allocated in multiple of 4 32 bit words and for 16-bit activations bias buffer should be allocated in mutiple of 2 64 bit words.
  • layout format will be **[N/P]×H×W×P weights for the complete P-weight “stripes” weights, followed by 1×H×W×|N|p array of weights for a final partial stripe < P weights (empty if |N|p≠0 ) P maximum is 4 (2 for 16-bit activations), activation unit first fetches all activations for the sums-of-products for the first 4 (2 for 16 bit)filters then the activations, for the next 4 (2) and so on. Below mention picture show layout for 16 bit activations
Parameters
[in]inputDataactivation buffer pointer
[in]outDataoutput buffer pointer
[in]inputDimsactivation dimension pointer
[in]outputDimsoutput dimension pointer
[in]filterDimsfilter dimension pointer
[in]filterDatafilter pointer
[in]biasDatabias pointer
[in]convParamconvolution parameter structure pointer
[in]actTypeoutput activation type
[in]intrplParaminterpolation param for PWL actType activation
Return values
Refercy_en_nnlite_status_t

◆ Cy_NNLite_DepthwiseConvolutionDMA()

cy_en_nnlite_status_t Cy_NNLite_DepthwiseConvolutionDMA ( const int8_t *  inputData,
int8_t *  outData,
const cy_nn_dims_t inputDims,
const cy_nn_dims_t outputDims,
const cy_nn_dims_t filterDims,
const int8_t *  filterData,
const int32_t *  biasData,
cy_nn_conv_params_t convParam,
cy_en_nnlite_fused_activation_t  actType,
cy_nn_act_intrpl_param_t intrplParam 
)

Depthwise DMA mode kernel API, API will configure DMA descriptor pointing nnlite MEMIO configuration structure.

Valid scratch buffer should be passed in convParam, scratch buffer will be used for nnlite MEMIO configuration structure, size of scratch buffer should be value return from Cy_NNLite_ScratchBufSize. CY_NNLITE_OP_QUEUED will be the return value on success After queuing kernel, DMA needs to be triggered by calling API Cy_TriggerNNLiteDMAQueue depth multiplier considers as additional stacked channels rather than separate filter channel = input_channel * depth

Note
sparse weight data is not supported in depth-wise convolution operation instead of normal “NHWC” special layout is used for depth-wise
  • Bias buffer should be always 128 bit aligned, i.e. for 8-bit activations bias buffer should be allocated in multiple of 4 32 bit words and for 16-bit activations bias buffer should be allocated in mutiple of for 2 64 bit words. the layout depends on the number of weights being processed in parallel 'P' (depthMultiplier) layout format will be [N/P]×H×W×P weights for the complete P-weight “stripes” weights, followed by 1×H×W×|N|p array of weights for a final partial stripe < P weights (empty if |N|p≠0 ) P 2-dimensional channel-specific filters in parallel, each called stripe is Pmax 4 for 8 bit activations (2 for 16-bit activations). For each 2D (HW) sampling position the activation unit first fetches all activations for the sums-of-products for the first 4 (2) filters (i.e. the first stripe), then the activations, for the next 4 (2) and so on. Below mentioned picture show layout with 16 bit activations
Parameters
[in]inputDataactivation buffer pointer
[in]outDataoutput buffer pointer
[in]inputDimsactivation dimension pointer
[in]outputDimsoutput dimension pointer
[in]filterDimsfilter dimension pointer
[in]filterDatafilter pointer
[in]biasDatabias pointer
[in]convParamconvolution parameter structure pointer
[in]actTypeoutput activation type
[in]intrplParaminterpolation param for PWL actType activation
Return values
Refercy_en_nnlite_status_t

◆ Cy_NNLite_FullyConnected()

cy_en_nnlite_status_t Cy_NNLite_FullyConnected ( const int8_t *  inputData,
int8_t *  outData,
const cy_nn_dims_t inputDims,
const cy_nn_dims_t outputDims,
const cy_nn_dims_t filterDims,
const int8_t *  filterData,
const int32_t *  biasData,
cy_nn_fc_params_t fcParam,
cy_en_nnlite_fused_activation_t  actType,
cy_nn_act_intrpl_param_t intrplParam 
)

Fully connected CPU mode kernel API, API will configure nnlite and then start nnlite operation.API will work in blocking mode For case inputDims->dims[0] > 1,scratch buffer is required scratch buffer size in CPU should be calculated using Cy_NNLite_FC_ScratchBufSize API if callback function in Kernel config structure is NULL, if valid callback function is passed in Kernel config, API will be non-blocking and callback function will be called after completion of layer, caller need to wait for callback function before calling another Kernel API, else error will be for other function.

Parameters
[in]inputDataactivation buffer pointer
[in]outDataoutput buffer pointer
[in]inputDimsactivation dimension pointer
[in]outputDimsoutput dimension pointer
[in]filterDimsfilter dimension pointer
[in]filterDatafilter data (weights or packed weights structure) pointer
[in]biasDatabias pointer N.b. 64-bit per value fo r16-bit activations
[in]fcParamfully Connected parameter structure pointer
[in]actTypeoutput activation type
[in]intrplParaminterpolation param for PWL actType activation
Return values
Refercy_en_nnlite_status_t

Fully connected CPU mode kernel API, API will configure nnlite and then start nnlite operation.API will work in blocking mode For case inputDims->dims[0] > 1,scratch buffer is required scratch buffer size in CPU should be calculated using Cy_NNLite_FC_ScratchBufSize API if callback function in Kernel config structure is NULL, if valid callback function is passed in Kernel config, API will be non-blocking and callback function will be called after completion of layer, caller need to wait for callback function before calling another Kernel API, else error will be for other function.

Kernel config structure should point to valid callback function. filterData points to weights If sparsityBaseAddr is NULL, otherwise weights pointer will be derived from sparsityBaseAddr and filterData will not be used. For case inputDims->dims[0] > 1,scratch buffer is required scratch buffer size in CPU should be calculated using Cy_NNLite_FC_ScratchBufSize API For DMA mode scratch is sum of Cy_NNLite_FC_ScratchBufSize & Cy_NNLite_DMAModeScratchBufSize

[in] inputData activation buffer pointer

[in] outData output buffer pointer

[in] inputDims activation dimension pointer

[in] outpututDims output dimension pointer

[in] filterDims filter dimension pointer

[in] filterData filter pointer

[in] biasData bias pointer

[in] sparsityBaseAddr sparsity map base pointer

[in] fcParam fully Connected parameter structure pointer

[in] actType output activation type

[in] intrplParam interpolation param for PWL output activation , null = nothing set

◆ Cy_NNLite_FullyConnectedDMA()

cy_en_nnlite_status_t Cy_NNLite_FullyConnectedDMA ( const int8_t *  inputData,
int8_t *  outData,
const cy_nn_dims_t inputDims,
const cy_nn_dims_t outputDims,
const cy_nn_dims_t filterDims,
const int8_t *  filterData,
const int32_t *  biasData,
cy_nn_fc_params_t fcParam,
cy_en_nnlite_fused_activation_t  actType,
cy_nn_act_intrpl_param_t intrplParam 
)

Fully connected DMA mode kernel API, API will configure DMA descriptor pointing nnlite MEMIO configuration structure.

Valid scratch buffer should be passed in fcParam, scratch buffer will be used for nnlite MEMIO configuration structure, size of scratch buffer should be value return from Cy_NNLite_ScratchBufSize + Cy_NNLite_FC_ScratchBufSize. Cy_NNLite_FC_ScratchBufSize is required for case inputDims->dims[0] > 1 CY_NNLITE_OP_QUEUED will be the return value on success After queuing kernel, DMA needs to be triggered by calling API Cy_TriggerNNLiteDMAQueue

Parameters
[in]inputDataactivation buffer pointer
[in]outDataoutput buffer pointer
[in]inputDimsactivation dimension pointer
[in]outputDimsoutput dimension pointer
[in]filterDimsfilter dimension pointer
[in]filterDatafilter data (weights or packed weights structure) pointer
[in]biasDatabias pointer N.b. 64-bit per value fo r16-bit activations
[in]fcParamfully Connected parameter structure pointer
[in]actTypeoutput activation type
[in]intrplParaminterpolation param for PWL actType activation
Return values
Refercy_en_nnlite_status_t

◆ Cy_NNLite_Avgpool()

cy_en_nnlite_status_t Cy_NNLite_Avgpool ( const int8_t *  inputData,
int8_t *  outData,
const cy_nn_dims_t inputDims,
const cy_nn_dims_t outputDims,
const cy_nn_dims_t filterDims,
cy_nn_pool_params_t avgpoolParam 
)

Average pool CPU mode kernel API, API will configure nnlite.

and then start nnlite operation. API will work in blocking mode if callback function in Kernel config structure is NULL, if valid callback function is passed in Kernel config, API will be non-blocking and callback function will be called after completion of layer, caller need to wait for callback function before calling another Kernel API, else error will be for other function

Parameters
[in]inputDataactivation buffer pointer
[in]outDataoutput buffer pointer
[in]inputDimsactivation dimension pointer
[in]outputDimsoutput dimension pointer
[in]filterDimsfilter dimension pointer
[in]avgpoolParamaverage pool parameter structure pointer
Return values
Refercy_en_nnlite_status_t

◆ Cy_NNLite_AvgpoolDMA()

cy_en_nnlite_status_t Cy_NNLite_AvgpoolDMA ( const int8_t *  inputData,
int8_t *  outData,
const cy_nn_dims_t inputDims,
const cy_nn_dims_t outputDims,
const cy_nn_dims_t filterDims,
cy_nn_pool_params_t avgpoolParam 
)

Average pool CPU mode kernel API, API will configure DMA descriptor pointing nnlite MEMIO configuration structure.

Valid scratch buffer should be passed in avgpoolParam, scratch buffer will be used for nnlite MEMIO configuration structure, size of scratch buffer should be value return from Cy_NNLite_ScratchBufSize. CY_NNLITE_OP_QUEUED will be the return value on success After queuing kernel, DMA needs to be triggered by calling API Cy_TriggerNNLiteDMAQueue

Parameters
[in]inputDataactivation buffer pointer
[in]outDataoutput buffer pointer
[in]inputDimsactivation dimension pointer
[in]outputDimsoutput dimension pointer
[in]filterDimsfilter dimension pointer
[in]avgpoolParamaverage pool parameter structure pointer
Return values
Refercy_en_nnlite_status_t

◆ Cy_NNLite_Maxpool()

cy_en_nnlite_status_t Cy_NNLite_Maxpool ( const int8_t *  inputData,
int8_t *  outData,
const cy_nn_dims_t inputDims,
const cy_nn_dims_t outputDims,
const cy_nn_dims_t filterDims,
cy_nn_pool_params_t poolParam 
)

Max pool CPU mode kernel API, API will configure nnlite.

and then start nnlite operation. API will work in blocking mode if callback function in Kernel config structure is NULL, if valid callback function is passed in Kernel config, API will be non-blocking and callback function will be called after completion of layer, caller need to wait for callback function before calling another Kernel API, else error will be for other function

Parameters
[in]inputDataactivation buffer pointer
[in]outDataoutput buffer pointer
[in]inputDimsactivation dimension pointer
[in]outputDimsoutput dimension pointer
[in]filterDimsfilter dimension pointer
[in]poolParamaverage pool parameter structure pointer
Return values
Refercy_en_nnlite_status_t

◆ Cy_NNLite_MaxpoolDMA()

cy_en_nnlite_status_t Cy_NNLite_MaxpoolDMA ( const int8_t *  inputData,
int8_t *  outData,
const cy_nn_dims_t inputDims,
const cy_nn_dims_t outputDims,
const cy_nn_dims_t filterDims,
cy_nn_pool_params_t poolParam 
)

Max pool CPU mode kernel API, API will configure DMA descriptor pointing nnlite MEMIO configuration structure.

Valid scratch buffer should be passed in poolParam, scratch buffer will be used for nnlite MEMIO configuration structure, size of scratch buffer should be value return from Cy_NNLite_ScratchBufSize. CY_NNLITE_OP_QUEUED will be the return value on success After queuing kernel, DMA needs to be triggered by calling API Cy_TriggerNNLiteDMAQueue

Parameters
[in]inputDataactivation buffer pointer
[in]outDataoutput buffer pointer
[in]inputDimsactivation dimension pointer
[in]outputDimsoutput dimension pointer
[in]filterDimsfilter dimension pointer
[in]poolParamaverage pool parameter structure pointer
Return values
Refercy_en_nnlite_status_t

◆ Cy_NNLite_Scaling_Setup()

cy_en_nnlite_status_t Cy_NNLite_Scaling_Setup ( cy_nn_scaling_t ss,
float  lhs_scale,
float  rhs_scale,
float  output_scale,
cy_en_nnlite_activation_size_t  in_size,
cy_en_nnlite_op_t  op_type,
cy_en_nnlite_fused_activation_t  act_type 
)

Precomputation of NPU scaling factor settings for NPU binary operations.

Parameters
ssScaling factors NPU Operation
lhs_scaleScale factor for "left hand side" input values
rhs_scaleScale factor for "right hand side" input values
output_scaleScale factor for final output values.
input_sizeBitwidth of (MAC) input values.
op_typeALU Operation
act_typeFused action function to be applied
Returns
cy_en_nnlite_status_t Success status (checks for unsupported ops/activations)

TODO Create some special-case "fast path" versions (e.g. for use inside LSTM)? Support per-filter and per-row setup for Conv and fully connected ops

◆ Cy_NNLite_Scaling_Q_Setup()

void Cy_NNLite_Scaling_Q_Setup ( cy_nn_scaling_t ss)

Set scaling configuration to "no scaling" (fast)

Parameters
ssPoint to Scaling configuration to be

◆ Cy_NNLite_AddSubMul()

cy_en_nnlite_status_t Cy_NNLite_AddSubMul ( const int8_t *  lhsData,
const int8_t *  rhsData,
int8_t *  outData,
const cy_nn_dims_t lhsDims,
const cy_nn_dims_t rhsOutDims,
const cy_nn_pwise_binary_params_t pwParams,
cy_en_nnlite_op_t  op_type,
cy_en_nnlite_fused_activation_t  act_type 
)

Generic binary op CPU mode kernel API, API will configure nnlite.

and then start nnlite operation. API will work in blocking mode if callback function in Kernel config structure is NULL, if valid callback function is passed in Kernel config, API will be non-blocking and callback function will be called after completion of layer, caller need to wait for callback function before calling another Kernel API, else error will be for other function

Limited broadcasting is supported. For rhsOuputDims [D_1,..,D_m,..,D_n] and lhsDims = [1,...,Dm,..Dn] lhsData is repeated for the [D_1,...,D_(m-1)] major coordinate positions in rhsData.

Internally implemented as "depthwise" summation using 1x1 kernel.

Parameters
[in]lhsDatalhs input tensor buffer pointer
[in]rhsDatarhs input tensor pointer (elts repeated if less elts than lhs)
[in]outDataoutput buffer pointer
[in]lhsDimsdimensions of lhs argument (repeated if less elts than inputDims )
[in]rhsOutDimsdimensions of rhs argument and output.
[in]pwParamsPointwise op params (lhs and output rescaling factors)
[in]op_typeMAC-unit operating mode to configure
[in]act_typeActivation function to configure
Return values
Refercy_en_nnlite_status_t

◆ Cy_NNLite_AddSubMulDMA()

cy_en_nnlite_status_t Cy_NNLite_AddSubMulDMA ( const int8_t *  lhsData,
const int8_t *  rhsData,
int8_t *  outData,
const cy_nn_dims_t lhsDims,
const cy_nn_dims_t rhsOutDims,
const cy_nn_pwise_binary_params_t pwParams,
cy_en_nnlite_op_t  op_type,
cy_en_nnlite_fused_activation_t  act_type 
)

Generic binary op CPU mode kernel API, API will configure DMA descriptor pointing nnlite MEMIO configuration structure.

Valid scratch buffer should be passed in pwParams, scratch buffer will be used for nnlite MEMIO configuration structure, size of scratch buffer should be value return from Cy_NNLite_ScratchBufSize. CY_NNLITE_OP_QUEUED will be the return value on success After queuing kernel, DMA needs to be triggered by calling API Cy_TriggerNNLiteDMAQueue

Limited broadcasting is supported. For rhsOuputDims [D_1,..,D_m,..,D_n] and lhsDims = [1,...,Dm,..Dn] lhsData is repeated for the [D_1,...,D_(m-1)] major coordinate positions in rhsData.

Internally implemented as "depthwise" summation using 1x1 kernel.

Parameters
[in]lhsDatalhs input tensor buffer pointer
[in]rhsDatarhs input tensor pointer (elts repeated if less elts than lhs)
[in]outDataoutput buffer pointer
[in]lhsDimsdimensions of lhs argument (repeated if less elts than inputDims )
[in]rhsOutDimsdimensions of rhs argument and output.
[in]pwParamsPointwise op params (lhs and output rescaling factors)
[in]op_typeMAC-unit operating mode to configure
[in]act_typeActivation function to configure
Return values
Refercy_en_nnlite_status_t

◆ Cy_NNLite_Add()

cy_en_nnlite_status_t Cy_NNLite_Add ( const int8_t *  lhsData,
const int8_t *  rhsData,
int8_t *  outData,
const cy_nn_dims_t lhsDims,
const cy_nn_dims_t rhsOutDims,
const cy_nn_pwise_binary_params_t pwParams 
)

Pointwise addition operation.

Pointwise addition CPU mode kernel API, API will configure nnlite. and then start nnlite operation. API will work in blocking mode if callback function in Kernel config structure is NULL, if valid callback function is passed in Kernel config, API will be non-blocking and callback function will be called after completion of layer, caller need to wait for callback function before calling another Kernel API, else error will be for other function

Limited broadcasting is supported. For rhsOuputDims [D_1,..,D_m,..,D_n] and lhsDims = [1,...,Dm,..Dn] lhsData is repeated for the [D_1,...,D_(m-1)] major coordinate positions in rhsData. Internally implemented as "depthwise" summation using 1x1 kernel.

Parameters
[in]lhsDatalhs input tensor buffer pointer
[in]rhsDatarhs input tensor pointer (elts repeated if less elts than lhs)
[in]outDataoutput buffer pointer
[in]lhsDimsdimensions of lhs argument (repeated if less elts than inputDims )
[in]rhsOutDimsrhs argument and output.
[in]pwParamsPointwise op params (lhs and output rescaling factors)
Return values
Refercy_en_nnlite_status_t

Pointwise addition operation.

Delegates to Cy_NNLite_AddSub

◆ Cy_NNLite_AddDMA()

cy_en_nnlite_status_t Cy_NNLite_AddDMA ( const int8_t *  lhsData,
const int8_t *  rhsData,
int8_t *  outData,
const cy_nn_dims_t lhsDims,
const cy_nn_dims_t rhsOutDims,
const cy_nn_pwise_binary_params_t pwParams 
)

Pointwise addition operation.

Pointwise addition DMA mode kernel API, API will configure DMA descriptor pointing nnlite MEMIO configuration structure. Valid scratch buffer should be passed in pwParams, scratch buffer will be used for nnlite MEMIO configuration structure, size of scratch buffer should be value return from Cy_NNLite_ScratchBufSize. CY_NNLITE_OP_QUEUED will be the return value on success After queuing kernel, DMA needs to be triggered by calling API Cy_TriggerNNLiteDMAQueue

Limited broadcasting is supported. For rhsOuputDims [D_1,..,D_m,..,D_n] and lhsDims = [1,...,Dm,..Dn] lhsData is repeated for the [D_1,...,D_(m-1)] major coordinate positions in rhsData. Internally implemented as "depthwise" summation using 1x1 kernel.

Parameters
[in]lhsDatalhs input tensor buffer pointer
[in]rhsDatarhs input tensor pointer (elts repeated if less elts than lhs)
[in]outDataoutput buffer pointer
[in]lhsDimsdimensions of lhs argument (repeated if less elts than inputDims )
[in]rhsOutDimsrhs argument and output.
[in]pwParamsPointwise op params (lhs and output rescaling factors)
Return values
Refercy_en_nnlite_status_t

◆ Cy_NNLite_Sub()

cy_en_nnlite_status_t Cy_NNLite_Sub ( const int8_t *  lhsData,
const int8_t *  rhsData,
int8_t *  outData,
const cy_nn_dims_t lhsDims,
const cy_nn_dims_t rhsOutDims,
const cy_nn_pwise_binary_params_t pwParams,
bool  left_from_right 
)

Pointwise addition operation.

Pointwise addition CPU mode kernel API, API will configure nnlite and then start nnlite operation.API will work in blocking mode if callback function in Kernel config structure is NULL, if valid callback function is passed in Kernel config, API will be non-blocking and callback function will be called after completion of layer, caller need to wait for callback function before calling another Kernel API, else error will be for other function

Limited broadcasting is supported. For rhsOuputDims [D_1,..,D_m,..,D_n] and lhsDims = [1,...,Dm,..Dn] lhsData is repeated for the [D_1,...,D_(m-1)] major coordinate positions in rhsData. Internally implemented as "depthwise" summation using 1x1 kernel.

Parameters
[in]lhsDatalhs input tensor buffer pointer
[in]rhsDatarhs input tensor pointer (elts repeated if less elts than lhs)
[in]outDataoutput buffer pointer
[in]lhsDimsdimensions of lhs argument (repeated if less elts than inputDims )
[in]rhsOutDimsrhs argument and output.
[in]pwParamsPointwise op params (lhs and output rescaling factors)
[in]left_from_rightCompute rhsData - lhsData rather than lhsData - rhsData
Return values
Refercy_en_nnlite_status_t

Pointwise addition operation.

Delegates to Cy_NNLite_AddSub

◆ Cy_NNLite_SubDMA()

cy_en_nnlite_status_t Cy_NNLite_SubDMA ( const int8_t *  lhsData,
const int8_t *  rhsData,
int8_t *  outData,
const cy_nn_dims_t lhsDims,
const cy_nn_dims_t rhsOutDims,
const cy_nn_pwise_binary_params_t pwParams,
bool  left_from_right 
)

Pointwise addition operation.

Pointwise addition DMA mode kernel API, API will configure DMA descriptor pointing nnlite MEMIO configuration structure. Valid scratch buffer should be passed in pwParams, scratch buffer will be used for nnlite MEMIO configuration structure, size of scratch buffer should be value return from Cy_NNLite_ScratchBufSize. CY_NNLITE_OP_QUEUED will be the return value on success After queuing kernel, DMA needs to be triggered by calling API Cy_TriggerNNLiteDMAQueue

Limited broadcasting is supported. For rhsOuputDims [D_1,..,D_m,..,D_n] and lhsDims = [1,...,Dm,..Dn] lhsData is repeated for the [D_1,...,D_(m-1)] major coordinate positions in rhsData. Internally implemented as "depthwise" summation using 1x1 kernel.

Parameters
[in]lhsDatalhs input tensor buffer pointer
[in]rhsDatarhs input tensor pointer (elts repeated if less elts than lhs)
[in]outDataoutput buffer pointer
[in]lhsDimsdimensions of lhs argument (repeated if less elts than inputDims )
[in]rhsOutDimsrhs argument and output.
[in]pwParamsPointwise op params (lhs and output rescaling factors)
[in]left_from_rightCompute rhsData - lhsData rather than lhsData - rhsData
Return values
Refercy_en_nnlite_status_t

◆ Cy_NNLite_Mul()

cy_en_nnlite_status_t Cy_NNLite_Mul ( const int8_t *  lhsData,
const int8_t *  rhsData,
int8_t *  outData,
const cy_nn_dims_t lhsDims,
const cy_nn_dims_t rhsOutDims,
const cy_nn_pwise_binary_params_t pwParams 
)

multiplication

Pointwise multiplication CPU mode kernel API, API will configure nnlite and then start nnlite operation. API will work in blocking mode if callback function in Kernel config structure is NULL, if valid callback function is passed in Kernel config, API will be non-blocking and callback function will be called after completion of layer, caller need to wait for callback function before calling another Kernel API, else error will be for other function

Limited broadcasting is supported. For rhsOuputDims [D_1,..,D_m,..,D_n] and lhsDims = [1,...,Dm,..Dn] lhsData is repeated for the [D_1,...,D_(m-1)] major coordinate positions in rhsData. Internally implemented as "depthwise" summation using 1x1 kernel.

Parameters
[in]lhsDatalhs input tensor buffer pointer
[in]rhsDatarhs input tensor pointer (elts repeated if less elts than lhs)
[in]outDataoutput buffer pointer
[in]lhsDimsdimensions of lhs argument (repeated if less elts than inputDims )
[in]rhsOutDimsrhs argument and output.
[in]pwParamsPointwise op params (lhs and output rescaling factors)
Return values
Refercy_en_nnlite_status_t

multiplication

Delegates to Cy_NNLite_AddSubMul

◆ Cy_NNLite_MulDMA()

cy_en_nnlite_status_t Cy_NNLite_MulDMA ( const int8_t *  lhsData,
const int8_t *  rhsData,
int8_t *  outData,
const cy_nn_dims_t lhsDims,
const cy_nn_dims_t rhsOutDims,
const cy_nn_pwise_binary_params_t pwParams 
)

Pointwise multiplication with simple broadcast.

Pointwise multiplication DMA mode kernel API, API will configure DMA descriptor pointing nnlite MEMIO configuration structure. Valid scratch buffer should be passed in pwParams, scratch buffer will be used for nnlite MEMIO configuration structure,size of scratch buffer should be value return from Cy_NNLite_ScratchBufSize. CY_NNLITE_OP_QUEUED will be the return value on success After queuing kernel, DMA needs to be triggered by calling API Cy_TriggerNNLiteDMAQueue

Limited broadcasting is supported. For rhsOuputDims [D_1,..,D_m,..,D_n] and lhsDims = [1,...,Dm,..Dn] lhsData is repeated for the [D_1,...,D_(m-1)] major coordinate positions in rhsData. Internally implemented as "depthwise" summation using 1x1 kernel.

Parameters
[in]lhsDatalhs input tensor buffer pointer
[in]rhsDatarhs input tensor pointer (elts repeated if less elts than lhs)
[in]outDataoutput buffer pointer
[in]lhsDimsdimensions of lhs argument (repeated if less elts than inputDims )
[in]rhsOutDimsrhs argument and output.
[in]pwParamsPointwise op params (lhs and output rescaling factors)
Return values
Refercy_en_nnlite_status_t

◆ Cy_NNLite_Activation()

cy_en_nnlite_status_t Cy_NNLite_Activation ( const int8_t *  inData,
int8_t *  outData,
const cy_nn_dims_t inoutDims,
const cy_nn_pwise_unary_params_t actParams,
cy_en_nnlite_fused_activation_t  act_type,
cy_nn_act_intrpl_param_t intrplParam 
)

Unfused Activation function CPU mode kernel API, API will configure nnlite and then start nnlite operation.

API will work in blocking mode if callback function in Kernel config structure is NULL, if valid callback function is passed in Kernel config, API will be non-blocking and callback function will be called after completion of layer, caller need to wait for callback function before calling another Kernel API, else error will be for other function

Internally implemented as "depthwise" operation on 1x1xC input

Parameters
[in]inDatarhs input tensor pointer (elts repeated if less elts than lhs)
[in]outDataoutput buffer pointer
[in]inoutDimsrhs argument and output.
[in]actParamsunfused activation op params (lhs and output rescaling factors)
[in]act_typeActivation function to apply.
[in]intrplParaminterpolation param for PWL output activation , null = nothing set
Return values
Refercy_en_nnlite_status_t

Callback function from kernel config structure will be called after completion of layer. Kernel config structure should point to valid callback function.

Internally implemented as "depthwise" operation on 1x1xC input

Parameters
[in]inDatarhs input tensor pointer (elts repeated if less elts than lhs)
[in]outDataoutput buffer pointer
[in]inoutDimsrhs argument and output.
[in]actParamsunfused activation op params (lhs and output rescaling factors)
[in]act_typeActivation function to apply.
[in]intrplParaminterpolation param for PWL output activation , null = nothing set
Return values
Refercy_en_nnlite_status_t

◆ Cy_NNLite_ActivationDMA()

cy_en_nnlite_status_t Cy_NNLite_ActivationDMA ( const int8_t *  inData,
int8_t *  outData,
const cy_nn_dims_t inoutDims,
const cy_nn_pwise_unary_params_t actParams,
cy_en_nnlite_fused_activation_t  act_type,
cy_nn_act_intrpl_param_t intrplParam 
)

Unfused Activation function DMA mode kernel API,API will configure DMA descriptor pointing nnlite MEMIO configuration structure.

Valid scratch buffer should be passed in actParams, scratch buffer will be used for nnlite MEMIO configuration structure,size of scratch buffer should be value return from Cy_NNLite_ScratchBufSize. CY_NNLITE_OP_QUEUED will be the return value on success After queuing kernel, DMA needs to be triggered by calling API Cy_TriggerNNLiteDMAQueue

Internally implemented as "depthwise" operation on 1x1xC input

Parameters
[in]inDatarhs input tensor pointer (elts repeated if less elts than lhs)
[in]outDataoutput buffer pointer
[in]inoutDimsrhs argument and output.
[in]actParamsunfused activation op params (lhs and output rescaling factors)
[in]act_typeActivation function to apply.
[in]intrplParaminterpolation param for PWL output activation , null = nothing set
Return values
Refercy_en_nnlite_status_t

◆ Cy_NNLite_LayerNorm()

cy_en_nnlite_status_t Cy_NNLite_LayerNorm ( const int8_t *  inputData,
int8_t *  outputData,
const cy_nn_dims_t inputDims,
const cy_nn_dims_t outputDims,
const cy_nn_layernorm_params_t lnParams 
)

Compute composite LayerNorm operation.

Note
This is a "macro" kernel requiring multiple primitive NNLite operations to compute.
Parameters
inputDataInput tensor data
outputDataOutput tensor data (MUST be distinct from inData)
inputDimsInput dimension pointer
outputDimsOutput dimension pointer
lnParamsLayerNorm parameter structure pointer.
Returns
cy_en_nnlite_status_t
Note
This is a "macro" kernel requiring multiple primitive NNLite operations to compute.
Parameters
inDataInput tensor data
outDataOutput tensor data (MUST be distinct from inData)
inputDimsInput dimension pointer
outputDimsOutput dimension pointer
lnParamLayerNorm parameter structure pointer.
Returns
cy_en_nnlite_status_t

◆ Cy_NNLite_Byte_Copy()

cy_en_nnlite_status_t Cy_NNLite_Byte_Copy ( const int8_t *  inData,
int8_t *  outData,
uint32_t  count 
)

Byte block copy using NNLite.

Internally implemented as "depthwise" operation on 1x1xC input

Parameters
[in]inDataaddress start byte vector to be copied
[in]outDatadestination start address
[in]countNumber of bytes to be copied
Return values
Refercy_en_nnlite_status_t

Byte block copy using NNLite.

Callback function from kernel config structure will be called after completion of layer. Kernel config structure should point to valid callback function.

Internally implemented as "depthwise" operation on 1x1xC input

Parameters
[in]inDatarhs input tensor pointer (elts repeated if less elts than lhs)
[in]outDataoutput buffer pointer
[in]inoutDimsrhs argument and output.
[in]actParamsunfused activation op params (lhs and output rescaling factors)
[in]act_typeActivation function to apply.
[in]intrplParaminterpolation param for PWL output activation , null = nothing set
Return values
Refercy_en_nnlite_status_t

Byte block copy using NNLite

Internally implemented as "depthwise" operation on 1x1xC input

Parameters
[in]inDataaddress start byte vector to be copied
[in]outDatadestination start address
[in]countNumber of bytes to be copied
Return values
Refercy_en_nnlite_status_t

◆ Cy_NNLite_Q31Reciprocal()

cy_en_nnlite_status_t Cy_NNLite_Q31Reciprocal ( const uint32_t *  inData,
float *  outData,
const cy_nn_dims_t inoutDims 
)

Float reciprocal of (sums of) unsigned Q.31 values CPU mode kernel API.

Internally implemented as summing WxC input over the minor axis to produce W outputs

API will configure nnlite and then start nnlite operation. Callback function from kernel config structure will be called after completion of layer. Kernel config structure should point to valid callback function.

Parameters
[in]inDatarhs input tensor pointer
[in]outDataoutput buffer pointer
[in]inoutDimsinput values
Return values
Refercy_en_nnlite_status_t

Internally implemented summing over the minor dimensions to produce W outputs from WxC inputs

API will configure nnlite and then start nnlite operation. Callback function from kernel config structure will be called after completion of layer. Kernel config structure should point to valid callback function.

Parameters
[in]inDatarhs input tensor pointer
[in]outDataoutput buffer pointer
[in]inoutDimsinput values dimensions
Return values
Refercy_en_nnlite_status_t

◆ Cy_NNLite_LSTM_Int8()

cy_en_nnlite_status_t Cy_NNLite_LSTM_Int8 ( cy_nn_lstm_context scratch_buffers,
const int8_t *  input_data,
const cy_nn_lstm_dims lstm_dims,
const int8_t *  input_to_input_weights,
const int8_t *  input_to_forget_weights,
const int8_t *  input_to_cell_weights,
const int8_t *  input_to_output_weights,
const int8_t *  recurrent_to_input_weights,
const int8_t *  recurrent_to_forget_weights,
const int8_t *  recurrent_to_cell_weights,
const int8_t *  recurrent_to_output_weights,
const int8_t *  projection_weights,
const cy_nn_lstm_params lstm,
int8_t *  output_state,
int16_t *  cell_state,
int8_t *  output_data 
)

LSTM unidirectional function with 8 bit input and output and 16 bit gate output Peephole connections, projection, clipping, combined input/forget gate and layer normalization are not supported.

Parameters
[in]scratch_buffersStruct containing scratch buffers Expected size for each scratch buffer is lstm_dims->num_batches * lstm_dims->num_outputs.
[in]input_dataPointer to input data
[in]lstm_dimsLSTM input parameters related to dimensions
[in]input_to_input_weightsInput to input weights
[in]input_to_forget_weightsInput to forget weights
[in]input_to_cell_weightsInput to cell weights
[in]input_to_output_weightsInput to output weights
[in]recurrent_to_input_weightsRecurrent to input weights
[in]recurrent_to_forget_weightsRecurrent to forget weights
[in]recurrent_to_cell_weightsRecurrent to cell weights
[in]recurrent_to_output_weightsRecurrent to output weights
[in]projection_weightsProjection weights. Not used.
[in]lstmLSTM parameters. See struct declaration
[in]output_statePointer to (recurrent) output state
[in]cell_statePointer to cell state
[in]output_dataPointer to output state
Note
Derived from and API consistent with CMSIS-NN cy_nn_lstm_unidirectional_s16_s8 implementation for convenience. Following assumptions are done based on LSTM functionality as supported by Keras version 2.9.0 at the time of development. As stated here, https://github.com/tensorflow/community/blob/master/rfcs/20180920-unify-rnn-interface.md Keras's LSTMCell is equivalent to TensorFlow's BasicLSTMCell, which does not support peephole, clipping or projection. Layer normalization and combined input/forget gate are not supported either.

1 Input to input weight can not be nullptr. Otherwise nullptr for combined input/forgat gate. 2 Cell weights are not used and should be nullptr. Otherwise needed for peephole connections. 3 Projection weight is not used and should be nullptr. Otherwise needed for projection.

Returns
cy_en_nnlite_status_t Exit status (CY_NNLITE_SUCCESS for successful execution)

◆ Cy_NNLite_SoftMax_ScratchBufSize()

uint32_t Cy_NNLite_SoftMax_ScratchBufSize ( const cy_nn_dims_t inoutDims,
const cy_en_nnlite_activation_size_t  act_size 
)

Compute scratch buffer size needed to compute row-wise softmax of 2D input tensor.

Parameters
[in]inoutDimsInput tensors dimensions (rows, cols)
[in]act_sizeData element size of input
Returns
uint32_t Size of scratch buffer required in bytes

Compute scratch buffer size needed to compute row-wise softmax of 2D input tensor.

Parameters
inoutDimsInput dimensions of softmax operation
act_sizeSize of input activation values
Returns
uint32_t Size of scratch buffer required

◆ Cy_NNLite_FC_ScratchBufSize()

uint32_t Cy_NNLite_FC_ScratchBufSize ( const cy_nn_dims_t inDims,
const cy_nn_dims_t outDims 
)

Compute size scratch buffer required for FC op.

Parameters
inDimsinput dimensions of FC operation
outDimsOutput dimensions of FC operation
Returns
uint32_t Size of scratch buffer required

◆ Cy_NNLite_DMAModeScratchBufSize()

uint32_t Cy_NNLite_DMAModeScratchBufSize ( void  )

Compute scratch buffer size needed for DMA mode API.

Returns
uint32_t Size of scratch buffer required in bytes

Compute scratch buffer size needed for DMA mode API.

◆ Cy_NNLite_TriggerDMAQueue()

cy_en_nnlite_status_t Cy_NNLite_TriggerDMAQueue ( void  )

Cy_NNLite_TriggerDMAQueue will trigger DMA transfer of Queued layer starting from first queued layer, callback function will be called after completion of all the Queued layer if valid callback function is passed in kernel context, API will work in blocking mode if callback function is NULL.

Return values
Refercy_en_nnlite_status_t

◆ Cy_NNLite_GetQueuedLayerCount()

uint32_t Cy_NNLite_GetQueuedLayerCount ( void  )

Cy_NNLite_GetQueuedLayerCount will return count of queued layer for DMA.

Return values
dmaQDepthnumber of layers in DMA Queue

◆ Cy_NNLite_GetCurrDMAQueue()

cy_en_nnlite_status_t Cy_NNLite_GetCurrDMAQueue ( cy_nnlite_dma_queue_config_t dmaQueue)

Cy_NNLite_GetCurrDMAQueue API will copy current dma queue in to dmaQueue pointer, valid dmaQueue pointer should be passed.

To get the runnable queue Cy_NNLite_GetCurrDMAQueue should be called after the created in Kernel DMA API such as Cy_NNLite_AvgpoolDMA and get executed by calling Cy_NNLite_TriggerDMAQueue

Parameters
[in]dmaQueuedma queue pointer in which dma queue will be copied
Return values
Refercy_en_nnlite_status_t

◆ Cy_NNLite_RunDMAQueue()

cy_en_nnlite_status_t Cy_NNLite_RunDMAQueue ( cy_nnlite_dma_queue_config_t dmaQueue)

Cy_NNLite_RunDMAQueue API will Trigger DMA dmaQueue queue valid dmaQueue pointer should be passed, DMA queue should return from Cy_NNLite_GetCurrDMAQueue queue will be in runnable state if Cy_NNLite_GetCurrDMAQueue called after queue created in Kernel DMA API such as Cy_NNLite_AvgpoolDMA and get executed by calling Cy_NNLite_TriggerDMAQueue.

API will work in blocking mode if callback function is passed as NULL in kernel context

Parameters
[in]dmaQueuedma queue pointer in which dma queue will be copied
Return values
Refercy_en_nnlite_status_t

◆ Cy_NNLite_SoftMax()

cy_en_nnlite_status_t Cy_NNLite_SoftMax ( const int8_t *  inData,
int8_t *  outData,
int8_t *  scratchBuf,
const cy_nn_dims_t inoutDims,
const cy_nn_pwise_unary_params_t smParams 
)

Compute row-wise softmax of 2D input tensor.

Parameters
inData
outData
expTempBuf
inoutDims
smParams
Returns
cy_en_nnlite_status_t

Compute row-wise softmax of 2D input tensor.

Note
This is a "macro" kernel requiring multiple primitive NNLite operations to compute.
Parameters
inDataInput tensor data
outDataOutput tensor data (MUST be distinct from inData)
scratchBufScratch buffer for intermediate values (required size returned by Cy_NNLite_SoftMax_ScratchBufSize) (should be word-aligned for performance)
inoutDimsDimensions of 2D input tensors (Set dim[0]==1 for 1D case)
smParamsInput/output tensor quantization parameters bitwidths etc.
Returns
cy_en_nnlite_status_t

◆ Cy_NNLite_FFT()

cy_en_nnlite_status_t Cy_NNLite_FFT ( int32_t *  ppBuf0,
int32_t *  ppBuf1,
unsigned int  fftStages 
)

Compute Q1.15 complex FFT.

NNLite implements Decimation-in-Time Radix-2 FFT for 16 bit input buffers should be allocated for 32 bit, buffers will be used in ping-pong mode final output will be in buf0 for even stage for odd stage buf1 will have final output

Note
FFT length =^= Number complex input values *2 = #
Parameters
ppBuf0Input / ping-pong buffer 0, Output (even stages/# values)
ppBuf1ping-pong buffer 1, Output (odd stages/# values)
fftStageslog_2(FFT length)
Returns
cy_en_nnlite_status_t

◆ Cy_NNLite_FFTDMA()

cy_en_nnlite_status_t Cy_NNLite_FFTDMA ( int32_t *  ppBuf0,
int32_t *  ppBuf1,
unsigned int  fftStages,
void *  scratchBuf 
)

Compute Q1.15 complex FFT DMA mode API API will configure DMA descriptor pointing nnlite MEMIO configuration structure.

Valid scratchBuf should be passed in pParam, scratch buffer will be used for nnlite MEMIO configuration structure, size of scratch buffer should be value return from Cy_NNLite_ScratchBufSize. CY_NNLITE_OP_QUEUED will be the return value on success After queuing kernel, DMA needs to be triggered by calling API Cy_TriggerNNLiteDMAQueue

NNLite implements Decimation-in-Time Radix-2 FFT

Note
FFT length =^= Number complex input values *2 = #
Parameters
ppBuf0Input / ping-pong buffer 0, Output (even stages/# values)
ppBuf1ping-pong buffer 1, Output (odd stages/# values)
fftStageslog_2(FFT length)
scratchBufScratch buffer for DMA mode
Returns
cy_en_nnlite_status_t

◆ Cy_NNLite_KernelInit()

cy_en_nnlite_status_t Cy_NNLite_KernelInit ( cy_kernel_config_t kernelConfig)

Kernel Init API, initialize PDL driver and setup IRQ handler, setup function pointers from kernelConfig argument.

This API needs to be called before calling any other kernel API

Parameters
[in]kernelConfigkernel configuration structure
Return values
cy_en_nnlite_status_t

Kernel Init API, initialize PDL driver and setup IRQ handler, setup function pointers from kernelConfig argument.

KernelConfig should have valid pointer for Mutex variable and function pointers for mutexCreate, mutexDelete, mutexLock, mutexUnlock and and should have valid pointers for Semaphore variable and function pointers for SemCreate, SemDelete, SemWait and SemGive for synchronization primitives. This API will allocate mutex and semaphore by calling mutexCreate and SemCreate, and will use them in successive call to other kernel public API's. API needs to be called before calling any other kernel API, If any of the pointers in KernelConfig is not valid API will return error code ,return value of API should be check to confirm successful initialization.

[in] kernelConfig kernel function pointers configuration structure

◆ Cy_NNLite_KernelDeInit()

cy_en_nnlite_status_t Cy_NNLite_KernelDeInit ( void  )

Kernel Deinit API, de-initialize PDL driver and synchronization primitives.

needs re initialization after this API is called. Should be called only at end of program

Return values
cy_en_nnlite_status_t

needs re initialization after this API is called. Should be called only at end of program