Skip to content
heliaCORE
API reference
HELIA HUB

LSTM Layer Functions

Machine-readable model

function

Unidirectional LSTM inference.

Include/arm_nnfunctions_flt.h:1781

arm_cmsis_nn_status arm_lstm_unidirectional_f32(
const float32_t *input,
float32_t *output,
const cmsis_nn_lstm_params_f32 *params,
cmsis_nn_lstm_context_f32 *buffers
)

Unidirectional LSTM inference.

Parameters of arm_lstm_unidirectional_f32
NameTypeDirectionDescription
inputconst float32_t *inPointer to the input sequence tensor.
outputfloat32_t *outPointer to the output sequence tensor.
paramsconst cmsis_nn_lstm_params_f32 *inLSTM parameters and weights.
bufferscmsis_nn_lstm_context_f32 *in, outMutable LSTM scratch and state buffers. temp1 and temp2 are sized by `arm_lstm_unidirectional_f32_temp1_get_buffer_size()` / `arm_lstm_unidirectional_f32_temp2_get_buffer_size()`, which report 0: the float implementation never dereferences them and both may be NULL.
Returns of arm_lstm_unidirectional_f32
Description
`ARM_CMSIS_NN_SUCCESS` on success or `ARM_CMSIS_NN_ARG_ERROR` on invalid arguments.
function

Unidirectional GRU layer for float32 input, output and state.

Include/arm_nnfunctions_flt.h:1812

arm_cmsis_nn_status arm_gru_unidirectional_f32(
const float32_t *input,
float32_t *output,
const cmsis_nn_gru_params_f32 *params,
cmsis_nn_gru_context_f32 *buffers
)

Unidirectional GRU layer for float32 input, output and state.

Implements the reset-after GRU (Keras / TFLite default) when params->reset_after is non-zero, and the pre-reset variant otherwise. The hidden state is zero-initialised for the first time step, unless buffers->hidden_state is supplied for streaming state carry (batch_size == 1), in which case it seeds the initial state and receives the final hidden state on return.

Parameters of arm_gru_unidirectional_f32
NameTypeDirectionDescription
inputconst float32_t *inInput sequence tensor. Must not overlap `output`: earlier outputs are re-read as the recurrent state for later time steps, so aliasing corrupts silently.
outputfloat32_t *outOutput (hidden-state) sequence tensor.
paramsconst cmsis_nn_gru_params_f32 *inStruct describing the GRU operator.
bufferscmsis_nn_gru_context_f32 *in, outScratch buffers. May be NULL when `reset_after` != 0. temp1 is sized by `arm_gru_unidirectional_f32_temp1_get_buffer_size()`.
Returns of arm_gru_unidirectional_f32
Description
ARM_CMSIS_NN_SUCCESS on success, ARM_CMSIS_NN_ARG_ERROR otherwise.
function

Get size of the temp1 scratch buffer required by armlstmunidirectionalf32().

Include/arm_nnfunctions_flt.h:1833

int32_t arm_lstm_unidirectional_f32_temp1_get_buffer_size(const cmsis_nn_lstm_params_f32 *lstm_params)

Get size of the temp1 scratch buffer required by arm_lstm_unidirectional_f32().

Parameters of arm_lstm_unidirectional_f32_temp1_get_buffer_size
NameTypeDirectionDescription
lstm_paramsconst cmsis_nn_lstm_params_f32 *inLSTM operator parameters, i.e. the same `cmsis_nn_lstm_params_f32` passed to `arm_lstm_unidirectional_f32()`. No field is read.
Returns of arm_lstm_unidirectional_f32_temp1_get_buffer_size
Description
0 for any non-NULL lstm_params, on every build target: the float32 implementation computes its gate values per hidden unit in automatics and never dereferences temp1 or temp2, so both context pointers may be NULL. Returns -1 only for a NULL lstm_params. The query exists so arena-sizing code can treat every LSTM variant alike; a future implementation that starts staging gate vectors would change this figure, so size from the query rather than hard-coding 0.
function

Get size of the temp2 scratch buffer required by armlstmunidirectionalf32().

Include/arm_nnfunctions_flt.h:1842

int32_t arm_lstm_unidirectional_f32_temp2_get_buffer_size(const cmsis_nn_lstm_params_f32 *lstm_params)

Get size of the temp2 scratch buffer required by arm_lstm_unidirectional_f32(). The contract is identical to arm_lstm_unidirectional_f32_temp1_get_buffer_size(), and the answer is the same 0 (temp2 is likewise never dereferenced).

Parameters of arm_lstm_unidirectional_f32_temp2_get_buffer_size
NameTypeDirectionDescription
lstm_paramsconst cmsis_nn_lstm_params_f32 *inLSTM operator parameters, i.e. the same `cmsis_nn_lstm_params_f32` passed to `arm_lstm_unidirectional_f32()`. No field is read.
Returns of arm_lstm_unidirectional_f32_temp2_get_buffer_size
Description
0 for any non-NULL lstm_params, on every build target: the float32 implementation computes its gate values per hidden unit in automatics and never dereferences temp1 or temp2, so both context pointers may be NULL. Returns -1 only for a NULL lstm_params. The query exists so arena-sizing code can treat every LSTM variant alike; a future implementation that starts staging gate vectors would change this figure, so size from the query rather than hard-coding 0.
function

Get size of the temp1 scratch buffer required by armgruunidirectionalf32().

Include/arm_nnfunctions_flt.h:1863

int32_t arm_gru_unidirectional_f32_temp1_get_buffer_size(const cmsis_nn_gru_params_f32 *gru_params)

Get size of the temp1 scratch buffer required by arm_gru_unidirectional_f32().

Parameters of arm_gru_unidirectional_f32_temp1_get_buffer_size
NameTypeDirectionDescription
gru_paramsconst cmsis_nn_gru_params_f32 *inGRU operator parameters, i.e. the same `cmsis_nn_gru_params_f32` passed to `arm_gru_unidirectional_f32()`. Only reset_after and hidden_size are read.
Returns of arm_gru_unidirectional_f32_temp1_get_buffer_size
Description
Required buffer size in bytes: hidden_size * sizeof(float32_t) when reset_after == 0 (the pre-reset formulation stages the r . h_prev vector in temp1; the vector is reused across batches and time steps, so neither batch_size nor time_steps enters), and 0 when reset_after != 0 (temp1 is never dereferenced and may be NULL). Returns -1 if gru_params is NULL, if hidden_size is negative, or if the byte count would not fit in an int32_t. The figure and the range checks are the same on every build target.
function

Unidirectional LSTM inference.

Include/arm_nnfunctions_flt.h:3558

arm_cmsis_nn_status arm_lstm_unidirectional_f16(
const float16_t *input,
float16_t *output,
const cmsis_nn_lstm_params_f16 *params,
cmsis_nn_lstm_context_f16 *buffers
)

Unidirectional LSTM inference.

Parameters of arm_lstm_unidirectional_f16
NameTypeDirectionDescription
inputconst float16_t *inPointer to the input sequence tensor.
outputfloat16_t *outPointer to the output sequence tensor.
paramsconst cmsis_nn_lstm_params_f16 *inLSTM parameters and weights.
bufferscmsis_nn_lstm_context_f16 *in, outMutable LSTM scratch and state buffers. temp1 and temp2 are sized by `arm_lstm_unidirectional_f32_temp1_get_buffer_size()` / `arm_lstm_unidirectional_f32_temp2_get_buffer_size()`, which report 0: the float implementation never dereferences them and both may be NULL.
Returns of arm_lstm_unidirectional_f16
Description
`ARM_CMSIS_NN_SUCCESS` on success or `ARM_CMSIS_NN_ARG_ERROR` on invalid arguments.
function

Unidirectional GRU layer for float16 input, output and state.

Include/arm_nnfunctions_flt.h:3589

arm_cmsis_nn_status arm_gru_unidirectional_f16(
const float16_t *input,
float16_t *output,
const cmsis_nn_gru_params_f16 *params,
cmsis_nn_gru_context_f16 *buffers
)

Unidirectional GRU layer for float16 input, output and state.

Implements the reset-after GRU (Keras / TFLite default) when params->reset_after is non-zero, and the pre-reset variant otherwise. The hidden state is zero-initialised for the first time step, unless buffers->hidden_state is supplied for streaming state carry (batch_size == 1), in which case it seeds the initial state and receives the final hidden state on return.

Parameters of arm_gru_unidirectional_f16
NameTypeDirectionDescription
inputconst float16_t *inInput sequence tensor. Must not overlap `output`: earlier outputs are re-read as the recurrent state for later time steps, so aliasing corrupts silently.
outputfloat16_t *outOutput (hidden-state) sequence tensor.
paramsconst cmsis_nn_gru_params_f16 *inStruct describing the GRU operator.
bufferscmsis_nn_gru_context_f16 *in, outScratch buffers. May be NULL when `reset_after` != 0. temp1 is sized by `arm_gru_unidirectional_f16_temp1_get_buffer_size()`.
Returns of arm_gru_unidirectional_f16
Description
ARM_CMSIS_NN_SUCCESS on success, ARM_CMSIS_NN_ARG_ERROR otherwise.
function

Get size of the temp1 scratch buffer required by armlstmunidirectionalf16().

Include/arm_nnfunctions_flt.h:3605

int32_t arm_lstm_unidirectional_f16_temp1_get_buffer_size(const cmsis_nn_lstm_params_f16 *lstm_params)

Get size of the temp1 scratch buffer required by arm_lstm_unidirectional_f16(). The contract is identical to arm_lstm_unidirectional_f32_temp1_get_buffer_size(), and the answer is the same 0 on every build target (the float16 implementation likewise never dereferences temp1 or temp2, which may both be NULL).

Parameters of arm_lstm_unidirectional_f16_temp1_get_buffer_size
NameTypeDirectionDescription
lstm_paramsconst cmsis_nn_lstm_params_f16 *inLSTM operator parameters, i.e. the same `cmsis_nn_lstm_params_f16` passed to `arm_lstm_unidirectional_f16()`. No field is read.
Returns of arm_lstm_unidirectional_f16_temp1_get_buffer_size
Description
0 for any non-NULL lstm_params, -1 for a NULL lstm_params.
function

Get size of the temp2 scratch buffer required by armlstmunidirectionalf16().

Include/arm_nnfunctions_flt.h:3613

int32_t arm_lstm_unidirectional_f16_temp2_get_buffer_size(const cmsis_nn_lstm_params_f16 *lstm_params)

Get size of the temp2 scratch buffer required by arm_lstm_unidirectional_f16(). The contract is identical to arm_lstm_unidirectional_f32_temp1_get_buffer_size(), and the answer is the same 0.

Parameters of arm_lstm_unidirectional_f16_temp2_get_buffer_size
NameTypeDirectionDescription
lstm_paramsconst cmsis_nn_lstm_params_f16 *inLSTM operator parameters, i.e. the same `cmsis_nn_lstm_params_f16` passed to `arm_lstm_unidirectional_f16()`. No field is read.
Returns of arm_lstm_unidirectional_f16_temp2_get_buffer_size
Description
0 for any non-NULL lstm_params, -1 for a NULL lstm_params.
function

Get size of the temp1 scratch buffer required by armgruunidirectionalf16().

Include/arm_nnfunctions_flt.h:3628

int32_t arm_gru_unidirectional_f16_temp1_get_buffer_size(const cmsis_nn_gru_params_f16 *gru_params)

Get size of the temp1 scratch buffer required by arm_gru_unidirectional_f16(). See arm_gru_unidirectional_f32_temp1_get_buffer_size() for the -1-on-invalid contract and the pre-reset degenerate-0 note; both apply here unchanged.

Parameters of arm_gru_unidirectional_f16_temp1_get_buffer_size
NameTypeDirectionDescription
gru_paramsconst cmsis_nn_gru_params_f16 *inGRU operator parameters, i.e. the same `cmsis_nn_gru_params_f16` passed to `arm_gru_unidirectional_f16()`. Only reset_after and hidden_size are read.
Returns of arm_gru_unidirectional_f16_temp1_get_buffer_size
Description
Required buffer size in bytes: hidden_size * sizeof(float16_t) when reset_after == 0, 0 when reset_after != 0 (temp1 is never dereferenced and may be NULL). Half the figure `arm_gru_unidirectional_f32_temp1_get_buffer_size()` returns for the same shape - sizing an f16 layer with the f32 query over-allocates, and the reverse under-allocates.