Skip to content

Commit

Permalink
[CodeStyle][isort] introduce isort (part6) (#48522)
Browse files Browse the repository at this point in the history
  • Loading branch information
SigureMo authored Dec 1, 2022
1 parent 08c5f4c commit bc01d56
Show file tree
Hide file tree
Showing 71 changed files with 178 additions and 212 deletions.
9 changes: 1 addition & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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/**",
]
Original file line number Diff line number Diff line change
Expand Up @@ -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__ = [
Expand Down
19 changes: 10 additions & 9 deletions python/paddle/distributed/passes/auto_parallel_grad_clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
5 changes: 1 addition & 4 deletions python/paddle/distribution/normal.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@
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):
Expand Down
7 changes: 1 addition & 6 deletions python/paddle/distribution/uniform.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@
_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


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@

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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import unittest

import numpy as np

import paddle
import paddle.fluid as fluid
from paddle.jit.api import declarative
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@
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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,9 @@
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@

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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@
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()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@

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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit bc01d56

Please sign in to comment.