explicitly provide memory format when calling to clone() at SortingKthValue.cu
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/28666
Test Plan: Imported from OSS
Differential Revision: D18333371
Pulled By: ifedan
fbshipit-source-id: 11d4bbdaf8e57c97a1c47181ce7e953f2ad5b49e
diff --git a/aten/src/ATen/native/cuda/SortingKthValue.cu b/aten/src/ATen/native/cuda/SortingKthValue.cu
index 1455214..4c229cb 100644
--- a/aten/src/ATen/native/cuda/SortingKthValue.cu
+++ b/aten/src/ATen/native/cuda/SortingKthValue.cu
@@ -191,9 +191,9 @@
Tensor median_cuda_template(const Tensor& self) {
TORCH_CHECK(self.numel() > 0, "median cannot be called with empty tensor");
if (self.dim() == 0 && self.numel() == 1) {
- return self.clone();
+ return self.clone(at::MemoryFormat::Contiguous);
}
- auto self_copy = self.clone().view(-1);
+ auto self_copy = self.clone(at::MemoryFormat::Contiguous).view(-1);
auto values = at::empty({1}, self.options());
auto indices = at::empty({1}, self.options().dtype(kLong));
TORCH_CHECK(