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

Quantization produces large scale coffiecient, which pervents the model from being loaded #390

Open
gaikwadrahul8 opened this issue Nov 27, 2024 · 2 comments
Assignees
Labels
status:awaiting review Awaiting PR review type:quantization For issues related to quantization

Comments

@gaikwadrahul8
Copy link

1. System information

Colab , as of 2023-10-23

2. Code

Please see the attached colab notebook here
https://colab.research.google.com/drive/1yUD0nDu8oeeDtQBa7xCbQWx_w8PxS4UC?usp=sharing
to reproduce the issue. It loads a pre-trained resnet18 from pytorch, converts it to onnx, converts it to tensorflow, and then exports it to tf-lite. ( The process is a bit convoluted, but I need a pretrained resnet18, and didn't find it in the tensorflow orbit so I used torchvision, hope that's ok.)

If you download the generated model (model_int8.tflite) and open it in netron.app and click on the first MaxPool2D op, you can see that the quantization scale is 1.3344405750530544e+36. See the attached image.

image

This scale parameter itself is of course implausible (impossible), but loading the model also produces an error here: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/kernels/internal/quantization_util.cc#L117

Does anybody know why the quantization parameter is that high, and what can be done to fix it? Furthermore, can I let the quantization fails explicitly when it generates such high values?

@gaikwadrahul8
Copy link
Author

This issue originally reported by @FabianSchuetze has been moved to this dedicated repository for ai-edge-torch to enhance issue tracking and prioritization. To ensure continuity, we have created this new issue on your behalf.

We appreciate your understanding and look forward to your continued involvement.

@pkgoogle
Copy link
Contributor

Still awaiting this PR: tensorflow/tensorflow#62605

@pkgoogle pkgoogle added status:awaiting review Awaiting PR review type:quantization For issues related to quantization labels Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:awaiting review Awaiting PR review type:quantization For issues related to quantization
Projects
None yet
Development

No branches or pull requests

2 participants