-
Notifications
You must be signed in to change notification settings - Fork 118
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
PyTorch 转 TFLite 使用 int8 量化 #274
Comments
如果需要静态量化(qat或者ptq)请按照examples/quantization下面的样例代码来(你直接把浮点的模型传入TFLiteConverter是不能直接得到静态量化的模型的),如果是动态量化,参考examples/converter/dynamic.py |
我使用的就是 examples/converter/dynamic.py 中的代码,然后我换了一个分类模型,希望得到 int8 量化后的 tflite。修改了需要传入的 dummy_input, |
dynamic.py下面还有一系列参数 你没抄全 |
你这里int8量化如果是指的全量化模型,你要用examples/quantization下的qat.py或者post.py https://www.tensorflow.org/lite/performance/post_training_quantization?hl=zh-cn 简言之动态量化是weight only量化 Update: 重新看了你的第一条帖子,你要int8的量化输入输出,那你肯定需要的是全量化,请按照全量化的代码样例来走,谢谢 |
converter = TFLiteConverter(
model,
dummy_input,
tflite_path=output_path,
strict_symmetric_check=True,
quantize_target_type='int8',
quantize_input_output_type = 'int8',
fuse_quant_dequant = True,
)
中 dummy_input 需要是 int8 类型吗?如果设置了 int8 类型会报
RuntimeError: expected scalar type Char but found Float
;如果设置了 float32 类型会报AssertionError: Unsupported types: input_type: float32, quantize_input_type: int8
。请问怎样能够解决这个问题,完整实现 PyTorch 转 TFLite 使用 int8 量化(包括输入输出)呢?
The text was updated successfully, but these errors were encountered: