diff --git a/python/paddle/fluid/dygraph/__init__.py b/python/paddle/fluid/dygraph/__init__.py index 551561428da72f932e34baad8ea36aa4722c6b21..1132ef393d552c878c8db27752c1f3e3280500d0 100644 --- a/python/paddle/fluid/dygraph/__init__.py +++ b/python/paddle/fluid/dygraph/__init__.py @@ -51,8 +51,6 @@ from .amp import * from .math_op_patch import monkey_patch_math_varbase -from .inplace_utils import inplace_apis_in_dygraph_only - __all__ = [] __all__ += layers.__all__ __all__ += base.__all__ diff --git a/python/paddle/fluid/dygraph/nn.py b/python/paddle/fluid/dygraph/nn.py index 2fa3945987dd165ea114e7917913410a4a2c4a29..16148e87ee76956ca330fe4aa95d6d7f4cb6ade4 100644 --- a/python/paddle/fluid/dygraph/nn.py +++ b/python/paddle/fluid/dygraph/nn.py @@ -30,6 +30,7 @@ from ..framework import ( in_dygraph_mode, _in_legacy_dygraph, ) + from ..data_feeder import ( convert_dtype, check_variable_and_dtype, diff --git a/python/paddle/nn/functional/activation.py b/python/paddle/nn/functional/activation.py index 89bb63643f6a1524d3d72dbe9db66780e3f54940..92d6c25ea3ac62e11d37deb42b0aaec1712fb556 100644 --- a/python/paddle/nn/functional/activation.py +++ b/python/paddle/nn/functional/activation.py @@ -15,9 +15,9 @@ import paddle from paddle import _C_ops, _legacy_C_ops, in_dynamic_mode from paddle.framework import core +from paddle.utils.inplace_utils import inplace_apis_in_dygraph_only from ...fluid.data_feeder import check_dtype, check_variable_and_dtype -from ...fluid.dygraph.inplace_utils import inplace_apis_in_dygraph_only from ...fluid.framework import ( _in_legacy_dygraph, convert_np_dtype_to_dtype_, diff --git a/python/paddle/tensor/manipulation.py b/python/paddle/tensor/manipulation.py index 06a229106347c1ec8c98eadfedc78f7e4454c8ac..676a97b840870edce1e95cf20c55b24b53bda337 100644 --- a/python/paddle/tensor/manipulation.py +++ b/python/paddle/tensor/manipulation.py @@ -20,6 +20,7 @@ import numpy as np import paddle from paddle import _C_ops, _legacy_C_ops +from paddle.utils.inplace_utils import inplace_apis_in_dygraph_only from ..common_ops_import import _varbase_creator, fill_constant from ..fluid.data_feeder import ( @@ -28,7 +29,6 @@ from ..fluid.data_feeder import ( 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 from ..framework import ( diff --git a/python/paddle/tensor/math.py b/python/paddle/tensor/math.py index 883d3c0e3aeb4b6e3d07cc9428aac016c656348d..6f3a5c58656118d56d714a166a67046ba3e8ae8f 100644 --- a/python/paddle/tensor/math.py +++ b/python/paddle/tensor/math.py @@ -14,7 +14,6 @@ """ math functions """ - # TODO: define math functions import numpy as np @@ -23,13 +22,15 @@ import paddle from paddle import _C_ops, _legacy_C_ops from paddle.common_ops_import import VarDesc, dygraph_only, dygraph_utils +# TODO: define math functions +from paddle.utils.inplace_utils import inplace_apis_in_dygraph_only + from ..fluid.data_feeder import ( 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 elementwise_sub, utils from ..framework import ( LayerHelper, diff --git a/python/paddle/fluid/dygraph/inplace_utils.py b/python/paddle/utils/inplace_utils.py similarity index 89% rename from python/paddle/fluid/dygraph/inplace_utils.py rename to python/paddle/utils/inplace_utils.py index fb27a5674b7d8b5eff301a26df77cde39dee8512..2ee809facab4feb1107d69bb298367c5706444be 100644 --- a/python/paddle/fluid/dygraph/inplace_utils.py +++ b/python/paddle/utils/inplace_utils.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved. +# Copyright (c) 2022 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. @@ -12,11 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -from ..wrapped_decorator import wrap_decorator -from ..framework import _non_static_mode import warnings import paddle from paddle import _C_ops, _legacy_C_ops +from paddle.fluid.framework import _non_static_mode +from paddle.fluid.wrapped_decorator import wrap_decorator # NOTE(pangyoki): The Inplace APIs with underline(`_`) is only valid for the method of calling `_C_ops`