m = torch.tensor([[1., 2., 3.], [4., 5., 6.]]) # (2, 3) normed = m / m.sum(dim=1) # (2, 3) / (2,) # RuntimeError: The size of tensor a (3) must match the size of # tensor b (2) at non-singleton dimension 1