-
Notifications
You must be signed in to change notification settings - Fork 527
Migrate runtime.xla_device in favor of core.xla_model.xla_device #9200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to further harmonize our docs to the idiomatic torch.device("xla"), torch.device("xla:0"), and torch.device("xla", 1)?
@@ -15,14 +15,14 @@ import torch | |||
import torch_xla | |||
import torch_xla.core.xla_model as xm | |||
|
|||
t = torch.randn(2, 2, device=xm.xla_device()) | |||
t = torch.randn(2, 2, device=torch_xla.device()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be changed to device="xla"
?
print(t.device) | ||
print(t) | ||
``` | ||
|
||
This code should look familiar. PyTorch/XLA uses the same interface as regular | ||
PyTorch with a few additions. Importing `torch_xla` initializes PyTorch/XLA, and | ||
`xm.xla_device()` returns the current XLA device. This may be a CPU or TPU | ||
`torch_xla.device()` returns the current XLA device. This may be a CPU or TPU |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be further simplified to simply describing that users get a devicea via torch.device("xla")
?
t0 = torch.randn(2, 2, device=xm.xla_device()) | ||
t1 = torch.randn(2, 2, device=xm.xla_device()) | ||
t0 = torch.randn(2, 2, device=torch_xla.device()) | ||
t1 = torch.randn(2, 2, device=torch_xla.device()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be device="xla"
?
fixes #7831