Skip to content
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

Add int and str type to device parameter of torch.tensor() #126404

Open
hyperkai opened this issue May 16, 2024 · 1 comment
Open

Add int and str type to device parameter of torch.tensor() #126404

hyperkai opened this issue May 16, 2024 · 1 comment
Labels
module: python frontend For issues relating to PyTorch's Python frontend triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Comments

@hyperkai
Copy link

hyperkai commented May 16, 2024

πŸ“š The doc issue

The doc explains device parameter but it doesn't have int and str type as shown below:

device (torch.device, optional) – the device of the constructed tensor. If None and data is a tensor then the device of data is used. If None and data is not a tensor then the result tensor is constructed on the current device.

Actually, device parameter with int and str type works as shown below:

import torch

torch.tensor(data=-3, device=0)
torch.tensor(data=-3, device='cuda:0')
# tensor(-3, device='cuda:0')

Suggest a potential alternative/fix

No response

cc @albanD

@mikaylagawarecki mikaylagawarecki added module: python frontend For issues relating to PyTorch's Python frontend triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module labels May 20, 2024
@albanD
Copy link
Collaborator

albanD commented May 20, 2024

Adding string sounds definitely good.
I'm not so sure about int as I'm not sure if it is not something we would like to change going forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: python frontend For issues relating to PyTorch's Python frontend triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

No branches or pull requests

3 participants