title: How to feed multiple input samples to a tensorflow model in C++ with a single Run
body: <p>With the python tensorflow API one can do something like this:</p>
  
  <pre><code>a = tf.placeholder(tf.float32)
  b = tf.placeholder(tf.float32)
  adder_node = a + b
  
  sess.run(adder_node, {a: [1,3], b: [2, 4]})
  </code></pre>
  
  <p>result: [ 3.  7.]</p>
  
  <p>Is there any way in C++ to feed multiple inputs to the model with a single call to the <code>Run</code> method? I tried to use an std::vector of feed_dicts</p>
  
  <pre><code>// prepare tensorflow inputs
  std::vector&lt;std::pair&lt;std::string, tensorflow::Tensor&gt;&gt; feed_dict;
  for(size_t i = 0; i &lt; noutput_items; i++) {
      tensorflow::TensorShape data_shape({1, d_vlen_in});
      tensorflow::Tensor n_tensor(tensorflow::DT_FLOAT, data_shape);
      auto n_data = n_tensor.flat&lt;float&gt;().data();
      for(int j = 0 ; j &lt; d_vlen_in ; j++) {
          n_data[j] = in[j];
      }
      feed_dict.push_back(std::make_pair(d_layer_in, n_tensor));
      in += d_vlen_in;
  }
  
  // prepare tensorflow outputs
  std::vector&lt;tensorflow::Tensor&gt; outputs;
  
  TF_CHECK_OK(d_session-&gt;Run(feed_dict, {d_layer_out}, {}, &amp;outputs));
  </code></pre>
  
  <p><code>d_layer_in</code> and <code>d_layer_out</code> are <code>std::strings</code>, "input" is my input layer/placeholder.</p>
  
  <p>However it fails with:</p>
  
  <pre><code>Non-OK-status: d_session-&gt;Run(feed_dict, {d_layer_out}, {}, &amp;outputs) status: Invalid argument: Endpoint "input" fed more than once.
  </code></pre>
  
  <p>Does anybody know a way of doing this? My main goal here is to improve the throughput.</p>