Export converts a live PyTorch nn.Module into an ONNX graph. The dynamo flag selects between TorchScript tracing and the newer torch.export-based capture path. Choose deliberately: dynamo=True became the default in PyTorch 2.9, but reported failures include several model families, and legacy dynamic_axes support is incomplete on that path. section 6.4
Listing 6.6 Export ResNet-18 to ONNX
torch.onnx.export(
model,
dummy_input, #A
"resnet18_fp32.onnx",
opset_version=17, #B
input_names=["input"],
output_names=["output"],
dynamic_axes={"input": {0: "batch"},
"output": {0: "batch"}}, #C
dynamo=False, #D
)A ResNet-18 export configured with the legacy exporter, opset 17, and a dynamic batch dimension. section 6.4

