Find which line is using pytorch operation

I got this result from the profiler:

aten::ne 5.64% 372.377ms 16.59% 1.095s 39.548us 390.012ms 5.91% 1.099s 39.721us 27680

As far as I can tell through searching my code, I am not calling torch.ne anywhere. How can I trace exactly which lines are using this function?

Probably some other function is calling torch.ne, i.e. comparing if tensor elements are smaller than or equal elementwise…

You could check if the profiler shows this method in its stacktrace as shown here and might then be able to narrow it down.