-
Notifications
You must be signed in to change notification settings - Fork 27.7k
ctx.save_for_backward doesn't save torch.Tensor subclasses fully #47117
Copy link
Copy link
Open
Labels
enhancementNot as big of a feature, but technically not a bug. Should be easy to fixNot as big of a feature, but technically not a bug. Should be easy to fixmodule: __torch_function__module: autogradRelated to torch.autograd, and the autograd engine in generalRelated to torch.autograd, and the autograd engine in generalmodule: docsRelated to our documentation, both in docs/ and docblocksRelated to our documentation, both in docs/ and docblocksneeds designWe want to add this feature but we need to figure out how firstWe want to add this feature but we need to figure out how firsttriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
Metadata
Metadata
Assignees
Labels
enhancementNot as big of a feature, but technically not a bug. Should be easy to fixNot as big of a feature, but technically not a bug. Should be easy to fixmodule: __torch_function__module: autogradRelated to torch.autograd, and the autograd engine in generalRelated to torch.autograd, and the autograd engine in generalmodule: docsRelated to our documentation, both in docs/ and docblocksRelated to our documentation, both in docs/ and docblocksneeds designWe want to add this feature but we need to figure out how firstWe want to add this feature but we need to figure out how firsttriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
🐛 Bug
Saving a torch.Tensor subclass with
ctx.save_for_backwardonly saves the base Tensor. The subclass type and additional data is removed (object slicing in C++ terminology).To Reproduce
Following the Extending PyTorch doc.
LoggingTensoris copy-pasted from there.Expected behavior
I would expect the subclass type to be preserved.
Expected:
Current result:
Environment
cc @hameerabbasi @rgommers @ezyang @albanD @zou3519 @gqchen @pearu @nikitaved @jlin27 @mruberry