Custom RNNs cant be made compatible with packedsequence without a significant amount of code. See the inbuilt RNN implementation for example: https://github.com/pytorch/pytorch/search?utf8=✓&q=packedsequence&type= 1.9k