It works pretty much the same as numpy, so you just need to use torch.sum(V, dim) where dim is the dimension where m is stored, e.g. if V is (m, n) -> dim=0.
More info the official documentation: https://pytorch.org/docs/stable/torch.html#torch.sum 7