Are Tensors column major or row major?

I’m porting some code from Caffe which column major and it would be helpful to know if torch is similarly column major or is row major.

1 Like

Torch Tensors are row-major.

1 Like

The data layout from torch and caffe are the same, and we have borrowed caffe kernels in the past.
Indeed, caffe is also row-major.

This “deformation_layer” isn’t part of upstream Caffe, so maybe it’s only their code to make the use of BLAS cleaner.

// reshape top blob to requested shape
vector out_shape;
if( > 0) out_shape.push_back(;

top[0]->Reshape( out_shape);