How to check if a small tensor is inside anthor large tensor
a = torch.tensor([[1,1],[2,2]])

I want to know if tensor([1,1]) is inside in a (return one bool)
a.eq(torch.tensor([1,1]))
tensor([[ True, True],
[False, False]])

–&gt; which should return a True to my case.
a.eq(torch.tensor([1,2]))
tensor([[ True, False],
[False, True]])

–&gt; which should return a false to my case.
Any suggestion?

You could convert it to a list and then check via in operator:
p = torch.arange(1, 5).reshape((2,2))
k = torch.tensor([1,2])
v = torch.tensor([1,3])

&gt;&gt; k.tolist() in p.tolist()

True

&gt;&gt; v.tolist() in p.tolist()

False

Or if you want to do it via torch only
torch.count_nonzero(k==p, 1) == len(k)


