Construct a new TensorArray or wrap an existing TensorArray handle. A note about the parameter `name`: The name of the `TensorArray` (even if passed in) is uniquified: each time a new `TensorArray` is created at runtime it is assigned its own name for the duration of the run. This
(self,
dtype,
size=None,
dynamic_size=None,
clear_after_read=None,
tensor_array_name=None,
handle=None,
flow=None,
infer_shape=True,
element_shape=None,
colocate_with_first_write_call=True,
name=None)
| 929 | """ |
| 930 | |
| 931 | def __init__(self, |
| 932 | dtype, |
| 933 | size=None, |
| 934 | dynamic_size=None, |
| 935 | clear_after_read=None, |
| 936 | tensor_array_name=None, |
| 937 | handle=None, |
| 938 | flow=None, |
| 939 | infer_shape=True, |
| 940 | element_shape=None, |
| 941 | colocate_with_first_write_call=True, |
| 942 | name=None): |
| 943 | """Construct a new TensorArray or wrap an existing TensorArray handle. |
| 944 | |
| 945 | A note about the parameter `name`: |
| 946 | |
| 947 | The name of the `TensorArray` (even if passed in) is uniquified: each time |
| 948 | a new `TensorArray` is created at runtime it is assigned its own name for |
| 949 | the duration of the run. This avoids name collisions if a `TensorArray` |
| 950 | is created within a `while_loop`. |
| 951 | |
| 952 | Args: |
| 953 | dtype: (required) data type of the TensorArray. |
| 954 | size: (optional) int32 scalar `Tensor`: the size of the TensorArray. |
| 955 | Required if handle is not provided. |
| 956 | dynamic_size: (optional) Python bool: If true, writes to the TensorArray |
| 957 | can grow the TensorArray past its initial size. Default: False. |
| 958 | clear_after_read: Boolean (optional, default: True). If True, clear |
| 959 | TensorArray values after reading them. This disables read-many |
| 960 | semantics, but allows early release of memory. |
| 961 | tensor_array_name: (optional) Python string: the name of the TensorArray. |
| 962 | This is used when creating the TensorArray handle. If this value is |
| 963 | set, handle should be None. |
| 964 | handle: (optional) A `Tensor` handle to an existing TensorArray. If this |
| 965 | is set, tensor_array_name should be None. Only supported in graph mode. |
| 966 | flow: (optional) A float `Tensor` scalar coming from an existing |
| 967 | `TensorArray.flow`. Only supported in graph mode. |
| 968 | infer_shape: (optional, default: True) If True, shape inference |
| 969 | is enabled. In this case, all elements must have the same shape. |
| 970 | element_shape: (optional, default: None) A `TensorShape` object specifying |
| 971 | the shape constraints of each of the elements of the TensorArray. |
| 972 | Need not be fully defined. |
| 973 | colocate_with_first_write_call: If `True`, the TensorArray will be |
| 974 | colocated on the same device as the Tensor used on its first write |
| 975 | (write operations include `write`, `unstack`, and `split`). If `False`, |
| 976 | the TensorArray will be placed on the device determined by the |
| 977 | device context available during its initialization. |
| 978 | name: A name for the operation (optional). |
| 979 | |
| 980 | Raises: |
| 981 | ValueError: if both handle and tensor_array_name are provided. |
| 982 | TypeError: if handle is provided but is not a Tensor. |
| 983 | """ |
| 984 | if (context.executing_eagerly() and |
| 985 | (flow is None or flow.dtype != dtypes.variant)): |
| 986 | # It is possible to create a Variant-style TensorArray even in eager mode, |
| 987 | # and this is fine but can have performance implications in eager. |
| 988 | # An example of when this happens is if a tf.function returns a |
nothing calls this directly
no test coverage detected