mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[Accelerator][Chore] Use existing acc
when raising an error (#150829)
As the title said, `acc` already exists so we just use it instead of calling `current_accelerator()` again. Pull Request resolved: https://github.com/pytorch/pytorch/pull/150829 Approved by: https://github.com/guangyey, https://github.com/Skylion007
This commit is contained in:
committed by
PyTorch MergeBot
parent
ec5f2e3028
commit
1239260a0e
@ -16,7 +16,7 @@ def _get_device_index(device: _device_t, optional: bool = False) -> int:
|
||||
raise RuntimeError("Accelerator expected")
|
||||
if acc.type != device.type:
|
||||
raise ValueError(
|
||||
f"{device.type} doesn't match the current accelerator {torch.accelerator.current_accelerator()}."
|
||||
f"{device.type} doesn't match the current accelerator {acc}."
|
||||
)
|
||||
device_index = device.index
|
||||
if device_index is None:
|
||||
|
Reference in New Issue
Block a user