-
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
Features/227 lshape #231
Features/227 lshape #231
Conversation
Could the fix be a squeeze() after the partial call? |
Thanks, indeed, that's probably what I need. I'll work on it now. |
Codecov Report
@@ Coverage Diff @@
## master #231 +/- ##
==========================================
+ Coverage 96.17% 96.18% +0.01%
==========================================
Files 47 47
Lines 6514 6639 +125
==========================================
+ Hits 6265 6386 +121
- Misses 249 253 +4
Continue to review full report at Codecov.
|
heat/core/operations.py
Outdated
@@ -208,8 +209,7 @@ def allclose(x, y, rtol=1e-05, atol=1e-08, equal_nan=False): | |||
return bool(_local_allclose.item()) | |||
|
|||
|
|||
|
|||
def any(x, axis=None, out=None): | |||
def any(x, axis=None, out=None, keepdim=None): |
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.
should this be keepdim=False instead of None?
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.
Done (now in logical.py).
heat/core/operations.py
Outdated
x : ht.tensor | ||
Input data. | ||
|
||
axis : None or int or tuple of ints, optional |
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.
can you add a bit of context to what this axis parameter does? i can see it in the examples but some text would be nice too
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.
Done (now in manipulations.py)
heat/core/operations.py
Outdated
if 0 in axis: | ||
lshape_losedim = (2,) + lshape_losedim | ||
else: | ||
lshape_losedim = (2 * lshape_losedim[0],) + lshape_losedim[1:] |
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.
the 2 seems fishy to me. can you justify it for me? I am just not seeing it
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.
Hi Daniel @coquelin77, EDITED
thanks, I'm really unhappy with this if statement. The problem is that, if axis is not None, the result of local_argmin/max and MPI_ARGMIN/MAX is made up of two sets of results really: the min/max values along a dimension, and the respective indices. So at this stage the dimension along the FIRST axis is the reduced dimension * 2. The min/max values are removed from the result at a later stage in the argmin/max() functions.
EDITED: never mind the par. below, I'm trying something else now.
(So having to re-add dimension of size 2 for the reduction axis is justified, it's cumbersome though and this "special behaviour" of argmin/max is giving me a lot of trouble pretty much whatever I'm working on. So @Markus-Goetz, @coquelin77 I'm thinking of adding __argreduce_op to operations.py and funnel argmin and argmax out to that function, leaving __reduce_op for "regular" reduction operations. )
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.
OK here's what it looks like now (operations.py lines 217-221)
# Take care of special cases argmin and argmax: keep partial.shape[0]
if (0 in axis and partial.shape[0] != 1):
lshape_losedim = (partial.shape[0],) + lshape_losedim
if (not 0 in axis and partial.shape[0] != x.lshape[0]):
lshape_losedim = (partial.shape[0],) + lshape_losedim[1:]
Basically, the assumption is that whenever the first dimension of partial is different from what it should be (1 if reduction along axis 0, or x.lshape[0] if reduction along any other axis), there will be a good reason for it so just keep that partial[0] as first dimension.
This way we don't need to add ifs for every quirky reduction operation that comes our way.
Please let me know if I'm overseeing something.
heat/core/tensor.py
Outdated
@@ -278,7 +280,7 @@ def allclose(self, other, rtol=1e-05, atol=1e-08, equal_nan=False): | |||
""" | |||
return operations.allclose(self, other, rtol, atol, equal_nan) | |||
|
|||
def any(self, axis=None, out=None): | |||
def any(self, axis=None, out=None, keepdim=None): |
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.
keepdim=False vs =None again
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.
done (dndarray.py)
heat/core/tensor.py
Outdated
x : ht.tensor | ||
Input data. | ||
|
||
axis : None or int or tuple of ints, optional |
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.
more explanation for axis as mentioned before
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.
done (dndarray.py)
Replaced dodgy if statement with a more general formulation.
(Re-implementation after merging with master)
…lations.squeeze()
Bump, has a minor conflict with the master |
until final implementation of Allgatherv is available
Alright @Markus-Goetz , @coquelin77 , I've commented out the test that fails for now, fixing that (Issue #273) needs fixing Allgatherv (#233, @Cdebus ). It would still be good to have squeeze() and the lshape fixes merged into master. Thanks, Claudia |
@Markus-Goetz there's still a quirk here with argmin and argmax. Even if axis = 0 (or contains 0), we can't lose the first dimension of partial, because partial_op in this case yields both the values and the indices, so dimension 0 of partial is by default at least 2 when it gets returned to the function. The fix has to happen in the argmin()/ argmax() functions. Not sure how to do that (yet).
Example:
With axis = 1: