Fix tensor.__deepcopy__ for lazy device (#73197)

Summary:
A small bug that misses `lazy` in tensor.__deepcopy__, which results in segmentation when deepcopy a lazy model.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/73197

Reviewed By: jbschlosser

Differential Revision: D34394482

Pulled By: wconstab

fbshipit-source-id: c84fdb9b3a827677971fd3477a92679d7dbce3c0
This commit is contained in:
Cody Yu 2022-02-22 17:58:35 -08:00 committed by Facebook GitHub Bot
parent d81a133b0d
commit c003d150ce

View File

@ -92,7 +92,7 @@ class Tensor(torch._C._TensorBase):
# does accurate alias tracking; however, the code below # does accurate alias tracking; however, the code below
# doesn't work because of # doesn't work because of
# https://github.com/pytorch/pytorch/issues/47442 # https://github.com/pytorch/pytorch/issues/47442
if self.is_sparse or self.device.type in ['xla', 'mlc', 'ort', 'meta', 'hpu']: if self.is_sparse or self.device.type in ['lazy', 'xla', 'mlc', 'ort', 'meta', 'hpu']:
new_tensor = self.clone() new_tensor = self.clone()
else: else:
new_storage = self.storage().__deepcopy__(memo) new_storage = self.storage().__deepcopy__(memo)