You could broadcast one tensor, which would use more memory for a potential performance gain:
out = torch.matmul(tensor_a.unsqueeze(1), tensor_b)
out = out.sum([1, 2])
print((out - res).abs().max())
> tensor(2.5580e-13, dtype=torch.float64)

Note that I used DoubleTensors to check the error, as the numerical errors could be accumulating quite a lot.