Backport 1.8 3827

Backport #3827: `BUG: core: consider both C and F order buffers as contiguous`