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 beclass 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”.