diff --git a/python/paddle/fluid/tests/unittests/test_function_hook.py b/python/paddle/fluid/tests/unittests/test_function_hook.py index d45ef528261f394ff54e94714aa40d345b9aa458..55981b01c408435d2824ca46dc62b9b4d0c15651 100644 --- a/python/paddle/fluid/tests/unittests/test_function_hook.py +++ b/python/paddle/fluid/tests/unittests/test_function_hook.py @@ -20,6 +20,7 @@ import numpy as np import paddle.fluid.core as core from paddle import _C_ops +from paddle.fluid.framework import _test_eager_guard class TestCapture: @@ -41,7 +42,7 @@ def grad_hook(grad): class TestBakcwardFunctionHookError(unittest.TestCase): - def test_hook(self): + def func_hook(self): input_data = np.ones([4, 4]).astype('float32') x = paddle.to_tensor(input_data.astype(np.float32), stop_gradient=False) @@ -58,6 +59,12 @@ class TestBakcwardFunctionHookError(unittest.TestCase): 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__": unittest.main()