Do not copy pin memory if it fails, just move
This commit is contained in:
parent
2e7b2d9926
commit
323b4aaf5a
|
|
@ -99,7 +99,10 @@ def _ensure_cpu_pinned(t: Optional[torch.Tensor]) -> Optional[torch.Tensor]:
|
|||
if t is None:
|
||||
return None
|
||||
if t.device.type != "cpu":
|
||||
t = t.to("cpu", copy=True)
|
||||
try:
|
||||
t = t.to("cpu", copy=True)
|
||||
except Exception:
|
||||
t = t.to("cpu")
|
||||
# Don't attempt to pin quantized tensors; many backends don't support it
|
||||
if _is_quantized_tensor(t):
|
||||
return t
|
||||
|
|
|
|||
Loading…
Reference in New Issue