Skip to content

Commit 55abc48

Browse files
committed
tc
1 parent cbcefa9 commit 55abc48

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

intermediate_source/memory_format_tutorial.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -341,18 +341,17 @@ def check_cl(*args, **kwargs):
341341
return check_cl
342342

343343

344-
old_attrs = dict()
344+
old_attrs = []
345345

346346

347347
def attribute(m):
348-
old_attrs[m] = dict()
349348
for i in dir(m):
350349
e = getattr(m, i)
351350
exclude_functions = ["is_cuda", "has_names", "numel", "stride", "Tensor", "is_contiguous", "__class__"]
352351
if i not in exclude_functions and not i.startswith("_") and "__call__" in dir(e):
353352
try:
354-
old_attrs[m][i] = e
355353
setattr(m, i, check_wrapper(e))
354+
old_attrs.append((m, i, e))
356355
except Exception as e:
357356
print(i)
358357
print(e)
@@ -372,9 +371,8 @@ def attribute(m):
372371
######################################################################
373372
# Code below is to recover the attributes of torch.
374373

375-
for (m, attrs) in old_attrs.items():
376-
for (k, v) in attrs.items():
377-
setattr(m, k, v)
374+
for m, i, e in reversed(old_attrs):
375+
setattr(m, i, e)
378376

379377
######################################################################
380378
# Work to do

0 commit comments

Comments
 (0)