Skip to content

fix pack_padded_sequence() #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix pack_padded_sequence()
Hi!
It seems like for pytorch 1.7.0, pack_padded_sequence's src_length  must be in cpu, even if we're using cuda: pytorch/pytorch#43227

I also tried this command in pytorch 1.6.0 to check for backward compatibility and there it works fine, both with and without adding .cpu()
antoniogois authored Nov 11, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit ef1b0f081fedfcf83ce39cd2f27dcc33d3cbb2d1
2 changes: 1 addition & 1 deletion joeynmt/encoders.py
Original file line number Diff line number Diff line change
@@ -113,7 +113,7 @@ def forward(self, embed_src: Tensor, src_length: Tensor, mask: Tensor) \
# apply dropout to the rnn input
embed_src = self.emb_dropout(embed_src)

packed = pack_padded_sequence(embed_src, src_length, batch_first=True)
packed = pack_padded_sequence(embed_src, src_length.cpu(), batch_first=True)
output, hidden = self.rnn(packed)

#pylint: disable=unused-variable