mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Revert "Return NoOpDeviceGuardImpl in replace of CudaDeviceGuard when device is not available, or cpu-only build (#160532)"
This reverts commit a956c4ab1cb13079203a8f07eb26218724f54dc8. Reverted https://github.com/pytorch/pytorch/pull/160532 on behalf of https://github.com/huydhn due to Reverted internally ([comment](https://github.com/pytorch/pytorch/pull/160532#issuecomment-3287745165))
This commit is contained in:
@ -1387,12 +1387,6 @@ class FakeTensorMode(TorchDispatchMode):
|
||||
# See NOTE: [torch.tensor, lift_fresh, and device movement]
|
||||
prev_only_lift_cpu_tensors = torch._C._only_lift_cpu_tensors()
|
||||
torch._C._set_only_lift_cpu_tensors(True)
|
||||
|
||||
# In the case of CPU-only build or cuda device unavailable,
|
||||
# we patch the cuda device guard to use NoOpDeviceGuardImpl.
|
||||
# This enables us to trace over cuda kernels under FakeTensorMode.
|
||||
torch._C._ensureCUDADeviceGuardSet()
|
||||
|
||||
maybe_prev_fake_mode = torch._C._unset_dispatch_mode(self._mode_key)
|
||||
if self is not maybe_prev_fake_mode:
|
||||
self.enter_stack.append(
|
||||
@ -1403,7 +1397,6 @@ class FakeTensorMode(TorchDispatchMode):
|
||||
# no-op (still need to re-set the fake mode though since we unset it)
|
||||
torch._C._set_dispatch_mode(self)
|
||||
self.enter_stack.append((False, None, prev_only_lift_cpu_tensors))
|
||||
|
||||
return self
|
||||
|
||||
def __exit__(
|
||||
|
Reference in New Issue
Block a user