Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QAT LSTM with hidden state (h0, c0) will get error #83

Closed
juyenshun opened this issue Jun 13, 2022 · 4 comments
Closed

QAT LSTM with hidden state (h0, c0) will get error #83

juyenshun opened this issue Jun 13, 2022 · 4 comments
Labels
question Further information is requested

Comments

@juyenshun
Copy link

Hi,

I want to apply hidden state on my LSTM model and run QAT. The model can run normally without Quantizer, but will get the error below when I apply QATQuantizer:

ERROR (tinynn.graph.tracer) inputs: ['input_1', 'input_2', 'input_3']
ERROR (tinynn.graph.tracer) forwards: []
ERROR (tinynn.graph.tracer) outputs: []
ERROR (tinynn.graph.tracer) constants: []

The attachment is an example file, thanks.
torch_lstm_test.zip

@peterjc123
Copy link
Collaborator

peterjc123 commented Jun 13, 2022

Please refer to the FAQ for exporting LSTM to TFLite. https://github.com/alibaba/TinyNeuralNetwork/blob/main/docs/FAQ.md#how-to-convert-a-model-with-lstm
As a requirement, you must remove the state inputs and outputs from your model.

@peterjc123 peterjc123 added the question Further information is requested label Jun 13, 2022
@peterjc123
Copy link
Collaborator

peterjc123 commented Jun 13, 2022

FYI, we only support dynamic quantization for the LSTM op. So, with your code, LSTM will still be evaluated with floating type numeric. If you want to mix QAT and dynamic quantization, then you may take a look at #81.

As for the model given in your example, dynamic quantization should be preferred. Please take a look at https://github.com/alibaba/TinyNeuralNetwork/blob/main/examples/quantization/dynamic.py .

@juyenshun
Copy link
Author

Thanks for your information, I will try it!

@peterjc123
Copy link
Collaborator

This issue will be closed due to inactivity. If you still have problems, please feel free to reopen it. Thanks for your support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants