There are two versions of torch.sum: one which sums all elements in a Tensor and returns a float, and one with sums all elements in each dimension of a Tensor and returns a Tensor.
>>> a = torch.randn(1,2)
>>> a

 1.1424  0.5776
[torch.FloatTensor of size 1x2]

>>> torch.sum(a)
1.7199773788452148

>>> torch.sum(a,0)

 1.1424
 0.5776
[torch.FloatTensor of size 2]

>>> torch.sum(a,1)

 1.7200
[torch.FloatTensor of size 1]