From 05ff6cc52d309ccfba217225f62b1bc427d626e2 Mon Sep 17 00:00:00 2001 From: Weilong Wu Date: Wed, 9 Mar 2022 12:18:38 +0800 Subject: [PATCH] bypass eager mode (#40245) --- .../paddle/fluid/tests/unittests/test_function_hook.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/python/paddle/fluid/tests/unittests/test_function_hook.py b/python/paddle/fluid/tests/unittests/test_function_hook.py index d45ef528261..55981b01c40 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() -- GitLab