From 0f0abcdeda84e6bbc3d83e94029108f1a2e3bd4a Mon Sep 17 00:00:00 2001 From: SigureMo Date: Sat, 26 Nov 2022 00:18:50 +0800 Subject: [PATCH 1/7] [CodeStyle][isort] introduce isort (part5) --- python/paddle/tensor/array.py | 5 +- python/paddle/tensor/attribute.py | 18 +++-- python/paddle/tensor/creation.py | 40 ++++++----- python/paddle/tensor/einsum.py | 21 +++--- .../paddle/tensor/layer_function_generator.py | 13 ++-- python/paddle/tensor/linalg.py | 24 +++---- python/paddle/tensor/logic.py | 17 ++--- python/paddle/tensor/manipulation.py | 42 +++++++----- python/paddle/tensor/math.py | 67 ++++++++++--------- python/paddle/tensor/ops.py | 12 ++-- python/paddle/tensor/random.py | 28 ++++---- python/paddle/tensor/search.py | 20 ++++-- python/paddle/tensor/stat.py | 12 ++-- python/paddle/tensor/to_string.py | 4 +- 14 files changed, 177 insertions(+), 146 deletions(-) diff --git a/python/paddle/tensor/array.py b/python/paddle/tensor/array.py index 382c6f524b4c57..8a70e2dd11a170 100644 --- a/python/paddle/tensor/array.py +++ b/python/paddle/tensor/array.py @@ -14,10 +14,9 @@ # Define functions about array. +from ..fluid.data_feeder import check_type, check_variable_and_dtype +from ..framework import LayerHelper, _non_static_mode, core from ..static import Variable -from ..framework import LayerHelper, core, _non_static_mode -from ..fluid.data_feeder import check_type -from ..fluid.data_feeder import check_variable_and_dtype __all__ = [] diff --git a/python/paddle/tensor/attribute.py b/python/paddle/tensor/attribute.py index e0db6a6e8b413f..3fa27a4f88b85b 100644 --- a/python/paddle/tensor/attribute.py +++ b/python/paddle/tensor/attribute.py @@ -12,21 +12,19 @@ # See the License for the specific language governing permissions and # limitations under the License. -from ..framework import core -from ..framework import LayerHelper -from ..fluid.data_feeder import check_variable_and_dtype -from ..fluid.data_feeder import check_type +# TODO: define functions to get tensor attributes + +import numpy as np -from .creation import assign -from .creation import _complex_to_real_dtype -# TODO: define functions to get tensor attributes import paddle from paddle import _C_ops, _legacy_C_ops -from ..static import Variable -from ..fluid.framework import _in_legacy_dygraph, in_dygraph_mode -import numpy as np +from ..fluid.data_feeder import check_type, check_variable_and_dtype +from ..fluid.framework import _in_legacy_dygraph, in_dygraph_mode +from ..framework import LayerHelper, core +from ..static import Variable +from .creation import _complex_to_real_dtype, assign __all__ = [] diff --git a/python/paddle/tensor/creation.py b/python/paddle/tensor/creation.py index ddde2a68988b9e..a561fe26284a06 100644 --- a/python/paddle/tensor/creation.py +++ b/python/paddle/tensor/creation.py @@ -12,32 +12,40 @@ # See the License for the specific language governing permissions and # limitations under the License. -import numpy as np +# TODO: define functions to get create a tensor + import math import re +import warnings + +import numpy as np + +import paddle +from paddle import _C_ops, _legacy_C_ops from paddle.common_ops_import import fill_constant -from ..fluid.layers import utils -from ..static import Variable, device_guard -from ..framework import _current_expected_place, _get_paddle_place -from ..framework import core -from ..framework import in_dygraph_mode, _non_static_mode -from ..framework import LayerHelper + from ..fluid.data_feeder import ( - check_variable_and_dtype, - check_type, check_dtype, + check_type, + check_variable_and_dtype, convert_dtype, ) -from ..framework import convert_np_dtype_to_dtype_ - -# TODO: define functions to get create a tensor -import paddle -from paddle import _C_ops, _legacy_C_ops from ..fluid.framework import ( - _in_legacy_dygraph, _in_eager_without_dygraph_check, + _in_legacy_dygraph, ) -import warnings +from ..fluid.layers import utils +from ..framework import ( + LayerHelper, + _current_expected_place, + _get_paddle_place, + _non_static_mode, + convert_np_dtype_to_dtype_, + core, + in_dygraph_mode, +) +from ..static import Variable, device_guard + __all__ = [] diff --git a/python/paddle/tensor/einsum.py b/python/paddle/tensor/einsum.py index 4864317254ddeb..50718b64409e93 100644 --- a/python/paddle/tensor/einsum.py +++ b/python/paddle/tensor/einsum.py @@ -12,22 +12,23 @@ # See the License for the specific language governing permissions and # limitations under the License. +import collections import itertools -import numpy as np import re +import string + +import numpy as np +import opt_einsum -from .linalg import matmul, transpose -from .manipulation import squeeze, unsqueeze, reshape -from .math import multiply -from .math import sum as paddle_sum -from ..fluid.framework import _in_legacy_dygraph from paddle import _C_ops, _legacy_C_ops + from ..fluid.data_feeder import check_type, check_variable_and_dtype -from ..fluid.layer_helper import LayerHelper from ..fluid.framework import _in_legacy_dygraph, in_dygraph_mode -import collections -import string -import opt_einsum +from ..fluid.layer_helper import LayerHelper +from .linalg import matmul, transpose +from .manipulation import reshape, squeeze, unsqueeze +from .math import multiply +from .math import sum as paddle_sum __all__ = [] diff --git a/python/paddle/tensor/layer_function_generator.py b/python/paddle/tensor/layer_function_generator.py index fb2a611257e131..fed73aff93bab9 100644 --- a/python/paddle/tensor/layer_function_generator.py +++ b/python/paddle/tensor/layer_function_generator.py @@ -13,22 +13,23 @@ # limitations under the License. import re -import warnings import string - +import warnings from io import StringIO -from ..static import Variable + +from paddle import _C_ops, _legacy_C_ops + +from ..fluid.data_feeder import check_variable_and_dtype from ..fluid.proto import framework_pb2 from ..framework import ( + LayerHelper, OpProtoHolder, _non_static_mode, convert_np_dtype_to_dtype_, core, in_dygraph_mode, ) -from ..framework import LayerHelper -from ..fluid.data_feeder import check_variable_and_dtype -from paddle import _C_ops, _legacy_C_ops +from ..static import Variable __all__ = [] diff --git a/python/paddle/tensor/linalg.py b/python/paddle/tensor/linalg.py index d7dcd5412ac381..0ffae882ee5f21 100644 --- a/python/paddle/tensor/linalg.py +++ b/python/paddle/tensor/linalg.py @@ -13,23 +13,23 @@ # limitations under the License. import numpy as np -from ..framework import LayerHelper -from ..framework import _non_static_mode, in_dygraph_mode + +import paddle +from paddle import _C_ops, _legacy_C_ops +from paddle.common_ops_import import VarDesc + from ..fluid.data_feeder import ( - check_variable_and_dtype, - check_type, check_dtype, + check_type, + check_variable_and_dtype, ) -from ..static import Variable from ..fluid.framework import _in_legacy_dygraph -from .manipulation import cast -from .math import multiply, add -from .logic import logical_not +from ..framework import LayerHelper, _non_static_mode, in_dygraph_mode +from ..static import Variable from .creation import full - -import paddle -from paddle.common_ops_import import VarDesc -from paddle import _C_ops, _legacy_C_ops +from .logic import logical_not +from .manipulation import cast +from .math import add, multiply __all__ = [] diff --git a/python/paddle/tensor/logic.py b/python/paddle/tensor/logic.py index 912c69245c0df8..90d820fa10c9f9 100755 --- a/python/paddle/tensor/logic.py +++ b/python/paddle/tensor/logic.py @@ -12,27 +12,28 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO: define logic functions of a tensor + import paddle + from ..fluid.data_feeder import check_type, check_variable_and_dtype -from .layer_function_generator import templatedoc -from ..static import Variable -# TODO: define logic functions of a tensor from ..fluid.framework import _in_eager_mode_ +from ..static import Variable +from .layer_function_generator import templatedoc if _in_eager_mode_: Tensor = paddle.fluid.framework.core.eager.Tensor else: from ..framework import VarBase as Tensor -from ..framework import in_dygraph_mode -from ..framework import LayerHelper -from ..fluid.framework import _in_legacy_dygraph - -# TODO: define logic functions of a tensor from paddle import _C_ops, _legacy_C_ops from paddle.tensor.creation import full +from ..fluid.framework import _in_legacy_dygraph +from ..framework import LayerHelper, in_dygraph_mode + + __all__ = [] diff --git a/python/paddle/tensor/manipulation.py b/python/paddle/tensor/manipulation.py index c1307e218a7a2b..f62652a8c0a8fc 100644 --- a/python/paddle/tensor/manipulation.py +++ b/python/paddle/tensor/manipulation.py @@ -12,31 +12,37 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO: define functions to manipulate a tensor + +import warnings from collections import Counter -from ..static import Variable -from ..framework import core, in_dygraph_mode -from ..fluid.framework import _in_legacy_dygraph, _non_static_mode -from ..framework import LayerHelper -from ..framework import convert_np_dtype_to_dtype_, dygraph_only +import numpy as np + +import paddle +from paddle import _C_ops, _legacy_C_ops + +from ..common_ops_import import _varbase_creator, dygraph_utils, fill_constant from ..fluid.data_feeder import ( - convert_dtype, - check_variable_and_dtype, - check_type, check_dtype, + check_type, + check_variable_and_dtype, + convert_dtype, ) -from ..fluid.layers import utils -import numpy as np -# TODO: define functions to manipulate a tensor from ..fluid.dygraph.inplace_utils import inplace_apis_in_dygraph_only -import paddle -from paddle import _C_ops, _legacy_C_ops -from ..common_ops_import import dygraph_utils, fill_constant, _varbase_creator -import warnings -from .creation import zeros -from .creation import _complex_to_real_dtype -from .creation import _real_to_complex_dtype +from ..fluid.framework import _in_legacy_dygraph, _non_static_mode +from ..fluid.layers import utils +from ..framework import ( + LayerHelper, + convert_np_dtype_to_dtype_, + core, + dygraph_only, + in_dygraph_mode, +) +from ..static import Variable +from .creation import _complex_to_real_dtype, _real_to_complex_dtype, zeros + __all__ = [] diff --git a/python/paddle/tensor/math.py b/python/paddle/tensor/math.py index 5a49c659952da8..a317820eddcea2 100644 --- a/python/paddle/tensor/math.py +++ b/python/paddle/tensor/math.py @@ -14,47 +14,55 @@ """ math functions """ -import numpy as np -from paddle.common_ops_import import VarDesc -from paddle.common_ops_import import dygraph_only -from paddle.common_ops_import import templatedoc -from paddle.common_ops_import import dygraph_utils +# TODO: define math functions -from .manipulation import cast -from .creation import _complex_to_real_dtype -from .layer_function_generator import generate_layer_fn +import numpy as np import paddle -from ..static import Variable -from ..framework import ( - core, - in_dygraph_mode, - _non_static_mode, - LayerHelper, - _in_legacy_dygraph, +from paddle import _C_ops, _legacy_C_ops +from paddle.common_ops_import import ( + VarDesc, + dygraph_only, + dygraph_utils, + templatedoc, ) -from ..fluid.framework import _in_legacy_dygraph -from ..framework import _varbase_creator, convert_np_dtype_to_dtype_ + from ..fluid.data_feeder import ( - check_variable_and_dtype, - check_type, check_dtype, + check_type, + check_variable_and_dtype, convert_dtype, ) from ..fluid.dygraph.inplace_utils import inplace_apis_in_dygraph_only -from ..fluid.layers import utils +from ..fluid.framework import _in_legacy_dygraph +from ..fluid.layers import elementwise_sub, utils +from ..framework import ( + LayerHelper, + _in_legacy_dygraph, + _non_static_mode, + _varbase_creator, + convert_np_dtype_to_dtype_, + core, + in_dygraph_mode, +) +from ..static import Variable +from .creation import _complex_to_real_dtype +from .layer_function_generator import generate_layer_fn +from .manipulation import cast -# TODO: define math functions from .ops import abs # noqa: F401 from .ops import acos # noqa: F401 +from .ops import acosh # noqa: F401 from .ops import asin # noqa: F401 +from .ops import asinh # noqa: F401 +from .ops import atan # noqa: F401 +from .ops import atanh # noqa: F401 from .ops import ceil # noqa: F401 from .ops import ceil_ # noqa: F401 from .ops import cos # noqa: F401 -from .ops import tan # noqa: F401 -from .ops import sinh # noqa: F401 from .ops import cosh # noqa: F401 +from .ops import erf # noqa: F401 from .ops import exp # noqa: F401 from .ops import exp_ # noqa: F401 from .ops import expm1 # noqa: F401 @@ -66,18 +74,13 @@ from .ops import round_ # noqa: F401 from .ops import rsqrt # noqa: F401 from .ops import rsqrt_ # noqa: F401 -from .ops import square # noqa: F401 -from .ops import atan # noqa: F401 -from .ops import erf # noqa: F401 +from .ops import sin # noqa: F401 +from .ops import sinh # noqa: F401 from .ops import sqrt # noqa: F401 from .ops import sqrt_ # noqa: F401 -from .ops import sin # noqa: F401 -from .ops import asinh # noqa: F401 -from .ops import acosh # noqa: F401 -from .ops import atanh # noqa: F401 +from .ops import square # noqa: F401 +from .ops import tan # noqa: F401 -from ..fluid.layers import elementwise_sub -from paddle import _C_ops, _legacy_C_ops __all__ = [] diff --git a/python/paddle/tensor/ops.py b/python/paddle/tensor/ops.py index c4d8b01762a2af..edabf3315c37fe 100644 --- a/python/paddle/tensor/ops.py +++ b/python/paddle/tensor/ops.py @@ -12,16 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. +from .. import _C_ops, _legacy_C_ops +from ..fluid.data_feeder import check_variable_and_dtype +from ..fluid.framework import _in_legacy_dygraph, in_dygraph_mode +from ..framework import LayerHelper from .layer_function_generator import ( - generate_layer_fn, + add_sample_code, generate_activation_fn, generate_inplace_fn, - add_sample_code, + generate_layer_fn, ) -from ..fluid.data_feeder import check_variable_and_dtype -from ..fluid.framework import in_dygraph_mode, _in_legacy_dygraph -from ..framework import LayerHelper -from .. import _C_ops, _legacy_C_ops __deprecated_func_name__ = { 'tanh_shrink': 'tanhshrink', diff --git a/python/paddle/tensor/random.py b/python/paddle/tensor/random.py index da7f8b6a28513d..1b80c872faca52 100644 --- a/python/paddle/tensor/random.py +++ b/python/paddle/tensor/random.py @@ -14,23 +14,27 @@ # TODO: define random functions -from ..framework import core -from ..framework import convert_np_dtype_to_dtype_, dygraph_only -from ..framework import LayerHelper +import paddle +from paddle import _C_ops, _legacy_C_ops +from paddle.fluid.framework import ( + _current_expected_place, + _in_legacy_dygraph, + in_dygraph_mode, +) +from paddle.static import Variable + from ..fluid.data_feeder import ( - check_variable_and_dtype, - check_type, check_dtype, check_shape, + check_type, + check_variable_and_dtype, ) from ..fluid.layers import utils -import paddle -from paddle import _C_ops, _legacy_C_ops -from paddle.static import Variable -from paddle.fluid.framework import ( - in_dygraph_mode, - _in_legacy_dygraph, - _current_expected_place, +from ..framework import ( + LayerHelper, + convert_np_dtype_to_dtype_, + core, + dygraph_only, ) __all__ = [] diff --git a/python/paddle/tensor/search.py b/python/paddle/tensor/search.py index f8c6861d48c84f..2beacff2a081a5 100755 --- a/python/paddle/tensor/search.py +++ b/python/paddle/tensor/search.py @@ -11,17 +11,25 @@ # 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. + +# TODO: define searching & indexing functions of a tensor + import numpy as np + import paddle -from ..framework import LayerHelper, convert_np_dtype_to_dtype_ +from paddle import _C_ops, _legacy_C_ops +from paddle.common_ops_import import VarDesc, Variable + from ..fluid.data_feeder import check_dtype, check_variable_and_dtype -from ..framework import core, in_dygraph_mode, _non_static_mode from ..fluid.framework import _in_legacy_dygraph -from paddle.common_ops_import import Variable -from paddle.common_ops_import import VarDesc -from paddle import _C_ops, _legacy_C_ops +from ..framework import ( + LayerHelper, + _non_static_mode, + convert_np_dtype_to_dtype_, + core, + in_dygraph_mode, +) -# TODO: define searching & indexing functions of a tensor # from ..fluid.layers import has_inf #DEFINE_ALIAS # from ..fluid.layers import has_nan #DEFINE_ALIAS diff --git a/python/paddle/tensor/stat.py b/python/paddle/tensor/stat.py index 4eefa198ea4377..d54cafdf04cdaa 100644 --- a/python/paddle/tensor/stat.py +++ b/python/paddle/tensor/stat.py @@ -14,15 +14,15 @@ # TODO: define statistical functions of a tensor -from ..static import Variable -from ..framework import LayerHelper -from ..framework import core -from paddle.fluid.framework import _in_legacy_dygraph, in_dygraph_mode -from .search import where -from ..fluid.data_feeder import check_type, check_variable_and_dtype import paddle from paddle import _C_ops, _legacy_C_ops +from paddle.fluid.framework import _in_legacy_dygraph, in_dygraph_mode + +from ..fluid.data_feeder import check_type, check_variable_and_dtype +from ..framework import LayerHelper, core +from ..static import Variable from .math import _get_reduce_axis_with_tensor +from .search import where __all__ = [] diff --git a/python/paddle/tensor/to_string.py b/python/paddle/tensor/to_string.py index bb38d152b56082..fda011b71779ce 100644 --- a/python/paddle/tensor/to_string.py +++ b/python/paddle/tensor/to_string.py @@ -13,9 +13,11 @@ # limitations under the License. import numpy as np -from ..framework import core + from paddle.fluid.data_feeder import check_type, convert_dtype +from ..framework import core + __all__ = [] From c34d2afdb4aefa94135764a2d3677f7e7e46a11b Mon Sep 17 00:00:00 2001 From: SigureMo Date: Sat, 26 Nov 2022 00:46:28 +0800 Subject: [PATCH 2/7] revert tensor/attribute.py --- python/paddle/tensor/attribute.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/python/paddle/tensor/attribute.py b/python/paddle/tensor/attribute.py index 3fa27a4f88b85b..e0db6a6e8b413f 100644 --- a/python/paddle/tensor/attribute.py +++ b/python/paddle/tensor/attribute.py @@ -12,19 +12,21 @@ # See the License for the specific language governing permissions and # limitations under the License. -# TODO: define functions to get tensor attributes - -import numpy as np +from ..framework import core +from ..framework import LayerHelper +from ..fluid.data_feeder import check_variable_and_dtype +from ..fluid.data_feeder import check_type +from .creation import assign +from .creation import _complex_to_real_dtype +# TODO: define functions to get tensor attributes import paddle from paddle import _C_ops, _legacy_C_ops - -from ..fluid.data_feeder import check_type, check_variable_and_dtype -from ..fluid.framework import _in_legacy_dygraph, in_dygraph_mode -from ..framework import LayerHelper, core from ..static import Variable -from .creation import _complex_to_real_dtype, assign +from ..fluid.framework import _in_legacy_dygraph, in_dygraph_mode + +import numpy as np __all__ = [] From 9cbed1d8fdf1c51c2c00aa1cb9b5c116c3d7ef3c Mon Sep 17 00:00:00 2001 From: SigureMo Date: Sat, 26 Nov 2022 01:25:39 +0800 Subject: [PATCH 3/7] Revert "revert tensor/attribute.py" This reverts commit c34d2afdb4aefa94135764a2d3677f7e7e46a11b. --- python/paddle/tensor/attribute.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/python/paddle/tensor/attribute.py b/python/paddle/tensor/attribute.py index e0db6a6e8b413f..3fa27a4f88b85b 100644 --- a/python/paddle/tensor/attribute.py +++ b/python/paddle/tensor/attribute.py @@ -12,21 +12,19 @@ # See the License for the specific language governing permissions and # limitations under the License. -from ..framework import core -from ..framework import LayerHelper -from ..fluid.data_feeder import check_variable_and_dtype -from ..fluid.data_feeder import check_type +# TODO: define functions to get tensor attributes + +import numpy as np -from .creation import assign -from .creation import _complex_to_real_dtype -# TODO: define functions to get tensor attributes import paddle from paddle import _C_ops, _legacy_C_ops -from ..static import Variable -from ..fluid.framework import _in_legacy_dygraph, in_dygraph_mode -import numpy as np +from ..fluid.data_feeder import check_type, check_variable_and_dtype +from ..fluid.framework import _in_legacy_dygraph, in_dygraph_mode +from ..framework import LayerHelper, core +from ..static import Variable +from .creation import _complex_to_real_dtype, assign __all__ = [] From 90850828e2e6f76c978648eef58d505b02f78d36 Mon Sep 17 00:00:00 2001 From: SigureMo Date: Sat, 26 Nov 2022 01:28:25 +0800 Subject: [PATCH 4/7] skip a import --- python/paddle/tensor/attribute.py | 4 ++-- python/paddle/tensor/creation.py | 1 - python/paddle/tensor/logic.py | 2 -- python/paddle/tensor/manipulation.py | 2 -- python/paddle/tensor/math.py | 2 -- 5 files changed, 2 insertions(+), 9 deletions(-) diff --git a/python/paddle/tensor/attribute.py b/python/paddle/tensor/attribute.py index 3fa27a4f88b85b..077633d06326fe 100644 --- a/python/paddle/tensor/attribute.py +++ b/python/paddle/tensor/attribute.py @@ -16,16 +16,16 @@ import numpy as np - import paddle from paddle import _C_ops, _legacy_C_ops from ..fluid.data_feeder import check_type, check_variable_and_dtype from ..fluid.framework import _in_legacy_dygraph, in_dygraph_mode from ..framework import LayerHelper, core -from ..static import Variable from .creation import _complex_to_real_dtype, assign +from ..static import Variable # isort: skip + __all__ = [] diff --git a/python/paddle/tensor/creation.py b/python/paddle/tensor/creation.py index a561fe26284a06..e44582c0f3a11b 100644 --- a/python/paddle/tensor/creation.py +++ b/python/paddle/tensor/creation.py @@ -46,7 +46,6 @@ ) from ..static import Variable, device_guard - __all__ = [] diff --git a/python/paddle/tensor/logic.py b/python/paddle/tensor/logic.py index 90d820fa10c9f9..a4cc95edfc7c35 100755 --- a/python/paddle/tensor/logic.py +++ b/python/paddle/tensor/logic.py @@ -17,7 +17,6 @@ import paddle from ..fluid.data_feeder import check_type, check_variable_and_dtype - from ..fluid.framework import _in_eager_mode_ from ..static import Variable from .layer_function_generator import templatedoc @@ -33,7 +32,6 @@ from ..fluid.framework import _in_legacy_dygraph from ..framework import LayerHelper, in_dygraph_mode - __all__ = [] diff --git a/python/paddle/tensor/manipulation.py b/python/paddle/tensor/manipulation.py index f62652a8c0a8fc..cb4fec4a33bd97 100644 --- a/python/paddle/tensor/manipulation.py +++ b/python/paddle/tensor/manipulation.py @@ -29,7 +29,6 @@ check_variable_and_dtype, convert_dtype, ) - from ..fluid.dygraph.inplace_utils import inplace_apis_in_dygraph_only from ..fluid.framework import _in_legacy_dygraph, _non_static_mode from ..fluid.layers import utils @@ -43,7 +42,6 @@ from ..static import Variable from .creation import _complex_to_real_dtype, _real_to_complex_dtype, zeros - __all__ = [] diff --git a/python/paddle/tensor/math.py b/python/paddle/tensor/math.py index a317820eddcea2..d10782f382639d 100644 --- a/python/paddle/tensor/math.py +++ b/python/paddle/tensor/math.py @@ -50,7 +50,6 @@ from .creation import _complex_to_real_dtype from .layer_function_generator import generate_layer_fn from .manipulation import cast - from .ops import abs # noqa: F401 from .ops import acos # noqa: F401 from .ops import acosh # noqa: F401 @@ -81,7 +80,6 @@ from .ops import square # noqa: F401 from .ops import tan # noqa: F401 - __all__ = [] _supported_int_dtype_ = [ From 7ef2ed7ae07b9213fc3cab86be5626644c7091cf Mon Sep 17 00:00:00 2001 From: SigureMo Date: Sat, 26 Nov 2022 01:52:52 +0800 Subject: [PATCH 5/7] resolve circular import --- python/paddle/common_ops_import.py | 4 +++- python/paddle/tensor/attribute.py | 3 +-- python/paddle/tensor/math.py | 9 ++------- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/python/paddle/common_ops_import.py b/python/paddle/common_ops_import.py index 47bce838936d44..d759bf1d9130b6 100644 --- a/python/paddle/common_ops_import.py +++ b/python/paddle/common_ops_import.py @@ -37,5 +37,7 @@ convert_dtype, ) from paddle.fluid.layers import fill_constant, utils, scale # noqa: F401 -from paddle.tensor.layer_function_generator import templatedoc # noqa: F401 +from paddle.fluid.layers.layer_function_generator import ( # noqa: F401 + templatedoc, +) import paddle.fluid as fluid # noqa: F401 diff --git a/python/paddle/tensor/attribute.py b/python/paddle/tensor/attribute.py index 077633d06326fe..d6f08f676b8ae2 100644 --- a/python/paddle/tensor/attribute.py +++ b/python/paddle/tensor/attribute.py @@ -22,10 +22,9 @@ from ..fluid.data_feeder import check_type, check_variable_and_dtype from ..fluid.framework import _in_legacy_dygraph, in_dygraph_mode from ..framework import LayerHelper, core +from ..static import Variable from .creation import _complex_to_real_dtype, assign -from ..static import Variable # isort: skip - __all__ = [] diff --git a/python/paddle/tensor/math.py b/python/paddle/tensor/math.py index d10782f382639d..40dd2291e4c0a6 100644 --- a/python/paddle/tensor/math.py +++ b/python/paddle/tensor/math.py @@ -21,12 +21,7 @@ import paddle from paddle import _C_ops, _legacy_C_ops -from paddle.common_ops_import import ( - VarDesc, - dygraph_only, - dygraph_utils, - templatedoc, -) +from paddle.common_ops_import import VarDesc, dygraph_only, dygraph_utils from ..fluid.data_feeder import ( check_dtype, @@ -48,7 +43,7 @@ ) from ..static import Variable from .creation import _complex_to_real_dtype -from .layer_function_generator import generate_layer_fn +from .layer_function_generator import generate_layer_fn, templatedoc from .manipulation import cast from .ops import abs # noqa: F401 from .ops import acos # noqa: F401 From 77a0bad45e5725d6469b5a81b276d47866753836 Mon Sep 17 00:00:00 2001 From: SigureMo Date: Sat, 26 Nov 2022 01:58:45 +0800 Subject: [PATCH 6/7] sort common_ops_import --- python/paddle/common_ops_import.py | 39 +++++++++++++++--------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/python/paddle/common_ops_import.py b/python/paddle/common_ops_import.py index d759bf1d9130b6..8274981e8a241f 100644 --- a/python/paddle/common_ops_import.py +++ b/python/paddle/common_ops_import.py @@ -11,33 +11,32 @@ # 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. -from paddle.fluid.layer_helper import LayerHelper # noqa: F401 -from paddle.fluid.param_attr import ParamAttr # noqa: F401 +import paddle.fluid as fluid # noqa: F401 +from paddle.fluid import core, dygraph_utils # noqa: F401 +from paddle.fluid.core import VarDesc # noqa: F401 +from paddle.fluid.data_feeder import ( # noqa: F401 + check_dtype, + check_type, + check_variable_and_dtype, + convert_dtype, +) from paddle.fluid.framework import ( # noqa: F401 - convert_np_dtype_to_dtype_, + OpProtoHolder, + Variable, + _dygraph_tracer, + _in_legacy_dygraph, _non_static_mode, _varbase_creator, - in_dygraph_mode, - _in_legacy_dygraph, -) -from paddle.fluid.framework import ( # noqa: F401 - device_guard, + convert_np_dtype_to_dtype_, default_main_program, + device_guard, dygraph_only, - _dygraph_tracer, + in_dygraph_mode, ) -from paddle.fluid.framework import OpProtoHolder, Variable # noqa: F401 from paddle.fluid.initializer import Constant # noqa: F401 -from paddle.fluid.core import VarDesc # noqa: F401 -from paddle.fluid import core, dygraph_utils # noqa: F401 -from paddle.fluid.data_feeder import ( # noqa: F401 - check_type, - check_dtype, - check_variable_and_dtype, - convert_dtype, -) -from paddle.fluid.layers import fill_constant, utils, scale # noqa: F401 +from paddle.fluid.layer_helper import LayerHelper # noqa: F401 +from paddle.fluid.layers import fill_constant, scale, utils # noqa: F401 from paddle.fluid.layers.layer_function_generator import ( # noqa: F401 templatedoc, ) -import paddle.fluid as fluid # noqa: F401 +from paddle.fluid.param_attr import ParamAttr # noqa: F401 From eba476f5abf42322f85a15a9e2a9e60a21f2df12 Mon Sep 17 00:00:00 2001 From: SigureMo Date: Sat, 26 Nov 2022 02:20:37 +0800 Subject: [PATCH 7/7] empty commit