I’m trying to elementwise-multiply a 4D matrix M of size [100,8,1,400] with a tensor gates of size  along a specific dimension.
I can’t get it to work by reshaping, bmm, or elementwise products. What I want is this, but then vectorized:
for i,gate in enumerate(gates): M[:,i,:,:] *= gate
It doesn’t seem like this should be hard, but I can’t seem to figure it out. Any help is appreciated!