Skip to content

Commit 020c443

Browse files
malfetfacebook-github-bot
authored andcommitted
Fix CustomAutogradTest.ReentrantPriority rerun failures (pytorch#49581)
Summary: Clear static variable at the end of the test to ensure test passes after re-runs Pull Request resolved: pytorch#49581 Test Plan: `./bin/test_api "--gtest_filter=CustomAutogradTest.ReentrantPriority" --gtest_repeat=50` Before the change all subsequent runs of the test failed with ``` ../test/cpp/api/autograd.cpp:681: Failure Expected equality of these values: order.size() Which is: 310 10 ``` Reviewed By: mrshenli Differential Revision: D25632374 Pulled By: malfet fbshipit-source-id: 4814d22b5dff15e1b38a0187e51070771fd58370
1 parent 43f6da7 commit 020c443

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

test/cpp/api/autograd.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,8 @@ TEST(CustomAutogradTest, ReentrantPriority) {
681681
ASSERT_EQ(order.size(), 10);
682682
ASSERT_EQ(std::count(order.begin(), order.end(), 1), 9);
683683
ASSERT_EQ(order.back(), 0);
684+
// Clear static variable in case test get executed in a loop
685+
order.clear();
684686
}
685687

686688
TEST(CustomAutogradTest, Hooks) {

0 commit comments

Comments
 (0)