tensorflow-onnx icon indicating copy to clipboard operation
tensorflow-onnx copied to clipboard

convert uint8 tflite model to onnx has dequant and quant nodes

Open tensorbuffer opened this issue 1 year ago • 0 comments

Describe the bug

The generated graph has consecutive dequant and quant node, with same scale and zero point. These are not needed. The weights can have one dequant to make it from uint8 to float.

Urgency

Kind of urgent. If this path (tflite to onnx) doesn't work, need to look into pb to onnx, but then pb have QAT fake quant nodes, not sure if that has issue converting or not.

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 18.04*): Ubuntu 20.04.6 LTS
  • TensorFlow Version:2.11.0
  • Python version:3.8.17
  • ONNX version (if applicable, e.g. 1.11*):1.15.0
  • ONNXRuntime version (if applicable, e.g. 1.11*):1.16.3

To Reproduce

python -m tf2onnx.convert --opset 16 --tflite ../tree_seg.tflite --output tree_seg.onnx

Screenshots

tflite2onnx the two nodes between the two conv nodes are not needed.

Additional context

tree_seg.zip

tensorbuffer avatar Jun 07 '24 23:06 tensorbuffer