Rate this Page
โ˜… โ˜… โ˜… โ˜… โ˜…

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 ONNXProgram to 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โ€.