-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Fix bincount for empty input #9757
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
Conversation
facebook-github-bot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zou3519 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
|
I'm a little concerned because the documentation is ill-defined for what happens in this case: https://pytorch.org/docs/master/torch.html?highlight=bincount#torch.bincount . If we're trying to match numpy, we should probably make the docs clearer on what happens in this edge case. |
|
Sure, I will clear up that as well. |
|
@zou3519 Are we not allowed to create 0-element tensors anymore? It seems |
|
It's working for me though I might not be on the latest master: I don't think we are disallowing empty tensor creation. edit: Tested on master and empty tensor creation works, maybe the error is something else? |
|
It was an nit in the ordering of the |
|
@pytorchbot retest this please |
facebook-github-bot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ssnl has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
|
Is this good to go? |
|
@pytorchbot retest this please. |
|
@ailzhang Is this good to go? |
torch/_torch_docs.py
Outdated
| :math:`out[n] += weights[i]` if :attr:`weights` is specified else | ||
| :math:`out[n] += 1`. | ||
| If the number of elements in :attr:`input` is 0, then the result is a tensor of size |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
torch/_torch_docs.py
Outdated
| Shape: | ||
| output (Tensor): ``Size([max(input) + 1])`` | ||
| output (Tensor): ``Size([max(input) + 1])`` if :attr:`input` is non-empty. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
@pytorchbot retest this please |
|
@ssnl Is this good to go? |
facebook-github-bot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
soumith is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Summary: Added tests too. Fixes pytorch#9756 . Pull Request resolved: pytorch#9757 Differential Revision: D8966879 Pulled By: soumith fbshipit-source-id: 9f08a9d5d5d037db16319141d7a227a5efa23869
Summary: Added tests too. Fixes pytorch#9756 . Pull Request resolved: pytorch#9757 Differential Revision: D8966879 Pulled By: soumith fbshipit-source-id: 9f08a9d5d5d037db16319141d7a227a5efa23869
|
the merge got botched for this one. working on re-merging! |
facebook-github-bot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
soumith has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Summary: Added tests too. Fixes #9756 . Pull Request resolved: pytorch/pytorch#9757 Reviewed By: Yangqing Differential Revision: D9348485 Pulled By: soumith fbshipit-source-id: e13afadf8dbea20ee6ee595383c522dcbaf8796a
Added tests too. Fixes #9756 .