tensorflow / tflite-micro

Infrastructure to enable deployment of ML models to low-power resource-constrained embedded targets (including microcontrollers and digital signal processors).
Apache License 2.0
1.74k stars 769 forks source link

Find LSTMCell accum_shift and LSTMCell accum_multiplier #2575

Closed Kullka closed 1 month ago

Kullka commented 1 month ago

Hello everyone, I'm trying to implement LSTM network after quantization by TensorFlow Lite to FPGA. But I don't know how to get LSTMCell accum_shift and LSTMCell accum_multiplier. Can anyone help me? Thank you.

3 lines below can be found in https://github.com/tensorflow/tflite-micro/blob/main/tensorflow/lite/kernels/internal/reference/lstm_cell.h_ image

ddavis-2015 commented 1 month ago

@Kullka

The LstmCell method is only used with the legacy LSTM kernel operator, which TFLM does not support. TFLM supports the UNIDIRECTIONAL_SEQUENCE_LSTM operator, which does not use the LstmCell method. The legacy LSTM operator is still supported in the TensorFlow repository. Any additional questions regarding LSTM should be posted as an issue in that repository.

The accum_shift and accum_multiplier are computed using tflite::QuantizeMultiplier and the code for these values can be found here.