onnx / tensorflow-onnx

Convert TensorFlow, Keras, Tensorflow.js and Tflite models to ONNX
Apache License 2.0
2.32k stars 432 forks source link

Single layer Keras LSTM converted to loop instead of ONNX LSTM op #1851

Open JonTriebenbach opened 2 years ago

JonTriebenbach commented 2 years ago

The attached example shows a Keras model with a single layer LSTM that is converted to a loop instead of the expected ONNX LSTM op.

Test system configuration: Using tensorflow/tensorflow:2.7.1 docker image:

tensorflow-cpu               2.7.1
tf2onnx                      1.10.0

This issue appears to be similar to tf.keras.layers.LSTM not converted to ONNX LSTM layer #1546 with pull request Add Keras LSTM support .

onnx_issue.zip

Please review this issue. Thanks.

ahallermed commented 2 years ago

@JonTriebenbach I had the same issue with tensorflow==2.7.0 and tf2onnx==1.9.2.

A simple upgrade from to tf2onnx==1.9.3 solved the issue, that lstms are shown as loops. At least for me.

hwangdeyu commented 2 years ago

This PR Add Keras LSTM support involved in tf2onnx verison == 1.9.3. So This issue should be fixed after tf2onnx == 1.9.3 theoretically. I also tried to test it in tensorflow==2.7.1 and tfonnx == 1.9.3/1.10.0, and the lstms are both LSTM op instand of loop.. image Could you check it again? Thanks.

JonTriebenbach commented 2 years ago

@hwangdeyu Yes, we have other LSTM models that now convert as expected with tf2onnx 1.9.3. Thank you for those fixes that corrected those other models. The problem is that this new model is not converting as expected. The problem shows on both 1.9.3, and on the latest 1.10.0.

I do not know what is different about this new model that is not converting as expected. We have other models that have multiple LSTM layers, which convert as expected, this model is only a single layer LSTM model, which indicates it is not a multi-layer model issue. There is some other complexity in this new model that is causing a conversion issue.

Please continue to investigate. Thank you.

mjlorenzo305 commented 2 years ago

any updates on this one?

AndreyOrb commented 1 year ago

Is there any progress with this issue?

AndreyOrb commented 2 months ago

Is there any ETA on this issue?

fatcat-z commented 2 months ago

Is there any ETA on this issue?

Not yet.