I think that, in general, your solution is the best you can do. The
issue is that if your original tensor is contiguous, there is no way
you can construct your desired tensor as a view into your original
tensor because there is no way you can get the elements in the
order you want by â€śstridingâ€ť through the elements of the original
tensor. So you have to make a copy of the elements of the original
tensor in order to put them in the desired order.

Having said that, it would be possible to get your desired tensor
without a copy in the unlikely event that your original tensor is
not contiguous and happens to have its elements in an order from
which you can create your desired tensor by striding.