diff --git a/python/paddle/fluid/dygraph/dygraph_to_static/utils.py b/python/paddle/fluid/dygraph/dygraph_to_static/utils.py index 4d755b24108aa847d46edf7269baab5f85b272db..41cd4676e608a9780e855206152391d843532e46 100644 --- a/python/paddle/fluid/dygraph/dygraph_to_static/utils.py +++ b/python/paddle/fluid/dygraph/dygraph_to_static/utils.py @@ -609,7 +609,8 @@ def _inject_import_statements(): import_statements = [ "import paddle", "from paddle import Tensor", "import paddle.fluid as fluid", "import paddle.jit.dy2static as _jst", - "from typing import *", "import numpy as np" + "from typing import *", "import numpy as np", "import warnings", + "warnings.filterwarnings('ignore', category=DeprecationWarning)" ] return '\n'.join(import_statements) + '\n' diff --git a/python/paddle/fluid/layers/math_op_patch.py b/python/paddle/fluid/layers/math_op_patch.py index 62fd6b1e566f090f95fbc0bd9d579da0522a25eb..3721b97368af1416c2ebd51ff767b52f14f9eada 100644 --- a/python/paddle/fluid/layers/math_op_patch.py +++ b/python/paddle/fluid/layers/math_op_patch.py @@ -378,7 +378,8 @@ def monkey_patch_variable(): "If your code works well in the older versions but crashes in this version, try to use " "%s(X, Y, axis=0) instead of %s. This transitional warning will be dropped in the future." % (file_name, line_num, EXPRESSION_MAP[method_name], - op_type, op_type, EXPRESSION_MAP[method_name])) + op_type, op_type, EXPRESSION_MAP[method_name]), + category=DeprecationWarning) current_block(self).append_op(type=op_type, inputs={ 'X': [self], diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_origin_info.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_origin_info.py index 8dac8889935904b54220adf1c5dd01ca63fe9236..b422164cf3816630c7dee67324fbfbabc268d6a6 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_origin_info.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_origin_info.py @@ -65,7 +65,7 @@ class TestOriginInfo(unittest.TestCase): self.func = simple_func def set_static_lineno(self): - self.static_abs_lineno_list = [7, 8, 9] + self.static_abs_lineno_list = [9, 10, 11] def set_dygraph_info(self): self.line_num = 3 @@ -149,7 +149,7 @@ class TestOriginInfoWithNestedFunc(TestOriginInfo): self.func = nested_func def set_static_lineno(self): - self.static_abs_lineno_list = [7, 9, 10, 11, 12] + self.static_abs_lineno_list = [9, 11, 12, 13, 14] def set_dygraph_info(self): self.line_num = 5 @@ -174,7 +174,7 @@ class TestOriginInfoWithDecoratedFunc(TestOriginInfo): self.func = decorated_func def set_static_lineno(self): - self.static_abs_lineno_list = [7, 8] + self.static_abs_lineno_list = [9, 10] def set_dygraph_info(self): self.line_num = 2 @@ -208,7 +208,7 @@ class TestOriginInfoWithDecoratedFunc2(TestOriginInfo): self.func = decorated_func2 def set_static_lineno(self): - self.static_abs_lineno_list = [7, 8] + self.static_abs_lineno_list = [9, 10] def set_dygraph_info(self): self.line_num = 2