Hey @tom, torch.topk is significantly slower than torch.sort
I’m running it on a tensor of dimension 300k and taking k=200 out.
sample code -
import torch
x = torch.rand(300000, device='cuda')

%timeit torch.topk(x, 200) # 1000 loops, best of 5: 2.96 ms per loop
%timeit torch.sort(x, descending=True)[0][:200] # 1000 loops, best of 5: 812 µs per loop

Can you please help me here?
Regards
Nikhil