-
Notifications
You must be signed in to change notification settings - Fork 55
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
Feature/669 bincount #670
Feature/669 bincount #670
Conversation
Codecov Report
@@ Coverage Diff @@
## master #670 +/- ##
=======================================
Coverage 97.37% 97.38%
=======================================
Files 87 87
Lines 16711 16758 +47
=======================================
+ Hits 16273 16320 +47
Misses 438 438
Continue to review full report at Codecov.
|
rerun tests |
5 similar comments
rerun tests |
rerun tests |
rerun tests |
rerun tests |
rerun tests |
68f081f
to
6807be1
Compare
rerun tests |
1 similar comment
rerun tests |
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.
This looks really good to me, thanks for implementing it!
heat/core/statistics.py
Outdated
counts = torch.bincount(x._DNDarray__array, weights, minlength) | ||
|
||
size = counts.size()[0] | ||
maxlength = x.comm.allreduce(size, op=MPI.MAX) |
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.
Interesting. I would have just calculated maxlength = x.max()+1
. You're bypassing all the __reduce_op() checks so you're probably more efficient :)
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.
I was curious. I get roughly 0.0001s ~ 0.0002s faster times in a very simple test.
heat/core/statistics.py
Outdated
Raises | ||
------ | ||
ValueError | ||
If split axes of `x` and `weights` are not the same. |
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.
Technically this can't be because both only have one axis.
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.
It happens in the one case with None and 0, but pytorch would be complaining anyway because of different input tensor lengths.
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.
Yes, I understood what you were referring to, I was just suggesting to reword this line because None
is not a split axis. Suggestions:
- "if the
split
attribute is not the same"? - "if
x
is distributed andweights
isn't, or vice versa"?
rerun tests |
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.
Great, thanks!
Description
Introduces the bincount function similar to the respective numpy and pytorch functions.
Issue/s resolved: #669
Changes proposed:
Type of change
Due Diligence
Does this change modify the behaviour of other functions? If so, which?
no