I don’t think torch.mul works if two tensors are not broadcastable.
For example,
x = torch.ones(3,2)
y = torch.ones(3)
torch.mul(x,y)
Gives an error:
RuntimeError: The size of tensor a (2) must match the size of tensor b (3) at non-singleton dimension 1
I am yet not able to find solution to how to multiply all columns of one tensor with other tensor
Ok found the solution:

  
    
    
    Multiply 1D tensor by 2D tensor 
  
  
    [TensorMultiplication] 
I am trying to multiply a 1D tensor by a 2D tensor as shown in the picture above (whereby each element of the first tensor is multiplied by each element in the corresponding row of the second tensor). If I were to run a*b, I would get RuntimeError: inconsistent tensor size. I could of course iterate through each tensor and multiply each of the corresponding elements, but I assume that there exists a ‘better’ way than this?