未验证 提交 05ff6cc5 编写于 作者: W Weilong Wu 提交者: GitHub

bypass eager mode (#40245)

上级 9968c563
...@@ -20,6 +20,7 @@ import numpy as np ...@@ -20,6 +20,7 @@ import numpy as np
import paddle.fluid.core as core import paddle.fluid.core as core
from paddle import _C_ops from paddle import _C_ops
from paddle.fluid.framework import _test_eager_guard
class TestCapture: class TestCapture:
...@@ -41,7 +42,7 @@ def grad_hook(grad): ...@@ -41,7 +42,7 @@ def grad_hook(grad):
class TestBakcwardFunctionHookError(unittest.TestCase): class TestBakcwardFunctionHookError(unittest.TestCase):
def test_hook(self): def func_hook(self):
input_data = np.ones([4, 4]).astype('float32') input_data = np.ones([4, 4]).astype('float32')
x = paddle.to_tensor(input_data.astype(np.float32), stop_gradient=False) x = paddle.to_tensor(input_data.astype(np.float32), stop_gradient=False)
...@@ -58,6 +59,12 @@ class TestBakcwardFunctionHookError(unittest.TestCase): ...@@ -58,6 +59,12 @@ class TestBakcwardFunctionHookError(unittest.TestCase):
assert test_cap.list == [1, 2, 1] assert test_cap.list == [1, 2, 1]
def test_hook(self):
# _register_void_function_post_hook do not support in eager mode
with _test_eager_guard():
pass
self.func_hook()
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册