Shortcuts

ONNX Backend for TorchDynamo

For a quick overview of torch.compiler, see torch.compiler.

Warning

The ONNX backend for torch.compile is a rapidly evolving beta technology.

torch.onnx.is_onnxrt_backend_supported()[source]

Returns True if ONNX Runtime dependencies are installed and usable to support TorchDynamo backend integration; False otherwise.

Example:

# xdoctest: +REQUIRES(env:TORCH_DOCTEST_ONNX)
>>> import torch
>>> if torch.onnx.is_onnxrt_backend_supported():
...     @torch.compile(backend="onnxrt")
...     def f(x):
...             return x * x
...     print(f(torch.randn(10)))
... else:
...     print("pip install onnx onnxscript onnxruntime")
...
Return type

bool

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources