title: Efficient element-wise multiplication of a matrix and a vector in TensorFlow
body: <p>What would be the most efficient way to multiply (element-wise) a 2D tensor (matrix):</p>
  
  <pre><code>x11 x12 .. x1N
  ...
  xM1 xM2 .. xMN
  </code></pre>
  
  <p>by a vertical vector:</p>
  
  <pre><code>w1
  ...
  wN
  </code></pre>
  
  <p>to obtain a new matrix:</p>
  
  <pre><code>x11*w1 x12*w2 ... x1N*wN
  ...
  xM1*w1 xM2*w2 ... xMN*wN
  </code></pre>
  
  <p>To give some context, we have <code>M</code> data samples in a batch that can be processed in parallel, and each <code>N</code>-element sample must be multiplied by weights <code>w</code> stored in a variable to eventually pick the largest <code>Xij*wj</code> for each row <code>i</code>.</p>