- Latency: is inference actually faster?
- Size: did the file shrink?
benchmark() runs locally, on your own machine, not on the platform. That is deliberate: latency numbers only mean something on the hardware you deploy to. Local benchmarks are free and do not consume plan quota.Built-in benchmark
Point the benchmark at two ONNX files and the data you want them timed on. It cycles through youreval_data across the timed runs, times both models on whichever ONNX Runtime provider is available on your machine, and reports the hardware it ran on.
quantized_model is the path to a .onnx file. If you unpacked a downloaded bundle, that is <bundle>/model.quantized.onnx — see the manifest for what else the bundle contains.Notes on the input
- Pass an iterable of samples: NumPy arrays, PyTorch tensors, or anything
np.asarraycan turn into a float32 array. - Every sample must match the shape the model expects. Batch size comes from your data: to time batch 32, pass samples of shape
(32, 3, 640, 640). - A 3-D sample (
C, H, W) gets a leading batch axis added, so(3, 224, 224)is fed as(1, 3, 224, 224).
You can reuse the same preprocessing function you used for calibrating the model. If no data samples are available and the network
makes the input go through a fixed number of layers, latency benchmarking is easier with synthetic data - more on this in the next
section.
Synthetic input
Without data at hand, setuse_synthetic=True and omit eval_data. The benchmark then reads the input shape from the model itself and synthesizes random inputs.
Terminal output
Withverbose=True (the default) the benchmark prints each run’s latency and tracks the running average:
The output is a BenchmarkResult
Accuracy is a separate job
Thebenchmark method does not report accuracy. To sign off on a quantized model, please run your task metric on a held-out labeled set, with the same preprocessing step.
Next steps
Calibration
Build a representative image set for ptq_static.
Quantization methods
Pick the right PTQ method or QAT.

