Really? What version of PyTorch? I have v0.4.0 and neither of the following worked:
import torch
x = torch.rand(5,5,5)
torch.sum(x, (1,2))
y = x.sum((1,2))

Both complained about wrong types.
I’d like a built in way to do this (that’s why I ended up on this page, after all).