Loading column major stored matrices in n-dimensions

Hey,

I have a n-dim data where the memory layout is column major (or rather first index first for n dimensions) instead of C++ default row major layout (last index first).

So if I load it with std::memcpy I get the following in 2D for illustration:

input
0.8147 0.0975 0.1576 0.1419
0.9058 0.2785 0.9706 0.4218
0.1270 0.5469 0.9572 0.9157
0.9134 0.9575 0.4854 0.7922
0.6324 0.9649 0.8003 0.9595

tensor:
0.8147 0.9058 0.1270 0.9134
0.6324 0.0975 0.2785 0.5469
0.9575 0.9649 0.1576 0.9706
0.9572 0.4854 0.8003 0.1419
0.4218 0.9157 0.7922 0.9595

Is there an interface for libtorch to automatically convert this? Or does someone know a good source? All I can find works for 2 dimensions, which is comparably easy compared to at compile time unknown number dimensions.

Cheers!