Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【Hackathon 6th Fundable Projects 3 No.344】fluid operator sequence_reverse #63562

Merged
merged 2 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions paddle/fluid/operators/sequence_ops/sequence_reverse_op.cc

This file was deleted.

26 changes: 0 additions & 26 deletions paddle/fluid/operators/sequence_ops/sequence_reverse_op.cu

This file was deleted.

199 changes: 0 additions & 199 deletions paddle/fluid/operators/sequence_ops/sequence_reverse_op.h

This file was deleted.

2 changes: 0 additions & 2 deletions python/paddle/static/nn/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
sequence_pad,
sequence_pool,
sequence_reshape,
sequence_reverse,
sequence_scatter,
sequence_slice,
sequence_softmax,
Expand Down Expand Up @@ -92,6 +91,5 @@
'sequence_reshape',
'sequence_scatter',
'sequence_enumerate',
'sequence_reverse',
'prelu',
]
69 changes: 0 additions & 69 deletions python/paddle/static/nn/sequence_lod.py
Original file line number Diff line number Diff line change
Expand Up @@ -1343,72 +1343,3 @@ def sequence_mask(x, maxlen=None, dtype='int64', name=None):
"""

return paddle.nn.functional.sequence_mask(x, maxlen, dtype, name)


@templatedoc()
def sequence_reverse(x, name=None):
"""
Note:
Only receives Tensor as input. If your input is Tensor, please use reverse Op.(static.nn.** :ref:`api_paddle_flip` ).

Only supports Tensor as input. It will reverse each sequence for input Tensor.
Currently it only supports 1-level Tensor. This operator is very useful when building a
reverse :ref:`api_paddle_nn_RNN` network.

.. code-block:: text

input(x) is a Tensor:
x.lod = [[0, 2, 5]]
x.data = [[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12],
[13,14, 15, 16],
[17,18, 19, 20]]
x.shape = [5, 4]

output Tensor with same shape and LoD info:
out.lod = [[0, 2, 5]]
out.data = [[5, 6, 7, 8],
[1, 2, 3, 4],
[17,18, 19, 20],
[13,14, 15, 16],
[9, 10, 11, 12]]
out.shape = [5, 4]

Args:
x(Tensor): Tensor with 1-level LoD info. Currently it only supports 1-level Tensor.
The data type should be float32, float64, int8, int32 or int64.
name(str, optional): The default value is None. Normally there is no need for user to set this property.
For more information, please refer to :ref:`api_guide_Name` .

Returns:
Tensor: Tensor reversed from input. The data type is same with input.

Examples:
.. code-block:: python

>>> import paddle
>>> paddle.enable_static()

>>> x = paddle.static.data(name='x', shape=[None, 10], dtype='float32', lod_level=1)
>>> x_reversed = paddle.static.nn.sequence_reverse(x)
"""
assert (
not in_dygraph_mode()
), "sequence layer is not supported in dygraph mode yet."
helper = LayerHelper("sequence_reverse", **locals())
check_variable_and_dtype(
x,
'x',
['float32', 'float64', 'int8', 'int32', 'int64'],
'static.nn.sequence_reverse',
)
out = helper.create_variable_for_type_inference(dtype=x.dtype)

helper.append_op(
type="sequence_reverse",
inputs={"X": x},
outputs={"Y": out},
attrs={},
)
return out
Loading