Skip to content

Commit 1664834

Browse files
committed
Fix error
1 parent 3fa7eb2 commit 1664834

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

torch_xla/torch_xla.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,15 @@ def device(index: int = None) -> torch.device:
3636
torch_xla._XLAC._xla_set_default_device(device)
3737
return torch.device(device)
3838

39-
if n is None:
39+
if index is None:
4040
return torch.device(torch_xla._XLAC._xla_get_default_device())
4141

4242
devices = xm.get_xla_supported_devices()
43-
if n > len(devices):
44-
raise IndexError('Device index {} out of range in {}'.format(n, devices))
43+
if index > len(devices):
44+
raise IndexError('Device index {} out of range in {}'.format(
45+
index, devices))
4546

46-
device = devices[n]
47+
device = devices[index]
4748
torch_xla._XLAC._xla_set_default_device(device)
4849
return torch.device(device)
4950

0 commit comments

Comments
 (0)