Ensure 2D or 3D inputs, as appropriate