Repository navigation
2.3.10
2.3.10
Important
Starting with onnx2tf v2.4.0, tf_converter will be deprecated and the default backend will be switched to flatbuffer_direct. With the v2.3.3 update, all backward compatible conversion options have been migrated to flatbuffer_direct, so I will only be doing minor bug fixes until April. If you provide us with ONNX sample models, I will consider incorporating them into flatbuffer_direct. I'll incorporate ai-edge-quantizer when I feel like it, but that will probably be about 10 years from now.
Summary
This branch hardens the native PyTorch export path so the raw-export canonicalization logic remains consistent across multiple previously fragile model families instead of fixing them one-by-one and reintroducing regressions elsewhere.
The main goal of this PR is to make the flatbuffer_direct + -cotof + -fdopt + -fdots + -fdodo + -fdoep workflow stable on a mixed regression set that repeatedly exposed layout-bridging, reshape, resize, transpose-conv, and output-boundary issues in the generated PyTorch package.
What this PR improves
- Strengthens raw-export canonicalization in
pytorch_exporter.pyfor channel-first/channel-last alias handling, including:- rank-3 and rank-4 alias materialization before reshape consumers
- singleton channel-first reshape propagation
- resize target-shape normalization across NHWC/NCHW bridges
- transpose-conv bridge recovery when an intermediate rank-4 view was accidentally collapsed into rank-3
- softmax axis correction only when the tensor is provably channel-first
- final output boundary cleanup so channel-first outputs are not needlessly re-permuted
- Preserves compatibility across previously conflicting fixes for:
- YOLOX
- PPHumanSeg
- TS AD Model
- PIDNet
- Version-RFB
- IAT LLIE
- Bread
- Bread Non-FM
- Reduces spurious native export regressions where helper-generated packages and raw-exported artifacts diverged for implementation-detail reasons rather than observable model behavior.
- Expands regression coverage in
tests/test_pytorch_exporter.pyandtests/test_tflite_builder_direct.pyto lock in the previously fragile canonicalization paths.
Why this matters
The recent failures were not isolated bugs in a single model. They came from the same class of canonicalization decisions being correct for one topology and incorrect for another. This PR treats the problem as a cross-model consistency issue and tightens the rewrite rules so they are applied only when the exporter has enough evidence about the intended logical layout and shape.
That makes the native package generation path more predictable and reduces the cycle of model-specific hotfixes that accidentally break another regression target.
Validation
Targeted regression tests were updated/added and the generated source was revalidated with py_compile.
In addition, the following end-to-end conversions were re-run with native export enabled:
python -m onnx2tf -i yolox_s.onnx -o tmp_yolox_s -tb flatbuffer_direct -cotof -fdopt -fdots -fdodo -fdoeppython -m onnx2tf -i human_segmentation_pphumanseg_2021oct.onnx -o tmp_human_segmentation_pphumanseg_2021oct -tb flatbuffer_direct -cotof -fdopt -fdots -fdodo -fdoeppython -m onnx2tf -i ts_ad_model.onnx -o tmp_ts_ad_model -tb flatbuffer_direct -cotof -fdopt -fdots -fdodo -fdoeppython -m onnx2tf -i pidnet_S_cityscapes_192x320.onnx -o tmp_pidnet_S_cityscapes_192x320 -tb flatbuffer_direct -cotof -fdopt -fdots -fdodo -fdoeppython -m onnx2tf -i version-RFB-640.onnx -o tmp_version-RFB-640 -tb flatbuffer_direct -cotof -fdopt -fdots -fdodo -fdoeppython -m onnx2tf -i iat_llie_180x320.onnx -o tmp_iat_llie_180x320 -tb flatbuffer_direct -cotof -fdopt -fdots -fdodo -fdoeppython -m onnx2tf -i bread_180x320.onnx -o tmp_bread_180x320 -tb flatbuffer_direct -cotof -fdopt -fdots -fdodo -fdoeppython -m onnx2tf -i bread_nonfm_180x320.onnx -o tmp_bread_nonfm_180x320 -tb flatbuffer_direct -cotof -fdopt -fdots -fdodo -fdoep
For all eight models:
- no export warnings remained
ONNX/TFLitechecks passedONNX/PyTorchchecks passed
Scope
The largest changes are in the native PyTorch exporter and its regression coverage. The accompanying test updates are intentionally extensive because the core issue here is regression prevention across multiple model topologies, not just a single bug fix.
What's Changed
- Stabilize native PyTorch export canonicalization across regression models by @PINTO0309 in #912
Full Changelog: 2.3.9...2.3.10