ONNX (Open Neural Network Exchange) is an open standard for serializing machine-learning models as portable computation graphs. It reduces dependence on a particular training framework or hardware accelerator, allowing models from frameworks such as PyTorch, TensorFlow, Keras, scikit-learn, and XGBoost to move toward different runtimes and platforms. section 5.1 section 5.7
The format and ONNX Runtime are related but distinct. The format describes the model graph; ONNX Runtime executes it through hardware-specific execution providers such as CPU and CUDA. Models can be exported, validated, optimized, quantized, and then run in a supported runtime. section 5.1 section 5.6.2
An ONNX model is built from:
- Operators such as MatMul, Add, reductions, tensor transformations, neural-network layers, and activation functions. section 5.2
- Strongly typed tensors described by element type, shape, and values. section 5.2
- A serialized graph using Protocol Buffers, with model metadata and inputs and outputs. section 5.2
Linear regression graph
The expression Y = XA + B becomes a graph with a MatMul node followed by an Add node. Python bindings declare tensor information, create nodes and a graph, assemble the model, check it with check_model, and serialize it to a .onnx file. section 5.2
A practical deployment path exports a trained model, validates schema and numerical agreement with the original implementation, selects an execution provider, and measures performance. Runtime optimization can apply constant folding, redundant-node removal, operator fusion, and layout transformations. On GPU systems, IOBinding keeps inputs or outputs on the target device to avoid unnecessary CPU–GPU copies. section 5.5 section 5.6.2
Transformer deployment
A BERT question-answering model can be exported from PyTorch with dynamic batch and sequence axes, checked, compared against the original outputs, and executed with ONNX Runtime. The same pattern supports CUDA execution and transformer-specific optimization; ONNX-based quantization can further produce an 8-bit model. section 5.5 section 5.6 section 6.3
Figure 5.1 ONNX overview
Use the ecosystem overview to trace how framework models move through the ONNX format toward runtimes, conversion, optimization, and deployment targets. section 5.1






