diff --git a/python/paddle/fluid/tests/unittests/test_directory_migration.py b/python/paddle/fluid/tests/unittests/test_directory_migration.py index 4212b73f214e8b0e9787beea230cbbe24cb8fb44..6968c6041baaf3dafc1e9b4251f4b63f59551f61 100644 --- a/python/paddle/fluid/tests/unittests/test_directory_migration.py +++ b/python/paddle/fluid/tests/unittests/test_directory_migration.py @@ -48,7 +48,6 @@ class TestDirectory(unittest.TestCase): 'paddle.distributed.ParallelEnv', 'paddle.DataParallel', 'paddle.jit', - 'paddle.jit.TracedLayer', 'paddle.jit.to_static', 'paddle.jit.ProgramTranslator', 'paddle.jit.TranslatedLayer', diff --git a/python/paddle/fluid/tests/unittests/test_imperative_mnist.py b/python/paddle/fluid/tests/unittests/test_imperative_mnist.py index d4a26eb4cef729103841855b300fa50ca358465c..7c8977ee1815e891cad9772db72ed8e6cdcb4601 100644 --- a/python/paddle/fluid/tests/unittests/test_imperative_mnist.py +++ b/python/paddle/fluid/tests/unittests/test_imperative_mnist.py @@ -21,7 +21,7 @@ from utils import DyGraphProgramDescTracerTestHelper import paddle import paddle.fluid as fluid from paddle.fluid import core -from paddle.fluid.framework import _in_legacy_dygraph, _test_eager_guard +from paddle.fluid.framework import _test_eager_guard from paddle.fluid.optimizer import SGDOptimizer from paddle.nn import Linear @@ -153,19 +153,7 @@ class TestImperativeMnist(unittest.TestCase): dy_x_data = img.numpy() label = data[1] label.stop_gradient = True - - if batch_id % 10 == 0 and _in_legacy_dygraph(): - cost, traced_layer = paddle.jit.TracedLayer.trace( - mnist, inputs=img - ) - if program is not None: - self.assertTrue(program, traced_layer.program) - program = traced_layer.program - traced_layer.save_inference_model( - './infer_imperative_mnist' - ) - else: - cost = mnist(img) + cost = mnist(img) if traced_layer is not None: cost_static = traced_layer([img]) diff --git a/python/paddle/fluid/tests/unittests/test_imperative_ptb_rnn.py b/python/paddle/fluid/tests/unittests/test_imperative_ptb_rnn.py index 55f7f1ec31f185d78b6996d65d8804fce8eee64b..2a59dd396f000b9400f09d6f0a16bfeefee03c05 100644 --- a/python/paddle/fluid/tests/unittests/test_imperative_ptb_rnn.py +++ b/python/paddle/fluid/tests/unittests/test_imperative_ptb_rnn.py @@ -16,7 +16,7 @@ import unittest import numpy as np from test_imperative_base import new_program_scope -from utils import DyGraphProgramDescTracerTestHelper, is_equal_program +from utils import DyGraphProgramDescTracerTestHelper import paddle import paddle.fluid as fluid @@ -24,9 +24,8 @@ import paddle.fluid.core as core import paddle.fluid.framework as framework from paddle.fluid.dygraph.base import to_variable from paddle.fluid.dygraph.nn import Embedding -from paddle.fluid.framework import _in_legacy_dygraph, _test_eager_guard +from paddle.fluid.framework import _test_eager_guard from paddle.fluid.optimizer import SGDOptimizer -from paddle.jit import TracedLayer class SimpleLSTMRNN(fluid.Layer): @@ -298,25 +297,8 @@ class TestDygraphPtbRnn(unittest.TestCase): y = to_variable(y_data) init_hidden = to_variable(init_hidden_data) init_cell = to_variable(init_cell_data) - if i % 5 == 0 and _in_legacy_dygraph(): - outs, traced_layer = TracedLayer.trace( - ptb_model, [x, y, init_hidden, init_cell] - ) - outs_static = traced_layer([x, y, init_hidden, init_cell]) - helper.assertEachVar(outs, outs_static) - - if program is not None: - self.assertTrue( - is_equal_program(traced_layer.program, program) - ) - program = traced_layer.program - - traced_layer.save_inference_model( - './infe_imperative_ptb_rnn', feed=list(range(4)) - ) - else: - outs = ptb_model(x, y, init_hidden, init_cell) + outs = ptb_model(x, y, init_hidden, init_cell) dy_loss, last_hidden, last_cell = outs diff --git a/python/paddle/fluid/tests/unittests/test_imperative_resnet.py b/python/paddle/fluid/tests/unittests/test_imperative_resnet.py index a8cf1fc8ce86af313c6fc6c0b92ec686fda941e0..559ea6ff71e86ef478e4c9b2aff5c61881f4450e 100644 --- a/python/paddle/fluid/tests/unittests/test_imperative_resnet.py +++ b/python/paddle/fluid/tests/unittests/test_imperative_resnet.py @@ -16,15 +16,14 @@ import unittest import numpy as np from test_imperative_base import new_program_scope -from utils import DyGraphProgramDescTracerTestHelper, is_equal_program +from utils import DyGraphProgramDescTracerTestHelper import paddle import paddle.fluid as fluid from paddle.fluid import BatchNorm, core from paddle.fluid.dygraph.base import to_variable -from paddle.fluid.framework import _in_legacy_dygraph, _test_eager_guard +from paddle.fluid.framework import _test_eager_guard from paddle.fluid.layer_helper import LayerHelper -from paddle.jit import TracedLayer # NOTE(zhiqiu): run with FLAGS_cudnn_deterministic=1 @@ -301,20 +300,7 @@ class TestDygraphResnet(unittest.TestCase): label.stop_gradient = True out = None - if batch_id % 5 == 0 and _in_legacy_dygraph(): - out, traced_layer = TracedLayer.trace(resnet, img) - if program is not None: - self.assertTrue( - is_equal_program(program, traced_layer.program) - ) - - traced_layer.save_inference_model( - './infer_imperative_resnet' - ) - - program = traced_layer.program - else: - out = resnet(img) + out = resnet(img) if traced_layer is not None: resnet.eval() diff --git a/python/paddle/fluid/tests/unittests/test_imperative_transformer_sorted_gradient.py b/python/paddle/fluid/tests/unittests/test_imperative_transformer_sorted_gradient.py index 0bd69f035910427307bf2e4b64ec1bff18141c76..3cc07ee6a3378b18da823a3fe94f59f71481b6a0 100644 --- a/python/paddle/fluid/tests/unittests/test_imperative_transformer_sorted_gradient.py +++ b/python/paddle/fluid/tests/unittests/test_imperative_transformer_sorted_gradient.py @@ -23,12 +23,11 @@ import paddle.nn.functional as F from paddle.fluid import Embedding, Layer, core from paddle.fluid.dygraph import guard, to_variable from paddle.fluid.framework import _in_legacy_dygraph, _test_eager_guard -from paddle.jit import TracedLayer from paddle.nn import Linear np.set_printoptions(suppress=True) -from utils import DyGraphProgramDescTracerTestHelper, is_equal_program +from utils import DyGraphProgramDescTracerTestHelper # Copy from models @@ -1171,27 +1170,7 @@ class TestDygraphTransformerSortGradient(unittest.TestCase): for i in range(batch_num): enc_inputs, dec_inputs, label, weights = create_data() - if False: - outs, traced_layer = TracedLayer.trace( - transformer, [enc_inputs, dec_inputs, label, weights] - ) - - ins_static = enc_inputs + dec_inputs + [label, weights] - outs_static = traced_layer(ins_static) - helper.assertEachVar(outs, outs_static) - if program is not None: - self.assertTrue( - is_equal_program(program, traced_layer.program) - ) - - program = traced_layer.program - traced_layer.save_inference_model( - './infer_imperative_transformer', - feed=list(range(len(ins_static))), - fetch=list(range(len(outs_static))), - ) - else: - outs = transformer(enc_inputs, dec_inputs, label, weights) + outs = transformer(enc_inputs, dec_inputs, label, weights) dy_sum_cost, dy_avg_cost, dy_predict, dy_token_num = outs diff --git a/python/paddle/fluid/tests/unittests/test_op_function_generator.py b/python/paddle/fluid/tests/unittests/test_op_function_generator.py index 53edabb18236c8ade2425b3a94c54f363b0561ab..f3991150193c345a8db41f9822edc037a7827c99 100644 --- a/python/paddle/fluid/tests/unittests/test_op_function_generator.py +++ b/python/paddle/fluid/tests/unittests/test_op_function_generator.py @@ -20,8 +20,6 @@ import paddle import paddle.fluid as fluid import paddle.fluid.layers as layers from paddle import _legacy_C_ops -from paddle.fluid.framework import in_dygraph_mode -from paddle.jit.api import TracedLayer class TestTracedLayer(fluid.dygraph.Layer): @@ -93,20 +91,6 @@ class TestVariable(unittest.TestCase): np.testing.assert_array_equal(y_grad, loss.gradient() * a) fluid.set_flags({"FLAGS_retain_grad_for_all_tensor": False}) - def test_traced_layer(self): - if in_dygraph_mode(): - return - with fluid.dygraph.guard(): - layer = TestTracedLayer("test_traced_layer") - a = np.random.uniform(-1, 1, self.shape).astype(self.dtype) - x = fluid.dygraph.to_variable(a) - res_dygraph, static_layer = TracedLayer.trace( - layer, inputs=x - ) # dygraph out - res_static_graph = static_layer([x])[0] - - np.testing.assert_array_equal(res_dygraph.numpy(), res_static_graph) - if __name__ == '__main__': unittest.main() diff --git a/python/paddle/jit/__init__.py b/python/paddle/jit/__init__.py index 4f32b7e29c60d3939de76e07a3ed6ad73010fe51..af4aad939acbe5e6d71d49a3f550eb30548fab1b 100644 --- a/python/paddle/jit/__init__.py +++ b/python/paddle/jit/__init__.py @@ -15,7 +15,6 @@ from .api import save from .api import load -from .api import TracedLayer from .api import set_code_level from .api import set_verbosity from .api import declarative as to_static @@ -34,5 +33,4 @@ __all__ = [ # noqa 'set_code_level', 'set_verbosity', 'not_to_static', - 'TracedLayer', ] diff --git a/python/paddle/jit/api.py b/python/paddle/jit/api.py index 95b07a989a7a7325d20e29ba583c02f3803460cd..ea30bb658b89f742cdac6619ff6c8aa6112b8ed6 100644 --- a/python/paddle/jit/api.py +++ b/python/paddle/jit/api.py @@ -74,9 +74,7 @@ from paddle.fluid.framework import dygraph_only, _non_static_mode from paddle.fluid.wrapped_decorator import wrap_decorator __all__ = [ - 'TracedLayer', 'declarative', - 'dygraph_to_static_func', 'set_code_level', 'set_verbosity', 'save', diff --git a/python/paddle/jit/dy2static/__init__.py b/python/paddle/jit/dy2static/__init__.py index 89204e62cee14329ed910726a71de103a26960dc..b55d5d672c2b118545d896ea2e0a5135ec76eb7c 100644 --- a/python/paddle/jit/dy2static/__init__.py +++ b/python/paddle/jit/dy2static/__init__.py @@ -36,6 +36,6 @@ from .convert_operators import convert_shape_compare # noqa: F401 from .assert_transformer import AssertTransformer from .ast_transformer import DygraphToStaticAst from .program_translator import convert_to_static -from .static_analysis import * # noqa: F403 +from .static_analysis import AstNodeWrapper, NodeVarType, StaticAnalysisVisitor __all__ = [] diff --git a/python/paddle/jit/dy2static/assert_transformer.py b/python/paddle/jit/dy2static/assert_transformer.py index 81bad1111b19205ac0f8dcd55855c9bacddba1c5..5fa5df0722886d3df3ea3546bad08a99e0bfc0b6 100644 --- a/python/paddle/jit/dy2static/assert_transformer.py +++ b/python/paddle/jit/dy2static/assert_transformer.py @@ -22,7 +22,7 @@ from .base_transformer import ( BaseTransformer, ) -__all__ = ['AssertTransformer'] +__all__ = [] class AssertTransformer(BaseTransformer): diff --git a/python/paddle/jit/dy2static/ast_transformer.py b/python/paddle/jit/dy2static/ast_transformer.py index 2acbda4c8b2aad51bbb1b8d3b018827acbee5477..9d61f6475db0cbc443f287e3886971e512f2ad25 100644 --- a/python/paddle/jit/dy2static/ast_transformer.py +++ b/python/paddle/jit/dy2static/ast_transformer.py @@ -71,7 +71,7 @@ from .decorator_transformer import ( from . import logging_utils from .utils import ast_to_source_code -__all__ = ['DygraphToStaticAst'] +__all__ = [] def apply_optimization(transformers): diff --git a/python/paddle/jit/dy2static/base_transformer.py b/python/paddle/jit/dy2static/base_transformer.py index 166753d05f57a41201d04202e840e73a31a42df1..2956d91deeee45428ab3843b81d58afb202bc3d5 100644 --- a/python/paddle/jit/dy2static/base_transformer.py +++ b/python/paddle/jit/dy2static/base_transformer.py @@ -27,6 +27,8 @@ from paddle.jit.dy2static.utils import ( get_attribute_full_name, ) +__all__ = [] + class BaseTransformer(gast.NodeTransformer): def visit(self, node): diff --git a/python/paddle/jit/dy2static/basic_api_transformer.py b/python/paddle/jit/dy2static/basic_api_transformer.py index 89fa0738b9a190413fcd26be8e3263f55f3859b9..f35bfb8625674ce97c87c8d9a797409fe8de0a37 100644 --- a/python/paddle/jit/dy2static/basic_api_transformer.py +++ b/python/paddle/jit/dy2static/basic_api_transformer.py @@ -23,6 +23,8 @@ from .base_transformer import ( BaseTransformer, ) +__all__ = [] + class BasicApiTransformer(BaseTransformer): """ diff --git a/python/paddle/jit/dy2static/break_continue_transformer.py b/python/paddle/jit/dy2static/break_continue_transformer.py index 670cc842f349b5f52b276a998244d56086a25f8d..e3de6e03ea704369a70fff64ca1222ebc5d1ce18 100644 --- a/python/paddle/jit/dy2static/break_continue_transformer.py +++ b/python/paddle/jit/dy2static/break_continue_transformer.py @@ -27,7 +27,7 @@ from .base_transformer import ( ForNodeVisitor, ) -__all__ = ['BreakContinueTransformer'] +__all__ = [] BREAK_NAME_PREFIX = '__break' CONTINUE_NAME_PREFIX = '__continue' diff --git a/python/paddle/jit/dy2static/call_transformer.py b/python/paddle/jit/dy2static/call_transformer.py index 012c73b99f65434070a32cc4f283eab8db1bac5e..fa1d71cbb4f53e145bae4239d154a3a338888afd 100644 --- a/python/paddle/jit/dy2static/call_transformer.py +++ b/python/paddle/jit/dy2static/call_transformer.py @@ -25,6 +25,8 @@ from .base_transformer import ( PDB_SET = "pdb.set_trace" +__all__ = [] + class CallTransformer(BaseTransformer): """ diff --git a/python/paddle/jit/dy2static/cast_transformer.py b/python/paddle/jit/dy2static/cast_transformer.py index 96a504d70cdb582fd3f5ff92d97775e9000a9103..c0d22d93a90707e7c2fde971bad80223a9069556 100644 --- a/python/paddle/jit/dy2static/cast_transformer.py +++ b/python/paddle/jit/dy2static/cast_transformer.py @@ -22,6 +22,8 @@ from .base_transformer import ( BaseTransformer, ) +__all__ = [] + class CastTransformer(BaseTransformer): """ diff --git a/python/paddle/jit/dy2static/convert_call_func.py b/python/paddle/jit/dy2static/convert_call_func.py index da0560cb346923cc99ed7544fd68d39143ee72c5..3a2ffa70fc946fadd6e0cd9969366b77865631ec 100644 --- a/python/paddle/jit/dy2static/convert_call_func.py +++ b/python/paddle/jit/dy2static/convert_call_func.py @@ -40,7 +40,7 @@ from paddle.jit.dy2static.logging_utils import ( from paddle.jit.dy2static.utils import is_paddle_func, unwrap from paddle.fluid.dygraph.layers import Layer -__all__ = ["convert_call"] +__all__ = [] # The api(s) should be considered as plain function and convert diff --git a/python/paddle/jit/dy2static/convert_operators.py b/python/paddle/jit/dy2static/convert_operators.py index 1d3e23a4b96b724ff9d19c15bed2b4c44f475ed8..f67e1dd1585b35846ecb47783de6ff7faa85cd7d 100644 --- a/python/paddle/jit/dy2static/convert_operators.py +++ b/python/paddle/jit/dy2static/convert_operators.py @@ -15,7 +15,7 @@ import re import paddle from paddle.fluid.data_feeder import convert_dtype -from paddle.jit.dy2static.variable_trans_func import ( +from .variable_trans_func import ( to_static_variable, ) from paddle.fluid.framework import core, Variable @@ -43,10 +43,13 @@ from .return_transformer import ( from paddle.jit.dy2static.utils import ( UndefinedVar, Dygraph2StaticException, + GetterSetterHelper, ) -from paddle.jit.dy2static.utils import GetterSetterHelper + from paddle.fluid.layers.utils import copy_mutable_vars +__all__ = [] + def convert_attr(x, attr): if isinstance(x, Variable) and attr == "size": diff --git a/python/paddle/jit/dy2static/create_variable_transformer.py b/python/paddle/jit/dy2static/create_variable_transformer.py index 808a047c3a283802aecb1d8ad479555e947253ee..ae34266af8d23830248304ef4d009dd4a0357af1 100644 --- a/python/paddle/jit/dy2static/create_variable_transformer.py +++ b/python/paddle/jit/dy2static/create_variable_transformer.py @@ -12,13 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -from paddle.jit.dy2static.static_analysis import ( +from .static_analysis import ( AstNodeWrapper, ) -from paddle.jit.dy2static.utils import ( +from .utils import ( FunctionNameLivenessAnalysis, ) -from paddle.jit.dy2static.variable_trans_func import ( +from .variable_trans_func import ( create_undefined_var, ) from .base_transformer import ( @@ -26,6 +26,9 @@ from .base_transformer import ( ) +__all__ = [] + + class CreateVariableTransformer(BaseTransformer): """ """ diff --git a/python/paddle/jit/dy2static/decorator_transformer.py b/python/paddle/jit/dy2static/decorator_transformer.py index cd33f8625a3b07813d5cc09973470c5a05667e69..01387fbc672b6fa7f1eaf57180c75b92d34f8c19 100644 --- a/python/paddle/jit/dy2static/decorator_transformer.py +++ b/python/paddle/jit/dy2static/decorator_transformer.py @@ -14,13 +14,13 @@ # limitations under the License. from paddle.utils import gast -from paddle.jit.dy2static.static_analysis import ( +from .static_analysis import ( AstNodeWrapper, ) from .base_transformer import ( BaseTransformer, ) -from paddle.jit.dy2static.utils import ( +from .utils import ( RE_PYNAME, RE_PYMODULE, ast_to_source_code, @@ -29,6 +29,8 @@ import warnings import re +__all__ = [] + IGNORE_NAMES = [ 'declarative', 'to_static', diff --git a/python/paddle/jit/dy2static/early_return_transformer.py b/python/paddle/jit/dy2static/early_return_transformer.py index 72076fb3cd8839bbb49f41e874ade96e27b99780..61cef0f61b565623367ea21ab4366d2a26619fe0 100644 --- a/python/paddle/jit/dy2static/early_return_transformer.py +++ b/python/paddle/jit/dy2static/early_return_transformer.py @@ -13,14 +13,14 @@ # limitations under the License. from paddle.utils import gast -from paddle.jit.dy2static.static_analysis import ( +from .static_analysis import ( AstNodeWrapper, ) from .base_transformer import ( BaseTransformer, ) -__all__ = ['EarlyReturnTransformer'] +__all__ = [] class EarlyReturnTransformer(BaseTransformer): diff --git a/python/paddle/jit/dy2static/function_spec.py b/python/paddle/jit/dy2static/function_spec.py index 370fb36bcfb91f41bbda1dd3382b227141d439d6..431f639a8197d7b5e3fa7a35dd79a8958df1f79e 100644 --- a/python/paddle/jit/dy2static/function_spec.py +++ b/python/paddle/jit/dy2static/function_spec.py @@ -32,6 +32,8 @@ from .utils import ( func_to_source_code, ) +__all__ = [] + class FunctionSpec: """ diff --git a/python/paddle/jit/dy2static/logging_utils.py b/python/paddle/jit/dy2static/logging_utils.py index ca36cb0b35aa5e3d49ce9649af828ab200273797..d3b806a5d7cd0a80b9aad16fa8a2f6d47aa4a891 100644 --- a/python/paddle/jit/dy2static/logging_utils.py +++ b/python/paddle/jit/dy2static/logging_utils.py @@ -18,7 +18,7 @@ import threading from paddle.fluid import log_helper from .utils import ast_to_source_code -__all__ = ["TranslatorLogger", "set_verbosity", "set_code_level"] +__all__ = [] VERBOSITY_ENV_NAME = 'TRANSLATOR_VERBOSITY' CODE_LEVEL_ENV_NAME = 'TRANSLATOR_CODE_LEVEL' diff --git a/python/paddle/jit/dy2static/logical_transformer.py b/python/paddle/jit/dy2static/logical_transformer.py index cd4d27ac73e57919f2d474432e7edb9e0824d042..59860d23bd17beb89614de367a5d3e00c1e21e82 100644 --- a/python/paddle/jit/dy2static/logical_transformer.py +++ b/python/paddle/jit/dy2static/logical_transformer.py @@ -13,11 +13,13 @@ # limitations under the License. from paddle.utils import gast -from paddle.jit.dy2static.utils import ast_to_source_code +from .utils import ast_to_source_code from .base_transformer import ( BaseTransformer, ) +__all__ = [] + cmpop_type_to_str = { gast.Eq: "==", gast.NotEq: "!=", diff --git a/python/paddle/jit/dy2static/loop_transformer.py b/python/paddle/jit/dy2static/loop_transformer.py index 4bb99e830b35016d57fcafb0a1bc23bdede017c8..fff46e56ffc9083d4d318e4cb558803ec695746c 100644 --- a/python/paddle/jit/dy2static/loop_transformer.py +++ b/python/paddle/jit/dy2static/loop_transformer.py @@ -17,22 +17,16 @@ from paddle.utils import gast from collections import defaultdict from paddle.fluid import unique_name -from paddle.jit.dy2static.static_analysis import ( - AstNodeWrapper, -) -from paddle.jit.dy2static.static_analysis import NodeVarType -from paddle.jit.dy2static.static_analysis import ( - StaticAnalysisVisitor, -) -from paddle.jit.dy2static.utils import ast_to_source_code -from paddle.jit.dy2static.utils import get_attribute_full_name -from paddle.jit.dy2static.utils import ( +from .static_analysis import AstNodeWrapper, NodeVarType, StaticAnalysisVisitor +from .utils import ( + ast_to_source_code, + get_attribute_full_name, create_nonlocal_stmt_nodes, create_get_args_node, create_set_args_node, -) -from paddle.jit.dy2static.utils import ( FunctionNameLivenessAnalysis, + GetterSetterHelper, + create_name_str, ) from .ifelse_transformer import ARGS_NAME from .base_transformer import ( @@ -41,12 +35,8 @@ from .base_transformer import ( ForNodeVisitor, ) -from paddle.jit.dy2static.utils import ( - GetterSetterHelper, - create_name_str, -) -__all__ = ['LoopTransformer', 'NameVisitor'] +__all__ = [] WHILE_CONDITION_PREFIX = 'while_condition' WHILE_BODY_PREFIX = 'while_body' diff --git a/python/paddle/jit/dy2static/origin_info.py b/python/paddle/jit/dy2static/origin_info.py index 7f3c7f719a53959a612fcf27d25c6d3b0da25b87..3ed9726772f95103c70a0633ef0157676aa5cf3d 100644 --- a/python/paddle/jit/dy2static/origin_info.py +++ b/python/paddle/jit/dy2static/origin_info.py @@ -24,6 +24,8 @@ from paddle.fluid.framework import Program from collections.abc import Sequence +__all__ = [] + class Location: """ diff --git a/python/paddle/jit/dy2static/partial_program.py b/python/paddle/jit/dy2static/partial_program.py index d1ebdbe5ccc57feb9a147e3dcc408bace103e96f..a4afeee0d721ae63dfd0629aec5066e34f941702 100644 --- a/python/paddle/jit/dy2static/partial_program.py +++ b/python/paddle/jit/dy2static/partial_program.py @@ -44,6 +44,8 @@ from paddle.fluid.dygraph.amp.auto_cast import ( ) from paddle import _legacy_C_ops +__all__ = [] + class NestSequence: """ diff --git a/python/paddle/jit/dy2static/program_translator.py b/python/paddle/jit/dy2static/program_translator.py index 37a85fc078bc9ab0291cba374a31c0e099df7449..b183537e2d10b48b5776be8b1fdceb4f3142f4f8 100644 --- a/python/paddle/jit/dy2static/program_translator.py +++ b/python/paddle/jit/dy2static/program_translator.py @@ -57,7 +57,7 @@ from .function_spec import ( from .ast_transformer import DygraphToStaticAst -__all__ = ['ProgramTranslator', 'convert_to_static'] +__all__ = [] # For each traced function, we set `max_traced_program_count` = 10 to consider caching performance. # Once exceeding the threshold, we will raise warning to users to make sure the conversion is as expected. diff --git a/python/paddle/jit/dy2static/return_transformer.py b/python/paddle/jit/dy2static/return_transformer.py index 8aa96b615784686355eb740a7b957a60ad5f78e0..0782bde83d36a43babd8744ebbed07bb1279d6e5 100644 --- a/python/paddle/jit/dy2static/return_transformer.py +++ b/python/paddle/jit/dy2static/return_transformer.py @@ -15,22 +15,18 @@ from paddle.utils import gast from paddle.fluid import unique_name -from paddle.jit.dy2static.utils import index_in_list -from .break_continue_transformer import ( - ForToWhileTransformer, +from .utils import ( + index_in_list, + ast_to_source_code, + Dygraph2StaticException, + ORIGI_INFO, ) -from paddle.jit.dy2static.utils import ast_to_source_code +from .break_continue_transformer import ForToWhileTransformer from .base_transformer import ( BaseTransformer, ) -from paddle.jit.dy2static.utils import Dygraph2StaticException -from paddle.jit.dy2static.utils import ORIGI_INFO - -__all__ = [ - 'RETURN_NO_VALUE_MAGIC_NUM', - 'RETURN_NO_VALUE_VAR_NAME', - 'ReturnTransformer', -] + +__all__ = [] # Constant for the name of the variable which stores the boolean state that we # should return diff --git a/python/paddle/jit/dy2static/static_analysis.py b/python/paddle/jit/dy2static/static_analysis.py index 5b6c3d1261c840100667a109f235f386529d1811..da3964e620963293aed0ae852d187fb81ef73245 100644 --- a/python/paddle/jit/dy2static/static_analysis.py +++ b/python/paddle/jit/dy2static/static_analysis.py @@ -22,7 +22,7 @@ from .utils import ( ast_to_source_code, ) -__all__ = ['AstNodeWrapper', 'NodeVarType', 'StaticAnalysisVisitor'] +__all__ = [] class NodeVarType: diff --git a/python/paddle/jit/dy2static/tensor_shape_transformer.py b/python/paddle/jit/dy2static/tensor_shape_transformer.py index ffdba7e790a77cdd9048b4bd250fe25f29d15f5b..94912d7e916905e436a675a247a5ba04e900768c 100644 --- a/python/paddle/jit/dy2static/tensor_shape_transformer.py +++ b/python/paddle/jit/dy2static/tensor_shape_transformer.py @@ -14,14 +14,16 @@ from paddle.utils import gast -from paddle.jit.dy2static.utils import ast_to_source_code -from paddle.jit.dy2static.static_analysis import ( +from .utils import ast_to_source_code +from .static_analysis import ( AstNodeWrapper, ) from .base_transformer import ( BaseTransformer, ) +__all__ = [] + class TensorShapeTransformer(BaseTransformer): """ diff --git a/python/paddle/jit/dy2static/typehint_transformer.py b/python/paddle/jit/dy2static/typehint_transformer.py index d5c23d1d7d73c1800430e951d5de21902f5b9012..129023ba3ed97deca0fef565686e325a05314c5d 100644 --- a/python/paddle/jit/dy2static/typehint_transformer.py +++ b/python/paddle/jit/dy2static/typehint_transformer.py @@ -20,6 +20,8 @@ from .base_transformer import ( BaseTransformer, ) +__all__ = [] + class TypeHintTransformer(BaseTransformer): """ diff --git a/python/paddle/jit/dy2static/variable_trans_func.py b/python/paddle/jit/dy2static/variable_trans_func.py index c98823242b40a091b917b5426e473df8080bf8e0..1501aa38fc12956bfb87f53323f21fb0a1935773 100644 --- a/python/paddle/jit/dy2static/variable_trans_func.py +++ b/python/paddle/jit/dy2static/variable_trans_func.py @@ -15,18 +15,13 @@ import paddle from paddle.utils import gast from paddle.fluid.framework import Variable -from paddle.jit.dy2static.utils import ( +from .utils import ( UndefinedVar, create_undefined_variable, ) from paddle.fluid.layers.utils import map_structure, is_sequence -__all__ = [ - 'create_bool_as_type', - 'create_fill_constant_node', - 'to_static_variable', - 'create_undefined_var', -] +__all__ = [] def create_undefined_var(name):