(I am not a Python veteran so pardon me if this is a naive question.)
Following the PyTorch tutorial, below code works fine.
import torch
x= torch.empty(5,3) # <========= HERE
print(x)
But the Visual Studio Code complains that:
E1101:Module 'torch' has no 'empty' member
Eclipse PyDev has a similar warning.
So I use below code to check what torch offers:
for (k, v) in torch.__dict__.items():
print(k, v)
And I find that it is a built-in:
empty <built-in method empty of type object at 0x00007FFA380E0A80>
Since it is a method, I searched all the *.py file in the torch package folder for something like def empty and empty, no luck.
So where is this empty method defined? Some pyd/DLL?
How is it imported into the namespace?
Or put it another way, how to create a built-in function for my own package?
ADD 1 -- 10:38 AM 11/12/2018
Extending Python Built-ins with C/C++
https://docs.python.org/3/extending/extending.html
I guess it's the torch::empty method. I have found a lot of matches in the github PyTorch codebase. But I haven't nailed the definition yet.