Long Long - 1 month ago 17
Python Question

what does C-contiguous fashion mean in caffe blob storage?

in caffe document :http://caffe.berkeleyvision.org/tutorial/net_layer_blob.html


Blob storage and communication#
A Blob is a wrapper over the actual data being processed and passed along by Caffe, and also under the hood provides synchronization capability between the CPU and the GPU. Mathematically, a blob is an N-dimensional array stored in a C-contiguous fashion.


it said a blob is stored in a C-contiguous fashion. what does C-contiguous fashion mean?

Answer

C contiguous fashion, is the opposite of Fortran fashion (also used by Matlab). It means that the n-dim data is stored as a long and contiguous array in memory. The order of the elements in memory is according to C fashion: trailing dimensions are stored first. That is if you have c by h by w 3d blob, in memory rows will be saved one after the other, and after completing all the rows of the first channel, only then the rows of the next channel are written.

Another way to look at it is that the i, j, k element is stored at

  blob[i*w*h + j*w + k]

See this wiki page for more information.