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 73dba66d3fca4f64bbe7e5ec763e541d664b9804..bf51ed9391e38bb7895258b7c1befbc5ea2abd0d 100644 --- a/python/paddle/fluid/dygraph/dygraph_to_static/assert_transformer.py +++ b/python/paddle/fluid/dygraph/dygraph_to_static/assert_transformer.py @@ -37,7 +37,7 @@ class AssertTransformer(gast.NodeTransformer): def visit_Assert(self, node): convert_assert_node = gast.parse( - 'fluid.dygraph.dygraph_to_static.convert_operators.convert_assert({test}, {msg})'. + 'paddle.jit.dygraph_to_static.convert_operators.convert_assert({test}, {msg})'. format( test=ast_to_source_code(node.test), msg=ast_to_source_code(node.msg) 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 71cb999eab0eb27935f876ad953a948881da267f..d724638f59d1ab561da2b6d616f077a2cea87963 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 = "fluid.dygraph.dygraph_to_static.convert_operators.convert_var_dtype({}, '{}')".format( + new_func_str = "paddle.jit.dygraph_to_static.convert_operators.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 5b8e6d2a9bdf36d45582fcabba5a740f353f78ac..997c6cad76daf09a119da6ea06d4067a6c9a15c5 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 = fluid.dygraph.dygraph_to_static.variable_trans_func.data_layer_not_check(name='q', shape=[-1], dtype='float32') - z = fluid.dygraph.dygraph_to_static.variable_trans_func.data_layer_not_check(name='z', shape=[-1], dtype='float32') + 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') def true_func(x, y, q): x = x+1 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 03b0de99071c2d401d299905de974f0e0977b85e..de24fb16158b181395dc24f218b30761381152fd 100644 --- a/python/paddle/fluid/dygraph/dygraph_to_static/list_transformer.py +++ b/python/paddle/fluid/dygraph/dygraph_to_static/list_transformer.py @@ -188,8 +188,8 @@ class ListTransformer(gast.NodeTransformer): pass elif isinstance(slice_node, gast.Index): value_code = ast_to_source_code(node.value) - i = "fluid.layers.cast(" \ - "x=fluid.dygraph.dygraph_to_static.variable_trans_func.to_static_variable({})," \ + i = "paddle.cast(" \ + "x=paddle.jit.dygraph_to_static.variable_trans_func.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 d7af786ad75c7e7c4f1b5f8889c4d3ef44c2057e..a12373da4783fe2e164c8db3e9c6ec35c678451f 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 = "fluid.dygraph.dygraph_to_static.convert_operators.convert_logical_not({})".format( + new_node_str = "paddle.jit.dygraph_to_static.convert_operators.convert_logical_not({})".format( arg) # NOTE: gast.parse returns Module(body=[expr(value=...)]) 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 c66778992c25c68a5adf6a17ae0cd46b57b02fd6..40b76e1421589e7b5fbcd430a6b05c2fb34887df 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 = "fluid.dygraph.dygraph_to_static.convert_operators.convert_while_loop" + while_func_name = "paddle.jit.dygraph_to_static.convert_operators.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 d555c8ed28f358a43e53966dd30d76d85a03dde5..bfeeb3bd9bd1864d6f26f8a14a67188ec79a8157 100644 --- a/python/paddle/fluid/dygraph/dygraph_to_static/print_transformer.py +++ b/python/paddle/fluid/dygraph/dygraph_to_static/print_transformer.py @@ -57,6 +57,6 @@ class PrintTransformer(gast.NodeTransformer): def _create_print_node(self, print_args): convert_print_func = gast.parse( - 'fluid.dygraph.dygraph_to_static.convert_operators.convert_print' + 'paddle.jit.dygraph_to_static.convert_operators.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 cad70f64c466f3ed61d65442230b246eacfd2a74..33ff673067bf2cb4873f6b3f9bfbe7fb25e22703 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 = "fluid.dygraph.dygraph_to_static.convert_operators.convert_var_shape" + convert_var_shape_func = "paddle.jit.dygraph_to_static.convert_operators.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 86593dc24aa8bda7906aab2001e8bd285f64288a..3b690c91f972e4fb9f67f022366a2a62a2705915 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 = '{} = fluid.dygraph.dygraph_to_static.convert_operators.convert_len({})'.format( + convert_len_node_source_str = '{} = paddle.jit.dygraph_to_static.convert_operators.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 a7d7d55d7a0013499b7c40928a14bba788c00fcb..44da4f8410fbceb9d3b7f0340e96b9068bbec7e9 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,20 +74,20 @@ def data_layer_not_check(name, shape, dtype='float32', lod_level=0): def to_static_variable_gast_node(name): - func_code = "{} = fluid.dygraph.dygraph_to_static.variable_trans_func\ + func_code = "{} = paddle.jit.dygraph_to_static.variable_trans_func\ .to_static_variable({})".format(name, name) return gast.parse(func_code).body[0] def create_static_variable_gast_node(name): - func_code = "{} = fluid.dygraph.dygraph_to_static.variable_trans_func\ + func_code = "{} = paddle.jit.dygraph_to_static.variable_trans_func\ .data_layer_not_check(name='{}', shape=[-1], dtype='float32')".format( name, name) return gast.parse(func_code).body[0] def create_fill_constant_node(name, value): - func_code = "{} = fluid.layers.fill_constant(shape=[1], ".format(name) + func_code = "{} = paddle.fill_constant(shape=[1], ".format(name) if isinstance(value, bool): func_code += "dtype='bool', value={})".format(value) 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 08d832b64a213fc217ae0baaba734ebfb58e9ceb..a0a68447f34aebcc7b2eaedfc59bca452484ddaa 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 = fluid.dygraph.dygraph_to_static.variable_trans_func. + q = paddle.jit.dygraph_to_static.variable_trans_func. data_layer_not_check(name='q', shape=[-1], dtype='float32') - z = fluid.dygraph.dygraph_to_static.variable_trans_func. + z = paddle.jit.dygraph_to_static.variable_trans_func. data_layer_not_check(name='z', shape=[-1], dtype='float32') def true_fn_0(q, x, y): diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_tensor_shape.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_tensor_shape.py index 46d2b220414c4ec975824271272e0a92d3c057c4..9047aef234b0df163b7ec2b2946dfd56ca369664 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_tensor_shape.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_tensor_shape.py @@ -52,7 +52,7 @@ def dyfunc_tensor_shape_4(x): def dyfunc_tensor_shape_5(x): # `res = fluid.layers.reshape(x, shape=(-1, s))` to # `res = fluid.layers.reshape(x, shape=(-1, - # fluid.dygraph.dygraph_to_static.convert_operators.convert_var_shape(x)[0]))` + # paddle.jit.dygraph_to_static.convert_operators.convert_var_shape(x)[0]))` x = fluid.dygraph.to_variable(x) s = x.shape[0] res = fluid.layers.reshape(x, shape=(-1, s)) @@ -65,7 +65,7 @@ def dyfunc_with_if_1(x): x_shape_0 = x.shape[0] if x_shape_0 < 1: # `res.shape[0]` is transformed into - # `fluid.dygraph.dygraph_to_static.convert_operators.convert_var_shape(res)[0]` + # `paddle.jit.dygraph_to_static.convert_operators.convert_var_shape(res)[0]` if res.shape[0] > 1: res = fluid.layers.fill_constant( value=2, shape=x.shape, dtype="int32") @@ -89,7 +89,7 @@ def dyfunc_with_if_2(x): def dyfunc_with_for_1(x): x = fluid.dygraph.to_variable(x) res = fluid.layers.fill_constant(value=0, shape=[1], dtype="int32") - # `x.shape[0]` is transformed into `fluid.dygraph.dygraph_to_static.convert_operators.convert_var_shape(x)[0]` + # `x.shape[0]` is transformed into `paddle.jit.dygraph_to_static.convert_operators.convert_var_shape(x)[0]` for i in range(x.shape[0]): res += 1 return res @@ -100,7 +100,7 @@ def dyfunc_with_for_2(x): x_shape_0 = x.shape[0] res = fluid.layers.fill_constant(value=0, shape=[1], dtype="int32") - # `x_shape_0` is transformed into `fluid.dygraph.dygraph_to_static.convert_operators.convert_var_shape(x)[0]` + # `x_shape_0` is transformed into `paddle.jit.dygraph_to_static.convert_operators.convert_var_shape(x)[0]` for i in range(x_shape_0): res += 1 return res @@ -124,7 +124,7 @@ def dyfunc_with_for_3(x): def dyfunc_with_while_1(x): x = fluid.dygraph.to_variable(x) res = fluid.layers.fill_constant(value=0, shape=[1], dtype="int32") - # `x.shape[0]` is transformed into `fluid.dygraph.dygraph_to_static.convert_operators.convert_var_shape(x)[0]` + # `x.shape[0]` is transformed into `paddle.jit.dygraph_to_static.convert_operators.convert_var_shape(x)[0]` i = 1 while i < x.shape[0]: res += 1 @@ -137,7 +137,7 @@ def dyfunc_with_while_2(x): x_shape_0 = x.shape[0] res = fluid.layers.fill_constant(value=0, shape=[1], dtype="int32") i = 1 - # `x_shape_0` is transformed into `fluid.dygraph.dygraph_to_static.convert_operators.convert_var_shape(x)[0]` + # `x_shape_0` is transformed into `paddle.jit.dygraph_to_static.convert_operators.convert_var_shape(x)[0]` while i < x_shape_0: res += 1 i = i + 2