8000 Fix erroneous quantization operations in TFLite model by puddly · Pull Request #39 · kahrendt/microWakeWord · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix erroneous quantization operations in TFLite model #39

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

Merged
merged 1 commit into from
Dec 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions microwakeword/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,11 @@ def representative_dataset_gen():
converter = tf.lite.TFLiteConverter.from_saved_model(path_to_model)
converter.optimizations = {tf.lite.Optimize.DEFAULT}

# Without this flag, the Streaming layer `state` variables are left as float32,
# resulting in Quantize and Dequantize operations before and after every `ReadVariable`
# and `AssignVariable` operation.
converter._experimental_variable_quantization = True

if quantize:
converter.target_spec.supported_ops = {tf.lite.OpsSet.TFLITE_BUILTINS_INT8}
converter.inference_input_type = tf.int8
Expand Down
0