You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PyTorch efficiency lint misses .to() after torch.randint #5666
The pytorch-efficiency-lint-redundant-to-call diagnostic detects .to(device) after torch.rand and others, but does not detect .to(device) or .to(torch.bool) after torch.randint. torch.randint accepts both device and dtype arguments, so these conversions can be specified when constructing the tensor.
Pyrefly should report pytorch-efficiency-lint-redundant-to-call for the torch.randint(...).to(torch.bool) and torch.randint(...).to(device) cases. Right now it only flags rand(...).
Environment:
Pyrefly 1.4.0
PyTorch 2.11.0
numpy 1.26.4
I'm not sure what other torch factories are also missed.
Sandbox Link
No sandbox due to torch requriement
(Only applicable for extension issues) IDE Information
I'd like to work on this. My plan is to extend the efficiency lint's factory list so torch.randint is handled like torch.rand, likely in the redundant-to-call check, and add test cases for the .to(torch.bool) and .to(device) forms. Could you assign this to me?
Activity
jay23606 commentedon Nov 17, 2026
I'd like to work on this. My plan is to extend the efficiency lint's factory list so torch.randint is handled like torch.rand, likely in the redundant-to-call check, and add test cases for the .to(torch.bool) and .to(device) forms. Could you assign this to me?