First of all, I want to explain the procedure how I get confused. I just read codes below:
y = torch.tensor([0, 2])
y_hat = torch.tensor([[0.1, 0.3, 0.6], [0.3, 0.2, 0.5]])
y_hat[[0, 1], y]
I wonder the syntax about the indexing operation. Naturally, I want to read the source code about torch.Tensor.__getitem__. I search the class Torch.Tensor but could not find the 'getitem' method. Consequently, I search its superclass torch._C._TensorBase and find the method, unfortunately it says # Defined in torch/csrc/autograd/python_variable.cpp.
Here is my question.
I read the cpp file but could not get the connection between the Pytorch code and cpp code, which means I could not figure out how the __getitem__ implemented. Actualyy, I even could not find the method at all in cpp file. So how can I get it?
I finally understand the initial problem about the indexing syntax, but I did not find the official refererence to it. So do you know something about it?