Repository navigation
2.3.4
2.3.4
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.
Summary
This PR significantly expands flatbuffer_direct builtin support and tightens runtime safety for the direct TFLite export path.
The main goal of this branch is to move a large set of README-listed ONNX operators from partial or custom-only handling into native builtin lowering, while also making the generated LiteRT models materially safer to execute.
In practical terms, this branch:
- broadens builtin ONNX operator coverage in
flatbuffer_direct - adds new validator-driven constrained lowerings for many previously missing ops
- hardens
DeformConvso the builtin path no longer aborts LiteRT oninvoke() - expands direct-path runtime and coverage tests accordingly
- updates public package metadata and README support tables to reflect the new baseline
Why this change matters
The flatbuffer_direct backend is most valuable when it can emit TFLite builtins instead of relying on TensorFlow conversion fallback or custom ops. This branch improves that value proposition in two ways:
- Coverage: many more README-supported ONNX ops now have builtin or builtin-decomposition paths.
- Reliability:
DeformConvnow uses a LiteRT-safe lowering strategy for the supported standard case, instead of producing models that could serialize and allocate but still abort at runtime.
Key improvements
1. Large builtin coverage expansion
This branch adds or completes builtin lowering coverage across multiple builder families, including signal, reduction, elementwise, indexing, normalization, pooling, attention, and loss paths.
Notable areas improved include:
- random/window ops
Bernoulli,BlackmanWindow,HammingWindow,HannWindow,RandomNormal,RandomUniform,RandomUniformLike
- reduction and numeric ops
LeakyRelu,Mean,ReduceLogSum,ReduceLogSumExp,ReduceSumSquare,ThresholdedRelu,IsInf,IsNaN,Shrink
- shape/indexing/spatial ops
AffineGrid,CenterCropPad,Compress,ReverseSequence,Scatter,TensorScatter
- normalization / pooling / matrix ops
GroupNormalization,LpPool,GlobalLpPool,Det
- attention / signal / embedding / losses
Attention,DFT,STFT,MelWeightMatrix,RotaryEmbedding,NegativeLogLikelihoodLoss,SoftmaxCrossEntropyLoss
- ROI / unpool / deformable paths
MaxRoiPool,MaxUnpool,DeformConv
These additions are backed by registry-level dispatch/validation work and corresponding builder implementations.
2. DeformConv LiteRT runtime safety
DeformConv received a dedicated runtime hardening pass.
The new builtin lowering is intentionally constrained to the standard 2D float pattern:
group=1offset_group=1- rank-4 input/output/offset(/mask)
FLOAT16/FLOAT32- constant weights and optional constant bias
The previous path could generate a model that converted successfully but aborted the LiteRT interpreter during invoke(). The new path fixes that by:
- removing the
GATHER(batchDims=1)dependency from the sampling path - replacing it with a global-index gather approach
- reducing the high-rank grouped transpose chain
- lowering the sampling path to a LiteRT-safer rank profile
Unsupported grouped DeformConv patterns are still preserved as explicit custom-op candidates when custom ops are enabled and allowlisted.
3. Better registry, reporting, and docs alignment
The branch updates the source of truth for builtin support in op_registry.py, then propagates that state into:
- README builtin support table
- README custom-op candidate policy table
- op coverage tests and snapshots
The README builtin summary count is also refreshed to the current table contents.
4. Version and release metadata update
Package and container-facing version references are updated from 2.3.3 to 2.3.4 to match the functional expansion in this branch.
Testing
The branch includes substantial test expansion for flatbuffer_direct, including:
- direct conversion tests
- LiteRT runtime smoke/parity tests
- coverage report assertions
- fallback/custom-op policy tests
A notable addition is subprocess-isolated runtime verification for DeformConv, so native LiteRT abort regressions fail safely inside tests instead of taking down the full pytest worker.
Test result used for this branch
pytest -q tests/test_tflite_builder_direct.py tests/test_tflite_builder_op_coverage.pyResult:
646 passed, 2 warnings in 129.48s
Files of interest
The core changes are concentrated in:
onnx2tf/tflite_builder/op_registry.pyonnx2tf/tflite_builder/op_builders/conv.pyonnx2tf/tflite_builder/op_builders/shape.pyonnx2tf/tflite_builder/op_builders/reduce.pyonnx2tf/tflite_builder/op_builders/elementwise.pyonnx2tf/tflite_builder/op_builders/pool.pyonnx2tf/tflite_builder/op_builders/index.pyonnx2tf/tflite_builder/op_builders/norm.pyonnx2tf/tflite_builder/op_builders/recurrent.pytests/test_tflite_builder_direct.pytests/test_tflite_builder_op_coverage.pyREADME.md
Compatibility notes
This PR intentionally favors explicit constrained builtin support over broad but unsafe lowering.
The clearest example is DeformConv: the supported builtin path is now narrower, but it is meaningfully more correct because it survives actual LiteRT execution. Patterns outside that safe envelope still retain the existing custom-op fallback policy.
What's Changed
- feat: expand flatbuffer_direct builtin coverage and runtime safety by @PINTO0309 in #904
Full Changelog: 2.3.3...2.3.4