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.

2 Likes

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.

1 Like

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;
out_shape.push_back(batch_size_);
if( param.nz() > 0) out_shape.push_back(param.nz());
out_shape.push_back(param.ny());
out_shape.push_back(param.nx());
out_shape.push_back(param.ncomponents());

top[0]->Reshape( out_shape);