2.2.2
2.2.2
Summary
This PR strengthens flatbuffer_direct conversion quality for DAMO-style graphs and broadens built-in operator coverage while keeping model contracts stable at graph boundaries.
Functional Improvements
- Added robust Float32 export path from FP16-heavy IR:
- Introduced
clone_model_ir_with_float32to promote FP16 tensors/options into FP32. - Added
prune_identity_cast_operatorsandoptimize_redundant_transpose_operatorsto simplify generated graphs before writing TFLite. - Applied the same transpose cleanup to FP16 export and preserved reduced-precision metadata handling.
- Introduced
- Improved late-stage dynamic shape correctness:
_resolve_dynamic_reshape_shapesnow supportsprefer_runtime_inferable_from_onnx_raw=Trueto preserve ONNX runtime-inferable-1templates instead of stale concretized shapes.- Extended dynamic-lineage preservation for
RANGEoutputs with runtime-dependent lengths. - Prevented aggressive reshape passthrough folding when
preserveDynamicShape=Trueis set.
- Added LiteRT compatibility fallback for unsupported
SPLITinput dtypes:- Rewrites unsupported
SPLITintoSLICEchains (with optional cast in/out) so conversion succeeds for dtype combinations not accepted by LiteRTSPLIT.
- Rewrites unsupported
- Added a new graph optimizer for DAMO-like normalization/padding layouts:
_optimize_transpose_flatten_globalnorm_pad_prepost_nhwc_chainsremoves redundant pre/post transpose wrappers and rewrites affected shape/pad metadata into NHWC-consistent form.
Operator Coverage Extensions
Inverse:- Expanded built-in lowering from only 2x2/3x3 to generic square
NxN(up to16x16) by Gauss-Jordan-style tensor-op decomposition.
- Expanded built-in lowering from only 2x2/3x3 to generic square
GatherND:- Added lowering support for
batch_dims > 0by flattening batch prefix, synthesizing batch indices (RANGE+TILE+CONCAT), gathering, then reshaping back.
- Added lowering support for
Gemm/MatMul -> FULLY_CONNECTEDpath:- Added explicit I/O cast handling so FP16 interfaces can safely execute with internal FP32 compute.
- Bidirectional
LSTMpath:- Added FP16<->FP32 cast bridges to keep built-in kernel use while preserving external dtype contracts.
Sliceshape inference:- Improved static metadata resolution for strided slicing with known bounds; avoids incorrect oversized static lengths when runtime clipping may occur.
GridSample:- Improved handling of partially-unknown shape metadata by merging with ONNX raw shape hints and inferring expected output dimensions when valid.
Validation/Registry Alignment
- Updated validators (
Inverse,GatherND,GridSample) to match new lowering capabilities and constraints. - Expanded op registry declarations for
GatherNDand shape/index helper ops (RANGE,SHAPE) required by new lowerings.
Tests
- Expanded
tests/test_tflite_builder_direct.pywith targeted regression tests covering:- FP16->FP32 IR promotion and cast/transpose cleanup
Inversestatic8x8loweringGatherND(batch_dims>0)and GridSample unknown-shape scenarios- FP16 FC cast bridges
- unsupported-
SPLITfallback rewriting - reshape runtime
-1preference behavior - transpose/flatten/globalnorm/pad chain optimization
- Local test result:
pytest -q tests/test_tflite_builder_direct.py568 passed, 1 warning
Release Metadata
- Bumped package version to
2.2.2(pyproject.toml,onnx2tf/__init__.py). - Updated Docker tag examples in README to
2.2.2.
What's Changed
- Improve flatbuffer_direct coverage and DAMO conversion robustness by @PINTO0309 in #899
Full Changelog: 2.2.1...2.2.2