MCPcopy Create free account
hub / github.com/pytorch/pytorch / unique

Method unique

torch/_tensor.py:898–919  ·  view source on GitHub ↗

r"""Returns the unique elements of the input tensor. See :func:`torch.unique`

(self, sorted=True, return_inverse=False, return_counts=False, dim=None)

Source from the content-addressed store, hash-verified

896 return torch._VF.split_with_sizes(self, split_size, dim)
897
898 def unique(self, sorted=True, return_inverse=False, return_counts=False, dim=None):
899 r"""Returns the unique elements of the input tensor.
900
901 See :func:`torch.unique`
902 """
903 if has_torch_function_unary(self):
904 return handle_torch_function(
905 Tensor.unique,
906 (self,),
907 self,
908 sorted=sorted,
909 return_inverse=return_inverse,
910 return_counts=return_counts,
911 dim=dim,
912 )
913 return torch.unique(
914 self,
915 sorted=sorted,
916 return_inverse=return_inverse,
917 return_counts=return_counts,
918 dim=dim,
919 )
920
921 def unique_consecutive(self, return_inverse=False, return_counts=False, dim=None):
922 r"""Eliminates all but the first element from every consecutive group of equivalent elements.

Callers 15

visualizeFunction · 0.80
inline_graphFunction · 0.80
add_nodeFunction · 0.80
intersectionFunction · 0.80
minusFunction · 0.80

Calls 1

handle_torch_functionFunction · 0.90

Tested by 15

test_integer_outputsMethod · 0.64
testMethod · 0.64
run_testMethod · 0.64
test_uniqueMethod · 0.64
test_sort_overflowMethod · 0.64
helperMethod · 0.64
test_uniqueMethod · 0.64
test_bernoulliMethod · 0.64
torch_uniqueMethod · 0.64