Solved by tom in post #2 
              
              
                The equivalent of mm_out is torch.mm(..., out=...). 
So is  the following correct? You have 
x = x.view(70, 20, 1, 1, 1024)
g = g.view(70, 20, 96, 1, 1)
w = w.view(1, 1, 96, 16, 1024)

and want to conceptually compute 
(x*g*w).sum(-1)

In this case, you might take a look at how F.bilinear is impleme…