8000 Make test_create_graph_and_full_backward_hook_cycle more robust to unrelated warnings by soulitzer · Pull Request #153407 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

Make test_create_graph_and_full_backward_hook_cycle more robust to unrelated warnings #153407

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: gh/soulitzer/362/base
Choose a base branch
from
Open
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions test/test_autograd.py
Original file line number Diff line number Diff line change
Expand Up @@ -9333,12 +9333,11 @@ def forward(self, x):
tmp.grad_fn.metadata["a"] = test

with set_warn_always_context(True):
with warnings.catch_warnings(record=True) as w:
with warnings.catch_warnings(record=True) as ws:
tmp.exp().sum().backward(create_graph=True)
self.assertTrue(len(w) == 1)
self.assertTrue(
"Using backward() with create_graph=True" in str(w[0].message)
)
filtered_ws = [
w for w in ws if "Using backward() with create_graph=True" in str(w.message)]
self.assertTrue(len(filtered_ws) == 1)

# Remove the backward + create_graph=True cycle
a.grad = None
Expand Down
Loading
0