TorchScript Unsupported PyTorch Constructs

Torch and Tensor Unsupported Attributes

TorchScript supports most methods defined on torch and torch.Tensor, but we do not have full coverage. Here are specific known ops and categories of ops which have diverging behavior between Python and TorchScript. If you encounter something else that is not supported please file a GitHub issue. Deprecated ops are not listed below.

Unsupported Tensor Methods

Unsupported Tensor Properties

Functions Not Correctly Bound on Torch

The following functions will fail if used in TorchScript, either because they are not bound on torch or because Python expects a different schema than TorchScript.

Ops With Divergent Schemas Between Torch & Python

The following categories of ops have divergent schemas:

Functions which construct tensors from non-tensor inputs do not support the requires_grad argument, except for torch.tensor. This covers the following ops:

The following functions require dtype, layout, device as parameters in TorchScript, but these parameters are optional in Python.

PyTorch Unsupported Modules and Classes

TorchScript cannot currently compile a number of other commonly used PyTorch constructs. Below are listed the modules that TorchScript does not support, and an incomplete list of PyTorch classes that are not supported. For unsupported modules we suggest using torch.jit.trace().


Access comprehensive developer documentation for PyTorch

View Docs


Get in-depth tutorials for beginners and advanced developers

View Tutorials


Find development resources and get your questions answered

View Resources