diff --git a/pyproject.toml b/pyproject.toml index 2c53986c539cafcf6f0232aa47afa2f72b7a645a..2530f0936b03da98b3042af826261accd57ca2b0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,13 +19,6 @@ extend_skip_glob = [ "python/paddle/fluid/tests/unittests/mlu/**", # These files will be fixed in the future - "cmake/**", - "paddle/**", - "r/**", - "tools/**", - "python/paddle/[!f]**", - "python/paddle/fluid/tests/unittests/[t-z]**", "python/paddle/fluid/tests/unittests/dygraph_to_static/test_error.py", - "python/paddle/fluid/tests/unittests/dygraph_to_static/**", - "python/paddle/fluid/tests/unittests/ipu/test_dy2static_ipu.py", + "python/paddle/jit/**", ] diff --git a/python/paddle/distributed/passes/auto_parallel_data_parallel_optimization.py b/python/paddle/distributed/passes/auto_parallel_data_parallel_optimization.py index 47759484a66ee294f804fc0d402bac6f7dbc3b06..66f80ee995049151c570e9a03f25852876e9b9ae 100644 --- a/python/paddle/distributed/passes/auto_parallel_data_parallel_optimization.py +++ b/python/paddle/distributed/passes/auto_parallel_data_parallel_optimization.py @@ -15,24 +15,25 @@ from collections import OrderedDict import paddle -from paddle.fluid import unique_name -from paddle.fluid.framework import default_main_program -from paddle.distributed.fleet.meta_optimizers.common import OP_ROLE_KEY, OpRole -from .pass_base import PassBase, PassType, register_pass from paddle.distributed.auto_parallel.operators.common import ( - is_data_parallel_scale_op, is_data_parallel_reduce_op, + is_data_parallel_scale_op, ) from paddle.distributed.auto_parallel.utils import ( find_higher_order_backward_op, + get_var_numel, + insert_dependencies_for_two_vars, + is_forward_op, is_loss_grad_op, is_optimize_op, - is_forward_op, ring_id_to_process_group, - get_var_numel, use_standalone_executor, - insert_dependencies_for_two_vars, ) +from paddle.distributed.fleet.meta_optimizers.common import OP_ROLE_KEY, OpRole +from paddle.fluid import unique_name +from paddle.fluid.framework import default_main_program + +from .pass_base import PassBase, PassType, register_pass # add new optimizers supporting rescale_grad here __rescale_grad_supported_opts__ = [ diff --git a/python/paddle/distributed/passes/auto_parallel_grad_clip.py b/python/paddle/distributed/passes/auto_parallel_grad_clip.py index a475f8e0ac317e3ac82d731bd1b50ee8f54a386c..af5259680e4a596042c5307c416c443a2477a104 100644 --- a/python/paddle/distributed/passes/auto_parallel_grad_clip.py +++ b/python/paddle/distributed/passes/auto_parallel_grad_clip.py @@ -12,27 +12,28 @@ # See the License for the specific language governing permissions and # limitations under the License. -import numpy as np from functools import reduce +import numpy as np + import paddle -from .pass_base import PassBase, register_pass -from ..auto_parallel.reshard import Resharder +from ..auto_parallel.dist_attribute import ( + OperatorDistributedAttribute, + TensorDistributedAttribute, +) from ..auto_parallel.process_group import get_world_process_group +from ..auto_parallel.reshard import Resharder from ..auto_parallel.utils import ( - is_gradient_clip_op, - is_optimize_op, OP_ROLE_KEY, OpRole, _get_comm_group, insert_dependencies_for_two_vars, + is_gradient_clip_op, + is_optimize_op, use_standalone_executor, ) -from ..auto_parallel.dist_attribute import ( - TensorDistributedAttribute, - OperatorDistributedAttribute, -) +from .pass_base import PassBase, register_pass def _get_params_grads(block): diff --git a/python/paddle/distribution/normal.py b/python/paddle/distribution/normal.py index b3877af277fbb96b5e949d120bc902dfdd1441a4..3eb3fd2d59009c48cf28a64fd6129ea5e0acaf06 100644 --- a/python/paddle/distribution/normal.py +++ b/python/paddle/distribution/normal.py @@ -21,10 +21,7 @@ import paddle from paddle.distribution import distribution from paddle.fluid.data_feeder import check_type, convert_dtype from paddle.fluid.framework import _non_static_mode -from paddle.fluid.layers import ( - nn, - tensor, -) +from paddle.fluid.layers import nn, tensor class Normal(distribution.Distribution): diff --git a/python/paddle/distribution/uniform.py b/python/paddle/distribution/uniform.py index b9566d3c8dbc274c182570bdba07199eeacd9c6e..1b1ef5906d964338f5c969f66c5ba274c39a7bdc 100644 --- a/python/paddle/distribution/uniform.py +++ b/python/paddle/distribution/uniform.py @@ -23,12 +23,7 @@ from paddle.fluid.framework import ( _non_static_mode, in_dygraph_mode, ) -from paddle.fluid.layers import ( - nn, - tensor, -) - -import paddle +from paddle.fluid.layers import nn, tensor from paddle.tensor import random diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/bert_dygraph_model.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/bert_dygraph_model.py index 8eb757d87ac4f90ad1aad644272699cde777f5c3..3e372a6d9408f6219ddec27b369bb3fd2d403567 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/bert_dygraph_model.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/bert_dygraph_model.py @@ -17,8 +17,8 @@ from transformer_dygraph_model import MultiHeadAttention, PrePostProcessLayer import paddle import paddle.fluid as fluid from paddle.fluid.dygraph import Embedding, Layer -from paddle.nn import Linear from paddle.jit.api import declarative +from paddle.nn import Linear class PositionwiseFeedForwardLayer(Layer): diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/simnet_dygraph_model.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/simnet_dygraph_model.py index f236faccdc2df8a78e40ab96f7522a8dcb1b4621..075900b939fdf16342f69646e351c6129f04ae84 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/simnet_dygraph_model.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/simnet_dygraph_model.py @@ -17,9 +17,6 @@ from functools import reduce import paddle import paddle.fluid as fluid import paddle.fluid.param_attr as attr - -from functools import reduce - from paddle.fluid.dygraph import Embedding, Layer from paddle.jit.api import declarative from paddle.static import Variable diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_convert_call.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_convert_call.py index 302045ed4038f22861db0019756958a663e37c11..743fff189cb9f860840d4a6083b09bb14f938f4d 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_convert_call.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_convert_call.py @@ -12,19 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. +import logging import unittest -import logging import numpy as np +from test_program_translator import get_source_code import paddle import paddle.fluid as fluid -from paddle.jit import ProgramTranslator -from paddle.jit.dy2static.convert_call_func import ( - CONVERSION_OPTIONS, -) -from test_program_translator import get_source_code import paddle.jit.dy2static as _jst +from paddle.jit import ProgramTranslator +from paddle.jit.dy2static.convert_call_func import CONVERSION_OPTIONS program_translator = ProgramTranslator() diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_lac.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_lac.py index dd4e7e6746d1ce8b7114e2728b772cef06704b01..54b97c9280a404f650bdc93773690daf4fd92b2c 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_lac.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_lac.py @@ -24,10 +24,8 @@ os.environ["CUDA_VISIBLE_DEVICES"] = "2" import paddle import paddle.fluid as fluid -from paddle.fluid.dygraph import to_variable -from paddle.fluid.dygraph import Embedding, GRUUnit - from paddle import _legacy_C_ops +from paddle.fluid.dygraph import Embedding, GRUUnit, to_variable from paddle.fluid.dygraph.io import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX from paddle.fluid.framework import _non_static_mode from paddle.jit import ProgramTranslator diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_len.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_len.py index 6ab1fbc9f2065718b54cd858aef5c66ac4b3ad54..3acd56b6f6fc7314bb1f6f303e6d2f6e25b17e76 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_len.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_len.py @@ -15,6 +15,7 @@ import unittest import numpy as np + import paddle import paddle.fluid as fluid from paddle.jit.api import declarative diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_logical.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_logical.py index 97454a8cefb5a69b8f6d4b75e0ec83f34f503a10..fd335c41ba24ef6bb0ea4a1e61d19b4a705d37d1 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_logical.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_logical.py @@ -22,10 +22,7 @@ import numpy as np import paddle import paddle.fluid as fluid from paddle.jit import ProgramTranslator -from paddle.jit.dy2static.logical_transformer import ( - cmpop_node_to_str, -) -from paddle.jit import ProgramTranslator +from paddle.jit.dy2static.logical_transformer import cmpop_node_to_str from paddle.utils import gast program_translator = ProgramTranslator() diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_loop.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_loop.py index c6c8a392274f2fcfd3190f20d22014755a09b98f..06b17978d6687ff2fa9487475ac5159653003864 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_loop.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_loop.py @@ -12,15 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -from paddle.utils import gast import inspect +import unittest + import numpy as np + import paddle import paddle.fluid as fluid -import unittest - -from paddle.jit.dy2static.loop_transformer import NameVisitor from paddle.jit.api import declarative +from paddle.jit.dy2static.loop_transformer import NameVisitor +from paddle.utils import gast SEED = 2020 np.random.seed(SEED) diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_mnist.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_mnist.py index fe7e463e1db2f3403bcd3737f4a2c4b284e10712..43947a505e6b7540ce2b4d93e1affa5a10b2c04a 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_mnist.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_mnist.py @@ -23,11 +23,11 @@ from predictor_utils import PredictorTools import paddle import paddle.fluid as fluid from paddle.fluid.dygraph import to_variable -from paddle.nn import Linear from paddle.fluid.dygraph.base import switch_to_static_graph from paddle.fluid.dygraph.io import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX from paddle.fluid.framework import _test_eager_guard from paddle.fluid.optimizer import AdamOptimizer +from paddle.nn import Linear SEED = 2020 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 b40eb92753dacca665c1f3fa968f1fb3101a9fbd..2c458b006daaf6b6a97535a3ab493f3cea438ada 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 @@ -26,16 +26,9 @@ from paddle.fluid.dygraph.io import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX from paddle.fluid.dygraph.nn import BatchNorm, Linear from paddle.fluid.initializer import MSRA from paddle.fluid.param_attr import ParamAttr -from paddle.fluid.dygraph.nn import BatchNorm -from paddle.nn import Linear -from paddle.jit.api import declarative from paddle.jit import ProgramTranslator - -from paddle.fluid.dygraph.io import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX - -import unittest - -from predictor_utils import PredictorTools +from paddle.jit.api import declarative +from paddle.nn import Linear # Note: Set True to eliminate randomness. # 1. For one operation, cuDNN has several algorithms, diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_reinforcement_learning.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_reinforcement_learning.py index 15e6827766a311b10e5e516b9bbbf35f32860513..b98d9c304dc9a33ae089c322da390ae44d667025 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_reinforcement_learning.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_reinforcement_learning.py @@ -21,7 +21,7 @@ import numpy as np import paddle import paddle.fluid as fluid -from paddle.fluid.dygraph import to_variable, Layer +from paddle.fluid.dygraph import Layer, to_variable from paddle.jit import ProgramTranslator from paddle.jit.api import declarative diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_resnet.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_resnet.py index fec0109168b50d91cd9a59c6a526ca17063ca037..00d6f24da345dbbc3c243d23c00a55800fb48275 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_resnet.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_resnet.py @@ -17,16 +17,14 @@ import os import tempfile import time import unittest -import paddle + import numpy as np from predictor_utils import PredictorTools import paddle import paddle.fluid as fluid - -from paddle.fluid.dygraph.nn import BatchNorm -from paddle.jit import ProgramTranslator from paddle.fluid.dygraph.io import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX +from paddle.fluid.dygraph.nn import BatchNorm from paddle.jit import ProgramTranslator SEED = 2020 diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_save_inference_model.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_save_inference_model.py index c22c78fefe3d2f5822a0ceb4b15995e2637290ab..461e9791d23ad3c153af35ff50e8edb4632f48eb 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_save_inference_model.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_save_inference_model.py @@ -15,16 +15,15 @@ import os import tempfile import unittest + import numpy as np import paddle import paddle.fluid as fluid +from paddle.fluid.dygraph.io import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX from paddle.jit import ProgramTranslator from paddle.jit.api import declarative -from paddle.jit.dy2static.partial_program import ( - partial_program_from, -) -from paddle.fluid.dygraph.io import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX +from paddle.jit.dy2static.partial_program import partial_program_from SEED = 2020 diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_save_load.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_save_load.py index b64bd35a0b0666e6a59c670f82d1529fa0c4f5e6..d9b0feeaeeca71696a19db99af581a77bd78925e 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_save_load.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_save_load.py @@ -12,16 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -import unittest import os import tempfile +import unittest import numpy as np -import paddle.fluid as fluid +from test_fetch_feed import Linear -from paddle.jit import ProgramTranslator +import paddle.fluid as fluid from paddle.fluid.optimizer import AdamOptimizer -from test_fetch_feed import Linear +from paddle.jit import ProgramTranslator np.random.seed(2020) diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_se_resnet.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_se_resnet.py index 4b1aad178d0208bd1fb2123b2a9c842afa719fe2..269f50a8dd9c5f19cdc394ebd55e112cdb108e90 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_se_resnet.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_se_resnet.py @@ -25,11 +25,11 @@ from predictor_utils import PredictorTools import paddle import paddle.fluid as fluid from paddle.fluid.dygraph.base import to_variable -from paddle.fluid.dygraph.nn import BatchNorm -from paddle.nn import Linear from paddle.fluid.dygraph.io import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX +from paddle.fluid.dygraph.nn import BatchNorm from paddle.jit import ProgramTranslator from paddle.jit.api import declarative +from paddle.nn import Linear SEED = 2020 np.random.seed(SEED) 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 b02f6f418b3afa2494e179d6a97fc82f97477fcb..ef9436864a83f4c02878f5f83fad02351e57ccaf 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 @@ -19,12 +19,11 @@ from test_lac import DynamicGRU import paddle import paddle.fluid as fluid -from paddle.fluid.dygraph.nn import Embedding -from paddle.nn import Linear from paddle.fluid.dygraph import to_variable from paddle.fluid.dygraph.nn import Embedding, Linear from paddle.jit import ProgramTranslator from paddle.jit.api import declarative +from paddle.nn import Linear SEED = 2020 program_translator = ProgramTranslator() diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_seq2seq.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_seq2seq.py index c7bef3d7b1ca3a160e3e4cd6bb43efcefbcb9c62..4a83495987cac71a5369d4b1e7baea2d1dd76806 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_seq2seq.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_seq2seq.py @@ -18,14 +18,13 @@ import time import unittest import numpy as np +from seq2seq_dygraph_model import AttentionModel, BaseModel +from seq2seq_utils import Seq2SeqModelHyperParams, get_data_iter + import paddle.fluid as fluid from paddle.fluid.clip import GradientClipByGlobalNorm from paddle.jit import ProgramTranslator -from seq2seq_dygraph_model import BaseModel, AttentionModel -from seq2seq_utils import Seq2SeqModelHyperParams -from seq2seq_utils import get_data_iter - place = ( fluid.CUDAPlace(0) if fluid.is_compiled_with_cuda() else fluid.CPUPlace() ) diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_tsm.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_tsm.py index 0919e4bced39b076d5012236c342461bb1933619..9c52786842dfd5766ab524efa77dc9a335cb550a 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_tsm.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_tsm.py @@ -23,12 +23,11 @@ from tsm_config_utils import merge_configs, parse_config, print_configs import paddle import paddle.fluid as fluid +from paddle.fluid.dygraph import to_variable from paddle.fluid.dygraph.nn import BatchNorm -from paddle.nn import Linear -from paddle.jit.api import declarative from paddle.jit import ProgramTranslator -from paddle.fluid.dygraph import to_variable -from tsm_config_utils import merge_configs, parse_config, print_configs +from paddle.jit.api import declarative +from paddle.nn import Linear random.seed(0) np.random.seed(0) diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_word2vec.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_word2vec.py index fb7027e88be6018109864a8dcdd489c7763ae8c2..44dd23a4c3abe14d20b4e20dd6ae548790a7fc69 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_word2vec.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_word2vec.py @@ -14,13 +14,12 @@ import math import random -import paddle -import numpy as np -import paddle -import paddle.fluid as fluid import unittest +import numpy as np + import paddle +import paddle.fluid as fluid from paddle.fluid.dygraph.nn import Embedding from paddle.jit import ProgramTranslator from paddle.jit.api import declarative diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/transformer_dygraph_model.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/transformer_dygraph_model.py index fb00473f3d4521a4dd7e656438e9600fe2fc3013..209127104bd4fde4327191f8e81bf2fb8b9eb4cb 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/transformer_dygraph_model.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/transformer_dygraph_model.py @@ -18,15 +18,10 @@ import paddle import paddle.fluid as fluid import paddle.fluid.layers as layers import paddle.nn.functional as F -from paddle.fluid.dygraph import ( - Embedding, - Layer, - LayerNorm, - to_variable, -) -from paddle.nn import Linear +from paddle.fluid.dygraph import Embedding, Layer, LayerNorm, to_variable from paddle.fluid.layers.utils import map_structure from paddle.jit.api import dygraph_to_static_func +from paddle.nn import Linear def position_encoding_init(n_position, d_pos_vec): diff --git a/python/paddle/fluid/tests/unittests/test_add_position_encoding_op.py b/python/paddle/fluid/tests/unittests/test_add_position_encoding_op.py index c908bfb5a4fc33660e3675e761c57cf752cfa50f..89c52dc203bca86732e8df05f9b767811da68aaa 100644 --- a/python/paddle/fluid/tests/unittests/test_add_position_encoding_op.py +++ b/python/paddle/fluid/tests/unittests/test_add_position_encoding_op.py @@ -11,9 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +import math import unittest + import numpy as np -import math from op_test import OpTest diff --git a/python/paddle/fluid/tests/unittests/test_affine_channel_op.py b/python/paddle/fluid/tests/unittests/test_affine_channel_op.py index 5221fd9d69465c12a73f33bde238cdf77a91db9a..1153d92a06fddf1ed795237aec794a1894b4f5da 100644 --- a/python/paddle/fluid/tests/unittests/test_affine_channel_op.py +++ b/python/paddle/fluid/tests/unittests/test_affine_channel_op.py @@ -16,6 +16,7 @@ Unit testing for affine_channel_op """ import unittest + import numpy as np from op_test import OpTest diff --git a/python/paddle/fluid/tests/unittests/test_data_norm_op.py b/python/paddle/fluid/tests/unittests/test_data_norm_op.py index b5a2e76fe87bf980414b424d61eb104645975d14..2b84f2b5685af7280970105f91d91159689ff726 100644 --- a/python/paddle/fluid/tests/unittests/test_data_norm_op.py +++ b/python/paddle/fluid/tests/unittests/test_data_norm_op.py @@ -14,13 +14,15 @@ """This is unit test of Test data_norm Op.""" import unittest + import numpy as np +from op_test import OpTest + import paddle -import paddle.fluid.core as core -from paddle.fluid.op import Operator import paddle.fluid as fluid -from op_test import OpTest +import paddle.fluid.core as core from paddle.fluid import Program, program_guard +from paddle.fluid.op import Operator def _reference_testing(x, batch_size, batch_sum, batch_square_sum, slot_dim=-1): diff --git a/python/paddle/fluid/tests/unittests/test_detach.py b/python/paddle/fluid/tests/unittests/test_detach.py index cf7214b858889b8f0bf98793c2fc0c53a1ab3d33..58190b150e6c783cd3ce537a94e6f376d31a29b5 100644 --- a/python/paddle/fluid/tests/unittests/test_detach.py +++ b/python/paddle/fluid/tests/unittests/test_detach.py @@ -18,8 +18,8 @@ import numpy as np import paddle import paddle.fluid as fluid -from paddle.nn import Linear from paddle.fluid.dygraph.base import to_variable +from paddle.nn import Linear class Test_Detach(unittest.TestCase): diff --git a/python/paddle/fluid/tests/unittests/test_dygraph_mnist_fp16.py b/python/paddle/fluid/tests/unittests/test_dygraph_mnist_fp16.py index b9a130be6bfbb85dab769834d5664283b6548f6b..477db13a701b70e9920e91639eb78bb42e8f0256 100644 --- a/python/paddle/fluid/tests/unittests/test_dygraph_mnist_fp16.py +++ b/python/paddle/fluid/tests/unittests/test_dygraph_mnist_fp16.py @@ -18,8 +18,8 @@ import numpy as np import paddle import paddle.fluid as fluid -from paddle.nn import Linear from paddle.fluid.framework import _test_eager_guard +from paddle.nn import Linear class SimpleImgConvPool(fluid.dygraph.Layer): diff --git a/python/paddle/fluid/tests/unittests/test_dygraph_multi_forward.py b/python/paddle/fluid/tests/unittests/test_dygraph_multi_forward.py index d8b8c2ac4f0dff01fa477fe91967c4a189a7648f..fd7f97063b646cad7ca871f20560cf9ffefc3793 100644 --- a/python/paddle/fluid/tests/unittests/test_dygraph_multi_forward.py +++ b/python/paddle/fluid/tests/unittests/test_dygraph_multi_forward.py @@ -20,9 +20,9 @@ from test_imperative_base import new_program_scope import paddle import paddle.fluid as fluid from paddle.fluid import core -from paddle.nn import Linear from paddle.fluid.dygraph.base import to_variable from paddle.fluid.optimizer import SGDOptimizer +from paddle.nn import Linear SEED = 123123111 diff --git a/python/paddle/fluid/tests/unittests/test_executor_return_tensor_not_overwriting.py b/python/paddle/fluid/tests/unittests/test_executor_return_tensor_not_overwriting.py index 9671448e3ff912432ccfd24c184dd21107cd7805..954d47287bfe13dcac899cde3d18bd8e0fcc607a 100644 --- a/python/paddle/fluid/tests/unittests/test_executor_return_tensor_not_overwriting.py +++ b/python/paddle/fluid/tests/unittests/test_executor_return_tensor_not_overwriting.py @@ -13,10 +13,11 @@ # limitations under the License. import unittest -import paddle + import numpy as np from op_test import OpTest, skip_check_grad_ci +import paddle import paddle.fluid as fluid diff --git a/python/paddle/fluid/tests/unittests/test_fill_zeros_like2_op.py b/python/paddle/fluid/tests/unittests/test_fill_zeros_like2_op.py index 5cf61d53b30eef2b4d80c389c2a8b0e20635546a..a610e52037be6788b0061dcd6fb41e7c9ecc07c1 100644 --- a/python/paddle/fluid/tests/unittests/test_fill_zeros_like2_op.py +++ b/python/paddle/fluid/tests/unittests/test_fill_zeros_like2_op.py @@ -16,6 +16,7 @@ import unittest import numpy as np from op_test import OpTest + from paddle.fluid.framework import convert_np_dtype_to_dtype_ diff --git a/python/paddle/fluid/tests/unittests/test_fuse_elewise_add_act_pass.py b/python/paddle/fluid/tests/unittests/test_fuse_elewise_add_act_pass.py index 6f3bc21e4bb86d84e8a5bfd042015ade61450876..b840fa205dc95fe9219a911cb56e9605d8305bb9 100644 --- a/python/paddle/fluid/tests/unittests/test_fuse_elewise_add_act_pass.py +++ b/python/paddle/fluid/tests/unittests/test_fuse_elewise_add_act_pass.py @@ -14,10 +14,11 @@ import os import unittest -import numpy +import numpy from parallel_executor_test_base import DeviceType, TestParallelExecutorBase from simple_nets import fc_with_batchnorm, init_data, simple_fc_net + import paddle import paddle.fluid as fluid import paddle.fluid.core as core diff --git a/python/paddle/fluid/tests/unittests/test_group_norm_op.py b/python/paddle/fluid/tests/unittests/test_group_norm_op.py index 2b74636939e9932d7e062ec45ac79b058be87475..24f0bc2a0b1f00ff4bb202652d68fe26a84f6abb 100644 --- a/python/paddle/fluid/tests/unittests/test_group_norm_op.py +++ b/python/paddle/fluid/tests/unittests/test_group_norm_op.py @@ -13,14 +13,15 @@ # limitations under the License. import unittest + import numpy as np +from op_test import OpTest, skip_check_grad_ci +from testsuite import create_op import paddle -import paddle.fluid.core as core import paddle.fluid as fluid -from op_test import OpTest, skip_check_grad_ci +import paddle.fluid.core as core from paddle.fluid.framework import _test_eager_guard -from testsuite import create_op def group_norm_naive(x, scale, bias, epsilon, groups, data_layout): diff --git a/python/paddle/fluid/tests/unittests/test_imperative_basic.py b/python/paddle/fluid/tests/unittests/test_imperative_basic.py index f92a248168793dd7795b046060a78ef8a183242e..4441098c941413e1519a41b69cb221ba4eaf5020 100644 --- a/python/paddle/fluid/tests/unittests/test_imperative_basic.py +++ b/python/paddle/fluid/tests/unittests/test_imperative_basic.py @@ -19,8 +19,8 @@ from test_imperative_base import new_program_scope import paddle import paddle.fluid as fluid -from paddle.fluid import core import paddle.fluid.dygraph_utils as dygraph_utils +from paddle.fluid import core from paddle.fluid.dygraph.layer_object_helper import LayerObjectHelper from paddle.fluid.framework import _in_legacy_dygraph, _test_eager_guard from paddle.fluid.layer_helper import LayerHelper diff --git a/python/paddle/fluid/tests/unittests/test_imperative_container_sequential.py b/python/paddle/fluid/tests/unittests/test_imperative_container_sequential.py index eca6e5d81d0109bd6b6f9e889c207ecdcff873ec..1049c08c64d40a2c136ae9ab56e1975d3f57654d 100644 --- a/python/paddle/fluid/tests/unittests/test_imperative_container_sequential.py +++ b/python/paddle/fluid/tests/unittests/test_imperative_container_sequential.py @@ -15,10 +15,10 @@ import unittest import numpy as np -from paddle.nn import Linear import paddle.fluid as fluid from paddle.fluid.framework import _test_eager_guard +from paddle.nn import Linear class TestImperativeContainerSequential(unittest.TestCase): diff --git a/python/paddle/fluid/tests/unittests/test_imperative_deepcf.py b/python/paddle/fluid/tests/unittests/test_imperative_deepcf.py index 532dddd87c5ce3b245142af9fc7658449fa66e9a..c4e280ea46fd0b819989e66ffc898e4cbf95081b 100644 --- a/python/paddle/fluid/tests/unittests/test_imperative_deepcf.py +++ b/python/paddle/fluid/tests/unittests/test_imperative_deepcf.py @@ -24,8 +24,8 @@ import paddle import paddle.fluid as fluid import paddle.fluid.core as core from paddle.fluid.dygraph.base import to_variable -from paddle.nn import Linear from paddle.fluid.framework import _test_eager_guard +from paddle.nn import Linear class DMF(fluid.Layer): diff --git a/python/paddle/fluid/tests/unittests/test_imperative_framework.py b/python/paddle/fluid/tests/unittests/test_imperative_framework.py index 4aec8b308a6c8d51bc9d8daf6e22051387c43dfa..abdc8edd89edfa3a52cb2d964f0d518c3cfc917c 100644 --- a/python/paddle/fluid/tests/unittests/test_imperative_framework.py +++ b/python/paddle/fluid/tests/unittests/test_imperative_framework.py @@ -20,7 +20,6 @@ from test_imperative_base import new_program_scope import paddle import paddle.fluid as fluid from paddle.fluid.framework import _test_eager_guard -import paddle class MLP(fluid.Layer): diff --git a/python/paddle/fluid/tests/unittests/test_imperative_gan.py b/python/paddle/fluid/tests/unittests/test_imperative_gan.py index 6b0e4fb66f5748bf6db979936e929546a40ddf1a..845f47434e59d7d7d3df2849d10e2d7f772f1676 100644 --- a/python/paddle/fluid/tests/unittests/test_imperative_gan.py +++ b/python/paddle/fluid/tests/unittests/test_imperative_gan.py @@ -20,10 +20,10 @@ from test_imperative_base import new_program_scope import paddle import paddle.fluid as fluid import paddle.fluid.core as core -from paddle.nn import Linear from paddle.fluid.dygraph.base import to_variable from paddle.fluid.framework import _test_eager_guard from paddle.fluid.optimizer import SGDOptimizer +from paddle.nn import Linear class Discriminator(fluid.Layer): diff --git a/python/paddle/fluid/tests/unittests/test_imperative_layer_trainable.py b/python/paddle/fluid/tests/unittests/test_imperative_layer_trainable.py index 335db28d70c2d036e53f7a07d5902067530efad2..73f101ed5ee280882d3a4773106db8bd5da9defa 100644 --- a/python/paddle/fluid/tests/unittests/test_imperative_layer_trainable.py +++ b/python/paddle/fluid/tests/unittests/test_imperative_layer_trainable.py @@ -16,10 +16,10 @@ import unittest import numpy as np +import paddle import paddle.fluid as fluid import paddle.fluid.dygraph as dygraph from paddle.fluid.framework import _test_eager_guard -import paddle class TestImperativeLayerTrainable(unittest.TestCase): diff --git a/python/paddle/fluid/tests/unittests/test_imperative_load_static_param.py b/python/paddle/fluid/tests/unittests/test_imperative_load_static_param.py index 8e9b6c7f2ff8ef40b0cd7fa0fa2fe97c41fd21b1..528ddac3ff4e57f757d05ea760499322c9b9e6d1 100644 --- a/python/paddle/fluid/tests/unittests/test_imperative_load_static_param.py +++ b/python/paddle/fluid/tests/unittests/test_imperative_load_static_param.py @@ -27,13 +27,9 @@ from paddle.fluid.dygraph.nn import ( Embedding, GroupNorm, LayerNorm, - NCE, PRelu, ) from paddle.nn import Linear -import numpy as np -import os -import tempfile class TestDygraphLoadStatic(unittest.TestCase): diff --git a/python/paddle/fluid/tests/unittests/test_imperative_mnist.py b/python/paddle/fluid/tests/unittests/test_imperative_mnist.py index 69796f69c6b23c9da03ccd350fd92ff6b605ca2a..66d7eb19fb4031b96d28dd22f29eb163b3352637 100644 --- a/python/paddle/fluid/tests/unittests/test_imperative_mnist.py +++ b/python/paddle/fluid/tests/unittests/test_imperative_mnist.py @@ -15,16 +15,15 @@ import unittest import numpy as np +from test_imperative_base import new_program_scope from utils import DyGraphProgramDescTracerTestHelper import paddle import paddle.fluid as fluid from paddle.fluid import core +from paddle.fluid.framework import _in_legacy_dygraph, _test_eager_guard from paddle.fluid.optimizer import SGDOptimizer from paddle.nn import Linear -from test_imperative_base import new_program_scope -from utils import DyGraphProgramDescTracerTestHelper -from paddle.fluid.framework import _test_eager_guard, _in_legacy_dygraph class SimpleImgConvPool(fluid.dygraph.Layer): 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 81eb24f98f8247c5c12f598e894c53cb2fdb4f8b..657774b7298a36f6e9597fe6c36f0725a7fd0581 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,14 +21,9 @@ 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.nn import Linear +from paddle.fluid.dygraph.nn import BatchNorm, Embedding, GRUUnit, Linear from paddle.fluid.framework import _test_eager_guard +from paddle.nn import Linear class Config: diff --git a/python/paddle/fluid/tests/unittests/test_imperative_optimizer.py b/python/paddle/fluid/tests/unittests/test_imperative_optimizer.py index 1650532e49d7a98da6b302543671172de3f69258..71eb99c229369cfa860b84d39e27535ae44fd7fa 100644 --- a/python/paddle/fluid/tests/unittests/test_imperative_optimizer.py +++ b/python/paddle/fluid/tests/unittests/test_imperative_optimizer.py @@ -16,10 +16,13 @@ import itertools import unittest import numpy as np +from test_imperative_base import new_program_scope import paddle import paddle.fluid as fluid +from paddle.distributed.fleet.meta_optimizers import DGCMomentumOptimizer from paddle.fluid import core +from paddle.fluid.framework import _test_eager_guard from paddle.fluid.optimizer import ( AdadeltaOptimizer, AdagradOptimizer, @@ -39,10 +42,6 @@ from paddle.fluid.optimizer import ( RMSPropOptimizer, SGDOptimizer, ) -from test_imperative_base import new_program_scope -from paddle.fluid.framework import _test_eager_guard - -from paddle.distributed.fleet.meta_optimizers import DGCMomentumOptimizer # Note(wangzhongpu) # In dygraph, don't support ModelAverage, DGCMomentumOptimizer, ExponentialMovingAverage, PipelineOptimizer, LookaheadOptimizer, RecomputeOptimizer. diff --git a/python/paddle/fluid/tests/unittests/test_imperative_optimizer_v2.py b/python/paddle/fluid/tests/unittests/test_imperative_optimizer_v2.py index 48ee814b4ddc9196d2cf89a1f0f22c7efee90be3..27c50d2e8af4ea1dcd3bf8ff2809336e869d9191 100644 --- a/python/paddle/fluid/tests/unittests/test_imperative_optimizer_v2.py +++ b/python/paddle/fluid/tests/unittests/test_imperative_optimizer_v2.py @@ -16,10 +16,13 @@ import itertools import unittest import numpy as np +from test_imperative_base import new_program_scope import paddle import paddle.fluid as fluid +from paddle.distributed.fleet.meta_optimizers import DGCMomentumOptimizer from paddle.fluid import core +from paddle.fluid.framework import _test_eager_guard from paddle.fluid.optimizer import ( AdadeltaOptimizer, AdagradOptimizer, @@ -36,10 +39,6 @@ from paddle.fluid.optimizer import ( RecomputeOptimizer, RMSPropOptimizer, ) -from test_imperative_base import new_program_scope -from paddle.fluid.framework import _test_eager_guard - -from paddle.distributed.fleet.meta_optimizers import DGCMomentumOptimizer # Note(wangzhongpu) # In dygraph, don't support ModelAverage, DGCMomentumOptimizer, ExponentialMovingAverage, PipelineOptimizer, LookaheadOptimizer, RecomputeOptimizer. diff --git a/python/paddle/fluid/tests/unittests/test_imperative_partitial_backward.py b/python/paddle/fluid/tests/unittests/test_imperative_partitial_backward.py index 29d42076e2c73956113d6d8b3d335023cc3230f2..67f5a7d26b5085a90473f000132fa7c24b35596d 100644 --- a/python/paddle/fluid/tests/unittests/test_imperative_partitial_backward.py +++ b/python/paddle/fluid/tests/unittests/test_imperative_partitial_backward.py @@ -16,9 +16,9 @@ import unittest import numpy as np +import paddle import paddle.fluid as fluid from paddle.fluid.framework import _test_eager_guard -import paddle class TestImperativePartitialBackward(unittest.TestCase): diff --git a/python/paddle/fluid/tests/unittests/test_imperative_reinforcement.py b/python/paddle/fluid/tests/unittests/test_imperative_reinforcement.py index 2a2d2ef905331730d63fb821226f218de206d488..2cc85fbc30f0d8858d62be7e27d4d7c84aab3a49 100644 --- a/python/paddle/fluid/tests/unittests/test_imperative_reinforcement.py +++ b/python/paddle/fluid/tests/unittests/test_imperative_reinforcement.py @@ -15,11 +15,11 @@ import unittest import numpy as np +from test_imperative_base import new_program_scope import paddle import paddle.fluid as fluid from paddle.fluid import core -from test_imperative_base import new_program_scope from paddle.fluid.framework import _test_eager_guard from paddle.fluid.optimizer import SGDOptimizer diff --git a/python/paddle/fluid/tests/unittests/test_imperative_resnet.py b/python/paddle/fluid/tests/unittests/test_imperative_resnet.py index 6c3fdf77a2d1c739475d428ea132472db41ec05c..53e8b1d93c4b7a37f553ed8a273b49614cbbd710 100644 --- a/python/paddle/fluid/tests/unittests/test_imperative_resnet.py +++ b/python/paddle/fluid/tests/unittests/test_imperative_resnet.py @@ -20,8 +20,7 @@ from utils import DyGraphProgramDescTracerTestHelper, is_equal_program import paddle import paddle.fluid as fluid -from paddle.fluid import core -from paddle.fluid import BatchNorm +from paddle.fluid import BatchNorm, core from paddle.fluid.dygraph.base import to_variable from paddle.fluid.framework import _in_legacy_dygraph, _test_eager_guard from paddle.fluid.layer_helper import LayerHelper diff --git a/python/paddle/fluid/tests/unittests/test_imperative_se_resnext.py b/python/paddle/fluid/tests/unittests/test_imperative_se_resnext.py index 265f3720680088cce378c6593d159b12943c474b..c09f6a1449faa861a27fd01f2d16d825b4abdd5e 100644 --- a/python/paddle/fluid/tests/unittests/test_imperative_se_resnext.py +++ b/python/paddle/fluid/tests/unittests/test_imperative_se_resnext.py @@ -21,7 +21,6 @@ import paddle import paddle.fluid as fluid from paddle.fluid import core from paddle.fluid.dygraph.nn import BatchNorm -from test_imperative_base import new_program_scope from paddle.fluid.framework import _test_eager_guard from paddle.fluid.layer_helper import LayerHelper diff --git a/python/paddle/fluid/tests/unittests/test_imperative_trace_non_persistable_inputs.py b/python/paddle/fluid/tests/unittests/test_imperative_trace_non_persistable_inputs.py index 959ed8bbfec38c1ceb0c4d3c1cf1d4dc6e9d4cf2..341aa800c962626eda0fa4b2d8a0b14f08b470e9 100644 --- a/python/paddle/fluid/tests/unittests/test_imperative_trace_non_persistable_inputs.py +++ b/python/paddle/fluid/tests/unittests/test_imperative_trace_non_persistable_inputs.py @@ -16,7 +16,7 @@ import os import unittest import numpy as np -import os + import paddle import paddle.fluid as fluid diff --git a/python/paddle/fluid/tests/unittests/test_imperative_transformer_sorted_gradient.py b/python/paddle/fluid/tests/unittests/test_imperative_transformer_sorted_gradient.py index f5737956c3b600a05114f92b8a4844d6e1d27360..654ebf198b7d09a0422c78f3b99b4290953bec1b 100644 --- a/python/paddle/fluid/tests/unittests/test_imperative_transformer_sorted_gradient.py +++ b/python/paddle/fluid/tests/unittests/test_imperative_transformer_sorted_gradient.py @@ -19,15 +19,12 @@ from test_imperative_base import new_program_scope import paddle import paddle.fluid as fluid -from paddle.fluid import Embedding, LayerNorm, Layer -from paddle.nn import Linear -from paddle.fluid.dygraph import to_variable, guard -from test_imperative_base import new_program_scope -from paddle.fluid.framework import _in_legacy_dygraph, _test_eager_guard -from paddle.fluid import core -import numpy as np import paddle.nn.functional as F +from paddle.fluid import Embedding, Layer, LayerNorm, core +from paddle.fluid.dygraph import guard, to_variable +from paddle.fluid.framework import _in_legacy_dygraph, _test_eager_guard from paddle.jit import TracedLayer +from paddle.nn import Linear np.set_printoptions(suppress=True) diff --git a/python/paddle/fluid/tests/unittests/test_isfinite_op.py b/python/paddle/fluid/tests/unittests/test_isfinite_op.py index 1ec8063bf57282cfe411b263891a355989e994b6..053e9bbc08f571348da93f1ca3323739e3dd3451 100644 --- a/python/paddle/fluid/tests/unittests/test_isfinite_op.py +++ b/python/paddle/fluid/tests/unittests/test_isfinite_op.py @@ -16,6 +16,7 @@ import unittest import numpy as np from op_test import OpTest + import paddle.fluid.core as core diff --git a/python/paddle/fluid/tests/unittests/test_jit_save_load.py b/python/paddle/fluid/tests/unittests/test_jit_save_load.py index eac870650489549ba920d217919850f1dac23f87..acb8d0859835f5673b5e66c13adf9b045593587b 100644 --- a/python/paddle/fluid/tests/unittests/test_jit_save_load.py +++ b/python/paddle/fluid/tests/unittests/test_jit_save_load.py @@ -23,11 +23,11 @@ import numpy as np import paddle import paddle.fluid as fluid -from paddle.nn import Linear from paddle.fluid import unique_name from paddle.fluid.dygraph.io import INFER_PARAMS_INFO_SUFFIX from paddle.fluid.layers.utils import flatten from paddle.jit.api import declarative +from paddle.nn import Linear from paddle.static import InputSpec BATCH_SIZE = 32 diff --git a/python/paddle/fluid/tests/unittests/test_learning_rate_scheduler.py b/python/paddle/fluid/tests/unittests/test_learning_rate_scheduler.py index dd37c2bff66a7a67cb27094ea0641ef465ae8be0..a31809c0974bb2353f9dbddd8df4505fa6124558 100644 --- a/python/paddle/fluid/tests/unittests/test_learning_rate_scheduler.py +++ b/python/paddle/fluid/tests/unittests/test_learning_rate_scheduler.py @@ -14,13 +14,15 @@ import copy import math -import numpy as np import unittest + +import numpy as np + import paddle import paddle.fluid as fluid -import paddle.fluid.layers as layers -import paddle.fluid.framework as framework import paddle.fluid.core as core +import paddle.fluid.framework as framework +import paddle.fluid.layers as layers def exponential_decay( diff --git a/python/paddle/fluid/tests/unittests/test_multiprocess_dataloader_dynamic.py b/python/paddle/fluid/tests/unittests/test_multiprocess_dataloader_dynamic.py index 2ea1b4faf8d24a2e5efd2b2a6276bf638972aa9c..8bcde4489e42542ecca9cf40d7fea23da0c35062 100644 --- a/python/paddle/fluid/tests/unittests/test_multiprocess_dataloader_dynamic.py +++ b/python/paddle/fluid/tests/unittests/test_multiprocess_dataloader_dynamic.py @@ -15,9 +15,6 @@ import sys import time import unittest -import numpy as np -import paddle -from paddle.nn import Linear import numpy as np from test_multiprocess_dataloader_static import ( @@ -31,8 +28,10 @@ from test_multiprocess_dataloader_static import ( prepare_places, ) +import paddle import paddle.fluid as fluid from paddle.io import DataLoader +from paddle.nn import Linear class SimpleFCNet(fluid.dygraph.Layer): diff --git a/python/paddle/fluid/tests/unittests/test_multiprocess_dataloader_iterable_dataset_dynamic.py b/python/paddle/fluid/tests/unittests/test_multiprocess_dataloader_iterable_dataset_dynamic.py index 1f15241b26c6a03a993b75bb3ad7b3c70d0f4bbd..e739c0c2cb755d908d620a122f7f883b1ba52a32 100644 --- a/python/paddle/fluid/tests/unittests/test_multiprocess_dataloader_iterable_dataset_dynamic.py +++ b/python/paddle/fluid/tests/unittests/test_multiprocess_dataloader_iterable_dataset_dynamic.py @@ -15,10 +15,6 @@ import sys import time import unittest -import numpy as np - -import paddle -from paddle.nn import Linear import numpy as np from test_multiprocess_dataloader_iterable_dataset_static import ( @@ -32,8 +28,10 @@ from test_multiprocess_dataloader_iterable_dataset_static import ( prepare_places, ) +import paddle import paddle.fluid as fluid from paddle.io import DataLoader +from paddle.nn import Linear class SimpleFCNet(fluid.dygraph.Layer): diff --git a/python/paddle/fluid/tests/unittests/test_ones_op.py b/python/paddle/fluid/tests/unittests/test_ones_op.py index 6b2bbd3786522f9392db15ba2877cf642e4cf186..02e349e0c30203f7c270f126f3a4489ee390572e 100644 --- a/python/paddle/fluid/tests/unittests/test_ones_op.py +++ b/python/paddle/fluid/tests/unittests/test_ones_op.py @@ -17,7 +17,6 @@ import unittest import numpy as np import paddle -import numpy as np class ApiOnesTest(unittest.TestCase): diff --git a/python/paddle/fluid/tests/unittests/test_paddle_save_load.py b/python/paddle/fluid/tests/unittests/test_paddle_save_load.py index ed9ffcaab9da999e385270fe636047d11097136a..c78fa2ed847b415e136314efba41eb1159c0d591 100644 --- a/python/paddle/fluid/tests/unittests/test_paddle_save_load.py +++ b/python/paddle/fluid/tests/unittests/test_paddle_save_load.py @@ -12,19 +12,20 @@ # See the License for the specific language governing permissions and # limitations under the License. -import unittest -import numpy as np import os -from io import BytesIO import tempfile +import unittest +from io import BytesIO + +import numpy as np +from test_imperative_base import new_program_scope import paddle +import paddle.fluid as fluid +import paddle.fluid.framework as framework import paddle.nn as nn import paddle.optimizer as opt -import paddle.fluid as fluid from paddle.fluid.optimizer import Adam -import paddle.fluid.framework as framework -from test_imperative_base import new_program_scope from paddle.optimizer.lr import LRScheduler BATCH_SIZE = 16 diff --git a/python/paddle/fluid/tests/unittests/test_pool3d_op.py b/python/paddle/fluid/tests/unittests/test_pool3d_op.py index 0c62aeb257ad36665eab0f6c688dbfe95363dc69..7204c0c49389ae5a145541e61a88052be100303a 100644 --- a/python/paddle/fluid/tests/unittests/test_pool3d_op.py +++ b/python/paddle/fluid/tests/unittests/test_pool3d_op.py @@ -13,11 +13,12 @@ # limitations under the License. import unittest + import numpy as np +from op_test import OpTest import paddle import paddle.fluid.core as core -from op_test import OpTest def adaptive_start_index(index, input_size, output_size): diff --git a/python/paddle/fluid/tests/unittests/test_roi_pool_op.py b/python/paddle/fluid/tests/unittests/test_roi_pool_op.py index b84cca41bbd29452a40a735012d933ea3f03eac0..6ae113fa8a1ca737590a70275173e5796bb39882 100644 --- a/python/paddle/fluid/tests/unittests/test_roi_pool_op.py +++ b/python/paddle/fluid/tests/unittests/test_roi_pool_op.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -import paddle -import unittest -import numpy as np import math import sys +import unittest +from decimal import ROUND_HALF_UP, Decimal + +import numpy as np from op_test import OpTest -from decimal import Decimal, ROUND_HALF_UP +import paddle def _round(x): diff --git a/python/paddle/fluid/tests/unittests/test_sigmoid_cross_entropy_with_logits_op.py b/python/paddle/fluid/tests/unittests/test_sigmoid_cross_entropy_with_logits_op.py index aa0e0e36ff613449bedd6462902ef1f8a4d1e075..ce18a4647966d37eb7953742d48581d8d1afe2f6 100644 --- a/python/paddle/fluid/tests/unittests/test_sigmoid_cross_entropy_with_logits_op.py +++ b/python/paddle/fluid/tests/unittests/test_sigmoid_cross_entropy_with_logits_op.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. +import unittest + import numpy as np from op_test import OpTest -from scipy.special import logit -from scipy.special import expit -import unittest -from paddle.fluid import Program, program_guard -import paddle.fluid as fluid +from scipy.special import expit, logit + import paddle +import paddle.fluid as fluid +from paddle.fluid import Program, program_guard class TestSigmoidCrossEntropyWithLogitsOp1(OpTest): diff --git a/python/paddle/fluid/tests/unittests/test_similarity_focus_op.py b/python/paddle/fluid/tests/unittests/test_similarity_focus_op.py index 6b92a3253b51b3c8dd310149cf093aa7fc73e087..1227a48949341439fde0bdff4906ffb7823761aa 100755 --- a/python/paddle/fluid/tests/unittests/test_similarity_focus_op.py +++ b/python/paddle/fluid/tests/unittests/test_similarity_focus_op.py @@ -13,6 +13,7 @@ # limitations under the License. import unittest + import numpy as np from op_test import OpTest diff --git a/python/paddle/fluid/tests/unittests/test_size_op.py b/python/paddle/fluid/tests/unittests/test_size_op.py index ac070c099e63c02642b135447890068fadc33ca1..b3ae19b8ef20eb5528b81dbc478cc564c1e87e0c 100644 --- a/python/paddle/fluid/tests/unittests/test_size_op.py +++ b/python/paddle/fluid/tests/unittests/test_size_op.py @@ -13,11 +13,12 @@ # limitations under the License. import unittest + import numpy as np -import paddle -import paddle.fluid as fluid from op_test import OpTest + import paddle +import paddle.fluid as fluid class TestSizeOp(OpTest): diff --git a/python/paddle/fluid/tests/unittests/test_static_save_load.py b/python/paddle/fluid/tests/unittests/test_static_save_load.py index c0472b16515a01cd86392a391311f1976d203599..8871966d350aa71c81f181ac2c4dca20f85f7dc9 100644 --- a/python/paddle/fluid/tests/unittests/test_static_save_load.py +++ b/python/paddle/fluid/tests/unittests/test_static_save_load.py @@ -13,18 +13,20 @@ # limitations under the License. +import errno +import os +import pickle +import tempfile import unittest + +import numpy as np +from test_imperative_base import new_program_scope + import paddle import paddle.fluid as fluid import paddle.fluid.core as core import paddle.fluid.framework as framework from paddle.fluid.optimizer import Adam -from test_imperative_base import new_program_scope -import numpy as np -import pickle -import os -import errno -import tempfile paddle.enable_static() diff --git a/python/paddle/fluid/tests/unittests/utils.py b/python/paddle/fluid/tests/unittests/utils.py index 04c3085c3dffc105e982856ecd382c5c520e4d99..a9cbc845c2dfb3e970d5f85b0d3860222caf4d3c 100644 --- a/python/paddle/fluid/tests/unittests/utils.py +++ b/python/paddle/fluid/tests/unittests/utils.py @@ -12,10 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -from paddle.fluid.framework import _dygraph_guard -import paddle.fluid as fluid import numpy as np +import paddle.fluid as fluid +from paddle.fluid.framework import _dygraph_guard + __all__ = ['DyGraphProgramDescTracerTestHelper', 'is_equal_program'] diff --git a/python/paddle/fluid/tests/unittests/xpu/test_affine_channel_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_affine_channel_op_xpu.py index fc3c9612ead016f84e935d55ad63da1ee3b2785a..13255906925655ac190ecf585ed8990c82de055b 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_affine_channel_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_affine_channel_op_xpu.py @@ -20,8 +20,10 @@ import sys sys.path.append("..") import unittest + import numpy as np from op_test_xpu import XPUOpTest + import paddle import paddle.fluid.core as core diff --git a/python/paddle/hapi/progressbar.py b/python/paddle/hapi/progressbar.py index 0f6f375b2a38be2497627faa849531e5e3eae93e..6c33d4962e79cbc51eb9af71f775232dcba48de8 100644 --- a/python/paddle/hapi/progressbar.py +++ b/python/paddle/hapi/progressbar.py @@ -13,10 +13,11 @@ # limitations under the License. import os +import struct import sys import time + import numpy as np -import struct __all__ = [] diff --git a/python/paddle/incubate/multiprocessing/reductions.py b/python/paddle/incubate/multiprocessing/reductions.py index 04fe123fdc1930af38d0d77530f62385aa98baaf..5bc1e2118621211af51b949b64620a1da167b8ae 100644 --- a/python/paddle/incubate/multiprocessing/reductions.py +++ b/python/paddle/incubate/multiprocessing/reductions.py @@ -12,18 +12,18 @@ # See the License for the specific language governing permissions and # limitations under the License. -import paddle +import copy # TODO: check the hooks of tensor # TODO: check serializing named tensor # TODO: check influence on autograd import sys -import copy import threading -from multiprocessing.util import register_after_fork +from collections import OrderedDict from multiprocessing.reduction import ForkingPickler +from multiprocessing.util import register_after_fork -from collections import OrderedDict +import paddle def _supported_check(): diff --git a/python/paddle/inference/wrapper.py b/python/paddle/inference/wrapper.py index c69cfa06f3982e117cd67303b40994e7b52b166e..ab532dc32266dcfa9c7d92d9bdb2d00891f888df 100644 --- a/python/paddle/inference/wrapper.py +++ b/python/paddle/inference/wrapper.py @@ -12,15 +12,21 @@ # See the License for the specific language governing permissions and # limitations under the License. -import paddle.fluid.core as core -from paddle.fluid.core import AnalysisConfig, PaddleDType, PaddlePlace -from paddle.fluid.core import PaddleInferPredictor, PaddleInferTensor -from paddle.fluid.core import convert_to_mixed_precision_bind - import os -import numpy as np from typing import Set +import numpy as np + +import paddle.fluid.core as core +from paddle.fluid.core import ( + AnalysisConfig, + PaddleDType, + PaddleInferPredictor, + PaddleInferTensor, + PaddlePlace, + convert_to_mixed_precision_bind, +) + DataType = PaddleDType PlaceType = PaddlePlace PrecisionType = AnalysisConfig.Precision diff --git a/python/paddle/static/nn/common.py b/python/paddle/static/nn/common.py index d70d958016ab4e38efd12b0767634bb5106e9da6..9fc2bbd975d5fb63901688bf65c26aacb2f8c8ee 100755 --- a/python/paddle/static/nn/common.py +++ b/python/paddle/static/nn/common.py @@ -13,19 +13,17 @@ # limitations under the License. import paddle -from paddle.fluid.param_attr import ParamAttr -from paddle.fluid.initializer import Normal, Constant -from paddle.fluid.framework import static_only, Variable, _non_static_mode -from paddle.fluid.layers.layer_function_generator import templatedoc - -from paddle.fluid.data_feeder import check_dtype - from paddle.common_ops_import import ( + LayerHelper, check_type, check_variable_and_dtype, utils, - LayerHelper, ) +from paddle.fluid.data_feeder import check_dtype +from paddle.fluid.framework import Variable, _non_static_mode, static_only +from paddle.fluid.initializer import Constant, Normal +from paddle.fluid.layers.layer_function_generator import templatedoc +from paddle.fluid.param_attr import ParamAttr __all__ = [] diff --git a/python/paddle/vision/datasets/folder.py b/python/paddle/vision/datasets/folder.py index 96a5b9b200eea988f5784d252b41f3a3f4891a74..650114cd19da3edd0e8e1e5bf8ce5a35c53953b9 100644 --- a/python/paddle/vision/datasets/folder.py +++ b/python/paddle/vision/datasets/folder.py @@ -13,6 +13,7 @@ # limitations under the License. import os + from PIL import Image import paddle