Closed guizili0 closed 3 weeks ago
import torch import random torch.manual_seed(0) random.seed(0) xpu_device = torch.device("xpu") cpu_device = torch.device("cpu") #tensor_dtype = torch.int64 tensor_dtype = torch.bool value_range = 2 a = torch.randint(value_range, (4099,)).to(dtype=tensor_dtype).to(xpu_device) print(a) print(a.shape) for dim in reversed(range(a.dim())): #output, output_indices = torch.mode(a, dim) #print(output) sorted, indices = torch.sort(a) print(sorted) sorted, indices = a.sort() print(sorted) sorted, indices = a.sort(stable=True) print(sorted) sorted_cpu, indices = torch.sort(a.to(cpu_device)) res = torch.equal(sorted.to(cpu_device), sorted_cpu) print(res)
sort result is wrong:
tensor([False, True, True, ..., False, True, True], device='xpu:0') torch.Size([4099]) tensor([False, True, True, ..., False, False, False], device='xpu:0') tensor([False, True, True, ..., False, False, False], device='xpu:0') tensor([False, True, True, ..., False, False, False], device='xpu:0') False
🐛 Describe the bug
Versions
sort result is wrong:
tensor([False, True, True, ..., False, True, True], device='xpu:0') torch.Size([4099]) tensor([False, True, True, ..., False, False, False], device='xpu:0') tensor([False, True, True, ..., False, False, False], device='xpu:0') tensor([False, True, True, ..., False, False, False], device='xpu:0') False