Skip to content
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

[QST] How to reshape or flatten a shape(layout)? #1893

Closed
ZhangZhiPku opened this issue Oct 22, 2024 · 1 comment
Closed

[QST] How to reshape or flatten a shape(layout)? #1893

ZhangZhiPku opened this issue Oct 22, 2024 · 1 comment

Comments

@ZhangZhiPku
Copy link

ZhangZhiPku commented Oct 22, 2024

I can not find a proper method to change the layout of a tensor.

if I have a tensor like:

A = cute::Tensor(some_ptr, make_shape(1, 2, 3, 4));

I don't know how to merge the axis 1 and axis 2(axis start with 0), and get a tensor like B:[1, 6, 4].

Could you give me an example for doing so?

@thakkarV
Copy link
Collaborator

"changing" layouts can mean a lot of things. It could either require physical data movement or could be a purely logical transformation of the tensor's view. if it is the former, you have to set up a copy and do the transpose yourself. if it is a logical reinterpretation of the view then composition should take care of it.

auto target = make_layout(make_shape(1,6,4));
composition(A, target);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants