prioritize caching rows or columns depending on whether input is F- or C-contiguous