W3cubDocs

/PyTorch 2.9

torch.Tensor.as_subclass

Tensor.as_subclass(cls) → Tensor

Makes a cls instance with the same data pointer as self. Changes in the output mirror changes in self, and the output stays attached to the autograd graph. cls must be a subclass of Tensor.

© 2025, PyTorch Contributors
PyTorch has a BSD-style license, as found in the LICENSE file.
https://docs.pytorch.org/docs/2.9/generated/torch.Tensor.as_subclass.html