What is the exactly implementation of torch.embedding?

I am currently working on class Embedding() in PyTorch and I looked at its implementation.

In the forward() method, it calls the F.embedding() method: https://github.com/pytorch/pytorch/blob/master/torch/nn/modules/sparse.py#L124.

Then I found that F.embedding() method finally calls the torch.embedding() method: https://github.com/pytorch/pytorch/blob/master/torch/nn/functional.py#L1814.

However, I could not find where is the implementation of the method torch.embedding().

Could someone help me, please?

It should eventually call into this method for the forward pass.

1 Like

Thank you! Your answer is very helpful to me! :grin: