Shortcuts

Note

This page describes an internal API which is not intended to be used outside of the PyTorch codebase and can be modified or removed without notice.

torch.compiler.is_dynamo_compiling

torch.compiler.is_dynamo_compiling()[source][source]

Indicates whether a graph is traced via TorchDynamo.

It’s stricter than is_compiling() flag, as it would only be set to True when TorchDynamo is used.

Example:

>>> def forward(self, x):
>>>     if not torch.compiler.is_dynamo_compiling():
>>>        pass # ...logic that is not needed in a TorchDynamo-traced graph...
>>>
>>>     # ...rest of the function...
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