diff --git a/.flake8 b/.flake8 index 84ebba974763b1a6539c0a507cd40bcc62fcd742..2d284df082e8aabc5dea987b11d1315167766a42 100644 --- a/.flake8 +++ b/.flake8 @@ -17,13 +17,13 @@ exclude = ignore = # E, see https://pycodestyle.pycqa.org/en/latest/intro.html#error-codes E203, - E401,E402, + E402, E501, E721,E722,E731,E741, # F, see https://flake8.pycqa.org/en/latest/user/error-codes.html F405, - F811,F841, + F841, # W, see https://pycodestyle.pycqa.org/en/latest/intro.html#error-codes W503 @@ -37,3 +37,9 @@ per-file-ignores = .cmake-format.py: F821 python/paddle/fluid/tests/unittests/dygraph_to_static/test_loop.py: F821 python/paddle/fluid/tests/unittests/dygraph_to_static/test_closure_analysis.py: F821 + # These files will be fixed in the future + python/paddle/fluid/tests/unittests/fft/test_fft_with_static_graph.py: F811 + python/paddle/fluid/tests/unittests/test_activation_nn_grad.py: F811 + python/paddle/fluid/tests/unittests/test_lstm_cudnn_op.py: F811 + python/paddle/fluid/tests/unittests/test_matmul_v2_op.py: F811 + python/paddle/fluid/tests/unittests/test_rrelu_op.py: F811 diff --git a/python/paddle/autograd/__init__.py b/python/paddle/autograd/__init__.py index 19742cf6afe6cd18a2608fbc4a090badf2038065..c05967ecd68be2905fec33728706a91dcf3e6dde 100644 --- a/python/paddle/autograd/__init__.py +++ b/python/paddle/autograd/__init__.py @@ -25,8 +25,6 @@ if _in_eager_mode_: else: from .py_layer import LegacyPyLayer as PyLayer # noqa: F401 from .py_layer import LegacyPyLayerContext as PyLayerContext # noqa: F401 -from ..framework import set_grad_enabled, is_grad_enabled # noqa: F401 -from ..fluid.dygraph.base import no_grad_ as no_grad # noqa: F401 from .saved_tensors_hooks import saved_tensors_hooks __all__ = [ # noqa diff --git a/python/paddle/distributed/auto_parallel/utils.py b/python/paddle/distributed/auto_parallel/utils.py index 0196ca9e7aefeb953c2fe78351ce468d8a9a217f..62004269e9b5681326608950e328dc247a640b7e 100644 --- a/python/paddle/distributed/auto_parallel/utils.py +++ b/python/paddle/distributed/auto_parallel/utils.py @@ -35,7 +35,6 @@ from paddle.fluid.framework import Variable from paddle.fluid.io import is_belong_to_optimizer, is_parameter OP_ROLE_KEY = core.op_proto_and_checker_maker.kOpRoleAttrName() -OpRole = core.op_proto_and_checker_maker.OpRole __no_shape_var_type__ = [ core.VarDesc.VarType.READER, diff --git a/python/paddle/distributed/fleet/elastic/__init__.py b/python/paddle/distributed/fleet/elastic/__init__.py index 447bedb21d59270e25bf15f4e9c8fee25c44521b..51fc0ca7d66de4ac29f36d7c7534a195b85077a1 100644 --- a/python/paddle/distributed/fleet/elastic/__init__.py +++ b/python/paddle/distributed/fleet/elastic/__init__.py @@ -13,7 +13,8 @@ # limitations under the License. import signal -import os, sys +import os +import sys from .manager import ElasticManager from .manager import ElasticStatus diff --git a/python/paddle/distributed/fleet/model.py b/python/paddle/distributed/fleet/model.py index 8a480f0b9ea6f2caf82fb3dbc506aa2f2a764dae..66c9804b5a398f82f0a229fb54e13bf45ad3602c 100755 --- a/python/paddle/distributed/fleet/model.py +++ b/python/paddle/distributed/fleet/model.py @@ -14,7 +14,6 @@ import paddle from paddle.distributed import fleet -from paddle.fluid.dygraph.varbase_patch_methods import _grad_scalar from .base.topology import ParallelMode from .meta_parallel import ( diff --git a/python/paddle/fluid/tests/custom_runtime/process_group_xccl.py b/python/paddle/fluid/tests/custom_runtime/process_group_xccl.py index 4abe2d7b634efb1c161106bee63b61fe126efde6..d97b889ff04c5f835e9478d70266796acb8738c4 100644 --- a/python/paddle/fluid/tests/custom_runtime/process_group_xccl.py +++ b/python/paddle/fluid/tests/custom_runtime/process_group_xccl.py @@ -18,7 +18,6 @@ import unittest import numpy as np import paddle -import paddle.fluid.core as core from paddle.fluid import core from paddle.fluid.dygraph.parallel import ParallelEnv from paddle.fluid.framework import _test_eager_guard diff --git a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_dist_save_load.py b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_dist_save_load.py index a9c525daae41f9552c01331867acce8800ef6fb1..553ce09704565efe6dac82da93bfb2658f70ff08 100644 --- a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_dist_save_load.py +++ b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_dist_save_load.py @@ -31,7 +31,6 @@ from paddle.distributed.fleet.meta_parallel.sharding.group_sharded_optimizer_sta from paddle.distributed.fleet.meta_parallel.sharding.group_sharded_stage2 import ( GroupShardedStage2, ) -from paddle.fluid.dygraph.nn import Linear from paddle.incubate.distributed.utils.io import load, save from paddle.nn import Linear diff --git a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_api.py b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_api.py index 6ecf1ca72d40af36892f305545a4e6c46b9d385e..ae6f7059bfa02b43bff330edf47eaa6f7bef172b 100644 --- a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_api.py +++ b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_api.py @@ -24,7 +24,6 @@ from paddle.distributed.sharding import ( group_sharded_parallel, save_group_sharded_model, ) -from paddle.fluid.dygraph.nn import Linear from paddle.fluid.framework import _test_eager_guard from paddle.nn import Linear diff --git a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_api_eager.py b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_api_eager.py index 3849b806085186bc0e12b2fc800f0ffdde66b0dd..4d9f43db7fa6c3e94d7c7553baeb6fa0dafc8ef4 100644 --- a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_api_eager.py +++ b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_api_eager.py @@ -22,7 +22,6 @@ from paddle.distributed.sharding import ( group_sharded_parallel, save_group_sharded_model, ) -from paddle.fluid.dygraph.nn import Linear from paddle.fluid.framework import _test_eager_guard from paddle.nn import Linear diff --git a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage2.py b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage2.py index fc562ffae22360aea3e3aee85f3a6a138b88bc49..84be00cc1ccd1e50efa2e02462a613f347c34d6d 100644 --- a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage2.py +++ b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage2.py @@ -28,7 +28,6 @@ from paddle.distributed.fleet.meta_parallel.sharding.group_sharded_optimizer_sta from paddle.distributed.fleet.meta_parallel.sharding.group_sharded_stage2 import ( GroupShardedStage2, ) -from paddle.fluid.dygraph.nn import Linear from paddle.fluid.framework import _test_eager_guard from paddle.nn import Linear diff --git a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage2_comm_overlap.py b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage2_comm_overlap.py index 7e2b626ec45ec49c7bc0516e45e58fde595e1288..e92577e78f8ddc01685f0b074b9e03515f8e1ec3 100644 --- a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage2_comm_overlap.py +++ b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage2_comm_overlap.py @@ -28,7 +28,6 @@ from paddle.distributed.fleet.meta_parallel.sharding.group_sharded_optimizer_sta from paddle.distributed.fleet.meta_parallel.sharding.group_sharded_stage2 import ( GroupShardedStage2, ) -from paddle.fluid.dygraph.nn import Linear from paddle.fluid.framework import _test_eager_guard from paddle.nn import Linear diff --git a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage3.py b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage3.py index d462eb339b80df0fac58acbf53ef990e408a9431..95e0bdc6a068d12ae47e7fd1e96c7625b896ed04 100644 --- a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage3.py +++ b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage3.py @@ -34,7 +34,6 @@ from paddle.distributed.fleet.meta_parallel.sharding.group_sharded_stage3 import from paddle.distributed.fleet.meta_parallel.sharding.group_sharded_utils import ( GroupShardedScaler, ) -from paddle.fluid.dygraph.nn import Linear from paddle.fluid.framework import _test_eager_guard from paddle.nn import Linear diff --git a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage3_offload.py b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage3_offload.py index 3bb6ed15a69da61565001de7fd98191bd82e0095..f12de252c2c15a4a5e8235cd60d45d195dc05dcf 100644 --- a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage3_offload.py +++ b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_group_sharded_stage3_offload.py @@ -24,7 +24,6 @@ from paddle.distributed.fleet.meta_parallel.sharding.group_sharded_stage3 import from paddle.distributed.fleet.meta_parallel.sharding.group_sharded_utils import ( GroupShardedScaler, ) -from paddle.fluid.dygraph.nn import Linear from paddle.fluid.framework import _test_eager_guard from paddle.nn import Linear diff --git a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_sharding_optimizer_stage2.py b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_sharding_optimizer_stage2.py index 2b4237507360ba86b6d1275fffd9a4697de7b2d8..e03360382612b28e124189cdc979dbc0119a6fe4 100644 --- a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_sharding_optimizer_stage2.py +++ b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_sharding_optimizer_stage2.py @@ -23,7 +23,6 @@ from paddle.distributed.fleet.meta_optimizers.dygraph_optimizer.sharding_optimiz ShardingOptimizerStage2, ) from paddle.distributed.fleet.utils.internal_storage import GradStorage -from paddle.fluid.dygraph.nn import Linear from paddle.fluid.framework import _test_eager_guard from paddle.nn import Linear diff --git a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_sharding_stage2.py b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_sharding_stage2.py index 9a7d1081a633cebad0f403dc0202f9f3c8238ae9..94a735a01f9981b8b220f3f057861da883d78601 100644 --- a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_sharding_stage2.py +++ b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_sharding_stage2.py @@ -29,7 +29,6 @@ from paddle.distributed.fleet.meta_optimizers.dygraph_optimizer.sharding_optimiz from paddle.distributed.fleet.meta_parallel.sharding.sharding_stage2 import ( ShardingStage2, ) -from paddle.fluid.dygraph.nn import Linear from paddle.fluid.framework import _test_eager_guard from paddle.nn import Linear diff --git a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_sharding_stage3.py b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_sharding_stage3.py index 6822872a39834e139f321ae2b4c9b318154ab635..189c683db2ee4b3cab7177aab807c7b620d756ea 100644 --- a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_sharding_stage3.py +++ b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_sharding_stage3.py @@ -35,7 +35,6 @@ from paddle.distributed.fleet.meta_parallel.sharding.sharding_stage3 import ( from paddle.distributed.fleet.meta_parallel.sharding.sharding_utils import ( ShardingScaler, ) -from paddle.fluid.dygraph.nn import Linear from paddle.fluid.framework import _test_eager_guard from paddle.nn import Linear diff --git a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_sharding_stage3_offload.py b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_sharding_stage3_offload.py index 1ebcff04c832705158af8aad369fd094962a0c7a..07819a2f815a8ef8188f689725f5480725ffb6be 100644 --- a/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_sharding_stage3_offload.py +++ b/python/paddle/fluid/tests/unittests/collective/fleet/dygraph_sharding_stage3_offload.py @@ -25,7 +25,6 @@ from paddle.distributed.fleet.meta_parallel.sharding.sharding_stage3 import ( from paddle.distributed.fleet.meta_parallel.sharding.sharding_utils import ( ShardingScaler, ) -from paddle.fluid.dygraph.nn import Linear from paddle.fluid.framework import _test_eager_guard from paddle.nn import Linear diff --git a/python/paddle/fluid/tests/unittests/collective/fleet/parallel_dygraph_control_flow_same.py b/python/paddle/fluid/tests/unittests/collective/fleet/parallel_dygraph_control_flow_same.py index 9bf0f50676be0c6925f938aa58de27e8e9d2c328..2c83a3322f5a90b456c14747b5aac02850f5d06d 100644 --- a/python/paddle/fluid/tests/unittests/collective/fleet/parallel_dygraph_control_flow_same.py +++ b/python/paddle/fluid/tests/unittests/collective/fleet/parallel_dygraph_control_flow_same.py @@ -18,7 +18,6 @@ from test_dist_base import TestParallelDyGraphRunnerBase, runtime_main import paddle import paddle.fluid as fluid from paddle.fluid.dygraph.base import to_variable -from paddle.fluid.dygraph.nn import Linear from paddle.nn import Linear np.random.seed(2021) diff --git a/python/paddle/fluid/tests/unittests/collective/fleet/parallel_dygraph_no_sync.py b/python/paddle/fluid/tests/unittests/collective/fleet/parallel_dygraph_no_sync.py index 970b0cee70e0f4cc52c39dd5d7172aa6f9d7aba7..59a0f9a25098d54c6d2bcafb9d71e11739dc3a6e 100644 --- a/python/paddle/fluid/tests/unittests/collective/fleet/parallel_dygraph_no_sync.py +++ b/python/paddle/fluid/tests/unittests/collective/fleet/parallel_dygraph_no_sync.py @@ -26,7 +26,6 @@ from test_dist_base import ( import paddle import paddle.distributed as dist import paddle.fluid as fluid -from paddle.fluid.dygraph.nn import Linear from paddle.nn import Linear seed = 90 diff --git a/python/paddle/fluid/tests/unittests/collective/fleet/parallel_dygraph_no_sync_control_flow.py b/python/paddle/fluid/tests/unittests/collective/fleet/parallel_dygraph_no_sync_control_flow.py index 8ac9d6b2113d1fade61d0e7292f6ee62b90287aa..59a59a8042bad58c11242009357d61303b74847e 100644 --- a/python/paddle/fluid/tests/unittests/collective/fleet/parallel_dygraph_no_sync_control_flow.py +++ b/python/paddle/fluid/tests/unittests/collective/fleet/parallel_dygraph_no_sync_control_flow.py @@ -18,7 +18,6 @@ from test_dist_base import runtime_main import paddle import paddle.fluid as fluid -from paddle.fluid.dygraph.nn import Linear from paddle.nn import Linear seed = 90 diff --git a/python/paddle/fluid/tests/unittests/collective/fleet/parallel_dygraph_se_resnext.py b/python/paddle/fluid/tests/unittests/collective/fleet/parallel_dygraph_se_resnext.py index eef3f6bdd743d32e66ece1dce11f6faace6c85cd..14bb4023b8cc5f2c72bf94da695aa9383a4896cd 100644 --- a/python/paddle/fluid/tests/unittests/collective/fleet/parallel_dygraph_se_resnext.py +++ b/python/paddle/fluid/tests/unittests/collective/fleet/parallel_dygraph_se_resnext.py @@ -20,7 +20,6 @@ from test_dist_base import TestParallelDyGraphRunnerBase, runtime_main import paddle import paddle.fluid as fluid from paddle.fluid.dygraph.base import to_variable -from paddle.fluid.dygraph.nn import Linear from paddle.nn import Linear batch_size = 64 diff --git a/python/paddle/fluid/tests/unittests/collective/multinode/mn_dygraph_group_sharded_stage3.py b/python/paddle/fluid/tests/unittests/collective/multinode/mn_dygraph_group_sharded_stage3.py index 5c328591bda7542887623bc7d2ab3d732584bfc8..72f89eb25f43f27c38b52fe20c975a7ad1b8d2b5 100644 --- a/python/paddle/fluid/tests/unittests/collective/multinode/mn_dygraph_group_sharded_stage3.py +++ b/python/paddle/fluid/tests/unittests/collective/multinode/mn_dygraph_group_sharded_stage3.py @@ -34,7 +34,6 @@ from paddle.distributed.fleet.meta_parallel.sharding.group_sharded_stage3 import from paddle.distributed.fleet.meta_parallel.sharding.group_sharded_utils import ( GroupShardedScaler, ) -from paddle.fluid.dygraph.nn import Linear from paddle.fluid.framework import _test_eager_guard from paddle.nn import Linear diff --git a/python/paddle/fluid/tests/unittests/collective/multinode/mn_dygraph_sharding_stage2.py b/python/paddle/fluid/tests/unittests/collective/multinode/mn_dygraph_sharding_stage2.py index d68a6cb5880dab0d389a8c33a74c13c0822703a9..b088bf424b85c5d6baf24c363bc3e8462e6f5f5a 100644 --- a/python/paddle/fluid/tests/unittests/collective/multinode/mn_dygraph_sharding_stage2.py +++ b/python/paddle/fluid/tests/unittests/collective/multinode/mn_dygraph_sharding_stage2.py @@ -29,7 +29,6 @@ from paddle.distributed.fleet.meta_optimizers.dygraph_optimizer.sharding_optimiz from paddle.distributed.fleet.meta_parallel.sharding.sharding_stage2 import ( ShardingStage2, ) -from paddle.fluid.dygraph.nn import Linear from paddle.fluid.framework import _test_eager_guard from paddle.nn import Linear diff --git a/python/paddle/fluid/tests/unittests/collective/process_group_gloo.py b/python/paddle/fluid/tests/unittests/collective/process_group_gloo.py index 990a8d486751c25cf6c67c389849804e3f032bb8..ad2c91381adf80edc166b781440346d85913975b 100644 --- a/python/paddle/fluid/tests/unittests/collective/process_group_gloo.py +++ b/python/paddle/fluid/tests/unittests/collective/process_group_gloo.py @@ -18,7 +18,6 @@ import unittest import numpy as np import paddle -import paddle.fluid.core as core from paddle.fluid import core from paddle.fluid.dygraph.parallel import ParallelEnv from paddle.fluid.framework import _test_eager_guard diff --git a/python/paddle/fluid/tests/unittests/collective/process_group_mpi.py b/python/paddle/fluid/tests/unittests/collective/process_group_mpi.py index 1e82dedcc5ff1ea3276addee07536dc48c1a2813..2fb9deb110e2a520bdb86756e38b6be0d12c6579 100644 --- a/python/paddle/fluid/tests/unittests/collective/process_group_mpi.py +++ b/python/paddle/fluid/tests/unittests/collective/process_group_mpi.py @@ -20,7 +20,6 @@ import numpy as np import paddle import paddle.distributed as dist -import paddle.fluid.core as core from paddle.distributed.collective import ( Group, _default_group_name, diff --git a/python/paddle/fluid/tests/unittests/dist_word2vec.py b/python/paddle/fluid/tests/unittests/dist_word2vec.py index 146521fa395f0ff0db0349e68a0c4c3777e624a0..ed3a83a5b42a9fd67233db5d85d29dcc4de3fdd6 100644 --- a/python/paddle/fluid/tests/unittests/dist_word2vec.py +++ b/python/paddle/fluid/tests/unittests/dist_word2vec.py @@ -138,8 +138,6 @@ class TestDistWord2vec2x2(TestDistRunnerBase): if __name__ == "__main__": - import os - os.environ['CPU_NUM'] = '1' os.environ['USE_CUDA'] = "FALSE" runtime_main(TestDistWord2vec2x2) diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_mobile_net.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_mobile_net.py index 8358c12edc4b6c798292f80d354f5588b8cac77f..ff36720594c097d454c3e37c9b7307f390c13a79 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_mobile_net.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_mobile_net.py @@ -23,7 +23,7 @@ from predictor_utils import PredictorTools import paddle import paddle.fluid as fluid from paddle.fluid.dygraph.io import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX -from paddle.fluid.dygraph.nn import BatchNorm, Linear +from paddle.fluid.dygraph.nn import BatchNorm from paddle.fluid.initializer import MSRA from paddle.fluid.param_attr import ParamAttr from paddle.jit import ProgramTranslator diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_sentiment.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_sentiment.py index c644cdfe0c446c77b55fd6910be2a10053e347ff..e259ce5cf2e47973fa4bafd6c1693fe63f4534fb 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_sentiment.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_sentiment.py @@ -20,7 +20,7 @@ from test_lac import DynamicGRU import paddle import paddle.fluid as fluid from paddle.fluid.dygraph import to_variable -from paddle.fluid.dygraph.nn import Embedding, Linear +from paddle.fluid.dygraph.nn import Embedding from paddle.jit import ProgramTranslator from paddle.jit.api import declarative from paddle.nn import Linear diff --git a/python/paddle/fluid/tests/unittests/ipu/test_pad_op_ipu.py b/python/paddle/fluid/tests/unittests/ipu/test_pad_op_ipu.py index f716c58e4a381d050b40cacd7a176f990ff9eb6d..702f2b4ea1c722f77485db8893dc3e884d84b526 100644 --- a/python/paddle/fluid/tests/unittests/ipu/test_pad_op_ipu.py +++ b/python/paddle/fluid/tests/unittests/ipu/test_pad_op_ipu.py @@ -126,13 +126,13 @@ class TestCase7(TestBase): @unittest.skip("Only support NCL, NCHW, NCDHW") -class TestCase7(TestBase): +class TestCase8(TestBase): def set_op_attrs(self): self.attrs = {"pad": [1, 2, 3, 4], "data_format": "NHWC"} @unittest.skip("Only support NCL, NCHW, NCDHW") -class TestCase7(TestBase): +class TestCase9(TestBase): def set_op_attrs(self): self.attrs = {"pad": [1, 2, 3, 4, 1, 3], "data_format": "NDHWC"} diff --git a/python/paddle/fluid/tests/unittests/parallel_dygraph_shared_unused_var.py b/python/paddle/fluid/tests/unittests/parallel_dygraph_shared_unused_var.py index 1f063f849e35098aa5b44d4915b869b98854886d..6257100779d672f5b4cd5782ce418423b7761ddb 100644 --- a/python/paddle/fluid/tests/unittests/parallel_dygraph_shared_unused_var.py +++ b/python/paddle/fluid/tests/unittests/parallel_dygraph_shared_unused_var.py @@ -18,7 +18,6 @@ from test_dist_base import TestParallelDyGraphRunnerBase, runtime_main import paddle import paddle.fluid as fluid from paddle.fluid.dygraph.base import to_variable -from paddle.fluid.dygraph.nn import Linear from paddle.nn import Linear np.random.seed(2021) diff --git a/python/paddle/fluid/tests/unittests/test_batch_norm_op.py b/python/paddle/fluid/tests/unittests/test_batch_norm_op.py index 9c3f04b1360c03e819883dbfa6ff7a745b4772cf..34b358130219d9a632886ed4146cd603851c5cca 100644 --- a/python/paddle/fluid/tests/unittests/test_batch_norm_op.py +++ b/python/paddle/fluid/tests/unittests/test_batch_norm_op.py @@ -847,7 +847,5 @@ class TestDygraphBatchNormOpenReserveSpace(unittest.TestCase): if __name__ == '__main__': - import paddle - paddle.enable_static() unittest.main() diff --git a/python/paddle/fluid/tests/unittests/test_batch_norm_op_v2.py b/python/paddle/fluid/tests/unittests/test_batch_norm_op_v2.py index 7056c34487bdbd135da6961c5c5b1b0faad12071..1818d392057e60c561f78ae465b452e4475cd362 100644 --- a/python/paddle/fluid/tests/unittests/test_batch_norm_op_v2.py +++ b/python/paddle/fluid/tests/unittests/test_batch_norm_op_v2.py @@ -422,7 +422,5 @@ class TestBatchNormUseGlobalStatsCase3(TestBatchNormUseGlobalStats): if __name__ == '__main__': - import paddle - paddle.enable_static() unittest.main() diff --git a/python/paddle/fluid/tests/unittests/test_collective_api_base.py b/python/paddle/fluid/tests/unittests/test_collective_api_base.py index 096ac99f9c9973c801eb1a14eeccf6e3d1abcc20..9a53ab77622f1632d41b045ce15d101c513e6349 100644 --- a/python/paddle/fluid/tests/unittests/test_collective_api_base.py +++ b/python/paddle/fluid/tests/unittests/test_collective_api_base.py @@ -14,6 +14,7 @@ import os import pickle +import socket import subprocess import sys import tempfile @@ -161,10 +162,6 @@ def runtime_main(test_class, col_type): model.run_trainer(args) -import socket -from contextlib import closing - - class TestDistBase(unittest.TestCase): def setUp(self): self._port_set = set() diff --git a/python/paddle/fluid/tests/unittests/test_collective_base.py b/python/paddle/fluid/tests/unittests/test_collective_base.py index 1483cd1d07a9c72d54e52d04c6d3d8fa2e15c8f0..238a145f05965d3c5ac3b2c8142e2330428161ab 100644 --- a/python/paddle/fluid/tests/unittests/test_collective_base.py +++ b/python/paddle/fluid/tests/unittests/test_collective_base.py @@ -14,6 +14,7 @@ import os import pickle +import socket import subprocess import sys import tempfile @@ -140,10 +141,6 @@ def runtime_main(test_class, col_type, sub_type): model.run_trainer(args) -import socket -from contextlib import closing - - class TestDistBase(unittest.TestCase): def setUp(self): self._port_set = set() diff --git a/python/paddle/fluid/tests/unittests/test_crop_op.py b/python/paddle/fluid/tests/unittests/test_crop_op.py index 5e13eacb6e5c947ba462e47ed5cdcae39b02b89d..1050fb0ad5c57399cc2ed391f00dd81e538f2e9f 100644 --- a/python/paddle/fluid/tests/unittests/test_crop_op.py +++ b/python/paddle/fluid/tests/unittests/test_crop_op.py @@ -150,7 +150,5 @@ class TestCropNoneShape(unittest.TestCase): if __name__ == '__main__': - import paddle - paddle.enable_static() unittest.main() diff --git a/python/paddle/fluid/tests/unittests/test_crop_tensor_op.py b/python/paddle/fluid/tests/unittests/test_crop_tensor_op.py index 620c10a2bd5f62442720c220e5e9e2977f730fac..e8d78956fd4355d9f3157f2f3ea9d02701f56780 100644 --- a/python/paddle/fluid/tests/unittests/test_crop_tensor_op.py +++ b/python/paddle/fluid/tests/unittests/test_crop_tensor_op.py @@ -271,7 +271,5 @@ class TestCropTensorException(unittest.TestCase): if __name__ == '__main__': - import paddle - paddle.enable_static() unittest.main() diff --git a/python/paddle/fluid/tests/unittests/test_dist_fleet_base.py b/python/paddle/fluid/tests/unittests/test_dist_fleet_base.py index c84bd2b7ca6bc876c0294cf7d5e5932c129375a9..f1a790d8e89c11e9b7ff0400196e5a9a160f7e0e 100644 --- a/python/paddle/fluid/tests/unittests/test_dist_fleet_base.py +++ b/python/paddle/fluid/tests/unittests/test_dist_fleet_base.py @@ -12,14 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import paddle -import paddle.distributed.fleet as fleet -import paddle.distributed.fleet.base.role_maker as role_maker -import paddle.fluid as fluid -from paddle.distributed.fleet.utils.ps_util import DistributedInfer - """ - high level unit test for distribute fleet. +high level unit test for distribute fleet. """ import argparse @@ -34,6 +28,10 @@ import unittest from contextlib import closing import paddle +import paddle.distributed.fleet as fleet +import paddle.distributed.fleet.base.role_maker as role_maker +import paddle.fluid as fluid +from paddle.distributed.fleet.utils.ps_util import DistributedInfer paddle.enable_static() diff --git a/python/paddle/fluid/tests/unittests/test_fuse_relu_depthwise_conv_pass.py b/python/paddle/fluid/tests/unittests/test_fuse_relu_depthwise_conv_pass.py index ed7cb760f053898720d53177aa9ad9a12f784599..a136a623d033159caf14603567ab82acd46abe7b 100644 --- a/python/paddle/fluid/tests/unittests/test_fuse_relu_depthwise_conv_pass.py +++ b/python/paddle/fluid/tests/unittests/test_fuse_relu_depthwise_conv_pass.py @@ -89,7 +89,7 @@ class TestMNIST(TestParallelExecutorBase): return optimizer if only_forward: - _optimizer = None + _optimizer = None # noqa: F811 ( fuse_op_first_loss, diff --git a/python/paddle/fluid/tests/unittests/test_gru_unit_op.py b/python/paddle/fluid/tests/unittests/test_gru_unit_op.py index 2f7c4a42e3362dbef17f209e10dc176e1180b018..92fadf591a76c5f23a7339bbd7ab751544bde13f 100644 --- a/python/paddle/fluid/tests/unittests/test_gru_unit_op.py +++ b/python/paddle/fluid/tests/unittests/test_gru_unit_op.py @@ -19,7 +19,6 @@ import numpy as np from op_test import OpTest import paddle.fluid as fluid -from paddle import fluid from paddle.fluid.framework import Program, program_guard from paddle.fluid.layers import gru_unit diff --git a/python/paddle/fluid/tests/unittests/test_imperative_ocr_attention_model.py b/python/paddle/fluid/tests/unittests/test_imperative_ocr_attention_model.py index 8c46a64162299c23a21b5583aea9bc9585ecb3e3..998e9de7ff85e82d6fd535d4088afe5f97843c68 100644 --- a/python/paddle/fluid/tests/unittests/test_imperative_ocr_attention_model.py +++ b/python/paddle/fluid/tests/unittests/test_imperative_ocr_attention_model.py @@ -21,7 +21,7 @@ import paddle import paddle.fluid as fluid from paddle.fluid import core from paddle.fluid.dygraph.base import to_variable -from paddle.fluid.dygraph.nn import BatchNorm, Embedding, GRUUnit, Linear +from paddle.fluid.dygraph.nn import BatchNorm, Embedding, GRUUnit from paddle.fluid.framework import _test_eager_guard from paddle.nn import Linear diff --git a/python/paddle/fluid/tests/unittests/test_math_op_patch.py b/python/paddle/fluid/tests/unittests/test_math_op_patch.py index a582b4951b1177f0e8cc053374359850b747b505..fb3b342131beec945ac517b08d9ae070a83c681a 100644 --- a/python/paddle/fluid/tests/unittests/test_math_op_patch.py +++ b/python/paddle/fluid/tests/unittests/test_math_op_patch.py @@ -53,7 +53,7 @@ class TestMathOpPatches(unittest.TestCase): place = fluid.CPUPlace() exe = fluid.Executor(place) a_np = np.random.random(size=[10, 1]).astype('float32') - b_np = exe.run( + (b_np,) = exe.run( fluid.default_main_program(), feed={"a": a_np}, fetch_list=[b] ) np.testing.assert_allclose(a_np + 10, b_np, rtol=1e-05) @@ -71,7 +71,7 @@ class TestMathOpPatches(unittest.TestCase): np.testing.assert_allclose(a_np - 10, b_np, rtol=1e-05) @prog_scope() - def test_radd_scalar(self): + def test_rsub_scalar(self): a = fluid.layers.data(name="a", shape=[1]) b = 10 - a place = fluid.CPUPlace() diff --git a/python/paddle/fluid/tests/unittests/test_norm_op.py b/python/paddle/fluid/tests/unittests/test_norm_op.py index 82e87967716ff551e27cf96c327b236b96f1db31..232d5ceda412be302dc5371695d1a9bc74fdc779 100644 --- a/python/paddle/fluid/tests/unittests/test_norm_op.py +++ b/python/paddle/fluid/tests/unittests/test_norm_op.py @@ -161,7 +161,5 @@ class API_NormTest(unittest.TestCase): if __name__ == '__main__': - import paddle - paddle.enable_static() unittest.main() diff --git a/python/paddle/fluid/tests/unittests/test_optimizer_for_varbase.py b/python/paddle/fluid/tests/unittests/test_optimizer_for_varbase.py index 183423ba9896c8bdb6281051bd2966d485c012c3..e53ac6bbd9ed3d2f07bdf8ebed2597d3ca861819 100644 --- a/python/paddle/fluid/tests/unittests/test_optimizer_for_varbase.py +++ b/python/paddle/fluid/tests/unittests/test_optimizer_for_varbase.py @@ -184,7 +184,7 @@ class TestOptimizerForVarBase(unittest.TestCase): z.backward() opt.step() - def func_test_create_param_lr_with_no_1_value_for_coverage(self): + def test_create_param_lr_with_no_1_value_for_coverage(self): with _test_eager_guard(): self.func_test_create_param_lr_with_1_for_coverage() self.func_test_create_param_lr_with_1_for_coverage() diff --git a/python/paddle/fluid/tests/unittests/test_reduce_op.py b/python/paddle/fluid/tests/unittests/test_reduce_op.py index 53a1af18ea29916e6a985e88c3b8fed37202054b..b101c24e77f8a08b33028aa7efdb586cd41a14cf 100644 --- a/python/paddle/fluid/tests/unittests/test_reduce_op.py +++ b/python/paddle/fluid/tests/unittests/test_reduce_op.py @@ -1114,7 +1114,5 @@ class TestAnyAPI(unittest.TestCase): if __name__ == '__main__': - import paddle - paddle.enable_static() unittest.main() diff --git a/python/paddle/fluid/tests/unittests/test_searchsorted_op.py b/python/paddle/fluid/tests/unittests/test_searchsorted_op.py index e5980cea170e7594776effea60af55e37911a760..c83e8d534463f2e773f0b1ba42832ea81d901fae 100644 --- a/python/paddle/fluid/tests/unittests/test_searchsorted_op.py +++ b/python/paddle/fluid/tests/unittests/test_searchsorted_op.py @@ -21,7 +21,6 @@ import paddle import paddle.fluid.core as core paddle.enable_static() -from op_test import OpTest class TestSearchSorted(OpTest): diff --git a/python/paddle/fluid/tests/unittests/test_split_and_merge_lod_tensor_op.py b/python/paddle/fluid/tests/unittests/test_split_and_merge_lod_tensor_op.py index c5350445a9de333009237c40b55123edd84dd1e8..943e197a96ec59169a486d51338dae7dcaf59683 100644 --- a/python/paddle/fluid/tests/unittests/test_split_and_merge_lod_tensor_op.py +++ b/python/paddle/fluid/tests/unittests/test_split_and_merge_lod_tensor_op.py @@ -22,7 +22,6 @@ import paddle.fluid.layers as layers from paddle.fluid import Program, program_guard from paddle.fluid.backward import append_backward from paddle.fluid.executor import Executor -from paddle.fluid.framework import Program, program_guard from paddle.fluid.layer_helper import LayerHelper from paddle.fluid.layers.control_flow import merge_lod_tensor, split_lod_tensor diff --git a/python/paddle/fluid/tests/unittests/test_sum_op.py b/python/paddle/fluid/tests/unittests/test_sum_op.py index 9626a872e2ffc21a18ecb8d4315973e10f5b9b0a..55ce3b31010ab7c429fa06bbfae207babaf8968a 100644 --- a/python/paddle/fluid/tests/unittests/test_sum_op.py +++ b/python/paddle/fluid/tests/unittests/test_sum_op.py @@ -19,7 +19,6 @@ import unittest import gradient_checker import numpy as np from decorator_helper import prog_scope -from op_test import OpTest import paddle import paddle.fluid as fluid diff --git a/python/paddle/fluid/tests/unittests/test_var_base.py b/python/paddle/fluid/tests/unittests/test_var_base.py index 62b66be09367dd488f2d2ea851700b6cc08c6018..6fe6583b52c9358ef01296994a8fa719ec2b1f21 100644 --- a/python/paddle/fluid/tests/unittests/test_var_base.py +++ b/python/paddle/fluid/tests/unittests/test_var_base.py @@ -1380,11 +1380,6 @@ class TestVarBase(unittest.TestCase): self.func_tensor_str_bf16() self.func_tensor_str_bf16() - def test_tensor_str_bf16(self): - with _test_eager_guard(): - self.func_tensor_str_bf16() - self.func_tensor_str_bf16() - def func_test_print_tensor_dtype(self): paddle.disable_static(paddle.CPUPlace()) a = paddle.rand([1]) diff --git a/python/paddle/fluid/tests/unittests/xpu/test_bilinear_interp_v2_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_bilinear_interp_v2_op_xpu.py index 974f5f67ba5d3a01026503d4912c2be96217783e..81e08c000b7f42c1cd785b885ba4eee4567db0bd 100755 --- a/python/paddle/fluid/tests/unittests/xpu/test_bilinear_interp_v2_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_bilinear_interp_v2_op_xpu.py @@ -18,7 +18,6 @@ import unittest import numpy as np sys.path.append("..") -import unittest from op_test_xpu import XPUOpTest from xpu.get_test_cover_info import ( diff --git a/python/paddle/fluid/tests/unittests/xpu/test_collective_base_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_collective_base_xpu.py index 31e061ed2a6318df27989423971dfe400e81614b..22e0a63e48ee93ebdf8bc671f8bda3a913485f52 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_collective_base_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_collective_base_xpu.py @@ -14,6 +14,7 @@ import os import pickle +import socket import subprocess import sys import tempfile @@ -165,10 +166,6 @@ def runtime_main(test_class, col_type, sub_type): model.run_trainer(args) -import socket -from contextlib import closing - - class TestDistBase(unittest.TestCase): def setUp(self): self._port_set = set() diff --git a/python/paddle/fluid/tests/unittests/xpu/test_mean_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_mean_op_xpu.py index 22f759b46f0c7502e12e7710f157a5bebcdc0e2c..3991862346bbae813f3d98fa8c5994b544031d3d 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_mean_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_mean_op_xpu.py @@ -26,7 +26,6 @@ from paddle.fluid import Program, program_guard np.random.seed(10) -from op_test_xpu import XPUOpTest from xpu.get_test_cover_info import ( XPUOpTestWrapper, create_test_class, diff --git a/python/paddle/fluid/tests/unittests/xpu/test_roll_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_roll_op_xpu.py index d747ade7b65164a674bab8f272991ca9c927188b..25b156a280a64e18316717b547cfaf3154e8b8d8 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_roll_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_roll_op_xpu.py @@ -79,7 +79,7 @@ class XPUTestRollOp(XPUOpTestWrapper): self.shifts = [8, -1] self.axis = [-1, -2] - class TestRollOpCase4(TestXPURollOp): + class TestRollOpCase5(TestXPURollOp): def init_shapes(self): self.x_shape = (100, 10, 5, 10) self.shifts = [20, -1] diff --git a/python/paddle/fluid/tests/unittests/xpu/test_sequence_unpad_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_sequence_unpad_op_xpu.py index 17edbf907b2e616ebe2ae4a024747f80c87b9ce5..c24b1c2cd946bae6779bf4b51c752c565c76f257 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_sequence_unpad_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_sequence_unpad_op_xpu.py @@ -19,9 +19,6 @@ import numpy as np sys.path.append("..") -import unittest - -import numpy as np from op_test_xpu import XPUOpTest from xpu.get_test_cover_info import ( XPUOpTestWrapper, diff --git a/python/paddle/jit/dy2static/call_transformer.py b/python/paddle/jit/dy2static/call_transformer.py index c5ae35ee3d4ac19b6119793e9be96cb8d7edafe9..012c73b99f65434070a32cc4f283eab8db1bac5e 100644 --- a/python/paddle/jit/dy2static/call_transformer.py +++ b/python/paddle/jit/dy2static/call_transformer.py @@ -62,7 +62,7 @@ class CallTransformer(BaseTransformer): 'enumerate', 'print', } - is_builtin = eval("is_builtin({})".format(func_str)) + is_builtin = eval("is_builtin({})".format(func_str)) # noqa: F811 need_convert = func_str in need_convert_builtin_func_list return is_builtin and not need_convert except Exception: diff --git a/python/paddle/nn/functional/activation.py b/python/paddle/nn/functional/activation.py index 69e54a067df25fd6c3334cd77fd3a7782f66e322..6bf32317a461fcb3b603bff48645f90ec51274f4 100644 --- a/python/paddle/nn/functional/activation.py +++ b/python/paddle/nn/functional/activation.py @@ -14,7 +14,6 @@ import paddle from paddle import _C_ops, _legacy_C_ops, in_dynamic_mode -from paddle.fluid.framework import _in_legacy_dygraph, in_dygraph_mode from paddle.framework import core from ...fluid.data_feeder import check_dtype, check_variable_and_dtype diff --git a/python/paddle/nn/functional/common.py b/python/paddle/nn/functional/common.py index 2e27a4fc8c6df4d09bd8645c105a25efd5078ccb..4fbb792ce85a41a5f173b87d483b4e1cb813fe05 100644 --- a/python/paddle/nn/functional/common.py +++ b/python/paddle/nn/functional/common.py @@ -14,7 +14,6 @@ import paddle from paddle import _C_ops, _legacy_C_ops -from paddle.fluid.framework import _in_legacy_dygraph from paddle.fluid.layer_helper import LayerHelper from paddle.fluid.layers.tensor import fill_constant from paddle.framework import core, in_dynamic_mode diff --git a/python/paddle/nn/functional/loss.py b/python/paddle/nn/functional/loss.py index 481598ab95858a797d0bb2b2200af97645919cc4..dd5c2e128268cf92c836a3cd44bbb74b13a4f418 100755 --- a/python/paddle/nn/functional/loss.py +++ b/python/paddle/nn/functional/loss.py @@ -17,7 +17,7 @@ import paddle import paddle.fluid as fluid from paddle import _C_ops, _legacy_C_ops, in_dynamic_mode -from paddle.framework import _non_static_mode, core +from paddle.framework import core from paddle.utils import deprecated from ...fluid.data_feeder import check_variable_and_dtype diff --git a/python/paddle/nn/layer/__init__.py b/python/paddle/nn/layer/__init__.py index 1acea10d6755cbc7c65125e305e8ff541d3a31df..3daf3185b7fc6d341941d733c821fe214f9d2499 100644 --- a/python/paddle/nn/layer/__init__.py +++ b/python/paddle/nn/layer/__init__.py @@ -43,7 +43,6 @@ from .common import Dropout # noqa: F401 from .common import Dropout2D # noqa: F401 from .common import Dropout3D # noqa: F401 from .common import AlphaDropout # noqa: F401 -from .common import Upsample # noqa: F401 from .common import UpsamplingBilinear2D # noqa: F401 from .common import UpsamplingNearest2D # noqa: F401 from .common import Fold diff --git a/python/paddle/tensor/math.py b/python/paddle/tensor/math.py index 857f99c8f6bce29d9d1fb54f8c7dd977686214b3..efa8d7c453b805058fc367714634b74bd3ee2beb 100644 --- a/python/paddle/tensor/math.py +++ b/python/paddle/tensor/math.py @@ -30,7 +30,6 @@ from ..fluid.data_feeder import ( convert_dtype, ) from ..fluid.dygraph.inplace_utils import inplace_apis_in_dygraph_only -from ..fluid.framework import _in_legacy_dygraph from ..fluid.layers import elementwise_sub, utils from ..framework import ( LayerHelper, diff --git a/python/paddle/tests/test_transforms.py b/python/paddle/tests/test_transforms.py index 7045b63455d355a10a58078c1e6b41f0af4e06fc..7d1280b8944dd0f846445a373b748b2d1a020d00 100644 --- a/python/paddle/tests/test_transforms.py +++ b/python/paddle/tests/test_transforms.py @@ -652,7 +652,7 @@ class TestTransformsTensor(TestTransformsCV2): transform = transforms.RandomResizedCrop(64) transform(1) - test_color_jitter = None + test_color_jitter = None # noqa: F811 class TestFunctional(unittest.TestCase): diff --git a/python/paddle/utils/flops.py b/python/paddle/utils/flops.py index 9c1317676934110029a46c27ca322c6bce1d0a1a..a930e0ef5488d8a492b76a69cd02c633c695f0ed 100644 --- a/python/paddle/utils/flops.py +++ b/python/paddle/utils/flops.py @@ -117,7 +117,7 @@ def _elementwise_mul_flops(input_shapes, attrs): @register_flops("elementwise_div") -def _elementwise_mul_flops(input_shapes, attrs): +def _elementwise_div_flops(input_shapes, attrs): """FLOPs computation for elementwise_div op. For elementwise_div(input,other): input_shapes = [shape_of_input, shape_of_ohther]