torch.onnx.testing#
Created On: Sep 10, 2025 | Last Updated On: Sep 10, 2025
Utilities to aid in testing exported ONNX models.
- torch.onnx.testing.assert_onnx_program(program, *, rtol=None, atol=None, args=None, kwargs=None, strategy='TorchExportNonStrictStrategy', backend='onnxruntime')[source]#
Assert that the ONNX model produces the same output as the PyTorch ExportedProgram.
- Parameters:
program (_onnx_program.ONNXProgram) â The
ONNXProgramto verify.rtol (float | None) â Relative tolerance.
atol (float | None) â Absolute tolerance.
args (tuple[Any, ...] | None) â The positional arguments to pass to the program. If None, the default example inputs in the ExportedProgram will be used.
kwargs (dict[str, Any] | None) â The keyword arguments to pass to the program. If None, the default example inputs in the ExportedProgram will be used.
strategy (str | None) â Assert the capture strategy used to export the program. Values can be class names like âTorchExportNonStrictStrategyâ. If None, the strategy is not asserted.
backend (Literal['onnxruntime', 'reference']) â The backend to use for evaluating the ONNX program. Supported values are âonnxruntimeâ and âreferenceâ.