Increasing the rank of a memref for vectorization

I think @nicolasvasilache might be referring to this post: MemRef type and data layout. Converting memref<64x128xf32> to memref<64x32xvector<4xf32>> is not a simple bitcast operation since the allocation of a vector type might have alignment constraints for a particular target, which would require introducing padding between the memref vector elements.

Note that you wouldn’t need a memref with a vector element type to perform a vector load/store. Vector transfer ops and the recently introduced vector.load and vector.store ops ('vector' Dialect - MLIR) allow you to perform a vector load/store on a memref with a scalar element type. For example:

%result = vector.load %base[%i, %j] : memref<100x100xf32>, vector<8xf32>

I don’t know the details of your particular case but it looks like you should be able to do something like (pseudo-code):

%cast = some_cast %B: memref<64x128xf32> to memref<64x32x4xf32>
%vload = vector.load %cast[%i, %j, 0] : memref<64x32x4xf32>, vector<4xf32>

of even without the cast:

%vload = vector.load %B[%i, %j*4] : memref<64x128xf32>, vector<4xf32>

Hopefully that helps!

Thanks,
Diego