未验证 提交 628ddcf3 编写于 作者: A Aurelius84 提交者: GitHub

[Dy2St]Fix is_paddle_func not take effect for plain paddle API (#51585)

* Fix is_paddle_func not take effect for plain paddle API

* fix typo

* fix typo
上级 9658f49b
...@@ -270,6 +270,7 @@ class TestNotToConvert2(TestRecursiveCall2): ...@@ -270,6 +270,7 @@ class TestNotToConvert2(TestRecursiveCall2):
# Situation 3 : test to_static for paddle api # Situation 3 : test to_static for paddle api
@paddle.jit.not_to_static
def forward(self, x): def forward(self, x):
if x.shape[0] > 1: if x.shape[0] > 1:
x = x + 1 x = x + 1
......
...@@ -327,19 +327,15 @@ def is_paddle_func(func, ignore_white_list=True): ...@@ -327,19 +327,15 @@ def is_paddle_func(func, ignore_white_list=True):
func = func.func func = func.func
func_name = getattr(func, '__name__', None) func_name = getattr(func, '__name__', None)
# In case of dynamically monkey patch customised function if inspect.ismethod(func):
# into paddle class obj, so we consider its class module func_name = func.__self__.__class__.__name__
# path as prefix.
if hasattr(func, "__self__"):
func = func.__self__
func_name = func.__class__.__name__
elif inspect.ismethod(func):
func = func.__func__ func = func.__func__
m = inspect.getmodule(func) m = inspect.getmodule(func)
flag = m is not None and m.__name__.startswith(PADDLE_MODULE_PREFIX) flag = m is not None and m.__name__.startswith(PADDLE_MODULE_PREFIX)
if ignore_white_list: if ignore_white_list:
flag = flag and not in_white_list(m, func_name) flag = flag and not in_white_list(m, func_name)
return flag return flag
except Exception: except Exception:
return False return False
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册