Self-Created Tools to convert ONNX files (NCHW) to TensorFlow/TFLite/Keras format (NHWC). The purpose of this tool is to solve the massive Transpose extrapolation problem in onnx-tensorflow (onnx-tf). I don't need a Star, but give me a pull request.
MIT License
708
stars
73
forks
source link
add option to enable only dynamic range quant #633
While output_integer_quantized_tflite already enables dynamic range quantization output, the option also triggers checks for calibration data, which is only required for full integer quantization, and causes errors when no calibration data is provided.
This is undesirable if only dynamic quantization is wanted.
2. Summary of corrections
A new option (-odrqt, --output-dynamic-range-quantized-tflite) is added to only enable dynamic range quant output, which doesn't need calibration data.
3. Before/After (If there is an operating log that can be used as a reference)
Before:
$ onnx2tf -i some_model_with_non_regular_input_shape.onnx -oiqt
(other output omitted)
Model conversion started ============================================================
INFO: input_op_name: input shape: [1] dtype: float32
ERROR: For INT8 quantization, the input data type must be Float32. Also, if --custom_input_op_name_np_data_path is not specified, all input OPs must assume 4D tensor image data. INPUT Name: input INPUT Shape: [1] INPUT dtype: float32
After:
$ onnx2tf -i some_model_with_non_regular_input_shape.onnx -odrqt
(other output omitted)
saved_model output started ==========================================================
saved_model output complete!
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
W0000 00:00:1715853625.734342 7691 tf_tfl_flatbuffer_helpers.cc:390] Ignored output_format.
W0000 00:00:1715853625.734397 7691 tf_tfl_flatbuffer_helpers.cc:393] Ignored drop_control_dependency.
Float32 tflite output complete!
W0000 00:00:1715853629.274694 7691 tf_tfl_flatbuffer_helpers.cc:390] Ignored output_format.
W0000 00:00:1715853629.274724 7691 tf_tfl_flatbuffer_helpers.cc:393] Ignored drop_control_dependency.
Float16 tflite output complete!
W0000 00:00:1715853631.535535 7691 tf_tfl_flatbuffer_helpers.cc:390] Ignored output_format.
W0000 00:00:1715853631.535568 7691 tf_tfl_flatbuffer_helpers.cc:393] Ignored drop_control_dependency.
Dynamic Range Quantization tflite output complete!
4. Issue number (only if there is a related issue)
1. Content and background
While
output_integer_quantized_tflite
already enables dynamic range quantization output, the option also triggers checks for calibration data, which is only required for full integer quantization, and causes errors when no calibration data is provided.This is undesirable if only dynamic quantization is wanted.
2. Summary of corrections
A new option (
-odrqt, --output-dynamic-range-quantized-tflite
) is added to only enable dynamic range quant output, which doesn't need calibration data.3. Before/After (If there is an operating log that can be used as a reference)
Before:
After:
4. Issue number (only if there is a related issue)