Closed zhenhuaw-me closed 4 years ago
--opset
can specify. Managing opset compatibility (example).tf2onnx
has a reasonable handling of layout - all in all, it has ~10 active developers. In one sentance, it's very like our propagation based approach with input/output shape unchanged when comparing the original model and output model - inserting Transpose
there. It could be inserting Transpose
operators first, and then remove most of them during graph optimization.
A mobilenet v2 example (official Google MobileNetV2 model) after convert is as below.
python -m tf2onnx.convert --graphdef ./mobilenet_v2_1.0_224/mobilenet_v2_1.0_224_frozen.pb \
--output mobilenet_v2.onnx --inputs input:0[1,224,224,3] --outputs MobilenetV2/Predictions/Softmax:0
The Transpose
for input.
Further more, tf2onnx
performs graph optimization such as fusing batch normalization and bias add into convolution. Better than what we expected before.
tf2onnx
doesn't support generate quantized ONNX model from TensorFlow models.
Converted official quantization-aware training mobilenet v1 model.
Given a quantiation-aware training tensorflow model, tf2onnx
:
FakeQuantWithMinMaxVars
are removed.FakeQuantWithMinMaxVars
of activations, tf2onnx
takes FakeQuantWithMinMaxVars
operators as custom operators, with which other tools can continue to work on Quantization-aware training support. Errors also reported, but we have the ONNX model still.
2020-07-13 20:00:35,570 - ERROR - Tensorflow op [MobilenetV1/MobilenetV1/Conv2d_0/act_quant/FakeQuantWithMinMaxVars: FakeQuantWithMinMaxVars] is not supported
2020-07-13 20:00:35,578 - ERROR - Tensorflow op [MobilenetV1/MobilenetV1/Conv2d_1_depthwise/act_quant/FakeQuantWithMinMaxVars: FakeQuantWithMinMaxVars] is not supported
......
2020-07-13 20:00:36,120 - ERROR - Unsupported ops: Counter({'FakeQuantWithMinMaxVars': 28})
And, they officially not support quantized tensorflow models:
If you want to convert a tensorflow model to onnx and than quantitize the onnx model you'd
Regarding the quantization, we have a chance here.
Limit support here as of July 13 2020. Not going to play around as we don't have much tf2 experience neither...
There is now
experimental support for tf-2.x
. With the exception of LSTM unit tests, all unit tests are enabled and passing. Unit tests that we still need to fix are marked with@skip_tf2
. GRU/LSTM's are converting but not runnable due to type/shape inference issues at runtime (working on that one). All unit tests are running in eager mode. After execution we take the python function, make it a graph and convert it to ONNX. When running under tf-2.x tf2onnx will use the tensorflow V2 controlflow.
We known the basic status here. Layout handling is better then we imaging and quantization is too limited.
https://github.com/onnx/tensorflow-onnx