# tensorflow::ops::TensorArray Class Reference

# tensorflow::
ops::
TensorArray

`
#include <data_flow_ops.h>
`


An array of Tensors of given size.

## Summary


Write data via Write and read via Read or Pack.


Args:

- scope: A [Scope](https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object
- size: The size of the array.
- dtype: The type of the elements on the tensor_array.

<br />


Optional attributes (see
`
https://www.tensorflow.org/versions/r2.5/api_docs/cc/struct/tensorflow/ops/tensor-array/attrs#structtensorflow_1_1ops_1_1_tensor_array_1_1_attrs
`
):

- element_shape: The expected shape of an element, if known. Used to validate the shapes of [TensorArray](https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/ops/tensor-array#classtensorflow_1_1ops_1_1_tensor_array) elements. If this shape is not fully specified, gathering zero-size TensorArrays is an error.
- dynamic_size: A boolean that determines whether writes to the [TensorArray](https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/ops/tensor-array#classtensorflow_1_1ops_1_1_tensor_array) are allowed to grow the size. By default, this is not allowed.
- clear_after_read: If true (default), Tensors in the [TensorArray](https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/ops/tensor-array#classtensorflow_1_1ops_1_1_tensor_array) are cleared after being read. This disables multiple read semantics but allows early release of memory.
- identical_element_shapes: If true (default is false), then all elements in the [TensorArray](https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/ops/tensor-array#classtensorflow_1_1ops_1_1_tensor_array) will be expected to have identical shapes. This allows certain behaviors, like dynamically checking for consistent shapes on write, and being able to fill in properly shaped zero tensors on stack even if the element_shape attribute is not fully defined.
- tensor_array_name: Overrides the name used for the temporary tensor_array resource. Default value is the name of the ' [TensorArray](https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/ops/tensor-array#classtensorflow_1_1ops_1_1_tensor_array) ' op (which is guaranteed unique).

<br />


Returns:

- `
  https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output
  ` handle: The handle to the [TensorArray](https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/ops/tensor-array#classtensorflow_1_1ops_1_1_tensor_array) .
- `
  https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output
  ` flow: A scalar used to control gradient flow.

<br />

| ### Constructors and Destructors ||
|---|---|
| ` https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/ops/tensor-array#classtensorflow_1_1ops_1_1_tensor_array_1a17fb1bdb76e98f8c83ec1cf24af87f3d (const :: https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope & scope, :: https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input size, DataType dtype) ` ||
| ` https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/ops/tensor-array#classtensorflow_1_1ops_1_1_tensor_array_1afede14d69c65d1efdc36f5ac00fc6351 (const :: https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope & scope, :: https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input size, DataType dtype, const https://www.tensorflow.org/versions/r2.5/api_docs/cc/struct/tensorflow/ops/tensor-array/attrs#structtensorflow_1_1ops_1_1_tensor_array_1_1_attrs & attrs) ` ||

| ### Public attributes ||
|---|---|
| ` https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/ops/tensor-array#classtensorflow_1_1ops_1_1_tensor_array_1ac6f0c80567abf77dbae5528ef5257c3c ` | ` :: https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output ` |
| ` https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/ops/tensor-array#classtensorflow_1_1ops_1_1_tensor_array_1a238401c92769f36d04f2f3b2db163fdf ` | ` :: https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output ` |
| ` https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/ops/tensor-array#classtensorflow_1_1ops_1_1_tensor_array_1a1b6149ac5da344ccb1561eefc5b0b25a ` | ` https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation ` |

| ### Public static functions ||
|---|---|
| ` https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/ops/tensor-array#classtensorflow_1_1ops_1_1_tensor_array_1ada85e1cd0c0611935f275655748441b6 (bool x) ` | ` https://www.tensorflow.org/versions/r2.5/api_docs/cc/struct/tensorflow/ops/tensor-array/attrs#structtensorflow_1_1ops_1_1_tensor_array_1_1_attrs ` |
| ` https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/ops/tensor-array#classtensorflow_1_1ops_1_1_tensor_array_1a3022cd4fccb5d056d0e670d51ad424b4 (bool x) ` | ` https://www.tensorflow.org/versions/r2.5/api_docs/cc/struct/tensorflow/ops/tensor-array/attrs#structtensorflow_1_1ops_1_1_tensor_array_1_1_attrs ` |
| ` https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/ops/tensor-array#classtensorflow_1_1ops_1_1_tensor_array_1a4d87fc9eee4243549ee11e45bb697ba9 (PartialTensorShape x) ` | ` https://www.tensorflow.org/versions/r2.5/api_docs/cc/struct/tensorflow/ops/tensor-array/attrs#structtensorflow_1_1ops_1_1_tensor_array_1_1_attrs ` |
| ` https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/ops/tensor-array#classtensorflow_1_1ops_1_1_tensor_array_1a6e6597bdcb607f327ba2047f3dafa449 (bool x) ` | ` https://www.tensorflow.org/versions/r2.5/api_docs/cc/struct/tensorflow/ops/tensor-array/attrs#structtensorflow_1_1ops_1_1_tensor_array_1_1_attrs ` |
| ` https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/ops/tensor-array#classtensorflow_1_1ops_1_1_tensor_array_1a26c71247662a164badad7ad3004f3409 (StringPiece x) ` | ` https://www.tensorflow.org/versions/r2.5/api_docs/cc/struct/tensorflow/ops/tensor-array/attrs#structtensorflow_1_1ops_1_1_tensor_array_1_1_attrs ` |

| ### Structs ||
|---|---|
| [tensorflow:: ops:: TensorArray:: Attrs](https://www.tensorflow.org/versions/r2.5/api_docs/cc/struct/tensorflow/ops/tensor-array/attrs) | Optional attribute setters for [TensorArray](https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/ops/tensor-array#classtensorflow_1_1ops_1_1_tensor_array) . |

## Public attributes

### flow

```
::tensorflow::Output flow
```

### handle

```
::tensorflow::Output handle
```

### operation

```
Operation operation
```

## Public functions

### TensorArray

```
 TensorArray(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input size,
  DataType dtype
)
```

### TensorArray

```
 TensorArray(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input size,
  DataType dtype,
  const TensorArray::Attrs & attrs
)
```

## Public static functions

### ClearAfterRead

```
Attrs ClearAfterRead(
  bool x
)
```

### DynamicSize

```
Attrs DynamicSize(
  bool x
)
```

### ElementShape

```
Attrs ElementShape(
  PartialTensorShape x
)
```

### IdenticalElementShapes

```
Attrs IdenticalElementShapes(
  bool x
)
```

### TensorArrayName

```
Attrs TensorArrayName(
  StringPiece x
)
```