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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
repeat_interleave throws IndexError on repeating size-zero dimension #22753
Comments
Sorry if off-topic but regarding unit tests: Speaking for myself, one of the nice features of the torch 1.0 release was expanded support for operations involving 0-element n-dimensional tensors (see #9947). But has there been a review of For example I checked |
@jhultman yes we did add tests for all the operators we decided to add support for as part of #9947 and related PRs. That doesn't cover every single operator (long tail problem...) and the specific operator in question was added after the general feature (so should have included tests as part of its PR). But having general operator-sized testing would help a lot here. |
@gchanan General operator-sized testing sounds like a very nice idea. What would that look like? I can open a new issue if you think appropriate. |
My rough thought is we should have a DSL or something that describes allowed input sizes and expected output sizes. That would also be useful for lazy tensors. And then we could drive automated, randomized testing based on that. |
Summary: Fixes pytorch/pytorch#22753 Pull Request resolved: pytorch/pytorch#23717 Differential Revision: D16623598 Pulled By: mrshenli fbshipit-source-id: 297a3274fb5a5b2fcc0c3ad601337d7eb29fdca2
馃悰 Bug
torch.repeat_interleave(input, repeats, dim)
throwsIndexError
wheninput.size(dim) == 0
. The correspondingnumpy.repeat
handles the size-zero case gracefully.To Reproduce
Expected behavior
Environment
PyTorch version: 1.1.0
CUDA used to build PyTorch: 9.0.176
OS: Ubuntu 16.04.4 LTS
Python version: 3.7
cuDNN version: /usr/lib/x86_64-linux-gnu/libcudnn.so.7.1.4
(I have also tried on torch nightly version 1.2.0.dev20190711 and it has not been fixed.)
Additional context
I think it would be more consistent and intuitive if
output.size(dim) == 0
wheneverinput.size(dim) * repeats == 0
. The output size should be determined by the product of the input size in the appropriate dimension and the repeats (broadcasted). This is how the numpy version is designed.For context, the converse works fine since the zero-dim does not participate:
This one throws IndexError but is supported in numpy:
I think it makes sense for "repeating empty by empty" to vacuously yield empty (of same size as input).
The text was updated successfully, but these errors were encountered: