[Bugfix][Relay][Frontend][Keras] Add a assertion to reject a invalid value for attribute units in RNN layers#15334
[Bugfix][Relay][Frontend][Keras] Add a assertion to reject a invalid value for attribute units in RNN layers#15334Hzfengsy merged 3 commits intoapache:mainfrom jikechao:fix_lstm_units
Conversation
Capture the invalid value of units.
|
Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment. Generated by tvm-bot |
echuraev
left a comment
There was a problem hiding this comment.
In general LGTM. I have some doubts. How did these models with incorrect units number work in old versions of Keras? I'm afraid that we can break a backward compatibility by this patch. Probably we could process this units number in the way how it was implemented in Keras? Or we can check Keras version and generate assert for newer versions of Keras. What do you think?
|
@echuraev Thanks for your comments! If In the new version of Keras, the called statement |
|
BTW, in addition to LSTM, RNN, and GRU, the Dense has the same bug. Thus we added an extra patch to fix |
|
@tvm-bot rerun |
echuraev
left a comment
There was a problem hiding this comment.
Thank you for clarification. LGTM.
|
Thanks for the fixing! |

This PR fixes two types of bugs:
Bug 1. fix a typo about the wrong API name in the test case.
Bug 2-5. add an assertion to reject the invalid model, which can be constructed in the old version of Keras. The attribute
unitsin LSTM, RNN, GRU, and Dense must have a positive value. Such invalid values can be used to construct a DL model successfully and can be converted to RelayIR successfully. In this pr, we reject these invalid models containing such layers.Steps to reproduce to bug-2 about LSTM: (Keras <= 2.6)
In the latest version of Keras, the invalid value for units will be rejected. Thus, the test case can be triggered using the Keras <=2.4.
Thus, we cannot new test cases into the unit tests.
cc @echuraev @leandron