Solved by tom in post #2 
              
              
                I like to use indexing and broadcasting for this: 
out = x[:, :, None] * emb[None, :, :]

Indexing with None inserts a new dimension (“unsqueeze” or “view” could achieve the same, but I like to use the above to help me see the alignment). 
For more advanced uses, torch.einsum can be useful, too. Her…