Apply function along dimension of tensor?

hi pytorch
Without getting too bogged down, I have a problem where I have a function f that I would like to apply for each row in the first dimension of a tensor. Is there a method like apply that doesn’t break autograd, but still parallelizes well? Or is my current method the best way to do this?

for i in range(y.size(0)): f(x,y[i])


Did you find a good solution for this?

I’m still not sure if .chunk copies values or reference. It’s used in rnn

I don’t think there’s an easy way to do it, but depending on what you’re trying to do it might be possible to compose some pytorch functions.