Skip to content

Commit c7b3aee

Browse files
committed
Update
1 parent ffab05c commit c7b3aee

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

conf.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,6 @@ def reset_seeds(gallery_conf, fname):
107107
random.seed(10)
108108
numpy.random.seed(10)
109109
torch.set_grad_enabled(True)
110-
111-
# Reset any patching from memory_format_tutorial
112-
if hasattr(torch, "old_attrs"):
113-
for (m, attrs) in torch.old_attrs.items():
114-
for (k, v) in attrs.items():
115-
setattr(m, k, v)
116-
delattr(torch, "old_attrs")
117110

118111

119112
gc.collect()

intermediate_source/memory_format_tutorial.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,20 @@ def attribute(m):
376376
for (k, v) in attrs.items():
377377
setattr(m, k, v)
378378

379+
# Recover Tensor
380+
torch.Tensor = old_attrs[torch.Tensor]["Tensor"]
381+
# Recover nn.functional
382+
torch.nn.functional = old_attrs[torch.nn.functional]["nn.functional"]
383+
# Recover torch
384+
torch.is_cuda = old_attrs[torch]["is_cuda"]
385+
torch.has_names = old_attrs[torch]["has_names"]
386+
torch.numel = old_attrs[torch]["numel"]
387+
torch.stride = old_attrs[torch]["stride"]
388+
torch.is_contiguous = old_attrs[torch]["is_contiguous"]
389+
torch.__class__ = old_attrs[torch]["__class__"]
390+
del old_attrs
391+
392+
379393
######################################################################
380394
# Work to do
381395
# ----------

0 commit comments

Comments
 (0)