# tf.compat.v1.shape

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.13.1/tensorflow/python/ops/array_ops.py#L642-L666) |

Returns the shape of a tensor.

    tf.compat.v1.shape(
        input,
        name=None,
        out_type=https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/dtypes#int32
    )

This operation returns a 1-D integer tensor representing the shape of `input`.

#### For example:

    t = tf.constant([[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]]])
    tf.shape(t)  # [2, 2, 3]

<br />

<br />

<br />

| ## Args ||
|---|---|
| `input` | A `Tensor` or `SparseTensor`. |
| `name` | A name for the operation (optional). |
| `out_type` | (Optional) The specified output type of the operation (`int32` or `int64`). Defaults to [`tf.int32`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf#int32). |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A `Tensor` of type `out_type`. ||

<br />