From e0d5f8a8207b5366582888a7d4bd2086f39c02ce Mon Sep 17 00:00:00 2001 From: minqiyang Date: Tue, 14 Aug 2018 18:16:59 +0800 Subject: [PATCH] Move compat module to python/paddle --- paddle/fluid/pybind/protobuf.cc | 3 +-- python/paddle/__init__.py | 1 + python/paddle/{fluid => }/compat.py | 0 python/paddle/dataset/conll05.py | 2 +- python/paddle/dataset/movielens.py | 2 +- python/paddle/dataset/wmt14.py | 2 +- python/paddle/dataset/wmt16.py | 2 +- python/paddle/fluid/backward.py | 2 +- python/paddle/fluid/framework.py | 2 +- python/paddle/fluid/layers/detection.py | 2 +- python/paddle/fluid/parallel_executor.py | 2 +- python/paddle/fluid/tests/unittests/test_compat.py | 2 +- python/paddle/fluid/tests/unittests/test_dist_base.py | 2 +- python/paddle/fluid/tests/unittests/test_exception.py | 2 +- python/paddle/fluid/tests/unittests/test_lookup_table_op.py | 2 +- python/paddle/fluid/tests/unittests/test_operator_desc.py | 2 +- python/paddle/fluid/tests/unittests/test_protobuf_descs.py | 2 +- python/paddle/fluid/tests/unittests/test_roi_pool_op.py | 2 +- .../paddle/fluid/transpiler/memory_optimization_transpiler.py | 2 +- python/paddle/reader/decorator.py | 2 +- 20 files changed, 19 insertions(+), 19 deletions(-) rename python/paddle/{fluid => }/compat.py (100%) diff --git a/paddle/fluid/pybind/protobuf.cc b/paddle/fluid/pybind/protobuf.cc index 2372db9715..7f06f7a9d7 100644 --- a/paddle/fluid/pybind/protobuf.cc +++ b/paddle/fluid/pybind/protobuf.cc @@ -205,8 +205,7 @@ void BindBlockDesc(pybind11::module *m) { void BindVarDsec(pybind11::module *m) { pybind11::class_ var_desc(*m, "VarDesc", ""); var_desc - .def("name", [](pd::VarDesc &self) { return self.Name(); }, - pybind11::return_value_policy::reference) + .def("name", &pd::VarDesc::Name, pybind11::return_value_policy::reference) .def("set_name", &pd::VarDesc::SetName) .def("set_shape", &pd::VarDesc::SetShape) .def("set_shapes", &pd::VarDesc::SetShapes) diff --git a/python/paddle/__init__.py b/python/paddle/__init__.py index 241a07a352..53746afdb2 100644 --- a/python/paddle/__init__.py +++ b/python/paddle/__init__.py @@ -24,4 +24,5 @@ except ImportError: import paddle.reader import paddle.dataset import paddle.batch +import paddle.compat batch = batch.batch diff --git a/python/paddle/fluid/compat.py b/python/paddle/compat.py similarity index 100% rename from python/paddle/fluid/compat.py rename to python/paddle/compat.py diff --git a/python/paddle/dataset/conll05.py b/python/paddle/dataset/conll05.py index c716b5af67..b23d127eeb 100644 --- a/python/paddle/dataset/conll05.py +++ b/python/paddle/dataset/conll05.py @@ -24,7 +24,7 @@ import tarfile import gzip import itertools import paddle.dataset.common -import paddle.fluid.compat as cpt +import paddle.compat as cpt from six.moves import zip, range __all__ = ['test, get_dict', 'get_embedding', 'convert'] diff --git a/python/paddle/dataset/movielens.py b/python/paddle/dataset/movielens.py index 15bbd00c0b..fe07daf5c3 100644 --- a/python/paddle/dataset/movielens.py +++ b/python/paddle/dataset/movielens.py @@ -28,7 +28,7 @@ import re import random import functools import six -import paddle.fluid.compat as cpt +import paddle.compat as cpt __all__ = [ 'train', 'test', 'get_movie_title_dict', 'max_movie_id', 'max_user_id', diff --git a/python/paddle/dataset/wmt14.py b/python/paddle/dataset/wmt14.py index d35e706131..cf366309c0 100644 --- a/python/paddle/dataset/wmt14.py +++ b/python/paddle/dataset/wmt14.py @@ -24,7 +24,7 @@ import tarfile import gzip import paddle.dataset.common -import paddle.fluid.compat as cpt +import paddle.compat as cpt __all__ = [ 'train', diff --git a/python/paddle/dataset/wmt16.py b/python/paddle/dataset/wmt16.py index f0051c7736..d68a6e8be7 100644 --- a/python/paddle/dataset/wmt16.py +++ b/python/paddle/dataset/wmt16.py @@ -35,7 +35,7 @@ import gzip from collections import defaultdict import paddle.dataset.common -import paddle.fluid.compat as cpt +import paddle.compat as cpt __all__ = [ "train", diff --git a/python/paddle/fluid/backward.py b/python/paddle/fluid/backward.py index e552b79219..aa62d34491 100644 --- a/python/paddle/fluid/backward.py +++ b/python/paddle/fluid/backward.py @@ -17,7 +17,7 @@ from . import core import collections import copy import six -from . import compat as cpt +from .. import compat as cpt from . import unique_name __all__ = ['append_backward'] diff --git a/python/paddle/fluid/framework.py b/python/paddle/fluid/framework.py index 5203aa160c..fbeb0e5940 100644 --- a/python/paddle/fluid/framework.py +++ b/python/paddle/fluid/framework.py @@ -19,7 +19,7 @@ import six import numpy as np -from . import compat as cpt +from .. import compat as cpt from .proto import framework_pb2 try: from . import core diff --git a/python/paddle/fluid/layers/detection.py b/python/paddle/fluid/layers/detection.py index 4f317a4030..9f8cb6ef0b 100644 --- a/python/paddle/fluid/layers/detection.py +++ b/python/paddle/fluid/layers/detection.py @@ -20,7 +20,7 @@ from .layer_function_generator import autodoc, templatedoc from ..layer_helper import LayerHelper from . import tensor from . import nn -from .. import compat as cpt +from ... import compat as cpt import math import six from functools import reduce diff --git a/python/paddle/fluid/parallel_executor.py b/python/paddle/fluid/parallel_executor.py index 35c3ab59c2..ac87b12a1c 100644 --- a/python/paddle/fluid/parallel_executor.py +++ b/python/paddle/fluid/parallel_executor.py @@ -17,7 +17,7 @@ import multiprocessing from . import core from . import framework from . import executor -from . import compat as cpt +from .. import compat as cpt import warnings import sys import six diff --git a/python/paddle/fluid/tests/unittests/test_compat.py b/python/paddle/fluid/tests/unittests/test_compat.py index 7f45ee7052..eabcced5d1 100644 --- a/python/paddle/fluid/tests/unittests/test_compat.py +++ b/python/paddle/fluid/tests/unittests/test_compat.py @@ -13,7 +13,7 @@ # limitations under the License. import unittest -import paddle.fluid.compat as cpt +import paddle.compat as cpt import six diff --git a/python/paddle/fluid/tests/unittests/test_dist_base.py b/python/paddle/fluid/tests/unittests/test_dist_base.py index e0b545183c..e059f2cd2a 100644 --- a/python/paddle/fluid/tests/unittests/test_dist_base.py +++ b/python/paddle/fluid/tests/unittests/test_dist_base.py @@ -124,7 +124,7 @@ def runtime_main(test_class): model.run_trainer(p, endpoints, trainer_id, trainers, is_dist) -import paddle.fluid.compat as cpt +import paddle.compat as cpt class TestDistBase(unittest.TestCase): diff --git a/python/paddle/fluid/tests/unittests/test_exception.py b/python/paddle/fluid/tests/unittests/test_exception.py index 6e4ea273a9..a43df91342 100644 --- a/python/paddle/fluid/tests/unittests/test_exception.py +++ b/python/paddle/fluid/tests/unittests/test_exception.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import paddle.fluid.compat as cpt +import paddle.compat as cpt import paddle.fluid.core as core import unittest diff --git a/python/paddle/fluid/tests/unittests/test_lookup_table_op.py b/python/paddle/fluid/tests/unittests/test_lookup_table_op.py index a325422c31..77fb8154f0 100644 --- a/python/paddle/fluid/tests/unittests/test_lookup_table_op.py +++ b/python/paddle/fluid/tests/unittests/test_lookup_table_op.py @@ -17,7 +17,7 @@ import numpy as np from op_test import OpTest import paddle.fluid.core as core from paddle.fluid.op import Operator -import paddle.fluid.compat as cpt +import paddle.compat as cpt class TestLookupTableOp(OpTest): diff --git a/python/paddle/fluid/tests/unittests/test_operator_desc.py b/python/paddle/fluid/tests/unittests/test_operator_desc.py index 5634e29d01..21a113f509 100644 --- a/python/paddle/fluid/tests/unittests/test_operator_desc.py +++ b/python/paddle/fluid/tests/unittests/test_operator_desc.py @@ -15,7 +15,7 @@ import unittest import paddle.fluid.core as core -import paddle.fluid.compat as cpt +import paddle.compat as cpt from paddle.fluid.framework import Program, default_startup_program diff --git a/python/paddle/fluid/tests/unittests/test_protobuf_descs.py b/python/paddle/fluid/tests/unittests/test_protobuf_descs.py index 2176db71b9..37de792114 100644 --- a/python/paddle/fluid/tests/unittests/test_protobuf_descs.py +++ b/python/paddle/fluid/tests/unittests/test_protobuf_descs.py @@ -14,7 +14,7 @@ import unittest import paddle.fluid.core as core -import paddle.fluid.compat as cpt +import paddle.compat as cpt from paddle.fluid.framework import Program 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 0f38b742d9..9b0a3f26b7 100644 --- a/python/paddle/fluid/tests/unittests/test_roi_pool_op.py +++ b/python/paddle/fluid/tests/unittests/test_roi_pool_op.py @@ -16,7 +16,7 @@ import unittest import numpy as np import math import sys -import paddle.fluid.compat as cpt +import paddle.compat as cpt from op_test import OpTest diff --git a/python/paddle/fluid/transpiler/memory_optimization_transpiler.py b/python/paddle/fluid/transpiler/memory_optimization_transpiler.py index 293c7841ec..0de994dda3 100644 --- a/python/paddle/fluid/transpiler/memory_optimization_transpiler.py +++ b/python/paddle/fluid/transpiler/memory_optimization_transpiler.py @@ -14,7 +14,7 @@ from collections import defaultdict from .. import core -from .. import compat as cpt +from ... import compat as cpt from ..framework import Program, default_main_program, Parameter from ..backward import _rename_arg_ from functools import reduce diff --git a/python/paddle/reader/decorator.py b/python/paddle/reader/decorator.py index 6ec36b2bb9..6d7ac876fd 100644 --- a/python/paddle/reader/decorator.py +++ b/python/paddle/reader/decorator.py @@ -27,7 +27,7 @@ from six.moves import zip import itertools import random import zlib -import paddle.fluid.compat as cpt +import paddle.compat as cpt def map_readers(func, *readers): -- GitLab