Skip to content

2.3.12

Choose a tag to compare

@PINTO0309 PINTO0309 released this 19 Mar 10:54
· 1936 commits to main since this release
4c1c5b5

2.3.12

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.

1. Content and background

This branch focuses on improving the practical stability of the flatbuffer_direct pipeline and the native PyTorch export path for transpose-heavy and layout-sensitive models.

The main motivation was a set of real regression cases that were already known to convert successfully in the past, but started to fail or degrade after recent changes. The affected patterns were not isolated to one model family: they spanned PIDNet, SiNet, DepthToSpace-based super-resolution models, detection heads such as FastestDet, and Dynamo ONNX artifacts generated from exported native PyTorch packages.

From a feature-improvement perspective, this PR is not just a collection of one-off fixes. It expands the optimizer and exporter so that more difficult graph topologies can stay on the fast path while preserving layout semantics, output shapes, and numerical parity.

2. Summary of corrections

  • Extended flatbuffer_direct graph optimization coverage for SiNet.

    • Added multiple SiNet-specific rewrite passes to eliminate redundant transpose-heavy residual, skip, resize, affine, concat, and PReLU chains.
    • Improved the transpose-gather-transpose optimizer so it can preserve the pre-transpose when mixed consumers remain, while still removing redundant round-trips for NHWC-friendly subgraphs.
    • Added focused regression tests for the newly optimized SiNet patterns.
  • Hardened the native PyTorch export canonicalization and fast-repair path.

    • Fixed the PIDNet pag4 binary alignment regression in generated native packages.
    • Added fast pre-canonicalization repair handling for SiNet-style generated packages and avoided unnecessarily expensive raw canonicalization when the fast repair path already resolves the problematic pattern.
    • Fixed DepthToSpace(mode=CRD) NHWC gather repair so the repaired gather slices the channel axis instead of corrupting the spatial height.
    • Fixed channel-first alias propagation through simple assignments so downstream axis rewrites also cover FastestDet-style heads.
    • Restored missing graph output shapes in exported Dynamo ONNX artifacts by recovering public output shape metadata from the generated package when ONNX shape inference leaves graph outputs empty.
  • Improved exporter artifact consistency.

    • Native PyTorch package export, TorchScript export, Exported Program export, and Dynamo ONNX export now behave more consistently on the repaired model families.
    • The Dynamo ONNX sanitizer now preserves usable output shape annotations for downstream tooling instead of leaving terminal outputs shape-less.
  • Expanded regression protection.

    • Added and updated targeted tests in tests/test_pytorch_exporter.py and tests/test_tflite_builder_direct.py for PIDNet, SiNet, DepthToSpace, FastestDet alias propagation, and Dynamo ONNX output-shape restoration.
    • Removed the obsolete mean/variance normalization parity test that was no longer needed and was surfacing third-party warnings unrelated to the project logic.
  • Updated package versioning.

    • Bumped the project version and container tag references from 2.3.11 to 2.3.12.
    • Refreshed uv.lock accordingly.

3. Before/After (If there is an operating log that can be used as a reference)

Representative regression cases addressed by this branch:

  • rfdn_64x64

    • Before: ONNX/PyTorch output check failed. reason=Evaluation output shape mismatch after layout alignment. onnx_shape=(1, 3, 256, 256) tflite_shape=(1, 3, 192, 256)
    • After: ONNX/PyTorch output check complete! ... max_abs=3.8147e-05 rmse=4.11336e-06 cosine=1 pass=True
  • FastestDet

    • Before: max_abs=0.514514 rmse=0.0449929 cosine=0.984069 pass=False
    • After: max_abs=1.37091e-05 rmse=3.60957e-07 cosine=1 pass=True
  • age_googlenet

    • Before: max_abs=0.787734 rmse=0.28074 cosine=0 pass=False
    • After: max_abs=2.11e-05 rmse=9.26852e-06 cosine=1 pass=True
    • Additional export artifact fix: the final Dynamo ONNX output shape is now restored correctly from [] to [1, 8].

Validation performed during the branch work included:

  • Targeted pytest coverage for the new exporter and optimizer regressions.
  • Re-running native export / accuracy-check flows on age_googlenet, FastestDet, and rfdn_64x64 to confirm that previously successful conversions did not regress.

4. Issue number (only if there is a related issue)

N/A

What's Changed

  • Improve flatbuffer_direct and native PyTorch export stability by @PINTO0309 in #914

Full Changelog: 2.3.11...2.3.12