Skip to content

Add generalized Buffer::transpose() and related ctors - #3427

Merged
abadams merged 2 commits into
masterfrom
srj-storage
Nov 10, 2018
Merged

Add generalized Buffer::transpose() and related ctors#3427
abadams merged 2 commits into
masterfrom
srj-storage

Conversation

@steven-johnson

Copy link
Copy Markdown
Contributor

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.

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.
Comment thread src/runtime/HalideBuffer.h Outdated
* 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) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair. done.

@abadams

abadams commented Nov 8, 2018

Copy link
Copy Markdown
Member

LGTM apart from disagreeing with the name

@steven-johnson steven-johnson changed the title Add Buffer::reorder() and related ctors Add generalized Buffer::transpose() and related ctors Nov 8, 2018
@abadams
abadams merged commit 8d2769f into master Nov 10, 2018
@steven-johnson
steven-johnson deleted the srj-storage branch November 13, 2018 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants