Repository navigation
Add option to control rechunking in reshape - #6753
Merged
Merged
Conversation
When the slow-moving (early) axes in `.reshape` are all size 1, then we can avoid an intermediate rechunk which could cause memory issues. ``` 00 01 | 02 03 # a[0, :, :] ----- | ----- 04 05 | 06 07 08 09 | 10 11 ============= 12 13 | 14 15 # a[1, :, :] ----- | ----- 16 17 | 18 19 20 21 | 22 23 -> (3, 4) 00 01 | 02 03 ----- | ----- 04 05 | 06 07 08 09 | 10 11 ----- | ----- 12 13 | 14 15 ----- | ----- 16 17 | 18 19 20 21 | 22 23 ``` xref dask#5544, specifically the examples given in dask#5544 (comment).
Adds a keyword to reshape to control merge / rechunking. See the documentation for an explanation.
Member
Author
TomAugspurger
marked this pull request as draft
October 20, 2020 14:22
TomAugspurger
marked this pull request as ready for review
November 5, 2020 18:49
TomAugspurger
commented
Nov 16, 2020
| an integer, then the result will be a 1-D array of that length. | ||
| One shape dimension can be -1. In this case, the value is | ||
| inferred from the length of the array and remaining dimensions. | ||
| merge_chunks : bool, default True |
Member
Author
There was a problem hiding this comment.
@jsignell do you have thoughts on this API? Does merge_chunks=True feel like a good description of what is done on master today? I see a couple alternatives:
merge_intermediate_chunks: Make it a bit clearer when things are getting merged.rechunk_leading_axes=False/True: Flip the logic to make it opt-in rather than opt-out.
Member
There was a problem hiding this comment.
I like it flipped, but rechunk_leading_axes feels long. This feels kind of like split_every=1 or something, but maybe reusing that kwarg is too confusing. Maybe split_chunks would work?
Member
|
I am fine with merging this as-is and seeing how it goes. Does that work for you @TomAugspurger? |
Member
Author
|
Works for me :) |
abduhbm
pushed a commit
to abduhbm/dask
that referenced
this pull request
Jan 19, 2021
* Avoid rechunking in reshape with chunksize=1 When the slow-moving (early) axes in `.reshape` are all size 1, then we can avoid an intermediate rechunk which could cause memory issues. ``` 00 01 | 02 03 # a[0, :, :] ----- | ----- 04 05 | 06 07 08 09 | 10 11 ============= 12 13 | 14 15 # a[1, :, :] ----- | ----- 16 17 | 18 19 20 21 | 22 23 -> (3, 4) 00 01 | 02 03 ----- | ----- 04 05 | 06 07 08 09 | 10 11 ----- | ----- 12 13 | 14 15 ----- | ----- 16 17 | 18 19 20 21 | 22 23 ``` xref dask#5544, specifically the examples given in dask#5544 (comment). * fix conditioni * remove breakpoint comment * API: Added merge_chunks to reshape Adds a keyword to reshape to control merge / rechunking. See the documentation for an explanation. * update images
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds on top of #6748, so a WIP for now. Just pushing this to show the docs to aid in review over there.
In
da.reshape, there's a tradeoff betweenThis adds a keyword to control that tradeoff. The default
merge_chunks=Trueis the current behavior and is backwards compatible.Here's a render of the new docs