From 291c55a2e4eae0978457861ec7040a1701c75864 Mon Sep 17 00:00:00 2001 From: wangxiaoning <71813629+wangxn12138@users.noreply.github.com> Date: Fri, 10 Feb 2023 15:33:47 +0800 Subject: [PATCH] [fluid clean]clean fluid.distribute_lookup_table (#50350) * fluid clean * fix optimizer * fix distributed_transpiler * fix fluid.__init__ * remove from fluid.init --- .../{fluid => distributed}/distribute_lookup_table.py | 0 python/paddle/fluid/__init__.py | 1 - .../fleet/parameter_server/pslib/optimizer_factory.py | 8 +++++--- python/paddle/fluid/optimizer.py | 6 +++++- python/paddle/fluid/transpiler/distribute_transpiler.py | 4 +++- python/paddle/fluid/transpiler/geo_sgd_transpiler.py | 4 +++- 6 files changed, 16 insertions(+), 7 deletions(-) rename python/paddle/{fluid => distributed}/distribute_lookup_table.py (100%) diff --git a/python/paddle/fluid/distribute_lookup_table.py b/python/paddle/distributed/distribute_lookup_table.py similarity index 100% rename from python/paddle/fluid/distribute_lookup_table.py rename to python/paddle/distributed/distribute_lookup_table.py diff --git a/python/paddle/fluid/__init__.py b/python/paddle/fluid/__init__.py index f1e991127be..1bd64072d14 100644 --- a/python/paddle/fluid/__init__.py +++ b/python/paddle/fluid/__init__.py @@ -67,7 +67,6 @@ from . import metrics from . import transpiler from . import incubate from .input import embedding, one_hot -from . import distribute_lookup_table from .param_attr import ParamAttr, WeightNormParamAttr from .data_feeder import DataFeeder diff --git a/python/paddle/fluid/incubate/fleet/parameter_server/pslib/optimizer_factory.py b/python/paddle/fluid/incubate/fleet/parameter_server/pslib/optimizer_factory.py index 2c5c1b58e58..49a771b3d0e 100644 --- a/python/paddle/fluid/incubate/fleet/parameter_server/pslib/optimizer_factory.py +++ b/python/paddle/fluid/incubate/fleet/parameter_server/pslib/optimizer_factory.py @@ -16,11 +16,13 @@ __all__ = ["DistributedAdam", "FLEET_GLOBAL_DICT"] import paddle from paddle.framework import core -from paddle.fluid.distribute_lookup_table import find_distributed_lookup_table -from paddle.fluid.distribute_lookup_table import ( +from paddle.distributed.distribute_lookup_table import ( + find_distributed_lookup_table, +) +from paddle.distributed.distribute_lookup_table import ( find_distributed_lookup_table_inputs, ) -from paddle.fluid.distribute_lookup_table import ( +from paddle.distributed.distribute_lookup_table import ( find_distributed_lookup_table_outputs, ) from google.protobuf import text_format diff --git a/python/paddle/fluid/optimizer.py b/python/paddle/fluid/optimizer.py index d7ab914f80f..02a85359374 100755 --- a/python/paddle/fluid/optimizer.py +++ b/python/paddle/fluid/optimizer.py @@ -18,7 +18,7 @@ import logging from collections import defaultdict import paddle -from paddle.fluid.distribute_lookup_table import find_distributed_lookup_table + from paddle.fluid.framework import ( Program, Variable, @@ -944,6 +944,10 @@ class Optimizer: :param loss: the loss variable. :param startup_program: the startup program """ + from paddle.distributed.distribute_lookup_table import ( + find_distributed_lookup_table, + ) + program = framework.default_main_program() global_block = framework.default_main_program().global_block() table_name = find_distributed_lookup_table(program) diff --git a/python/paddle/fluid/transpiler/distribute_transpiler.py b/python/paddle/fluid/transpiler/distribute_transpiler.py index 32486a8dadd..9532ece8503 100644 --- a/python/paddle/fluid/transpiler/distribute_transpiler.py +++ b/python/paddle/fluid/transpiler/distribute_transpiler.py @@ -50,7 +50,6 @@ from ..framework import ( ) from .details import wait_server_ready, UnionFind, VarStruct, VarsDistributed from .details import delete_ops, find_op_by_output_arg -from ..distribute_lookup_table import find_distributed_lookup_table from . import collective LOOKUP_TABLE_TYPE = ["lookup_table", "lookup_table_v2"] @@ -612,6 +611,9 @@ class DistributeTranspiler: sync_mode=False, current_endpoint="127.0.0.1:7000") """ + from paddle.distributed.distribute_lookup_table import ( + find_distributed_lookup_table, + ) err_msg = """ diff --git a/python/paddle/fluid/transpiler/geo_sgd_transpiler.py b/python/paddle/fluid/transpiler/geo_sgd_transpiler.py index 80b39dceaac..dd8b80b2e32 100644 --- a/python/paddle/fluid/transpiler/geo_sgd_transpiler.py +++ b/python/paddle/fluid/transpiler/geo_sgd_transpiler.py @@ -39,7 +39,6 @@ from ..framework import ( ) from .details import wait_server_ready, VarsDistributed from .details import delete_ops -from ..distribute_lookup_table import find_distributed_lookup_table from .distribute_transpiler import ( DistributeTranspiler, DistributeTranspilerConfig, @@ -48,6 +47,9 @@ from .distribute_transpiler import ( ServerRuntimeConfig, ) from paddle.fluid.incubate.fleet.parameter_server.mode import DistributedMode +from paddle.distributed.distribute_lookup_table import ( + find_distributed_lookup_table, +) RPC_OP_ROLE_ATTR_NAME = ( op_role_attr_name -- GitLab