Skip to content

Commit

Permalink
fix the stack op bug in the old IR (PaddlePaddle#66457)
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroRains authored and inaomIIsfarell committed Jul 31, 2024
1 parent a934541 commit dc23d84
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions test/legacy_test/test_stack_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit dc23d84

Please sign in to comment.