Check if tensor elements in a value list

You can achieve this with a for loop:

>>> sum(a==i for i in vals).bool()
tensor([[ True,  True, False],
        [ True,  True, False]])
1 Like