|
|
|
@ -742,11 +742,10 @@ def topk(input, k):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def lod_tensor_to_array(x, table):
|
|
|
|
|
"""This function performs the operation that converts an LOD_Tensor to
|
|
|
|
|
an array.
|
|
|
|
|
""" Convert a LOD_TENSOR to an LOD_TENSOR_ARRAY.
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
x (Variable|list): The tensor that needs to be converted to an array.
|
|
|
|
|
x (Variable|list): The LOD tensor to be converted to a LOD tensor array.
|
|
|
|
|
table (ParamAttr|list): The variable that stores the level of lod
|
|
|
|
|
which is ordered by sequence length in
|
|
|
|
|
descending order.
|
|
|
|
@ -776,11 +775,10 @@ def lod_tensor_to_array(x, table):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def array_to_lod_tensor(x, table):
|
|
|
|
|
"""This function performs the operations that converts an array to
|
|
|
|
|
an LOD_Tensor.
|
|
|
|
|
"""Convert a LoD_Tensor_Aarry to an LoDTensor.
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
x (Variable|list): The array that needs to be converted to a tensor.
|
|
|
|
|
x (Variable|list): The lod tensor array to be converted to a tensor.
|
|
|
|
|
table (ParamAttr|list): The variable that stores the level of lod
|
|
|
|
|
which is ordered by sequence length in
|
|
|
|
|
descending order.
|
|
|
|
@ -808,7 +806,8 @@ def array_to_lod_tensor(x, table):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def increment(x, value=1.0, in_place=True):
|
|
|
|
|
"""This function performs an operation that increments each value in the
|
|
|
|
|
"""
|
|
|
|
|
This function performs an operation that increments each value in the
|
|
|
|
|
input :math:`x` by an amount: :math:`value` as mentioned in the input
|
|
|
|
|
parameter. This operation is performed in-place by default.
|
|
|
|
|
|
|
|
|
@ -841,17 +840,24 @@ def increment(x, value=1.0, in_place=True):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def array_write(x, i, array=None):
|
|
|
|
|
"""This function performs the operation to write the data out as an
|
|
|
|
|
LOD_TENSOR_ARRAY.
|
|
|
|
|
"""
|
|
|
|
|
This function writes the given input variable to the specified position
|
|
|
|
|
indicating by the arrary index to an output LOD_TENSOR_ARRAY. If the
|
|
|
|
|
output LOD_TENSOR_ARRAY is not given(None), a new one will be created and
|
|
|
|
|
returned.
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
x (Variable|list): The input tensor from which the data will be read.
|
|
|
|
|
i (Variable|list): The subscript index in tensor array, that points the
|
|
|
|
|
place from which data will be read.
|
|
|
|
|
array (Variable|list): The data can be read into this variable if
|
|
|
|
|
this is assigned.
|
|
|
|
|
i (Variable|list): The index of the output LOD_TENSOR_ARRAY, pointing to
|
|
|
|
|
the position to which the input tensor will be
|
|
|
|
|
written.
|
|
|
|
|
array (Variable|list): The output LOD_TENSOR_ARRAY to which the input
|
|
|
|
|
tensor will be written. If this parameter is
|
|
|
|
|
NONE, a new LOD_TENSOR_ARRAY will be created and
|
|
|
|
|
returned.
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
Variable: The tensor type variable that has the data written to it.
|
|
|
|
|
Variable: The output LOD_TENSOR_ARRAY where the input tensor is written.
|
|
|
|
|
|
|
|
|
|
Examples:
|
|
|
|
|
.. code-block::python
|
|
|
|
@ -1228,7 +1234,7 @@ class DynamicRNN(object):
|
|
|
|
|
self._assert_in_rnn_block_("step_input")
|
|
|
|
|
if not isinstance(x, Variable):
|
|
|
|
|
raise TypeError(
|
|
|
|
|
"step_input() can only take a Variable as its input")
|
|
|
|
|
"step_input() can only take a Variable as its input.")
|
|
|
|
|
parent_block = self._parent_block_()
|
|
|
|
|
if self.lod_rank_table is None:
|
|
|
|
|
self.lod_rank_table = parent_block.create_var(
|
|
|
|
@ -1289,8 +1295,8 @@ class DynamicRNN(object):
|
|
|
|
|
|
|
|
|
|
def __call__(self, *args, **kwargs):
|
|
|
|
|
if self.status != DynamicRNN.AFTER_RNN:
|
|
|
|
|
raise ValueError(
|
|
|
|
|
"Dynamic RNN outputs can only be retrieved after rnn block")
|
|
|
|
|
raise ValueError(("Output of the dynamic RNN can only be visited "
|
|
|
|
|
"outside the rnn block."))
|
|
|
|
|
if len(self.outputs) == 1:
|
|
|
|
|
return self.outputs[0]
|
|
|
|
|
else:
|
|
|
|
|