Skip to content

Commit

Permalink
Zero sized tensor support for repeat_interleave (#23717)
Browse files Browse the repository at this point in the history
Summary:
Fixes pytorch/pytorch#22753
Pull Request resolved: pytorch/pytorch#23717

Differential Revision: D16623598

Pulled By: mrshenli

fbshipit-source-id: 297a3274fb5a5b2fcc0c3ad601337d7eb29fdca2
  • Loading branch information
zasdfgbnm authored and facebook-github-bot committed Aug 5, 2019
1 parent b3221da commit 99bada8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions aten/src/ATen/native/Repeat.h
Expand Up @@ -9,6 +9,9 @@ static inline Tensor repeat_interleave_common(const Tensor &repeats) {
TORCH_CHECK(repeats.dim() == 1, "repeat_interleave only accept 1D vector as repeat");
TORCH_CHECK(repeats.scalar_type() == at::kLong, "repeats has to be Long tensor");
TORCH_CHECK((repeats >= 0).all().item<uint8_t>(), "repeats can not be negative");
if (repeats.size(0) == 0) {
return at::empty_like(repeats);
}
Tensor repeats_ = repeats.contiguous();
Tensor cumsum = repeats.cumsum(0);
int64_t total = cumsum[-1].item<int64_t>();
Expand Down

0 comments on commit 99bada8

Please sign in to comment.