title: tensorflow Invalid argument: In[0] is not a matrix
body: <p>i am new to tensorflow C++ API and struggling to find documentation 
     online. this short code performs inner product of two vectors 
     W and x1, compile fine but there are run time errors, 
     i copy the code and error
     logs here. thanks a lot for the help</p>
  
  <pre><code>#include "tensorflow/cc/client/client_session.h"
  #include "tensorflow/cc/ops/standard_ops.h"
  #include "tensorflow/core/framework/tensor.h"
  
  int main() {
  
    using namespace tensorflow;
    using namespace tensorflow::ops;
  
    Tensor W (DT_FLOAT,TensorShape({2})); 
    Tensor x1(DT_FLOAT,TensorShape({2})); 
  
    auto W_map  = W .tensor&lt;float,1&gt;();
    auto x1_map = x1.tensor&lt;float,1&gt;();
  
    for(int i=0;i&lt;L;++i) { 
      W_map(i)  = -1; 
      x1_map(i) =  1;  
    }
    std::cout&lt;&lt;"W  \n"&lt;&lt;W .flat&lt;float&gt;()&lt;&lt;"\n debug "&lt;&lt;W .DebugString()&lt;&lt;std::endl;
    std::cout&lt;&lt;"x1 \n"&lt;&lt;x1.flat&lt;float&gt;()&lt;&lt;"\n debug "&lt;&lt;x1.DebugString()&lt;&lt;std::endl; 
  
    Scope root = Scope::NewRootScope();
    ClientSession session(root);
  
    // either line of code gives similar run time error
   // auto v1 = MatMul(root.WithOpName("v1"), W, x1,  MatMul::TransposeA(true));
    auto v1 = MatMul(root.WithOpName("v1"), W, x1, MatMul::TransposeB(true));
  
    std::vector&lt;Tensor&gt; o1; 
  
    TF_CHECK_OK(session.Run({v1}, &amp;o1));
  }
  
  ===========================
  
  hweekuans-MacBook-Pro:linear_model hweekuan$ ./linear
  
  W  
  -1
  -1
   debug Tensor&lt;type: float shape: [2] values: -1 -1&gt;
  
  x1 
  1
  1
   debug Tensor&lt;type: float shape: [2] values: 1 1&gt;
  
  F tensorflow/cc/20170412/linear_model/linear.cc:37] Check failed:   ::tensorflow::Status::OK() == (session.Run({v1}, &amp;o1)) (OK vs. Invalid argument: In[0] is not a matrix
       [[Node: v1 = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=true, _device="/job:localhost/replica:0/task:0/cpu:0"](Const/Const, Const_1/Const)]])
  Abort trap: 6
  </code></pre>