title: tf.while_loop strange behavior with tf.concat
body: <p>I'm trying to build a matrix through concatenating elements and reusing the matrix as an input in a tf.while_loop , the output of tf.concat is expected to be a tensor of shape <code>(x+1,y)</code> but instead it returns (x+1) tensors of shape <code>(y,)</code> which causes the two structures to not have the same nested structure.</p>
  
  <p>Here is a code snippet that recreates the issue:</p>
  
  <pre><code>@tf.function(autograph=False)
  def cond(a):
      if a.shape[0] != None:
          return tf.less(a.shape[0],5)
      else:
          return tf.constant(True)
  
  
  def loop():
      ans = tf.while_loop(cond,
                          lambda a: tf.concat([a,tf.zeros((1,5),dtype=tf.float64)],axis=0),
                          loop_vars=[tf.zeros((1,5),dtype=tf.float64)],
                          shape_invariants=[tf.TensorShape((None,5))],parallel_iterations=1)
  
      return ans
  </code></pre>
  
  <p>Adding a <code>@tf.function</code> decorator to the loop simply causes it to freeze without giving an error message or anything of the sort.</p>
  
  <p>Here is the error message without a <code>@tf.function</code> decorator :</p>
  
  <pre><code>ValueError: The two structures don't have the same nested structure.
  
  First structure: type=list str=[TensorSpec(shape=(1, 5), dtype=tf.float64, name=None)]
  
  Second structure: type=list str=[&lt;tf.Tensor: shape=(5,), dtype=float64, numpy=array([0., 0., 0., 0., 0.])&gt;, &lt;tf.Tensor: shape=(5,), dtype=float64, numpy=array([0., 0., 0., 0., 0.])&gt;]
  </code></pre>
  
  <p>I am not quite sure why the function is returning a list of multiple tensors, instead of one tensor with the desired shape.</p>
  
  <p>If I change the axis in <code>tf.concat</code> to 1, then the function runs without any problems, even though I am not allowing the second component of the shape to change.</p>
  
  <p>I would appreciate any explanation for why this could be happening, thanks in advance.</p>