What's the efficient way to lookup embedding from a given tensor

Hi.
I want to know is there any efficient way to get some rows from a given tensor, like lookup_embedding in tensorflow.
For a given tensor with requires_grad = True, it will applied some functions/changes/masks, and then used as a look up table. Thus I am trying to find exactly the same way what tf.nn.embedding_lookup does.
Directly tensor[index] works, I wonder, is there more efficient way to do that.

Appreciate for any replies.

I also have similar problems.

You can use this API: nn.Embedding.from_pretrained

https://pytorch.org/docs/stable/torch.html#torch.index_select

I found that the direct way tensor[index] is more efficient than nn.Embedding.from_pretrained.
Any Comment?