title: Error loading TensorFlow graph with C API
body: <p>I'm trying to use the TensorFlow C API to load and execute a graph.  It keeps failing and I can't figure out why.</p>
  
  <p>I first use this Python script to create a very simple graph and save it to a file.</p>
  
  <pre><code>import tensorflow as tf
  graph = tf.Graph()
  with graph.as_default():
      input = tf.placeholder(tf.float32, [10, 3], name='input')
      output = tf.reduce_sum(input**2, name='output')
  tf.train.write_graph(graph, '.', 'test.pbtxt')
  </code></pre>
  
  <p>Then I use this C++ code to load it in.</p>
  
  <pre><code>#include &lt;fstream&gt;
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;c_api.h&gt;
  
  using namespace std;
  
  int main() {
      ifstream graphFile("test.pbtxt");
      string graphText((istreambuf_iterator&lt;char&gt;(graphFile)), istreambuf_iterator&lt;char&gt;());
      TF_Buffer* buffer = TF_NewBufferFromString(graphText.c_str(), graphText.size());
      TF_Graph* graph = TF_NewGraph();
      TF_ImportGraphDefOptions* importOptions = TF_NewImportGraphDefOptions();
      TF_Status* status = TF_NewStatus();
      TF_GraphImportGraphDef(graph, buffer, importOptions, status);
      cout&lt;&lt;TF_GetCode(status)&lt;&lt;endl;
      return 0;
  }
  </code></pre>
  
  <p>The status code it prints is 3, or <code>TF_INVALID_ARGUMENT</code>.  Which argument is invalid and why?  I verified the file contents are loaded correctly into <code>graphText</code>, and all the other arguments are trivial.</p>