Torch.jit.script for torch.nn.utils.rnn.pack_padded_sequence

I have struggled with the problem several days.
Now I implemented torch.nn.utils.rnn.pack_padded_sequence with variable batch size and sequence length. The model is already trained and work fine in python. I want to embed it in my c++ project. I used torch.jit.script but it always inform me that
for operator (Tensor 0, Tensor 1, Tensor 2) -> Tensor:
expected a value of type Tensor for argument ‘2’ but found bool
I changed the batch_first to tensor.ones() and in forward prediction, it informs me that
argument ‘batch_first’ (position 3) must be bool
it is really ridiculous. And most examples online are trace implementation.
Can somebody help me or give me some hints?
Thx a lot!

1 Like

Indeed, pack_padded_sequences does not work with TorchScript yet.

I’m so sad :frowning: This is Important for me…

I’m thinking about opening an issue in Github, just to make sure PT devs have this under their radar. Hopefully the necessary change is easy to implement (although I have no idea on how TorchScript internals work…)

I have opened an issue in Github to track this: