Is there a way to do Pytorch element wise equality treating each dimension as an element?
I have two tensors and I want to check for equality treating an array in one dimension as the element

I have 2 tensors

lo = torch.Tensor(([1., 1., 0.],
                   [0., 1., 1.],
                   [0., 0., 0.],
                   [1., 1., 1.]))
lo = torch.Tensor(([1., 1., 0.],
                   [0., 0., 0.],
                   [0., 0., 0.],
                   [0., 0., 0.]))


I've tried using
torch.eq(lee, lo)
which returns a tensor like

tensor([[1, 1, 1],
        [1, 0, 0],
        [1, 1, 1],
        [0, 0, 0]], dtype=torch.uint8)


Is there a way to have the output become

tensor([1, 0, 1, 0])


as the only complete element that matches is the first?

edit:
I've come up with this solution

lee = lee.tolist()
lo = lo.tolist()
out = []
for i, j in enumerate(lee):
  if j == lo[i]:
    out.append(1)
  else:
    out.append(0)


and out will be [1, 0, 1, 0]
But is there an easier way?

You can simply use torch.all(tensor, dim). 

code:

l1 = torch.Tensor(([1., 1., 0.],
                   [0., 1., 1.],
                   [0., 0., 0.],
                   [1., 1., 1.]))
l2 = torch.Tensor(([1., 1., 0.],
                   [0., 0., 0.],
                   [0., 0., 0.],
                   [0., 0., 0.]))
print(torch.eq(l1, l2))
print(torch.all(torch.eq(l1, l2),  dim=0)) # equivalent to dim = -2
print(torch.all(torch.eq(l1, l2),  dim=1)) # equivalent to dim = -1


output:

tensor([[1, 1, 1],
        [1, 0, 0],
        [1, 1, 1],
        [0, 0, 0]], dtype=torch.uint8)
tensor([0, 0, 0], dtype=torch.uint8)
tensor([1, 0, 1, 0], dtype=torch.uint8) # your desired output

