Powered by OpenAIRE graph
Found an issue? Give us feedback
addClaim

Tools to convert ONNX files (NCHW) to TensorFlow format (NHWC)

Authors: Hyodo, Katsuya;

Tools to convert ONNX files (NCHW) to TensorFlow format (NHWC)

Abstract

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: d20dba8 Optimize redundant transpose chains in flatbuffer_direct e7641fa Update 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_float16 into flatbuffer-direct export calls. Added model-level metadata plumbing to serialize reduced_precision_support in direct-written TFLite flatbuffers. Metadata now correctly reflects: fp16accfp16 when -eatfp16 is enabled, fp16accfp32 otherwise. This addresses mismatch cases where *_float16.tflite metadata stayed fp16accfp32 despite -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, optional REVERSE_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 UNIQUE options 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. 4) Dtype harmonization and 64-bit normalization improvements Added consistent INT64 -> INT32 and UINT64 -> UINT32 normalization 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->INT32 CAST 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 -1 cases, avoids over-resolving shapes that should remain runtime-dynamic, better treatment of onnxRawNewShape with existing concrete newShape. Improved replacement logic for EXPAND_DIMS / SQUEEZE to RESHAPE: 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/mul forms), 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. 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 If NMS-guard subpattern variant. Improved generic If branch mux dtype normalization. Strengthened Loop state 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: onnx2tf package version 2.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

If you use onnx2tf in your research, please cite it using these metadata.

  • BIP!
    Impact byBIP!
    selected citations
    These citations are derived from selected sources.
    This is an alternative to the "Influence" indicator, which also reflects the overall/total impact of an article in the research community at large, based on the underlying citation network (diachronically).
    0
    popularity
    This indicator reflects the "current" impact/attention (the "hype") of an article in the research community at large, based on the underlying citation network.
    Average
    influence
    This indicator reflects the overall/total impact of an article in the research community at large, based on the underlying citation network (diachronically).
    Average
    impulse
    This indicator reflects the initial momentum of an article directly after its publication, based on the underlying citation network.
    Average
Powered by OpenAIRE graph
Found an issue? Give us feedback
selected citations
These citations are derived from selected sources.
This is an alternative to the "Influence" indicator, which also reflects the overall/total impact of an article in the research community at large, based on the underlying citation network (diachronically).
BIP!Citations provided by BIP!
popularity
This indicator reflects the "current" impact/attention (the "hype") of an article in the research community at large, based on the underlying citation network.
BIP!Popularity provided by BIP!
influence
This indicator reflects the overall/total impact of an article in the research community at large, based on the underlying citation network (diachronically).
BIP!Influence provided by BIP!
impulse
This indicator reflects the initial momentum of an article directly after its publication, based on the underlying citation network.
BIP!Impulse provided by BIP!
0
Average
Average
Average