Skip to content

Conversation

@vishwakftw
Copy link
Contributor

@vishwakftw vishwakftw commented Jul 24, 2018

Added tests too. Fixes #9756 .

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a 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.

@zou3519
Copy link
Contributor

zou3519 commented Jul 24, 2018

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.

@vishwakftw
Copy link
Contributor Author

Sure, I will clear up that as well.

@vishwakftw
Copy link
Contributor Author

@zou3519 Are we not allowed to create 0-element tensors anymore? It seems torch.tensor([], ...) is failing.

@zou3519
Copy link
Contributor

zou3519 commented Jul 24, 2018

It's working for me though I might not be on the latest master:

In [1]: import torch

In [2]: torch.tensor([], dtype=torch.long, device='cuda')
Out[2]: tensor([], device='cuda:0', dtype=torch.int64)

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?

@vishwakftw
Copy link
Contributor Author

It was an nit in the ordering of the if clauses. Sorry about that.

@yf225
Copy link
Contributor

yf225 commented Jul 24, 2018

@pytorchbot retest this please

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a 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.

@vishwakftw
Copy link
Contributor Author

Is this good to go?

@ailzhang
Copy link
Contributor

@pytorchbot retest this please.

@vishwakftw
Copy link
Contributor Author

@ailzhang Is this good to go?

: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.

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.

@ssnl
Copy link
Collaborator

ssnl commented Aug 7, 2018

@pytorchbot retest this please

@vishwakftw
Copy link
Contributor Author

@ssnl Is this good to go?

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a 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.

PenghuiCheng pushed a commit to PenghuiCheng/pytorch that referenced this pull request Aug 10, 2018
Summary:
Added tests too. Fixes pytorch#9756 .
Pull Request resolved: pytorch#9757

Differential Revision: D8966879

Pulled By: soumith

fbshipit-source-id: 9f08a9d5d5d037db16319141d7a227a5efa23869
goodlux pushed a commit to goodlux/pytorch that referenced this pull request Aug 15, 2018
Summary:
Added tests too. Fixes pytorch#9756 .
Pull Request resolved: pytorch#9757

Differential Revision: D8966879

Pulled By: soumith

fbshipit-source-id: 9f08a9d5d5d037db16319141d7a227a5efa23869
@soumith soumith reopened this Aug 15, 2018
@soumith
Copy link
Contributor

soumith commented Aug 15, 2018

the merge got botched for this one. working on re-merging!

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a 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.

zdevito pushed a commit to zdevito/ATen that referenced this pull request Aug 16, 2018
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
@vishwakftw vishwakftw deleted the bincount-empty-fix branch August 17, 2018 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

torch.bincount errors on empty input

9 participants