Code autocomplete problem

I just started learning pytorch, I don’t quite understand why I can’t use auto-completion for some functions in Pycharm and VS Code.Such as torch.empty(), torch.zeros(), etc.
Can you help me with this problem?
Thanks~ o( ̄︶ ̄)o

This issue is tracked here and fixes are actively developed. :wink:

Here is a pyi that PR12500 generates:

As far as I know it works with mypy and PyCharm and has reasonable coverage.

Best regards

Thomas

This pyi file solves most built-in functions autocomplete problem. Many thanks to tom. However, when I try to type torch.nn, Pycharm shows warning ‘cannot find reference nn in __init__.pyi’. It seems this pyi file shadows all package of torch like torch.nn and torch.autograd. Is there any way to solve this? I will be very appreciated with that!

the pytorch 1.0.1 still not works. the torch.randn, torch.FloatTenser() can not be autocompleted by vscode or wingide.

1 Like

torch.FloatTensor is deprecated, so not recommending that is a feature.
There are bugs to be expected, but I see that you(?) already found issue 16996, which is a good place to report those.

Best regards

Thomas

I faced a similar problem with pytorch 1.4, vs code 1.42 with torch.nn as it was not showing autocomplete. I changed the language server from microsoft to jedi and now autocomplete works.

1 Like