I read the pytorch’s rnn code, I found there are two implementaions on cpu and gpu.
In pytorch/nn/_functions/rnn.py, they use batch_sizes parameter in VariableRecurrent which is running on cpu, and there is no batch_sizes parameter in CudnnRNN which is running on gpu, so maybe dynamic batching is not supported on gpu. I’m not 100% sure about it.
I don’t really understand the VariableRecurrent’s logic flow, I think it uses the corresponding output and calculate the loss.
Now I’m goting to padding the sequences to max length, and use the right output(some short length sequence’s output is not the last one) to get loss.
Please tell me if you have any new answers! Thanks!