diff --git a/python/paddle/fluid/dygraph/dygraph_to_static/assert_transformer.py b/python/paddle/fluid/dygraph/dygraph_to_static/assert_transformer.py index bf51ed9391e38bb7895258b7c1befbc5ea2abd0d..fe70fd1094f581caf0ae028bb63ec1dc155928fc 100644 --- a/python/paddle/fluid/dygraph/dygraph_to_static/assert_transformer.py +++ b/python/paddle/fluid/dygraph/dygraph_to_static/assert_transformer.py @@ -37,8 +37,7 @@ class AssertTransformer(gast.NodeTransformer): def visit_Assert(self, node): convert_assert_node = gast.parse( - 'paddle.jit.dygraph_to_static.convert_operators.convert_assert({test}, {msg})'. - format( + 'paddle.jit.dy2static.convert_assert({test}, {msg})'.format( test=ast_to_source_code(node.test), msg=ast_to_source_code(node.msg) if node.msg else "")).body[0].value diff --git a/python/paddle/fluid/dygraph/dygraph_to_static/call_transformer.py b/python/paddle/fluid/dygraph/dygraph_to_static/call_transformer.py index 4b3940f233ee79e389862b5f04f8c90913b01046..c2481d16825ec8d5ed3903da0414b4b03ae92e03 100644 --- a/python/paddle/fluid/dygraph/dygraph_to_static/call_transformer.py +++ b/python/paddle/fluid/dygraph/dygraph_to_static/call_transformer.py @@ -70,8 +70,7 @@ class CallTransformer(gast.NodeTransformer): if PDB_SET in func_str: return node - new_func_str = "paddle.jit.dygraph_to_static.convert_call({})".format( - func_str) + new_func_str = "paddle.jit.dy2static.convert_call({})".format(func_str) new_func_ast = gast.parse(new_func_str).body[0].value node.func = new_func_ast diff --git a/python/paddle/fluid/dygraph/dygraph_to_static/cast_transformer.py b/python/paddle/fluid/dygraph/dygraph_to_static/cast_transformer.py index d724638f59d1ab561da2b6d616f077a2cea87963..1171b5dbdfa22a21714de53ace9a8d11283bc013 100644 --- a/python/paddle/fluid/dygraph/dygraph_to_static/cast_transformer.py +++ b/python/paddle/fluid/dygraph/dygraph_to_static/cast_transformer.py @@ -39,7 +39,7 @@ class CastTransformer(gast.NodeTransformer): func_str = ast_to_source_code(node.func).strip() if func_str in self._castable_type and len(node.args) > 0: args_str = ast_to_source_code(node.args[0]).strip() - new_func_str = "paddle.jit.dygraph_to_static.convert_operators.convert_var_dtype({}, '{}')".format( + new_func_str = "paddle.jit.dy2static.convert_var_dtype({}, '{}')".format( args_str, func_str) new_node = gast.parse(new_func_str).body[0].value return new_node diff --git a/python/paddle/fluid/dygraph/dygraph_to_static/ifelse_transformer.py b/python/paddle/fluid/dygraph/dygraph_to_static/ifelse_transformer.py index ef8871a5fc53fc3fc7381a38119f4f9416e36a32..9c338546e233323ef50cb78c61907f803bf8cb17 100644 --- a/python/paddle/fluid/dygraph/dygraph_to_static/ifelse_transformer.py +++ b/python/paddle/fluid/dygraph/dygraph_to_static/ifelse_transformer.py @@ -310,8 +310,8 @@ def parse_cond_return(parent_vars_dict, if_vars_dict, else_vars_dict, After transformed, q and z are created in parent scope. For example, x, y = 5, 10 - q = paddle.jit.dygraph_to_static.variable_trans_func.data_layer_not_check(name='q', shape=[-1], dtype='float32') - z = paddle.jit.dygraph_to_static.variable_trans_func.data_layer_not_check(name='z', shape=[-1], dtype='float32') + q = paddle.jit.dy2static.data_layer_not_check(name='q', shape=[-1], dtype='float32') + z = paddle.jit.dy2static.data_layer_not_check(name='z', shape=[-1], dtype='float32') def true_func(x, y, q): x = x+1 @@ -460,7 +460,7 @@ def create_convert_ifelse_node(return_name_ids, false_func, is_if_expr=False): """ - Create `paddle.jit.dygraph_to_static.convert_operators.convert_ifelse( + Create `paddle.jit.dy2static.convert_ifelse( pred, true_fn, false_fn, true_args, false_args, return_vars)` to replace original `python if/else` statement. """ @@ -491,7 +491,7 @@ def create_convert_ifelse_node(return_name_ids, return_vars = create_name_nodes(return_name_ids) convert_ifelse_layer = gast.parse( - 'paddle.jit.dygraph_to_static.convert_operators.convert_ifelse(' + 'paddle.jit.dy2static.convert_ifelse(' '{pred}, {true_fn}, {false_fn}, {true_args}, {false_args}, {return_vars})'. format( pred=ast_to_source_code(pred), diff --git a/python/paddle/fluid/dygraph/dygraph_to_static/list_transformer.py b/python/paddle/fluid/dygraph/dygraph_to_static/list_transformer.py index de24fb16158b181395dc24f218b30761381152fd..9819f5fb72bbc48068629da93181f35d6087cecd 100644 --- a/python/paddle/fluid/dygraph/dygraph_to_static/list_transformer.py +++ b/python/paddle/fluid/dygraph/dygraph_to_static/list_transformer.py @@ -189,7 +189,7 @@ class ListTransformer(gast.NodeTransformer): elif isinstance(slice_node, gast.Index): value_code = ast_to_source_code(node.value) i = "paddle.cast(" \ - "x=paddle.jit.dygraph_to_static.variable_trans_func.to_static_variable({})," \ + "x=paddle.jit.dy2static.to_static_variable({})," \ "dtype='int64')".format(ast_to_source_code(slice_node)) assign_code = "{} = fluid.layers.array_write(x={}, i={}, array={})" \ .format(target_name, value_code, i, target_name) diff --git a/python/paddle/fluid/dygraph/dygraph_to_static/logical_transformer.py b/python/paddle/fluid/dygraph/dygraph_to_static/logical_transformer.py index f0089ddbd4b49b79b0ecf0bb8e9b589c88e02383..8f3690f26fc23775480034f30f20d8afe358ddde 100644 --- a/python/paddle/fluid/dygraph/dygraph_to_static/logical_transformer.py +++ b/python/paddle/fluid/dygraph/dygraph_to_static/logical_transformer.py @@ -34,7 +34,7 @@ class LogicalTransformer(gast.NodeTransformer): self.generic_visit(node) if isinstance(node.op, gast.Not): arg = ast_to_source_code(node.operand) - new_node_str = "paddle.jit.dygraph_to_static.convert_operators.convert_logical_not({})".format( + new_node_str = "paddle.jit.dy2static.convert_logical_not({})".format( arg) # NOTE: gast.parse returns Module(body=[expr(value=...)]) new_node = gast.parse(new_node_str).body[0].value @@ -67,7 +67,7 @@ class LogicalTransformer(gast.NodeTransformer): nodes = [pre_logic_node] + [post_logic_node] args = [ast_to_source_code(child) for child in nodes] - new_node_str = "paddle.jit.dygraph_to_static.convert_operators.convert_logical_{}(x={}, y={})".format( + new_node_str = "paddle.jit.dy2static.convert_logical_{}(x={}, y={})".format( api_type, args[0], args[1]) # NOTE: gast.parse return Module(body=[expr(...)]) new_node = gast.parse(new_node_str).body[0].value diff --git a/python/paddle/fluid/dygraph/dygraph_to_static/loop_transformer.py b/python/paddle/fluid/dygraph/dygraph_to_static/loop_transformer.py index 40b76e1421589e7b5fbcd430a6b05c2fb34887df..0b6c7c45b3804fbf07d707995658fb17e3880d80 100644 --- a/python/paddle/fluid/dygraph/dygraph_to_static/loop_transformer.py +++ b/python/paddle/fluid/dygraph/dygraph_to_static/loop_transformer.py @@ -46,7 +46,7 @@ def create_while_node(condition_name, body_name, loop_var_names): # For example: loop_var_names = [a, b, foo.x], the type of `a` or `b` is gast.Name, # but the type of `foo.x` gast.Attribute. - while_func_name = "paddle.jit.dygraph_to_static.convert_operators.convert_while_loop" + while_func_name = "paddle.jit.dy2static.convert_while_loop" while_node_str = "[{}] = {}({}, {}, [{}])".format( ",".join(loop_var_names), while_func_name, condition_name, body_name, ",".join(loop_var_names)) diff --git a/python/paddle/fluid/dygraph/dygraph_to_static/print_transformer.py b/python/paddle/fluid/dygraph/dygraph_to_static/print_transformer.py index c227c281bb15412beae07d1ec0ba24bfb83490ae..9d1ec35764b090cb786fef261e05eedd7f78247d 100644 --- a/python/paddle/fluid/dygraph/dygraph_to_static/print_transformer.py +++ b/python/paddle/fluid/dygraph/dygraph_to_static/print_transformer.py @@ -51,6 +51,5 @@ class PrintTransformer(gast.NodeTransformer): def _create_print_node(self, print_args): convert_print_func = gast.parse( - 'paddle.jit.dygraph_to_static.convert_operators.convert_print' - ).body[0].value + 'paddle.jit.dy2static.convert_print').body[0].value return gast.Call(func=convert_print_func, args=print_args, keywords=[]) diff --git a/python/paddle/fluid/dygraph/dygraph_to_static/tensor_shape_transformer.py b/python/paddle/fluid/dygraph/dygraph_to_static/tensor_shape_transformer.py index 33ff673067bf2cb4873f6b3f9bfbe7fb25e22703..6cdf2799624586a55d9e02d2050b16ac7f5f36e1 100644 --- a/python/paddle/fluid/dygraph/dygraph_to_static/tensor_shape_transformer.py +++ b/python/paddle/fluid/dygraph/dygraph_to_static/tensor_shape_transformer.py @@ -26,7 +26,7 @@ from paddle.fluid.dygraph.dygraph_to_static.static_analysis import StaticAnalysi def create_convert_shape_node(var_shape_node): assert isinstance(var_shape_node, (gast.Attribute, gast.Subscript)) - convert_var_shape_func = "paddle.jit.dygraph_to_static.convert_operators.convert_var_shape" + convert_var_shape_func = "paddle.jit.dy2static.convert_var_shape" if isinstance(var_shape_node, gast.Attribute): api_shape_node = gast.Call( diff --git a/python/paddle/fluid/dygraph/dygraph_to_static/utils.py b/python/paddle/fluid/dygraph/dygraph_to_static/utils.py index 18e60ed0e172e39c9d2cbc500fa7263f8f5fabd2..7a234580712ac15c946100ed60fc8e2d8849bd16 100644 --- a/python/paddle/fluid/dygraph/dygraph_to_static/utils.py +++ b/python/paddle/fluid/dygraph/dygraph_to_static/utils.py @@ -922,7 +922,7 @@ class ForNodeVisitor(object): else: iter_var_name = ast_to_source_code(self.iter_node).strip() - convert_len_node_source_str = '{} = paddle.jit.dygraph_to_static.convert_operators.convert_len({})'.format( + convert_len_node_source_str = '{} = paddle.jit.dy2static.convert_len({})'.format( self.iter_var_len_name, iter_var_name) convert_len_node = gast.parse(convert_len_node_source_str).body[0] diff --git a/python/paddle/fluid/dygraph/dygraph_to_static/variable_trans_func.py b/python/paddle/fluid/dygraph/dygraph_to_static/variable_trans_func.py index 44da4f8410fbceb9d3b7f0340e96b9068bbec7e9..8da7b40db4c6b7f732cdd66f3f1c5df483f463b1 100644 --- a/python/paddle/fluid/dygraph/dygraph_to_static/variable_trans_func.py +++ b/python/paddle/fluid/dygraph/dygraph_to_static/variable_trans_func.py @@ -74,13 +74,13 @@ def data_layer_not_check(name, shape, dtype='float32', lod_level=0): def to_static_variable_gast_node(name): - func_code = "{} = paddle.jit.dygraph_to_static.variable_trans_func\ - .to_static_variable({})".format(name, name) + func_code = "{} = paddle.jit.dy2static.to_static_variable({})".format(name, + name) return gast.parse(func_code).body[0] def create_static_variable_gast_node(name): - func_code = "{} = paddle.jit.dygraph_to_static.variable_trans_func\ + func_code = "{} = paddle.jit.dy2static\ .data_layer_not_check(name='{}', shape=[-1], dtype='float32')".format( name, name) return gast.parse(func_code).body[0] diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/ifelse_simple_func.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/ifelse_simple_func.py index f017eb2457691f7bba9f7c32cb190bf0bc903eb3..34d7b59a9b487b2424be8c9368b7dcc6dcbf59c0 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/ifelse_simple_func.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/ifelse_simple_func.py @@ -59,9 +59,9 @@ def dyfunc_with_if_else3(x): # The var is created only in one of If.body or If.orelse node, and it used as gast.Load firstly after gast.If node. # The transformed code: """ - q = paddle.jit.dygraph_to_static.variable_trans_func. + q = paddle.jit.dy2static. data_layer_not_check(name='q', shape=[-1], dtype='float32') - z = paddle.jit.dygraph_to_static.variable_trans_func. + z = paddle.jit.dy2static. data_layer_not_check(name='z', shape=[-1], dtype='float32') def true_fn_0(q, x, y): @@ -77,8 +77,8 @@ def dyfunc_with_if_else3(x): n = x + 3 return q, x, y, z q, x, y, z = fluid.layers.cond(fluid.layers.mean(x)[0] < 5, lambda : - paddle.jit.dygraph_to_static.convert_call(true_fn_0)(q, x, y), - lambda : paddle.jit.dygraph_to_static.convert_call(false_fn_0)(q, + paddle.jit.dy2static.convert_call(true_fn_0)(q, x, y), + lambda : paddle.jit.dy2static.convert_call(false_fn_0)(q, x, y)) """ y = x + 1