Thanks eqy. Yes, DataParallel is used for the model: model = nn.DataParallel(model).cuda(). And the dimension of the first tensor SeqDist is 446x446 and the second tensor sum_idx is 446. The multiplication SeqDist * sum_idx is to select the rows specified in sum_idx and calculate each row’s average.
If the first dimension of the tensors changes, I don’t know how to make the multiplication work…