pytorch
2625dab1 - Modify unique to return sizes when dim is zero-length

Commit
3 years ago
Modify unique to return sizes when dim is zero-length Fixes #75730 Previously, `torch.unique` returned a tensor of size `[0]` when the dimension supplied to `dim` is zero length. Instead, I've changed `torch.unique` to return a tensor matching the input size. Changes: - Modify `torch.unique` to return an an empty tensor of size `sizes` as the values output, when `dim` is zero length in the input tensor. - Make the same change in the CUDA implementation of `torch.unique`. - Update `test_unique_dim` to expect an empty tensor with size matching the input tensor. Pull Request resolved: https://github.com/pytorch/pytorch/pull/75764 Approved by: https://github.com/mruberry
Author
Committer
Parents
  • aten/src/ATen/native
    • File
      Unique.cpp
    • cuda
      • File
        Unique.cu
  • test
    • File
      test_sort_and_select.py