The MySharedTensor is a temporary solution because it only works in a few of ops and cannot seamlessly adapt to all ops that the native Tensor supports. This is the reason I said it won’t work generally.
I hope the pytorch team can add this new feature in the future.
By the way, I want MySharedTensor can work with conv2d without allocating new memory. What should I do?