$ show PINTO0309/onnx2tf
onnx2tf is a production-ready ONNX to TensorFlow/TFLite conversion framework that employs a sophisticated pass-based optimization pipeline. The system converts ONNX models through preprocessing, lowering to an intermediate representation (ModelIR), applying 50+ optimization passes (layout transformation, operator fusion, quantization), and exporting to target formats including TFLite, SavedModel, PyTorch nn.Module, and TorchScript. Its architecture features clean separation between operator implementations, IR transformation passes, and backend-specific exporters, with the flatbuffer_direct backend providing 100x+ faster conversion by bypassing TensorFlow graph construction. The framework includes comprehensive accuracy validation tools, dynamic shape handling, and model surgery capabilities for intermediate layer extraction.
The LLM identified 5 files worth highlighting for reuse:
Manages tensor layout state (NHWC/NCHW) throughout the conversion pipeline. Provides isolated layout tracking and reconciliation logic that could be extracted for use in any tensor processing system. Demonstrates non-obvious skill in handling complex layout transformations and propagation through optimization passes.
Implements a robust pass execution framework with transactional support, recovery mechanisms, and phase tracking. This isolated component provides a reusable foundation for any compiler or transformation system requiring ordered pass execution with rollback capabilities. Shows craftsmanship in its context management and diagnostic reporting.
Handles elementwise operations with proper broadcasting, type promotion, and layout considerations. This modular component could be extracted for use in expression compilers or tensor libraries. Demonstrates skill in managing the complexities of elementwise operations across different data types and layouts.
Collection of utility functions for safe tensor operations, transpose handling, and node information generation. These general-purpose utilities are minimally coupled and could be reused in various tensor processing contexts. Shows attention to detail in error handling and edge case management.
Manages operator registration, capability checking, and fallback mechanisms for custom operators. This isolated component provides a reusable pattern for any system needing to validate and route operations based on backend support. Demonstrates skill in designing extensible operator systems with graceful degradation.