LSTM Layer Functions
-
riscv_nmsis_nn_status riscv_lstm_unidirectional_s16_s8(nmsis_nn_lstm_context *scratch_buffers, const int8_t *input_data, const nmsis_nn_lstm_dims *lstm_dims, const int8_t *in_to_in_weights, const int8_t *in_to_forget_weights, const int8_t *in_to_cell_weights, const int8_t *in_to_out_weights, const int8_t *recurrent_to_in_weights, const int8_t *recurrent_to_forget_weights, const int8_t *recurrent_to_cell_weights, const int8_t *recurrent_to_out_weights, const int16_t *cell_to_in_weights, const int16_t *cell_to_forget_weights, const int16_t *cell_to_out_weights, const int8_t *projection_weights, const nmsis_nn_lstm_params *lstm, int8_t *output_state, int16_t *cell_state, int8_t *output_data)
- group LSTM
Functions
-
riscv_nmsis_nn_status riscv_lstm_unidirectional_s16_s8(nmsis_nn_lstm_context *scratch_buffers, const int8_t *input_data, const nmsis_nn_lstm_dims *lstm_dims, const int8_t *in_to_in_weights, const int8_t *in_to_forget_weights, const int8_t *in_to_cell_weights, const int8_t *in_to_out_weights, const int8_t *recurrent_to_in_weights, const int8_t *recurrent_to_forget_weights, const int8_t *recurrent_to_cell_weights, const int8_t *recurrent_to_out_weights, const int16_t *cell_to_in_weights, const int16_t *cell_to_forget_weights, const int16_t *cell_to_out_weights, const int8_t *projection_weights, const nmsis_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.
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 nullpr. Otherwise needed for projection.
Supported framework: TensorFlow Lite micro
Note
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.
- Parameters
scratch_buffers – [in] Struct containing scratch buffers Expected size for each scratch buffer is lstm_dims->num_batches * lstm_dims->num_outputs.
input_data – [in] Pointer to input data
lstm_dims – [in] LSTM input parameters related to dimensions
input_to_input_weights – [in] Input to input weights
input_to_forget_weights – [in] Input to forget weights
input_to_cell_weights – [in] Input to cell weights
input_to_output_weights – [in] Input to output weights
recurrent_to_input_weights – [in] Recurrent to input weights
recurrent_to_forget_weights – [in] Recurrent to forget weights
recurrent_to_cell_weights – [in] Recurrent to cell weights
recurrent_to_output_weights – [in] Recurrent to output weights
cell_to_input_weights – [in] Cell to input weights. Not used.
cell_to_forget_weights – [in] Cell to forget weights. Not used.
cell_to_output_weights – [in] Cell to output weights. Not used.
projection_weights – [in] Projection weights. Not used.
lstm – [in] LSTM parameters. See struct declaration
output_state – [in] Pointer to (recurrent) output state
cell_state – [in] Pointer to cell state
output_data – [in] Pointer to output state
- Returns
The function returns
RISCV_NMSIS_NN_SUCCESS
-
riscv_nmsis_nn_status riscv_lstm_unidirectional_s16_s8(nmsis_nn_lstm_context *scratch_buffers, const int8_t *input_data, const nmsis_nn_lstm_dims *lstm_dims, const int8_t *in_to_in_weights, const int8_t *in_to_forget_weights, const int8_t *in_to_cell_weights, const int8_t *in_to_out_weights, const int8_t *recurrent_to_in_weights, const int8_t *recurrent_to_forget_weights, const int8_t *recurrent_to_cell_weights, const int8_t *recurrent_to_out_weights, const int16_t *cell_to_in_weights, const int16_t *cell_to_forget_weights, const int16_t *cell_to_out_weights, const int8_t *projection_weights, const nmsis_nn_lstm_params *lstm, int8_t *output_state, int16_t *cell_state, int8_t *output_data)