Adding layer array_length (#6817)

del_some_in_makelist
kavyasrinet 7 years ago committed by GitHub
parent 3c6399d1b2
commit ab916e54b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -585,9 +585,23 @@ def shrink_memory(x, i, table):
def array_length(array):
"""
This function creates an operator to find the length of the
"""This function performs the operation to find the length of the input
LOD_TENSOR_ARRAY.
Args:
array (LOD_TENSOR_ARRAY): The input array that will be used
to compute the length.
Returns:
Variable: The length of the input LoDTensorArray.
Examples:
.. code-block::python
tmp = fluid.layers.zeros(shape=[10], dtype='int32')
i = fluid.layers.fill_constant(shape=[1], dtype='int64', value=10)
arr = fluid.layers.array_write(tmp, i=i)
arr_len = fluid.layers.array_length(arr)
"""
helper = LayerHelper('array_length', **locals())
tmp = helper.create_tmp_variable(dtype='int64')

Loading…
Cancel
Save