Talmaj/onnx2pytorch
Transform ONNX model to PyTorch representation
What it solves
It allows users to convert neural network models from the ONNX format to PyTorch. This enables developers to leverage PyTorch's backend and its extensive set of features for manipulating neural networks that were originally exported to ONNX.
How it works
The library provides a ConvertModel class that takes a loaded ONNX model as input and transforms it into a PyTorch model. It maps ONNX operators to their PyTorch equivalents, ensuring that operators or attributes that cannot be expressed in PyTorch raise an error rather than producing incorrect results.
Who it’s for
Developers and researchers who have models in ONNX format and want to move them into the PyTorch ecosystem for inference or further manipulation.
Highlights
- Broad Model Support: Successfully converts various architectures including MobileNet, ResNet, BERT-Squad, and YOLOv4.
- Differential Testing: Operators are tested against
onnxruntimeand ONNX'sReferenceEvaluatoracross different schema revisions. - Debug Mode: Includes a debug flag to compare activations between the PyTorch version and the original ONNX runtime to pinpoint discrepancies.
- Inference Ready: Supports batch sizes greater than 1 and uses inference mode for BatchNorm layers.
Related
- Project
- Project
- Project
- Project
- Project