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