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 8 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
2 changes: 1 addition & 1 deletion .ci/docker/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Refer to ./jenkins/build.sh for tutorial build instructions

sphinx==5.0.0
sphinx-gallery==0.11.1
sphinx-gallery==0.19.0
sphinx_design
docutils==0.16
sphinx-copybutton
Expand Down
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
1 change: 1 addition & 0 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def reset_seeds(gallery_conf, fname):
'pypandoc': {'extra_args': ['--mathjax', '--toc'],
'filters': ['.jenkins/custom_pandoc_filter.py'],
},
'parallel': True,
}

html_baseurl = 'https://pytorch.org/tutorials/' # needed for sphinx-sitemap
Expand Down
2 changes: 1 addition & 1 deletion custom_directives.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def run(self):
if 'intro' in self.options:
intro = self.options['intro'][:195] + '...'
else:
_, blocks = sphinx_gallery.gen_rst.split_code_and_text_blocks(abs_fname)
_, blocks = sphinx_gallery.py_source_parser.split_code_and_text_blocks(abs_fname)
intro, _ = sphinx_gallery.gen_rst.extract_intro_and_title(abs_fname, blocks[0][1])

thumbnail_rst = ''
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