Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions python/paddle/static/nn/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
check_variable_and_dtype,
)
from paddle.nn.initializer import Constant, Normal
from paddle.utils import deprecated

__all__ = []

Expand Down Expand Up @@ -570,6 +571,12 @@ def group_norm(
return helper.append_activation(group_norm_out)


@deprecated(
since="3.0.0",
update_to="paddle.nn.Conv2D",
level=1,
reason="This API will be deprecated in the future, because it's just for old statics mode, please use paddle.nn.Conv2D instead.",
)
def conv2d(
input,
num_filters,
Expand Down Expand Up @@ -697,6 +704,10 @@ def conv2d(
Examples:
.. code-block:: python

>>> # doctest: +SKIP("env set will not work in ci check because import paddle in global_exec")
>>> # set env var before import paddle to disable pir mode, following example code use os module.
>>> import os
>>> os.environ['FLAGS_enable_pir_api'] = '0'
>>> import paddle
>>> paddle.enable_static()

Expand All @@ -705,6 +716,9 @@ def conv2d(
>>> print(conv2d.shape)
(-1, 2, 30, 30)
"""
assert (
not in_pir_mode()
), "paddle.static.nn.conv2d is not supported in pir mode, please set the environment variable FLAGS_enable_pir_api=0 to switch old static mode."

check_variable_and_dtype(
input, 'input', ['uint16', 'float16', 'float32', 'float64'], 'conv2d'
Expand Down
74 changes: 73 additions & 1 deletion python/paddle/static/nn/sequence_lod.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,18 @@

import paddle
from paddle.base.data_feeder import check_variable_and_dtype
from paddle.base.framework import in_dygraph_mode
from paddle.base.framework import in_dygraph_mode, in_pir_mode
from paddle.base.layer_helper import LayerHelper
from paddle.utils import deprecated

__all__ = []


@deprecated(
since="3.0.0",
level=1,
reason="This API will be deprecated in the future, because it's just for old statics mode.",
)
def sequence_conv(
input,
num_filters,
Expand Down Expand Up @@ -120,6 +126,10 @@ def sequence_conv(

.. code-block:: python

>>> # doctest: +SKIP("env set will not work in ci check because import paddle in global_exec")
>>> # set env var before import paddle to disable pir mode, following example code use os module.
>>> import os
>>> os.environ['FLAGS_enable_pir_api'] = '0'
>>> import paddle
>>> paddle.enable_static()

Expand All @@ -130,6 +140,9 @@ def sequence_conv(
assert (
not in_dygraph_mode()
), "sequence layer is not supported in dygraph mode yet."
assert (
not in_pir_mode()
), "sequence layer is not supported in pir mode, please set the environment variable FLAGS_enable_pir_api=0 to switch old static mode."
check_variable_and_dtype(
input, 'input', ['float32', 'float64'], 'sequence_conv'
)
Expand Down Expand Up @@ -160,6 +173,11 @@ def sequence_conv(
return helper.append_activation(pre_act)


@deprecated(
since="3.0.0",
level=1,
reason="This API will be deprecated in the future, because it's just for old statics mode.",
)
def sequence_softmax(input, use_cudnn=False, name=None):
r"""

Expand Down Expand Up @@ -218,6 +236,10 @@ def sequence_softmax(input, use_cudnn=False, name=None):

.. code-block:: python

>>> # doctest: +SKIP("env set will not work in ci check because import paddle in global_exec")
>>> # set env var before import paddle to disable pir mode, following example code use os module.
>>> import os
>>> os.environ['FLAGS_enable_pir_api'] = '0'
>>> import paddle
>>> paddle.enable_static()

Expand All @@ -232,6 +254,9 @@ def sequence_softmax(input, use_cudnn=False, name=None):
assert (
not in_dygraph_mode()
), "sequence layer is not supported in dygraph mode yet."
assert (
not in_pir_mode()
), "sequence layer is not supported in pir mode, please set the environment variable FLAGS_enable_pir_api=0 to switch old static mode."
helper = LayerHelper('sequence_softmax', **locals())
check_variable_and_dtype(
input, 'input', ['float32', 'float64'], 'sequence_softmax'
Expand All @@ -247,6 +272,11 @@ def sequence_softmax(input, use_cudnn=False, name=None):
return softmax_out


@deprecated(
since="3.0.0",
level=1,
reason="This API will be deprecated in the future, because it's just for old statics mode.",
)
def sequence_pool(input, pool_type, is_test=False, pad_value=0.0):
r"""

Expand Down Expand Up @@ -323,6 +353,10 @@ def sequence_pool(input, pool_type, is_test=False, pad_value=0.0):

.. code-block:: python

>>> # doctest: +SKIP("env set will not work in ci check because import paddle in global_exec")
>>> # set env var before import paddle to disable pir mode, following example code use os module.
>>> import os
>>> os.environ['FLAGS_enable_pir_api'] = '0'
>>> import paddle
>>> paddle.enable_static()

Expand All @@ -337,6 +371,10 @@ def sequence_pool(input, pool_type, is_test=False, pad_value=0.0):
assert (
not in_dygraph_mode()
), "sequence layer is not supported in dygraph mode yet."
assert (
not in_pir_mode()
), "sequence layer is not supported in pir mode, please set the environment variable FLAGS_enable_pir_api=0 to switch old static mode."

check_variable_and_dtype(
input, 'input', ['float32', 'float64'], 'sequence_pool'
)
Expand Down Expand Up @@ -364,6 +402,11 @@ def sequence_pool(input, pool_type, is_test=False, pad_value=0.0):
return pool_out


@deprecated(
since="3.0.0",
level=1,
reason="This API will be deprecated in the future, because it's just for old statics mode.",
)
def sequence_first_step(input):
"""

Expand Down Expand Up @@ -410,6 +453,10 @@ def sequence_first_step(input):

.. code-block:: python

>>> # doctest: +SKIP("env set will not work in ci check because import paddle in global_exec")
>>> # set env var before import paddle to disable pir mode, following example code use os module.
>>> import os
>>> os.environ['FLAGS_enable_pir_api'] = '0'
>>> import paddle
>>> paddle.enable_static()

Expand All @@ -422,6 +469,11 @@ def sequence_first_step(input):
return sequence_pool(input=input, pool_type="first")


@deprecated(
since="3.0.0",
level=1,
reason="This API will be deprecated in the future, because it's just for old statics mode.",
)
def sequence_last_step(input):
"""

Expand Down Expand Up @@ -469,6 +521,10 @@ def sequence_last_step(input):

.. code-block:: python

>>> # doctest: +SKIP("env set will not work in ci check because import paddle in global_exec")
>>> # set env var before import paddle to disable pir mode, following example code use os module.
>>> import os
>>> os.environ['FLAGS_enable_pir_api'] = '0'
>>> import paddle
>>> paddle.enable_static()

Expand All @@ -481,6 +537,11 @@ def sequence_last_step(input):
return sequence_pool(input=input, pool_type="last")


@deprecated(
since="3.0.0",
level=1,
reason="This API will be deprecated in the future, because it's just for old statics mode.",
)
def sequence_expand(x, y, ref_level=-1, name=None):
r"""

Expand Down Expand Up @@ -561,6 +622,10 @@ def sequence_expand(x, y, ref_level=-1, name=None):
Examples:
.. code-block:: python

>>> # doctest: +SKIP("env set will not work in ci check because import paddle in global_exec")
>>> # set env var before import paddle to disable pir mode, following example code use os module.
>>> import os
>>> os.environ['FLAGS_enable_pir_api'] = '0'
>>> import paddle
>>> from paddle import base
>>> paddle.enable_static()
Expand Down Expand Up @@ -608,6 +673,9 @@ def sequence_expand(x, y, ref_level=-1, name=None):
assert (
not in_dygraph_mode()
), "sequence layer is not supported in dygraph mode yet."
assert (
not in_pir_mode()
), "sequence layer is not supported in pir mode, please set the environment variable FLAGS_enable_pir_api=0 to switch old static mode."
check_variable_and_dtype(
x, 'x', ['float32', 'float64', 'int32', 'int64'], 'sequence_expand'
)
Expand All @@ -623,6 +691,10 @@ def sequence_expand(x, y, ref_level=-1, name=None):
return tmp


@deprecated(
update_to="paddle.nn.functional.sequence_mask",
level=1,
)
def sequence_mask(x, maxlen=None, dtype='int64', name=None):
r"""
**SequenceMask Layer**
Expand Down