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 2372db9715e..7f06f7a9d72 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 241a07a3529..53746afdb25 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 c716b5af67c..b23d127eeb3 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 15bbd00c0bc..fe07daf5c33 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 d35e7061315..cf366309c0d 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 f0051c77366..d68a6e8be7a 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 e552b792198..aa62d344911 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 5203aa160cc..fbeb0e5940e 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 4f317a40309..9f8cb6ef0bb 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 35c3ab59c22..ac87b12a1ce 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 7f45ee70523..eabcced5d12 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 e0b545183cc..e059f2cd2ab 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 6e4ea273a9a..a43df91342a 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 a325422c316..77fb8154f04 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 5634e29d01f..21a113f509b 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 2176db71b95..37de7921141 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 0f38b742d91..9b0a3f26b79 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 293c7841eca..0de994dda3e 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 6ec36b2bb9c..6d7ac876fdf 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