Published March 6, 2026
| Version 2.2.1
Software
Open
Tools to convert ONNX files (NCHW) to TensorFlow format (NHWC)
Authors/Creators
Description
2.2.1
Summary
This PR delivers a broad flatbuffer_direct upgrade focused on three goals:
- feature parity with the TF-converter path where practical,
- safer dtype/shape handling for dynamic graphs,
- stronger final-stage graph optimization for layout-heavy models.
It includes the two commits in fix-sgsch:
d20dba8Optimize redundant transpose chains in flatbuffer_directe7641faUpdate flatbuffer_direct converters, metadata handling, and tests
Key Improvements
1) FP16 accumulation metadata parity between TF-converter and flatbuffer_direct
- Added propagation of
enable_accumulation_type_float16into flatbuffer-direct export calls. - Added model-level metadata plumbing to serialize
reduced_precision_supportin direct-written TFLite flatbuffers. - Metadata now correctly reflects:
fp16accfp16when-eatfp16is enabled,fp16accfp32otherwise.
- This addresses mismatch cases where
*_float16.tflitemetadata stayedfp16accfp32despite-eatfp16.
2) New/expanded builtin op coverage
- Added CumProd builtin lowering path (
build_cumprod_op) using a TFLite decomposition:RANGE,LESS/LESS_EQUAL,RESHAPE,TILE,FILL,SELECT_V2,REDUCE_PROD, optionalREVERSE_V2.
- Added Unique builtin lowering path (
build_unique_op) with validation constraints. - Added CastLike builtin lowering path (
build_castlike_op). - Added Upsample dispatch entry to reuse Resize lowering/validation path.
- Added
UNIQUEoptions serialization support in model writer (UniqueOptions).
3) Scatter/Index robustness upgrades
- ScatterND:
- support numeric updates dtype (with casting to data dtype as needed),
- normalize negative indices to ONNX semantics before scatter,
- improve dynamic-shape compatibility for shape/signature handling.
- ScatterElements:
- relaxed/expanded rank handling for
indices/updates, - runtime shape handling for dynamic updates,
- improved coordinate assembly for mismatched rank scenarios.
- relaxed/expanded rank handling for
4) Dtype harmonization and 64-bit normalization improvements
- Added consistent
INT64 -> INT32andUINT64 -> UINT32normalization in critical paths. - Improved binary op dtype selection for mixed integer/float inputs and comparison ops.
- Added unary/reduce dtype harmonization helpers to prevent runtime mismatches after upstream dtype normalization.
- Improved
Where/control-flow mux dtype normalization for signed/unsigned integer outputs. - Added constant-input CAST folding and redundant
INT64->INT32CAST chain cleanup in post-lowering optimization.
5) Dynamic shape and reshape stability fixes
- Reworked dynamic reshape resolution behavior:
- preserves runtime-driven
newShape=[]intent when required, - uses safer template sanitization for
0/ multiple-1cases, - avoids over-resolving shapes that should remain runtime-dynamic,
- better treatment of
onnxRawNewShapewith existing concretenewShape.
- preserves runtime-driven
- Improved replacement logic for
EXPAND_DIMS/SQUEEZEtoRESHAPE:- dynamic cases are preserved where static rewrite would be unsafe,
- dynamic squeeze rewrite path uses runtime shape plumbing when valid.
- Improved static-shape reconciliation and signature sanitation for edge dynamic-lineage cases.
6) Layout/transpose optimization expansion
Added and integrated multiple strict/final-stage optimization passes in lower_from_onnx2tf.py, including:
- transpose-split mixed pre-concat consolidation,
- channel-shuffle reshape/transpose rewrite to gather,
- transpose-gather-transpose axis-remap cleanup,
- post-transpose InstanceNorm/bias/add chain simplification,
- affine chain folding (
mul/add/mulforms), - split-conv-concat bridge rewrite to single post adapter,
- concat/mul/add/transpose(+add/mean/reshape-tail) bridge reductions,
- additional terminal/final-pass reapplication for late-introduced patterns.
These reduce redundant transposes/casts and stabilize final graph topology after late rewrites.
7) GridSample and pooling support expansion
- GridSample:
- expanded support to rank-5 border padding path (
padding_mode in {zeros, border}), - refined indexing/clipping behavior and flattened indexing paths for border/zero modes.
- expanded support to rank-5 border padding path (
- MaxPool1D:
- expanded kernel/stride handling constraints (positive kernel/stride with more explicit indices-mode checks).
8) Accuracy evaluation and error-report runtime resilience
- Accuracy evaluator now supports safer dynamic-dimension defaults and layout-aware dynamic dimension inference.
- Added runtime TFLite input resize helper usage in evaluator and direct-op error report path.
- Prevents shape-signature incompatibility issues during validation/inference when model inputs are dynamic.
9) Control-flow handling improvements
- Extended supported
IfNMS-guard subpattern variant. - Improved generic
Ifbranch mux dtype normalization. - Strengthened
Loopstate output remapping/casting logic for dtype/shape consistency.
10) Documentation and release updates
- Updated README builtin coverage/constraints table to reflect current direct-lowering capabilities.
- Clarified that accumulation-type option applies to both tf_converter and flatbuffer_direct paths.
- Version bumped:
onnx2tfpackage version2.2.0 -> 2.2.1- Docker tags in README updated accordingly.
Validation
Executed full direct-builder regression:
pytest -q tests/test_tflite_builder_direct.py- Result: 554 passed, 1 warning, 0 failures.
Also added/updated extensive tests for:
- CumProd builtin dispatch,
- Unique builtin lowering,
- ScatterND negative-index normalization and dtype casting,
- Upsample opset9 / Pad opset9 compatibility,
- dynamic reshape/signature preservation,
- transpose/layout optimization rewrites,
- integer dtype normalization in control-flow and elementwise paths,
- GridSample rank-5 border validation.
What's Changed
- flatbuffer_direct: add CumProd/Unique/CastLike, fp16 metadata parity, and shape/dtype optimizations by @PINTO0309 in https://github.com/PINTO0309/onnx2tf/pull/898
Full Changelog: https://github.com/PINTO0309/onnx2tf/compare/2.2.0...2.2.1
Notes
Files
PINTO0309/onnx2tf-2.2.1.zip
Files
(2.6 MB)
| Name | Size | Download all |
|---|---|---|
|
md5:458923f3d28b5a7056e59ae9077d21a9
|
2.6 MB | Preview Download |
Additional details
Related works
- Is supplement to
- Software: https://github.com/PINTO0309/onnx2tf/tree/2.2.1 (URL)
Software
- Repository URL
- https://github.com/PINTO0309/onnx2tf