Add generalized Buffer::transpose() and related ctors - #3427
Merged
Conversation
It was awkward to use Buffer for non-planar data; `make_interleaved` supports only a limited case. This adds an arbitrary `reorder` method, and related ctors, that allow for easily making Buffers that have storage ordering that doesn't match the dimension ordering. (This will be used by #3423 to make the results of `Func::realize()` have the proper layout automatically.) Also, some drive-by cleanup in Buffer to use delegating ctors in some spots.
abadams
reviewed
Nov 8, 2018
| * pass a vector that lists each dimension index exactly once, in the desired order. | ||
| * For instance, to reorder a 3-dimensional planar image to be interleaved, | ||
| * pass {2, 0, 1} for storage_order */ | ||
| void reorder(const std::vector<int> &order) { |
Member
There was a problem hiding this comment.
I think it would be better to name this "transpose". In Halide::Func, reorder and reorder_storage both have no effect on how something is indexed, but change the underlying representation. Transpose is the complement. It swizzles indexing without changing the underlying representation.
Member
|
LGTM apart from disagreeing with the name |
abadams
approved these changes
Nov 8, 2018
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.
It was awkward to use Buffer for non-planar data;
make_interleavedsupports only a limited case. This adds an arbitraryreordermethod, and related ctors, that allow for easily making Buffers that have storage ordering that doesn't match the dimension ordering. (This will be used by #3423 to make the results ofFunc::realize()have the proper layout automatically.)Also, some drive-by cleanup in Buffer to use delegating ctors in some spots.