Improved Tensor::resize to avoid cases where Tensor could be made to have a non-contiguous range.