From fb82d72c61e86c7132b49b8446e778a042287984 Mon Sep 17 00:00:00 2001 From: Yibing Liu Date: Thu, 30 Apr 2020 16:21:27 +0800 Subject: [PATCH] Move complex into dir incubate (#24254) * Move complex into dir incubate, test=develop * Fix imports, test=develop * Fix docs, test=develop * Forbid import functions from paddle.incubate directly, test=develop --- python/paddle/__init__.py | 2 +- .../unittests/test_complex_elementwise_layers.py | 2 +- .../fluid/tests/unittests/test_complex_kron.py | 4 ++-- .../fluid/tests/unittests/test_complex_reshape.py | 2 +- .../fluid/tests/unittests/test_complex_sum_layer.py | 2 +- .../tests/unittests/test_complex_trace_layer.py | 2 +- python/paddle/incubate/__init__.py | 13 +++++++++++++ python/paddle/{ => incubate}/complex/__init__.py | 0 python/paddle/{ => incubate}/complex/helper.py | 2 +- .../{ => incubate}/complex/tensor/__init__.py | 0 .../paddle/{ => incubate}/complex/tensor/linalg.py | 8 ++++---- .../{ => incubate}/complex/tensor/manipulation.py | 4 ++-- python/paddle/{ => incubate}/complex/tensor/math.py | 7 ++++--- python/setup.py.in | 5 +++-- 14 files changed, 34 insertions(+), 19 deletions(-) create mode 100644 python/paddle/incubate/__init__.py rename python/paddle/{ => incubate}/complex/__init__.py (100%) rename python/paddle/{ => incubate}/complex/helper.py (97%) rename python/paddle/{ => incubate}/complex/tensor/__init__.py (100%) rename python/paddle/{ => incubate}/complex/tensor/linalg.py (92%) rename python/paddle/{ => incubate}/complex/tensor/manipulation.py (98%) rename python/paddle/{ => incubate}/complex/tensor/math.py (99%) diff --git a/python/paddle/__init__.py b/python/paddle/__init__.py index 374be895ff8..bc5a72bf8e7 100644 --- a/python/paddle/__init__.py +++ b/python/paddle/__init__.py @@ -38,7 +38,7 @@ import paddle.tensor import paddle.nn import paddle.framework import paddle.imperative -import paddle.complex +import paddle.incubate.complex as complex # TODO: define alias in tensor and framework directory from .tensor.random import randperm diff --git a/python/paddle/fluid/tests/unittests/test_complex_elementwise_layers.py b/python/paddle/fluid/tests/unittests/test_complex_elementwise_layers.py index 45fa40b228a..0ced775689e 100644 --- a/python/paddle/fluid/tests/unittests/test_complex_elementwise_layers.py +++ b/python/paddle/fluid/tests/unittests/test_complex_elementwise_layers.py @@ -15,7 +15,7 @@ import unittest import numpy as np from numpy.random import random as rand -import paddle.complex as cpx +from paddle import complex as cpx import paddle.fluid as fluid import paddle.fluid.dygraph as dg diff --git a/python/paddle/fluid/tests/unittests/test_complex_kron.py b/python/paddle/fluid/tests/unittests/test_complex_kron.py index 50817a8734b..863d61e6027 100644 --- a/python/paddle/fluid/tests/unittests/test_complex_kron.py +++ b/python/paddle/fluid/tests/unittests/test_complex_kron.py @@ -13,7 +13,7 @@ # limitations under the License. from paddle import fluid, tensor -import paddle.complex as cpx +import paddle import paddle.fluid.dygraph as dg import numpy as np import unittest @@ -40,7 +40,7 @@ class ComplexKronTestCase(unittest.TestCase): with dg.guard(place): x_var = dg.to_variable(self.x) y_var = dg.to_variable(self.y) - out_var = cpx.kron(x_var, y_var) + out_var = paddle.complex.kron(x_var, y_var) np.testing.assert_allclose(out_var.numpy(), self.ref_result) diff --git a/python/paddle/fluid/tests/unittests/test_complex_reshape.py b/python/paddle/fluid/tests/unittests/test_complex_reshape.py index 4b1370a56e3..6d124d8da2b 100644 --- a/python/paddle/fluid/tests/unittests/test_complex_reshape.py +++ b/python/paddle/fluid/tests/unittests/test_complex_reshape.py @@ -13,7 +13,7 @@ # limitations under the License. import paddle.fluid as fluid -import paddle.complex as cpx +from paddle import complex as cpx import paddle.fluid.dygraph as dg import numpy as np import unittest diff --git a/python/paddle/fluid/tests/unittests/test_complex_sum_layer.py b/python/paddle/fluid/tests/unittests/test_complex_sum_layer.py index e8110fd3a96..f8637b44888 100644 --- a/python/paddle/fluid/tests/unittests/test_complex_sum_layer.py +++ b/python/paddle/fluid/tests/unittests/test_complex_sum_layer.py @@ -15,7 +15,7 @@ import unittest import numpy as np from numpy.random import random as rand -import paddle.complex as cpx +from paddle import complex as cpx import paddle.fluid as fluid import paddle.fluid.dygraph as dg diff --git a/python/paddle/fluid/tests/unittests/test_complex_trace_layer.py b/python/paddle/fluid/tests/unittests/test_complex_trace_layer.py index 97123597b6f..5293d594be9 100644 --- a/python/paddle/fluid/tests/unittests/test_complex_trace_layer.py +++ b/python/paddle/fluid/tests/unittests/test_complex_trace_layer.py @@ -15,7 +15,7 @@ import unittest import numpy as np from numpy.random import random as rand -import paddle.complex as cpx +from paddle import complex as cpx import paddle.fluid as fluid import paddle.fluid.dygraph as dg diff --git a/python/paddle/incubate/__init__.py b/python/paddle/incubate/__init__.py new file mode 100644 index 00000000000..76e0e91197f --- /dev/null +++ b/python/paddle/incubate/__init__.py @@ -0,0 +1,13 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/python/paddle/complex/__init__.py b/python/paddle/incubate/complex/__init__.py similarity index 100% rename from python/paddle/complex/__init__.py rename to python/paddle/incubate/complex/__init__.py diff --git a/python/paddle/complex/helper.py b/python/paddle/incubate/complex/helper.py similarity index 97% rename from python/paddle/complex/helper.py rename to python/paddle/incubate/complex/helper.py index 9d96e4d49ad..504cf51cec5 100644 --- a/python/paddle/complex/helper.py +++ b/python/paddle/incubate/complex/helper.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from ..fluid import framework +from ...fluid import framework def is_complex(x): diff --git a/python/paddle/complex/tensor/__init__.py b/python/paddle/incubate/complex/tensor/__init__.py similarity index 100% rename from python/paddle/complex/tensor/__init__.py rename to python/paddle/incubate/complex/tensor/__init__.py diff --git a/python/paddle/complex/tensor/linalg.py b/python/paddle/incubate/complex/tensor/linalg.py similarity index 92% rename from python/paddle/complex/tensor/linalg.py rename to python/paddle/incubate/complex/tensor/linalg.py index 99c0ca5fbfa..3badf36280e 100644 --- a/python/paddle/complex/tensor/linalg.py +++ b/python/paddle/incubate/complex/tensor/linalg.py @@ -13,8 +13,8 @@ # limitations under the License. from ..helper import is_complex, is_real, complex_variable_exists -from ...fluid.framework import ComplexVariable -from ...fluid import layers +from ....fluid.framework import ComplexVariable +from ....fluid import layers __all__ = ['matmul', ] @@ -26,10 +26,10 @@ def matmul(x, y, transpose_x=False, transpose_y=False, alpha=1.0, name=None): Args: x (ComplexVariable|Variable): The first input, can be a ComplexVariable - with data type complex32 or complex64, or a Variable with data type + with data type complex64 or complex128, or a Variable with data type float32 or float64. y (ComplexVariable|Variable): The second input, can be a ComplexVariable - with data type complex32 or complex64, or a Variable with data type + with data type complex64 or complex128, or a Variable with data type float32 or float64. transpose_x (bool): Whether to transpose :math:`x` before multiplication. transpose_y (bool): Whether to transpose :math:`y` before multiplication. diff --git a/python/paddle/complex/tensor/manipulation.py b/python/paddle/incubate/complex/tensor/manipulation.py similarity index 98% rename from python/paddle/complex/tensor/manipulation.py rename to python/paddle/incubate/complex/tensor/manipulation.py index ed04f2ff3a4..7852260a31e 100644 --- a/python/paddle/complex/tensor/manipulation.py +++ b/python/paddle/incubate/complex/tensor/manipulation.py @@ -14,8 +14,8 @@ from paddle.common_ops_import import * from ..helper import is_complex, is_real, complex_variable_exists -from ...fluid.framework import ComplexVariable -from ...fluid import layers +from ....fluid.framework import ComplexVariable +from ....fluid import layers __all__ = [ 'reshape', diff --git a/python/paddle/complex/tensor/math.py b/python/paddle/incubate/complex/tensor/math.py similarity index 99% rename from python/paddle/complex/tensor/math.py rename to python/paddle/incubate/complex/tensor/math.py index da53c98541e..51477abd5dc 100644 --- a/python/paddle/complex/tensor/math.py +++ b/python/paddle/incubate/complex/tensor/math.py @@ -14,9 +14,9 @@ from paddle.common_ops_import import * from ..helper import is_complex, is_real, complex_variable_exists -from ...fluid.framework import ComplexVariable -from ...fluid import layers -from ...tensor import math +from ....fluid.framework import ComplexVariable +from ....fluid import layers +from ....tensor import math __all__ = [ 'elementwise_add', @@ -368,6 +368,7 @@ def kron(x, y, name=None): import numpy as np import paddle + from paddle import fluid import paddle.fluid.dygraph as dg a = np.array([[1.0+1.0j, 2.0+1.0j], [3.0+1.0j, 4.0+1.0j]]) diff --git a/python/setup.py.in b/python/setup.py.in index 5e5f964e168..8432361403b 100644 --- a/python/setup.py.in +++ b/python/setup.py.in @@ -139,8 +139,9 @@ packages=['paddle', 'paddle.dataset', 'paddle.reader', 'paddle.distributed', - 'paddle.complex', - 'paddle.complex.tensor', + 'paddle.incubate', + 'paddle.incubate.complex', + 'paddle.incubate.complex.tensor', 'paddle.framework', 'paddle.fluid', 'paddle.fluid.dygraph', -- GitLab