From dc23d84cab196475e70a543563d8a0caac1ce1be Mon Sep 17 00:00:00 2001 From: Zero Rains Date: Thu, 25 Jul 2024 23:47:24 +0800 Subject: [PATCH] fix the stack op bug in the old IR (#66457) --- test/legacy_test/test_stack_op.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/test/legacy_test/test_stack_op.py b/test/legacy_test/test_stack_op.py index 0ba15aafea423..55199ce9b07e9 100644 --- a/test/legacy_test/test_stack_op.py +++ b/test/legacy_test/test_stack_op.py @@ -390,19 +390,20 @@ def test_dygraph(self): paddle.enable_static() -# class TestStackListOfSingleTensor(unittest.TestCase): -# def setUp(self): -# paddle.disable_static() -# paddle.seed(2022) -# self.x = [paddle.randn((4, 2, 6), dtype="float32")] - -# def test_list_single_tensor(self): -# expect = paddle.stack(self.x) -# paddle.base.core._set_prim_all_enabled(True) -# st_model = paddle.jit.to_static(paddle.stack, full_graph=True) -# actual = st_model(self.x) -# np.testing.assert_allclose(expect, actual) -# paddle.enable_static() +class TestStackListOfSingleTensor(unittest.TestCase): + def setUp(self): + paddle.disable_static() + paddle.seed(2022) + self.x = [paddle.randn((4, 2, 6), dtype="float32")] + self.x[0].stop_gradient = False + + def test_list_single_tensor(self): + expect = paddle.stack(self.x) + paddle.base.core._set_prim_all_enabled(True) + st_model = paddle.jit.to_static(paddle.stack, full_graph=True) + actual = st_model(self.x) + np.testing.assert_allclose(expect, actual) + paddle.enable_static() class TestPrimStackGrad(unittest.TestCase):