subclass_zoo icon indicating copy to clipboard operation
subclass_zoo copied to clipboard

Fix composite compliance

Open zou3519 opened this issue 2 years ago • 0 comments

Aka, https://github.com/pytorch/pytorch/issues/69991

Motivation

We should make sure all PyTorch operations are "Composite Compliant". This condition is necessary for operators that look out-of-place to preserve the Tensor Subclass when passed in a Tensor Subclass.

Consider the following hypothetical out-of-place operation:

def my_add(x, y):
  result = x.clone()
  result.add_(y)
  return result

You may expect this to work the same as torch.add. However, if x is not a Tensor Subclass, but y is a Tensor subclass, then this returns us a regular Tensor, NOT a Tensor subclass!

zou3519 avatar Mar 24 '22 15:03 zou3519