Skip to content

Commit

Permalink
pack_padded_sequence: Check for empty (zero-element) tensors (#21461)
Browse files Browse the repository at this point in the history
Summary:
Fixes: #20529

Thank you, JamieCT for the bug report with reproducing script.
Pull Request resolved: pytorch/pytorch#21461

Differential Revision: D15696183

Pulled By: ezyang

fbshipit-source-id: a93cde2c924f8447563c64ce8a1cf75fcee60a01
  • Loading branch information
t-vi authored and facebook-github-bot committed Jun 6, 2019
1 parent 0c91a5f commit 5bd8175
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions aten/src/ATen/native/PackedSequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ std::tuple<Tensor, Tensor> _pack_padded_sequence(const Tensor& _input, const Ten

int64_t batch_size = input.size(1);
int64_t * lengths = lengths_t.data<int64_t>();
TORCH_CHECK(input.numel() > 0, "Cannot pack empty tensors.");
TORCH_CHECK(lengths_t.size(0) == batch_size,
"Expected `len(lengths)` to be equal to batch_size, but got ", lengths_t.size(0),
" (batch_size=", batch_size, ")");
Expand Down

0 comments on commit 5bd8175

Please sign in to comment.