Hi all,
I have tried two ways for batch index_select,  but there are still some problems.Here are weight tensor and index:
W = torch.rand(40000, 1024)
index = torch.randint(0, 40000, size=(256, 2000))

256 is the batch size
I could achieve a batch index_select by following two ways:
 first way:   W[ index, :]

 second way:   torch.gather( W.expand(256,-1,-1) , 1 , index.unsqueeze(2).expand( -1 , -1, 1024) )

The both result tensors are same and with same size [256, 2000, 1024]
The first ways cost lots of memory because the result tensor does not shared the same memory with source tensor. The second way using gather cost lots of time.
Do anyone have a more efficient way to achieve batch index_select?