Skip to content

[test] memory format tutorial #3351

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 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 0 additions & 1 deletion .jenkins/validate_tutorials_built.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
"intermediate_source/tensorboard_profiler_tutorial", # reenable after 2.0 release.
"advanced_source/semi_structured_sparse", # reenable after 3303 is fixed.
"intermediate_source/torchrec_intro_tutorial", # reenable after 3302 is fixe
"intermediate_source/memory_format_tutorial", # causes other tutorials like torch_logs fail. "state" issue, reseting dynamo didn't help
]

def tutorial_source_dirs() -> List[Path]:
Expand Down
10 changes: 4 additions & 6 deletions intermediate_source/memory_format_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,18 +341,17 @@ def check_cl(*args, **kwargs):
return check_cl


old_attrs = dict()
old_attrs = []


def attribute(m):
old_attrs[m] = dict()
for i in dir(m):
e = getattr(m, i)
exclude_functions = ["is_cuda", "has_names", "numel", "stride", "Tensor", "is_contiguous", "__class__"]
if i not in exclude_functions and not i.startswith("_") and "__call__" in dir(e):
try:
old_attrs[m][i] = e
setattr(m, i, check_wrapper(e))
old_attrs.append((m, i, e))
except Exception as e:
print(i)
print(e)
Expand All @@ -372,9 +371,8 @@ def attribute(m):
######################################################################
# Code below is to recover the attributes of torch.

for (m, attrs) in old_attrs.items():
for (k, v) in attrs.items():
setattr(m, k, v)
for m, i, e in reversed(old_attrs):
setattr(m, i, e)

######################################################################
# Work to do
Expand Down
Loading