CMSIS-NN  
CMSIS NN Software Library

Functions

void arm_nn_lstm_calculate_gate_s8_s16 (const int8_t *input, const int8_t *input_to_gate_weights, const int32_t *input_to_gate_bias, const cmsis_nn_scaling input_to_gate_scaling, const int8_t *output_state, const int8_t *recurrent_to_gate_weights, const int32_t *recurrent_to_gate_bias, const cmsis_nn_scaling recurrent_to_gate, const int32_t n_batch, const int32_t n_input, const int32_t n_output, const int32_t n_cell, const arm_nn_activation_type activation_type, int16_t *gate)
 Updates a LSTM gate for an iteration step of LSTM function, int8x8_16 version. More...
 
arm_cmsis_nn_status arm_nn_lstm_step_s8_s16 (const int8_t *input, const int8_t *input_to_input_weight, const int8_t *input_to_forget_weight, const int8_t *input_to_cell_weight, const int8_t *input_to_output_weight, const int8_t *recurrent_to_input_weight, const int8_t *recurrent_to_forget_weight, const int8_t *recurrent_to_cell_weight, const int8_t *recurrent_to_output_weight, const cmsis_nn_lstm_params *lstm, const int n_batch, const int n_cell, const int n_input, const int n_output, int8_t *output_state, int16_t *cell_state, int8_t *output, cmsis_nn_lstm_context *scratch_buffers)
 Update LSTM function for an iteration step. More...
 
void arm_nn_lstm_update_cell_state_s16 (const int32_t n_block, const int32_t cell_state_scale, int16_t *cell_state, const int16_t *input_gate, const int16_t *forget_gate, const int16_t *cell_gate)
 Update cell state for a single LSTM iteration step, int8x8_16 version. More...
 
void arm_nn_lstm_update_output_s8_s16 (const int n_batch, const int n_cell, const int n_output, int16_t *cell_state, const int32_t cell_state_scale, const int16_t *output_gate, const cmsis_nn_scaling hidden_scaling, const int32_t hidden_offset, int8_t *output_state, int16_t *cell_gate_scratch, int8_t *scratch)
 Calculate the output state tensor of an LSTM step, s8 input/output and s16 weight version. More...
 
void arm_nn_vec_mat_mul_result_acc_s8 (const int8_t *lhs, const int8_t *rhs, const int32_t *bias, int16_t *dst, const int32_t output_offset, const int32_t multiplier, const int32_t shift, const int32_t rhs_cols, const int32_t rhs_rows, const int32_t batch)
 The result of the multiplication is accumulated to the passed result buffer. Multiplies a matrix by a "batched" vector (i.e. a matrix with a batch dimension composed by input vectors independent from each other). More...
 

Description

Support functions for LSTM

Function Documentation

◆ arm_nn_lstm_calculate_gate_s8_s16()

void arm_nn_lstm_calculate_gate_s8_s16 ( const int8_t *  input,
const int8_t *  input_to_gate_weights,
const int32_t *  input_to_gate_bias,
const cmsis_nn_scaling  input_to_gate_scaling,
const int8_t *  output_state,
const int8_t *  recurrent_to_gate_weights,
const int32_t *  recurrent_to_gate_bias,
const cmsis_nn_scaling  recurrent_to_gate_scaling,
const int32_t  n_batch,
const int32_t  n_input,
const int32_t  n_output,
const int32_t  n_cell,
const arm_nn_activation_type  activation_type,
int16_t *  gate 
)

param[in] input Input data param[in] input_to_gate_weights Input to gate weights param[in] input_to_gate_bias Input to gate weights param[in] input_to_gate_scaling Input to gate scaling param[in] activation Actival min and max values param[in] output_state Output state param[in] recurrent_to_gate_weights Recurrent to gate weights param[in] recurrent_to_gate_bias Recurrent to gate bias param[in] recurrent_to_gate_scaling Recurrent to gate scaling param[in] n_batch Batch size param[in] n_input Input size param[out] n_output Output size param[in] activation_type Activation type (sigmoid or tanh) param[out] n_cell Cell size

◆ arm_nn_lstm_step_s8_s16()

arm_cmsis_nn_status arm_nn_lstm_step_s8_s16 ( const int8_t *  input,
const int8_t *  input_to_input_weight,
const int8_t *  input_to_forget_weight,
const int8_t *  input_to_cell_weight,
const int8_t *  input_to_output_weight,
const int8_t *  recurrent_to_input_weight,
const int8_t *  recurrent_to_forget_weight,
const int8_t *  recurrent_to_cell_weight,
const int8_t *  recurrent_to_output_weight,
const cmsis_nn_lstm_params lstm,
const int  n_batch,
const int  n_cell,
const int  n_input,
const int  n_output,
int8_t *  output_state,
int16_t *  cell_state,
int8_t *  output,
cmsis_nn_lstm_context scratch_buffers 
)

param[in] input Input data param[in] input_to_input_weight Input to input gate weights param[in] input_to_forget_weight Input to forget gate weights param[in] input_to_cell_weight Input to cell gate weights param[in] input_to_output_weight Input to output weights param[in] recurrent_to_input_weight Recurrent signal to input weights param[in] recurrent_to_forget_weight Recurrent signal to forget gate weights param[in] recurrent_to_cell_weight Recurrent signal to cell gate weighst param[in] recurrent_to_output_weight Recurrent signal to output weights param[in] lstm LSTM parameters param[in] n_batch Batch size param[in] n_cell Cell size param[in] n_input Input size param[in] n_output Output size param[out] output_state Output state param[out] cell_state Internal state param[out] output Output signal param[in] *scratch_buffers Struct containing scratch buffers

◆ arm_nn_lstm_update_cell_state_s16()

void arm_nn_lstm_update_cell_state_s16 ( const int32_t  n_block,
const int32_t  cell_state_scale,
int16_t *  cell_state,
const int16_t *  input_gate,
const int16_t *  forget_gate,
const int16_t *  cell_gate 
)
Parameters
[in]n_blocktotal number of cells for all batches
[in]cell_state_scaleScaling factor of cell state
[in]cell_stateInput/output vector, size n_batch*n_cell
[in]input_gateInput vector of size n_block
[in]forget_gateInput/scratch vector of size n_block, always modified
[in]cell_gateInput vector of size, n_block

◆ arm_nn_lstm_update_output_s8_s16()

void arm_nn_lstm_update_output_s8_s16 ( const int  n_batch,
const int  n_cell,
const int  n_output,
int16_t *  cell_state,
const int32_t  cell_state_scale,
const int16_t *  output_gate,
const cmsis_nn_scaling  hidden_scale,
const int32_t  hidden_offset,
int8_t *  output_state,
int16_t *  scratch0,
int8_t *  scratch1 
)
Parameters
[in]n_batchThe number of distinct vectors in each array
[in]n_cellNumber of cells
[in]n_outputNumber of outputs
[in,out]cell_stateCell state, size n_batch*n_cell
[in]cell_state_scaleScaling of cell_state
[in]output_gateOutput gate
[in]hidden_scaleEffective scaling of cell_state .* output_gate
[in]hidden_offsetZero point for cell_state .* output_gate
[out]output_stateOutput state
[in]scratch0Scratch buffer
[in]scratch1Scratch buffer

◆ arm_nn_vec_mat_mul_result_acc_s8()

void arm_nn_vec_mat_mul_result_acc_s8 ( const int8_t *  lhs,
const int8_t *  rhs,
const int32_t *  bias,
int16_t *  dst,
const int32_t  dst_offset,
const int32_t  multiplier,
const int32_t  shift,
const int32_t  rhs_cols,
const int32_t  rhs_rows,
const int32_t  batch 
)
Parameters
[in]lhsBatched vector
[in]rhsWeights input
[in]biasBias vector
[out]dstOutput
[in]dst_offsetOutput offset
[in]multiplierMultiplier for quantization
[in]shiftShift for quantization
[in]rhs_colsInput size (for each batch)
[in]rhs_rowsOutput size (for each batch)
[in]batchBatch size