Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dy2Stat]Filter UserWarings while @to_static #45754

Merged
merged 3 commits into from
Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion python/paddle/fluid/dygraph/dygraph_to_static/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
3 changes: 2 additions & 1 deletion python/paddle/fluid/layers/math_op_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,8 @@ def __impl__(self, other_var):
"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],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def set_test_func(self):
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
Expand Down Expand Up @@ -149,7 +149,7 @@ def set_test_func(self):
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
Expand All @@ -174,7 +174,7 @@ def set_test_func(self):
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
Expand Down Expand Up @@ -208,7 +208,7 @@ def set_test_func(self):
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
Expand Down