未验证 提交 8c17fc0b 编写于 作者: 张春乔 提交者: GitHub

[CodeStyle][PLR0402] import a.b to from a import b (#52125)

上级 0c5a4bac

要显示的变更太多。

To preserve performance only 1000 of 1000+ files are displayed.
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
# limitations under the License. # limitations under the License.
import paddle import paddle
import paddle.nn as nn
import paddle.nn.functional as F import paddle.nn.functional as F
from paddle import nn
from .utils import ( from .utils import (
drop_connect, drop_connect,
......
...@@ -18,8 +18,8 @@ import re ...@@ -18,8 +18,8 @@ import re
from functools import partial from functools import partial
import paddle import paddle
import paddle.nn as nn
import paddle.nn.functional as F import paddle.nn.functional as F
from paddle import nn
# Parameters for the entire model (stem, all blocks, and head) # Parameters for the entire model (stem, all blocks, and head)
GlobalParams = collections.namedtuple( GlobalParams = collections.namedtuple(
......
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
import numpy as np import numpy as np
import paddle import paddle
import paddle.nn as nn
import paddle.optimizer as opt import paddle.optimizer as opt
from paddle import nn
BATCH_SIZE = 16 BATCH_SIZE = 16
BATCH_NUM = 4 BATCH_NUM = 4
......
...@@ -115,6 +115,9 @@ select = [ ...@@ -115,6 +115,9 @@ select = [
# "B030", # "B030",
"B032", "B032",
# "B904", # "B904",
# Pylint
"PLR0402",
] ]
unfixable = [ unfixable = [
"NPY001" "NPY001"
......
...@@ -15,8 +15,7 @@ from functools import partial ...@@ -15,8 +15,7 @@ from functools import partial
from typing import Optional, Union from typing import Optional, Union
import paddle import paddle
import paddle.nn as nn from paddle import Tensor, nn
from paddle import Tensor
from ..functional import compute_fbank_matrix, create_dct, power_to_db from ..functional import compute_fbank_matrix, create_dct, power_to_db
from ..functional.window import get_window from ..functional.window import get_window
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import paddle.fluid as fluid # noqa: F401 from paddle import fluid # noqa: F401
from paddle.fluid import core, dygraph_utils # noqa: F401 from paddle.fluid import core, dygraph_utils # noqa: F401
from paddle.fluid.core import VarDesc # noqa: F401 from paddle.fluid.core import VarDesc # noqa: F401
from paddle.fluid.data_feeder import ( # noqa: F401 from paddle.fluid.data_feeder import ( # noqa: F401
......
...@@ -18,7 +18,7 @@ import os ...@@ -18,7 +18,7 @@ import os
import numpy as np import numpy as np
import paddle import paddle
import paddle.static as static from paddle import static
from paddle.fluid import core from paddle.fluid import core
......
...@@ -33,7 +33,7 @@ import tarfile ...@@ -33,7 +33,7 @@ import tarfile
import numpy import numpy
import paddle.dataset.common import paddle.dataset.common
import paddle.utils.deprecated as deprecated from paddle.utils import deprecated
__all__ = [] __all__ = []
......
...@@ -24,7 +24,7 @@ import gzip ...@@ -24,7 +24,7 @@ import gzip
import tarfile import tarfile
import paddle.dataset.common import paddle.dataset.common
import paddle.utils.deprecated as deprecated from paddle.utils import deprecated
__all__ = [] __all__ = []
......
...@@ -33,10 +33,9 @@ import functools ...@@ -33,10 +33,9 @@ import functools
import tarfile import tarfile
from multiprocessing import cpu_count from multiprocessing import cpu_count
import paddle.utils.deprecated as deprecated
from paddle.dataset.image import load_image_bytes, simple_transform from paddle.dataset.image import load_image_bytes, simple_transform
from paddle.reader import map_readers, xmap_readers from paddle.reader import map_readers, xmap_readers
from paddle.utils import try_import from paddle.utils import deprecated, try_import
from .common import download from .common import download
......
...@@ -26,7 +26,7 @@ import string ...@@ -26,7 +26,7 @@ import string
import tarfile import tarfile
import paddle.dataset.common import paddle.dataset.common
import paddle.utils.deprecated as deprecated from paddle.utils import deprecated
__all__ = [] __all__ = []
......
...@@ -23,7 +23,7 @@ import collections ...@@ -23,7 +23,7 @@ import collections
import tarfile import tarfile
import paddle.dataset.common import paddle.dataset.common
import paddle.utils.deprecated as deprecated from paddle.utils import deprecated
__all__ = [] __all__ = []
......
...@@ -24,7 +24,7 @@ import struct ...@@ -24,7 +24,7 @@ import struct
import numpy import numpy
import paddle.dataset.common import paddle.dataset.common
import paddle.utils.deprecated as deprecated from paddle.utils import deprecated
__all__ = [] __all__ = []
......
...@@ -29,7 +29,7 @@ import zipfile ...@@ -29,7 +29,7 @@ import zipfile
import numpy as np import numpy as np
import paddle.dataset.common import paddle.dataset.common
import paddle.utils.deprecated as deprecated from paddle.utils import deprecated
__all__ = [] __all__ = []
......
...@@ -26,7 +26,7 @@ import tempfile ...@@ -26,7 +26,7 @@ import tempfile
import numpy as np import numpy as np
import paddle.dataset.common import paddle.dataset.common
import paddle.utils.deprecated as deprecated from paddle.utils import deprecated
__all__ = [] __all__ = []
......
...@@ -25,8 +25,8 @@ import tarfile ...@@ -25,8 +25,8 @@ import tarfile
import numpy as np import numpy as np
from PIL import Image from PIL import Image
import paddle.utils.deprecated as deprecated
from paddle.dataset.common import download from paddle.dataset.common import download
from paddle.utils import deprecated
__all__ = [] __all__ = []
......
...@@ -23,7 +23,7 @@ parse training set and test set into paddle reader creators. ...@@ -23,7 +23,7 @@ parse training set and test set into paddle reader creators.
import tarfile import tarfile
import paddle.dataset.common import paddle.dataset.common
import paddle.utils.deprecated as deprecated from paddle.utils import deprecated
__all__ = [] __all__ = []
......
...@@ -33,7 +33,7 @@ import tarfile ...@@ -33,7 +33,7 @@ import tarfile
from collections import defaultdict from collections import defaultdict
import paddle import paddle
import paddle.utils.deprecated as deprecated from paddle.utils import deprecated
__all__ = [] __all__ = []
......
...@@ -23,8 +23,7 @@ import numpy as np ...@@ -23,8 +23,7 @@ import numpy as np
import paddle import paddle
import paddle.distributed.auto_parallel.utils as auto_utils import paddle.distributed.auto_parallel.utils as auto_utils
import paddle.utils as utils from paddle import static, utils
from paddle import static
from paddle.distributed import fleet from paddle.distributed import fleet
from paddle.fluid.executor import _to_name_str from paddle.fluid.executor import _to_name_str
from paddle.framework import IrGraph from paddle.framework import IrGraph
......
...@@ -18,7 +18,7 @@ import os ...@@ -18,7 +18,7 @@ import os
import paddle import paddle
# (TODO: GhostScreaming) It will be removed later. # (TODO: GhostScreaming) It will be removed later.
import paddle.fluid.core as core from paddle.fluid import core
from paddle.framework import in_dygraph_mode from paddle.framework import in_dygraph_mode
from .communication.group import Group, _add_new_group, is_initialized from .communication.group import Group, _add_new_group, is_initialized
......
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
import numpy as np import numpy as np
import paddle import paddle
import paddle.distributed.communication.stream as stream from paddle import framework
import paddle.framework as framework from paddle.distributed.communication import stream
from .serialization_utils import ( from .serialization_utils import (
convert_object_to_tensor, convert_object_to_tensor,
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import paddle.distributed.communication.stream as stream from paddle.distributed.communication import stream
from paddle.distributed.communication.reduce import ReduceOp from paddle.distributed.communication.reduce import ReduceOp
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import paddle.distributed.communication.stream as stream from paddle.distributed.communication import stream
def alltoall(in_tensor_list, out_tensor_list, group=None, sync_op=True): def alltoall(in_tensor_list, out_tensor_list, group=None, sync_op=True):
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
import contextlib import contextlib
import paddle.distributed as dist import paddle.distributed as dist
import paddle.framework as framework from paddle import framework
from paddle.distributed.communication.group import ( from paddle.distributed.communication.group import (
_get_global_group, _get_global_group,
_warn_cur_rank_not_in_group, _warn_cur_rank_not_in_group,
......
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
import paddle import paddle
import paddle.distributed as dist import paddle.distributed as dist
import paddle.distributed.communication.stream as stream from paddle import framework
import paddle.framework as framework from paddle.distributed.communication import stream
from .serialization_utils import ( from .serialization_utils import (
convert_object_to_tensor, convert_object_to_tensor,
......
...@@ -16,7 +16,7 @@ import warnings ...@@ -16,7 +16,7 @@ import warnings
import paddle import paddle
import paddle.distributed as dist import paddle.distributed as dist
import paddle.framework as framework from paddle import framework
class Group: class Group:
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import paddle.distributed.communication.stream as stream from paddle.distributed.communication import stream
def recv(tensor, src=0, group=None, sync_op=True): def recv(tensor, src=0, group=None, sync_op=True):
......
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
# limitations under the License. # limitations under the License.
import paddle import paddle
import paddle.distributed.communication.stream as stream from paddle import framework
import paddle.framework as framework from paddle.distributed.communication import stream
class ReduceOp: class ReduceOp:
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import paddle.distributed.communication.stream as stream from paddle.distributed.communication import stream
from paddle.distributed.communication.reduce import ReduceOp from paddle.distributed.communication.reduce import ReduceOp
from paddle.distributed.communication.stream.reduce_scatter import ( from paddle.distributed.communication.stream.reduce_scatter import (
_reduce_scatter_base as _reduce_scatter_base_stream, _reduce_scatter_base as _reduce_scatter_base_stream,
......
...@@ -16,8 +16,8 @@ import numpy as np ...@@ -16,8 +16,8 @@ import numpy as np
import paddle import paddle
import paddle.distributed as dist import paddle.distributed as dist
import paddle.distributed.communication.stream as stream from paddle import framework
import paddle.framework as framework from paddle.distributed.communication import stream
from .serialization_utils import ( from .serialization_utils import (
convert_object_to_tensor, convert_object_to_tensor,
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import paddle.distributed.communication.stream as stream from paddle.distributed.communication import stream
def send(tensor, dst=0, group=None, sync_op=True): def send(tensor, dst=0, group=None, sync_op=True):
......
...@@ -14,9 +14,9 @@ ...@@ -14,9 +14,9 @@
import paddle import paddle
import paddle.distributed as dist import paddle.distributed as dist
import paddle.fluid.data_feeder as data_feeder from paddle import framework
import paddle.framework as framework
from paddle.distributed.communication.group import _get_global_group from paddle.distributed.communication.group import _get_global_group
from paddle.fluid import data_feeder
def _all_gather_into_tensor_in_dygraph( def _all_gather_into_tensor_in_dygraph(
......
...@@ -12,13 +12,13 @@ ...@@ -12,13 +12,13 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import paddle.fluid.data_feeder as data_feeder from paddle import framework
import paddle.framework as framework
from paddle.distributed.communication.group import ( from paddle.distributed.communication.group import (
_get_global_group, _get_global_group,
_warn_cur_rank_not_in_group, _warn_cur_rank_not_in_group,
) )
from paddle.distributed.communication.reduce import ReduceOp, _get_reduce_op from paddle.distributed.communication.reduce import ReduceOp, _get_reduce_op
from paddle.fluid import data_feeder
def _all_reduce_in_dygraph(tensor, op, group, sync_op, use_calc_stream): def _all_reduce_in_dygraph(tensor, op, group, sync_op, use_calc_stream):
......
...@@ -14,12 +14,12 @@ ...@@ -14,12 +14,12 @@
import paddle import paddle
import paddle.distributed as dist import paddle.distributed as dist
import paddle.fluid.data_feeder as data_feeder from paddle import framework
import paddle.framework as framework
from paddle.distributed.communication.group import ( from paddle.distributed.communication.group import (
_get_global_group, _get_global_group,
_warn_cur_rank_not_in_group, _warn_cur_rank_not_in_group,
) )
from paddle.fluid import data_feeder
def _all_to_all_tensor_in_dygraph( def _all_to_all_tensor_in_dygraph(
......
...@@ -12,13 +12,13 @@ ...@@ -12,13 +12,13 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import paddle.fluid.data_feeder as data_feeder from paddle import framework
import paddle.framework as framework
from paddle.distributed.communication.group import ( from paddle.distributed.communication.group import (
_get_global_group, _get_global_group,
_get_or_throw_group_rank, _get_or_throw_group_rank,
_warn_cur_rank_not_in_group, _warn_cur_rank_not_in_group,
) )
from paddle.fluid import data_feeder
def _broadcast_in_dygraph( def _broadcast_in_dygraph(
......
...@@ -12,13 +12,13 @@ ...@@ -12,13 +12,13 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import paddle.fluid.data_feeder as data_feeder from paddle import framework
import paddle.framework as framework
from paddle.distributed.communication.group import ( from paddle.distributed.communication.group import (
_get_global_group, _get_global_group,
_get_or_throw_group_rank, _get_or_throw_group_rank,
_warn_cur_rank_not_in_group, _warn_cur_rank_not_in_group,
) )
from paddle.fluid import data_feeder
def _recv_in_dygraph( def _recv_in_dygraph(
......
...@@ -12,14 +12,14 @@ ...@@ -12,14 +12,14 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import paddle.fluid.data_feeder as data_feeder from paddle import framework
import paddle.framework as framework
from paddle.distributed.communication.group import ( from paddle.distributed.communication.group import (
_get_global_group, _get_global_group,
_get_or_throw_group_rank, _get_or_throw_group_rank,
_warn_cur_rank_not_in_group, _warn_cur_rank_not_in_group,
) )
from paddle.distributed.communication.reduce import ReduceOp, _get_reduce_op from paddle.distributed.communication.reduce import ReduceOp, _get_reduce_op
from paddle.fluid import data_feeder
def _reduce_in_dygraph( def _reduce_in_dygraph(
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
# limitations under the License. # limitations under the License.
import paddle import paddle
import paddle.framework as framework from paddle import framework
from paddle.distributed.communication.group import ( from paddle.distributed.communication.group import (
_get_global_group, _get_global_group,
_warn_cur_rank_not_in_group, _warn_cur_rank_not_in_group,
......
...@@ -16,13 +16,13 @@ import warnings ...@@ -16,13 +16,13 @@ import warnings
import paddle import paddle
import paddle.distributed as dist import paddle.distributed as dist
import paddle.fluid.data_feeder as data_feeder from paddle import framework
import paddle.framework as framework
from paddle.distributed.communication.group import ( from paddle.distributed.communication.group import (
_get_global_group, _get_global_group,
_get_or_throw_group_rank, _get_or_throw_group_rank,
_warn_cur_rank_not_in_group, _warn_cur_rank_not_in_group,
) )
from paddle.fluid import data_feeder
def _scatter_tensor_in_dygraph( def _scatter_tensor_in_dygraph(
......
...@@ -12,13 +12,13 @@ ...@@ -12,13 +12,13 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import paddle.fluid.data_feeder as data_feeder from paddle import framework
import paddle.framework as framework
from paddle.distributed.communication.group import ( from paddle.distributed.communication.group import (
_get_global_group, _get_global_group,
_get_or_throw_group_rank, _get_or_throw_group_rank,
_warn_cur_rank_not_in_group, _warn_cur_rank_not_in_group,
) )
from paddle.fluid import data_feeder
def _send_in_dygraph( def _send_in_dygraph(
......
...@@ -24,9 +24,9 @@ from paddle.fluid.wrapped_decorator import wrap_decorator ...@@ -24,9 +24,9 @@ from paddle.fluid.wrapped_decorator import wrap_decorator
protobuf_version = google.protobuf.__version__ protobuf_version = google.protobuf.__version__
if protobuf_version >= "4.21.0": if protobuf_version >= "4.21.0":
import google._upb._message as _message from google._upb import _message
else: else:
import google.protobuf.pyext._message as _message from google.protobuf.pyext import _message
__all__ = [] __all__ = []
......
...@@ -20,10 +20,10 @@ from multiprocessing import Manager, Process ...@@ -20,10 +20,10 @@ from multiprocessing import Manager, Process
import numpy as np import numpy as np
import paddle import paddle
import paddle.fluid.core as core
from paddle.distributed.fleet.base.private_helper_function import ( from paddle.distributed.fleet.base.private_helper_function import (
wait_server_ready, wait_server_ready,
) )
from paddle.fluid import core
__all__ = [] __all__ = []
......
...@@ -24,7 +24,7 @@ import numpy as np ...@@ -24,7 +24,7 @@ import numpy as np
from google.protobuf import text_format from google.protobuf import text_format
import paddle import paddle
import paddle.framework as framework from paddle import framework
from paddle.fluid import core, debugger from paddle.fluid import core, debugger
from paddle.fluid.proto import framework_pb2 from paddle.fluid.proto import framework_pb2
from paddle.static import Program from paddle.static import Program
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
from google.protobuf import text_format from google.protobuf import text_format
import paddle.fluid.core as core from paddle.fluid import core
from paddle.fluid.proto import data_feed_pb2 from paddle.fluid.proto import data_feed_pb2
__all__ = [] __all__ = []
......
...@@ -267,7 +267,7 @@ class Fleet: ...@@ -267,7 +267,7 @@ class Fleet:
) )
self._role_maker._generate_role() self._role_maker._generate_role()
import paddle.distributed.fleet as fleet from paddle.distributed import fleet
fleet.util._set_role_maker(self._role_maker) fleet.util._set_role_maker(self._role_maker)
...@@ -1557,7 +1557,7 @@ class Fleet: ...@@ -1557,7 +1557,7 @@ class Fleet:
if self._runtime_handle is None: if self._runtime_handle is None:
self._runtime_handle = RuntimeFactory()._create_runtime(context) self._runtime_handle = RuntimeFactory()._create_runtime(context)
import paddle.distributed.fleet as fleet from paddle.distributed import fleet
fleet.util._set_strategy(context["valid_strategy"]) fleet.util._set_strategy(context["valid_strategy"])
...@@ -1651,7 +1651,7 @@ class Fleet: ...@@ -1651,7 +1651,7 @@ class Fleet:
if self._runtime_handle is None: if self._runtime_handle is None:
self._runtime_handle = RuntimeFactory()._create_runtime(context) self._runtime_handle = RuntimeFactory()._create_runtime(context)
import paddle.distributed.fleet as fleet from paddle.distributed import fleet
fleet.util._set_strategy(context["valid_strategy"]) fleet.util._set_strategy(context["valid_strategy"])
......
...@@ -63,7 +63,7 @@ import tempfile ...@@ -63,7 +63,7 @@ import tempfile
import time import time
from argparse import REMAINDER, ArgumentParser from argparse import REMAINDER, ArgumentParser
import paddle.framework as framework from paddle import framework
from paddle.distributed.fleet import ascend_utils, cloud_utils, launch_utils from paddle.distributed.fleet import ascend_utils, cloud_utils, launch_utils
from paddle.distributed.fleet.elastic import enable_elastic, launch_elastic from paddle.distributed.fleet.elastic import enable_elastic, launch_elastic
from paddle.distributed.fleet.launch_utils import ( from paddle.distributed.fleet.launch_utils import (
......
...@@ -28,8 +28,8 @@ import time ...@@ -28,8 +28,8 @@ import time
from contextlib import closing from contextlib import closing
from distutils.util import strtobool from distutils.util import strtobool
import paddle.framework as framework
import paddle.utils.cpp_extension.extension_utils as utils import paddle.utils.cpp_extension.extension_utils as utils
from paddle import framework
logger = logging.getLogger("root") logger = logging.getLogger("root")
logger.propagate = False logger.propagate = False
......
...@@ -87,7 +87,7 @@ def get_rng_state_tracker(): ...@@ -87,7 +87,7 @@ def get_rng_state_tracker():
def model_parallel_random_seed(seed=None): def model_parallel_random_seed(seed=None):
import paddle.distributed.fleet as fleet from paddle.distributed import fleet
hcg = fleet.get_hybrid_communicate_group() hcg = fleet.get_hybrid_communicate_group()
rank = hcg.get_model_parallel_rank() rank = hcg.get_model_parallel_rank()
......
...@@ -16,8 +16,8 @@ from collections import namedtuple ...@@ -16,8 +16,8 @@ from collections import namedtuple
import hccl.manage.api as hccl import hccl.manage.api as hccl
import paddle.framework.core as core
from paddle.distributed import fleet from paddle.distributed import fleet
from paddle.framework import core
from paddle.optimizer import Optimizer from paddle.optimizer import Optimizer
from . import ascend_parser from . import ascend_parser
......
...@@ -15,7 +15,7 @@ from functools import reduce ...@@ -15,7 +15,7 @@ from functools import reduce
import numpy as np import numpy as np
import paddle.framework.core as core from paddle.framework import core
__all__ = [] __all__ = []
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
import paddle.static as static from paddle import static
from paddle.fluid import core from paddle.fluid import core
from paddle.utils import unique_name from paddle.utils import unique_name
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
import paddle.static as static from paddle import static
from .common import ( from .common import (
OP_ROLE_KEY, OP_ROLE_KEY,
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import paddle.nn as nn from paddle import nn
__all__ = [] __all__ = []
......
...@@ -45,8 +45,7 @@ import re ...@@ -45,8 +45,7 @@ import re
from functools import partial from functools import partial
import paddle import paddle
import paddle.framework as framework from paddle import framework, nn
import paddle.nn as nn
from paddle.incubate.distributed.fleet import recompute_hybrid from paddle.incubate.distributed.fleet import recompute_hybrid
from ...utils.log_util import layer_to_str, logger from ...utils.log_util import layer_to_str, logger
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
import paddle import paddle
import paddle.framework as framework from paddle import framework
from ..meta_optimizers.dygraph_optimizer import HybridParallelOptimizer from ..meta_optimizers.dygraph_optimizer import HybridParallelOptimizer
from ..utils.hybrid_parallel_util import ( from ..utils.hybrid_parallel_util import (
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
import numpy as np import numpy as np
import paddle import paddle
import paddle.framework as framework from paddle import framework
from ...utils.log_util import logger from ...utils.log_util import logger
from .utils import number_2_dtype, paddle_2_number from .utils import number_2_dtype, paddle_2_number
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
import os import os
import warnings import warnings
import paddle.fluid as fluid from paddle import fluid
from paddle.fluid import core from paddle.fluid import core
from paddle.fluid.compiler import CompiledProgram from paddle.fluid.compiler import CompiledProgram
from paddle.fluid.executor import Executor from paddle.fluid.executor import Executor
...@@ -820,7 +820,7 @@ class TheOnePSRuntime(RuntimeBase): ...@@ -820,7 +820,7 @@ class TheOnePSRuntime(RuntimeBase):
send_ctx, dense_map, proto_txt, string_hosts, fluid.global_scope() send_ctx, dense_map, proto_txt, string_hosts, fluid.global_scope()
) )
import paddle.distributed.fleet as fleet from paddle.distributed import fleet
fleet.util.barrier() fleet.util.barrier()
info = self._communicator.get_client_info() info = self._communicator.get_client_info()
...@@ -1566,7 +1566,7 @@ class TheOnePSRuntime(RuntimeBase): ...@@ -1566,7 +1566,7 @@ class TheOnePSRuntime(RuntimeBase):
) )
else: else:
threshold = 0 threshold = 0
import paddle.distributed.fleet as fleet from paddle.distributed import fleet
fleet.util.barrier() fleet.util.barrier()
if self.role_maker._is_first_worker(): if self.role_maker._is_first_worker():
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
from .fs import LocalFS # noqa: F401 from .fs import LocalFS # noqa: F401
from .fs import HDFSClient # noqa: F401 from .fs import HDFSClient # noqa: F401
from .ps_util import DistributedInfer # noqa: F401 from .ps_util import DistributedInfer # noqa: F401
import paddle.utils.deprecated as deprecated from paddle.utils import deprecated
from paddle.distributed import fleet from paddle.distributed import fleet
import paddle import paddle
......
...@@ -16,10 +16,10 @@ from collections import defaultdict ...@@ -16,10 +16,10 @@ from collections import defaultdict
import numpy as np import numpy as np
import paddle.distributed.fleet as fleet from paddle.distributed import fleet
# (TODO: GhostScreaming) It will be removed later. # (TODO: GhostScreaming) It will be removed later.
import paddle.fluid.core as core from paddle.fluid import core
from paddle.fluid.framework import in_dygraph_mode from paddle.fluid.framework import in_dygraph_mode
from paddle.framework import Block, Program from paddle.framework import Block, Program
......
...@@ -45,7 +45,7 @@ class DistributedInfer: ...@@ -45,7 +45,7 @@ class DistributedInfer:
def init_distributed_infer_env( def init_distributed_infer_env(
self, exe, loss, role_maker=None, dirname=None self, exe, loss, role_maker=None, dirname=None
): ):
import paddle.distributed.fleet as fleet from paddle.distributed import fleet
if fleet.fleet._runtime_handle is None: if fleet.fleet._runtime_handle is None:
fleet.init(role_maker=role_maker) fleet.init(role_maker=role_maker)
...@@ -73,7 +73,7 @@ class DistributedInfer: ...@@ -73,7 +73,7 @@ class DistributedInfer:
global_main_program = self.origin_main_program global_main_program = self.origin_main_program
def _get_sparse_table_map(self): def _get_sparse_table_map(self):
import paddle.distributed.fleet as fleet from paddle.distributed import fleet
if self.sparse_table_maps is None: if self.sparse_table_maps is None:
self.sparse_table_maps = {} self.sparse_table_maps = {}
......
...@@ -764,7 +764,7 @@ class FP16Pass(AMPPass): ...@@ -764,7 +764,7 @@ class FP16Pass(AMPPass):
__target_dtype = core.VarDesc.VarType.FP16 __target_dtype = core.VarDesc.VarType.FP16
elif self.target_dtype == "bfloat16": elif self.target_dtype == "bfloat16":
import paddle.static.amp.bf16.amp_utils as amp_utils from paddle.static.amp.bf16 import amp_utils
AMPList = amp_utils.AutoMixedPrecisionListsBF16 AMPList = amp_utils.AutoMixedPrecisionListsBF16
__target_dtype = core.VarDesc.VarType.BF16 __target_dtype = core.VarDesc.VarType.BF16
......
...@@ -17,8 +17,8 @@ import os ...@@ -17,8 +17,8 @@ import os
from _collections import defaultdict from _collections import defaultdict
import paddle import paddle
import paddle.fluid.framework as framework
from paddle.distributed.passes.pass_base import PassBase, register_pass from paddle.distributed.passes.pass_base import PassBase, register_pass
from paddle.fluid import framework
from paddle.framework import core from paddle.framework import core
from paddle.static import Parameter, Program from paddle.static import Parameter, Program
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
# limitations under the License. # limitations under the License.
import paddle import paddle
import paddle.fluid as fluid from paddle import fluid
from paddle.distributed.fleet.base.private_helper_function import ( from paddle.distributed.fleet.base.private_helper_function import (
wait_server_ready, wait_server_ready,
) )
......
...@@ -18,10 +18,10 @@ import pickle ...@@ -18,10 +18,10 @@ import pickle
import time import time
from collections import namedtuple from collections import namedtuple
import paddle.fluid.core as core
from paddle.distributed.launch.context import Node from paddle.distributed.launch.context import Node
from paddle.distributed.rpc.internal import PythonFunc, _serialize from paddle.distributed.rpc.internal import PythonFunc, _serialize
from paddle.distributed.utils.launch_utils import logger from paddle.distributed.utils.launch_utils import logger
from paddle.fluid import core
WorkerInfo = namedtuple("WorkerInfo", ["name", "rank", "ip", "port"]) WorkerInfo = namedtuple("WorkerInfo", ["name", "rank", "ip", "port"])
......
...@@ -20,7 +20,7 @@ import unittest ...@@ -20,7 +20,7 @@ import unittest
import numpy as np import numpy as np
import paddle import paddle
import paddle.static as static from paddle import static
from paddle.utils.cpp_extension.extension_utils import run_cmd from paddle.utils.cpp_extension.extension_utils import run_cmd
......
...@@ -17,7 +17,7 @@ import os ...@@ -17,7 +17,7 @@ import os
from utils import extra_compile_args, paddle_includes from utils import extra_compile_args, paddle_includes
import paddle import paddle
import paddle.fluid.core as core from paddle.fluid import core
from paddle.utils.cpp_extension import CppExtension, CUDAExtension, setup from paddle.utils.cpp_extension import CppExtension, CUDAExtension, setup
if paddle.is_compiled_with_cuda(): if paddle.is_compiled_with_cuda():
......
...@@ -19,7 +19,7 @@ import numpy as np ...@@ -19,7 +19,7 @@ import numpy as np
from utils import extra_cc_args, extra_nvcc_args, paddle_includes from utils import extra_cc_args, extra_nvcc_args, paddle_includes
import paddle import paddle
import paddle.static as static from paddle import static
from paddle.utils.cpp_extension import get_build_directory, load from paddle.utils.cpp_extension import get_build_directory, load
from paddle.utils.cpp_extension.extension_utils import run_cmd from paddle.utils.cpp_extension.extension_utils import run_cmd
......
...@@ -19,7 +19,7 @@ import numpy as np ...@@ -19,7 +19,7 @@ import numpy as np
from utils import extra_cc_args, extra_nvcc_args, paddle_includes from utils import extra_cc_args, extra_nvcc_args, paddle_includes
import paddle import paddle
import paddle.static as static from paddle import static
from paddle.utils.cpp_extension import get_build_directory, load from paddle.utils.cpp_extension import get_build_directory, load
from paddle.utils.cpp_extension.extension_utils import run_cmd from paddle.utils.cpp_extension.extension_utils import run_cmd
......
...@@ -19,7 +19,7 @@ import numpy as np ...@@ -19,7 +19,7 @@ import numpy as np
from utils import extra_cc_args, extra_nvcc_args, paddle_includes from utils import extra_cc_args, extra_nvcc_args, paddle_includes
import paddle import paddle
import paddle.static as static from paddle import static
from paddle.utils.cpp_extension import get_build_directory, load from paddle.utils.cpp_extension import get_build_directory, load
from paddle.utils.cpp_extension.extension_utils import run_cmd from paddle.utils.cpp_extension.extension_utils import run_cmd
......
...@@ -20,7 +20,7 @@ from utils import extra_cc_args, extra_nvcc_args, paddle_includes ...@@ -20,7 +20,7 @@ from utils import extra_cc_args, extra_nvcc_args, paddle_includes
import paddle import paddle
import paddle.nn.functional as F import paddle.nn.functional as F
import paddle.static as static from paddle import static
from paddle.utils.cpp_extension import get_build_directory, load from paddle.utils.cpp_extension import get_build_directory, load
from paddle.utils.cpp_extension.extension_utils import run_cmd from paddle.utils.cpp_extension.extension_utils import run_cmd
......
...@@ -19,7 +19,7 @@ import numpy as np ...@@ -19,7 +19,7 @@ import numpy as np
from utils import extra_cc_args, extra_nvcc_args, paddle_includes from utils import extra_cc_args, extra_nvcc_args, paddle_includes
import paddle import paddle
import paddle.static as static from paddle import static
from paddle.utils.cpp_extension import get_build_directory, load from paddle.utils.cpp_extension import get_build_directory, load
from paddle.utils.cpp_extension.extension_utils import run_cmd from paddle.utils.cpp_extension.extension_utils import run_cmd
......
...@@ -20,7 +20,7 @@ import unittest ...@@ -20,7 +20,7 @@ import unittest
import numpy as np import numpy as np
import paddle import paddle
import paddle.static as static from paddle import static
from paddle.utils.cpp_extension.extension_utils import run_cmd from paddle.utils.cpp_extension.extension_utils import run_cmd
from paddle.vision.transforms import Compose, Normalize from paddle.vision.transforms import Compose, Normalize
......
...@@ -20,7 +20,7 @@ import unittest ...@@ -20,7 +20,7 @@ import unittest
import numpy as np import numpy as np
import paddle import paddle
import paddle.static as static from paddle import static
from paddle.utils.cpp_extension.extension_utils import run_cmd from paddle.utils.cpp_extension.extension_utils import run_cmd
from paddle.vision.transforms import Compose, Normalize from paddle.vision.transforms import Compose, Normalize
......
...@@ -19,7 +19,7 @@ import numpy as np ...@@ -19,7 +19,7 @@ import numpy as np
from utils import extra_cc_args, paddle_includes from utils import extra_cc_args, paddle_includes
import paddle import paddle
import paddle.static as static from paddle import static
from paddle.utils.cpp_extension import get_build_directory, load from paddle.utils.cpp_extension import get_build_directory, load
from paddle.utils.cpp_extension.extension_utils import run_cmd from paddle.utils.cpp_extension.extension_utils import run_cmd
......
...@@ -49,7 +49,7 @@ class TestCustomCPUProfilerPlugin(unittest.TestCase): ...@@ -49,7 +49,7 @@ class TestCustomCPUProfilerPlugin(unittest.TestCase):
def test_custom_profiler(self): def test_custom_profiler(self):
import paddle import paddle
import paddle.profiler as profiler from paddle import profiler
paddle.set_device('custom_cpu') paddle.set_device('custom_cpu')
......
...@@ -44,7 +44,7 @@ def custom_relu_dynamic(func, device, dtype, np_x, use_func=True): ...@@ -44,7 +44,7 @@ def custom_relu_dynamic(func, device, dtype, np_x, use_func=True):
def custom_relu_static(func, device, dtype, np_x, use_func=True): def custom_relu_static(func, device, dtype, np_x, use_func=True):
import paddle import paddle
import paddle.static as static from paddle import static
paddle.enable_static() paddle.enable_static()
paddle.set_device(device) paddle.set_device(device)
......
...@@ -16,11 +16,10 @@ import os ...@@ -16,11 +16,10 @@ import os
from collections import namedtuple from collections import namedtuple
import paddle import paddle
import paddle.fluid as fluid from paddle import fluid
import paddle.fluid.core as core
from paddle.distributed import fleet from paddle.distributed import fleet
from paddle.distributed.fleet.meta_optimizers.ascend import ascend_optimizer from paddle.distributed.fleet.meta_optimizers.ascend import ascend_optimizer
from paddle.fluid import unique_name from paddle.fluid import core, unique_name
from paddle.fluid.layer_helper import LayerHelper from paddle.fluid.layer_helper import LayerHelper
Block = namedtuple('Block', ['program']) Block = namedtuple('Block', ['program'])
......
...@@ -18,8 +18,8 @@ import unittest ...@@ -18,8 +18,8 @@ import unittest
import numpy as np import numpy as np
import paddle import paddle
import paddle.fluid as fluid from paddle import fluid
import paddle.fluid.core as core from paddle.fluid import core
from paddle.incubate.asp import ASPHelper from paddle.incubate.asp import ASPHelper
paddle.enable_static() paddle.enable_static()
......
...@@ -18,8 +18,8 @@ import unittest ...@@ -18,8 +18,8 @@ import unittest
import numpy as np import numpy as np
import paddle import paddle
import paddle.fluid as fluid from paddle import fluid
import paddle.fluid.core as core from paddle.fluid import core
from paddle.incubate import asp as sparsity from paddle.incubate import asp as sparsity
from paddle.incubate.asp.supported_layer_list import ( from paddle.incubate.asp.supported_layer_list import (
supported_layers_and_prune_func_map, supported_layers_and_prune_func_map,
......
...@@ -18,7 +18,7 @@ import unittest ...@@ -18,7 +18,7 @@ import unittest
import numpy as np import numpy as np
import paddle import paddle
import paddle.fluid.core as core from paddle.fluid import core
from paddle.incubate.asp import ASPHelper from paddle.incubate.asp import ASPHelper
......
...@@ -18,8 +18,8 @@ import unittest ...@@ -18,8 +18,8 @@ import unittest
import numpy as np import numpy as np
import paddle import paddle
import paddle.fluid as fluid from paddle import fluid
import paddle.fluid.core as core from paddle.fluid import core
from paddle.incubate.asp import ASPHelper from paddle.incubate.asp import ASPHelper
paddle.enable_static() paddle.enable_static()
......
...@@ -18,8 +18,8 @@ import unittest ...@@ -18,8 +18,8 @@ import unittest
import numpy as np import numpy as np
import paddle import paddle
import paddle.fluid as fluid from paddle import fluid
import paddle.fluid.core as core from paddle.fluid import core
from paddle.incubate.asp import ASPHelper from paddle.incubate.asp import ASPHelper
paddle.enable_static() paddle.enable_static()
......
...@@ -18,8 +18,8 @@ import unittest ...@@ -18,8 +18,8 @@ import unittest
import numpy as np import numpy as np
import paddle import paddle
import paddle.fluid as fluid from paddle import fluid
import paddle.fluid.core as core from paddle.fluid import core
from paddle.incubate.asp import ASPHelper from paddle.incubate.asp import ASPHelper
......
...@@ -19,8 +19,8 @@ import unittest ...@@ -19,8 +19,8 @@ import unittest
import numpy as np import numpy as np
import paddle import paddle
import paddle.distributed.fleet as fleet from paddle.distributed import fleet
import paddle.fluid.core as core from paddle.fluid import core
from paddle.incubate.asp import ASPHelper from paddle.incubate.asp import ASPHelper
cuda_visible_devices = os.getenv('CUDA_VISIBLE_DEVICES') cuda_visible_devices = os.getenv('CUDA_VISIBLE_DEVICES')
......
...@@ -19,8 +19,8 @@ import unittest ...@@ -19,8 +19,8 @@ import unittest
import numpy as np import numpy as np
import paddle import paddle
import paddle.distributed.fleet as fleet from paddle import fluid
import paddle.fluid as fluid from paddle.distributed import fleet
from paddle.incubate import asp as sparsity from paddle.incubate import asp as sparsity
from paddle.incubate.asp import ASPHelper from paddle.incubate.asp import ASPHelper
......
...@@ -19,8 +19,8 @@ import unittest ...@@ -19,8 +19,8 @@ import unittest
import numpy as np import numpy as np
import paddle import paddle
import paddle.distributed.fleet as fleet from paddle import fluid
import paddle.fluid as fluid from paddle.distributed import fleet
from paddle.incubate import asp as sparsity from paddle.incubate import asp as sparsity
from paddle.incubate.asp import ASPHelper from paddle.incubate.asp import ASPHelper
......
...@@ -18,8 +18,8 @@ import unittest ...@@ -18,8 +18,8 @@ import unittest
import numpy as np import numpy as np
import paddle import paddle
import paddle.fluid as fluid
import paddle.fluid.incubate.checkpoint.auto_checkpoint as acp import paddle.fluid.incubate.checkpoint.auto_checkpoint as acp
from paddle import fluid
from paddle.fluid import unique_name from paddle.fluid import unique_name
from paddle.fluid.framework import program_guard from paddle.fluid.framework import program_guard
......
...@@ -15,10 +15,8 @@ ...@@ -15,10 +15,8 @@
import numpy as np import numpy as np
import paddle import paddle
import paddle.nn as nn
import paddle.nn.functional as F import paddle.nn.functional as F
import paddle.static as static from paddle import nn, static, utils
import paddle.utils as utils
from paddle.distributed import fleet from paddle.distributed import fleet
from paddle.distributed.fleet import auto from paddle.distributed.fleet import auto
......
...@@ -17,7 +17,7 @@ import sys ...@@ -17,7 +17,7 @@ import sys
import numpy as np import numpy as np
import paddle import paddle
import paddle.static as static from paddle import static
from paddle.distributed import fleet from paddle.distributed import fleet
sys.path.append("..") sys.path.append("..")
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
# limitations under the License. # limitations under the License.
import paddle import paddle
import paddle.static as static from paddle import static
from paddle.distributed import fleet from paddle.distributed import fleet
from paddle.distributed.auto_parallel.cluster import Cluster from paddle.distributed.auto_parallel.cluster import Cluster
from paddle.distributed.auto_parallel.cost import CostEstimator from paddle.distributed.auto_parallel.cost import CostEstimator
......
...@@ -18,10 +18,8 @@ import tempfile ...@@ -18,10 +18,8 @@ import tempfile
import numpy as np import numpy as np
import paddle import paddle
import paddle.nn as nn
import paddle.nn.functional as F import paddle.nn.functional as F
import paddle.static as static from paddle import nn, static, utils
import paddle.utils as utils
from paddle.distributed.fleet import auto from paddle.distributed.fleet import auto
from paddle.io import Dataset from paddle.io import Dataset
......
...@@ -18,8 +18,8 @@ import tempfile ...@@ -18,8 +18,8 @@ import tempfile
import numpy as np import numpy as np
import paddle import paddle
import paddle.nn as nn
import paddle.nn.functional as F import paddle.nn.functional as F
from paddle import nn
from paddle.distributed.fleet import auto from paddle.distributed.fleet import auto
from paddle.io import Dataset from paddle.io import Dataset
......
...@@ -18,8 +18,8 @@ import tempfile ...@@ -18,8 +18,8 @@ import tempfile
import numpy as np import numpy as np
import paddle import paddle
import paddle.nn as nn
import paddle.nn.functional as F import paddle.nn.functional as F
from paddle import nn
from paddle.distributed.fleet import auto from paddle.distributed.fleet import auto
paddle.enable_static() paddle.enable_static()
......
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
from engine_api_dp import MyDataset from engine_api_dp import MyDataset
import paddle import paddle
import paddle.nn as nn
import paddle.nn.functional as F import paddle.nn.functional as F
from paddle import nn
from paddle.distributed.fleet import auto from paddle.distributed.fleet import auto
paddle.enable_static() paddle.enable_static()
......
...@@ -20,10 +20,8 @@ import unittest ...@@ -20,10 +20,8 @@ import unittest
from test_cluster import cluster_json from test_cluster import cluster_json
import paddle import paddle
import paddle.nn as nn
import paddle.nn.functional as F import paddle.nn.functional as F
import paddle.static as static from paddle import nn, static, utils
import paddle.utils as utils
from paddle.distributed import fleet from paddle.distributed import fleet
from paddle.distributed.auto_parallel.cluster import Cluster from paddle.distributed.auto_parallel.cluster import Cluster
from paddle.distributed.auto_parallel.completion import Completer from paddle.distributed.auto_parallel.completion import Completer
......
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
import unittest import unittest
import paddle import paddle
import paddle.nn as nn
import paddle.nn.functional as F import paddle.nn.functional as F
from paddle import nn
from paddle.distributed.fleet import auto from paddle.distributed.fleet import auto
from paddle.static import InputSpec from paddle.static import InputSpec
......
...@@ -18,9 +18,8 @@ import unittest ...@@ -18,9 +18,8 @@ import unittest
import numpy as np import numpy as np
import paddle import paddle
import paddle.nn as nn
import paddle.nn.functional as F import paddle.nn.functional as F
import paddle.static as static from paddle import nn, static
from paddle.distributed import fleet from paddle.distributed import fleet
from paddle.distributed.auto_parallel.dist_context import ( from paddle.distributed.auto_parallel.dist_context import (
DistributedContext, DistributedContext,
......
...@@ -18,9 +18,8 @@ import unittest ...@@ -18,9 +18,8 @@ import unittest
import numpy as np import numpy as np
import paddle import paddle
import paddle.nn as nn
import paddle.nn.functional as F import paddle.nn.functional as F
import paddle.static as static from paddle import nn, static
from paddle.distributed import fleet from paddle.distributed import fleet
from paddle.distributed.auto_parallel.dist_context import DistributedContext from paddle.distributed.auto_parallel.dist_context import DistributedContext
from paddle.distributed.fleet import auto from paddle.distributed.fleet import auto
......
...@@ -17,8 +17,8 @@ import tempfile ...@@ -17,8 +17,8 @@ import tempfile
import unittest import unittest
import paddle import paddle
import paddle.nn as nn
import paddle.nn.functional as F import paddle.nn.functional as F
from paddle import nn
from paddle.distributed.fleet import auto from paddle.distributed.fleet import auto
paddle.enable_static() paddle.enable_static()
......
...@@ -17,9 +17,8 @@ import unittest ...@@ -17,9 +17,8 @@ import unittest
import numpy as np import numpy as np
import paddle import paddle
import paddle.nn as nn
import paddle.nn.functional as F import paddle.nn.functional as F
import paddle.static as static from paddle import nn, static
from paddle.distributed.fleet import auto from paddle.distributed.fleet import auto
from paddle.io import Dataset from paddle.io import Dataset
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册