') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); [Tutorial] Fix formatting, grammar, dead link by mkroening · Pull Request #9281 · apache/tvm · GitHub
Skip to content

[Tutorial] Fix formatting, grammar, dead link - #9281

Merged
masahi merged 4 commits into
apache:mainfrom
mkroening:tutorial-fix
Oct 23, 2021
Merged

[Tutorial] Fix formatting, grammar, dead link#9281
masahi merged 4 commits into
apache:mainfrom
mkroening:tutorial-fix

Conversation

@mkroening

Copy link
Copy Markdown
Contributor

This fixes a few issues (formatting, dead links, grammar), I encountered when reading the tutorial.

@hogepodge, could you review this?

@mkroening
mkroening requested a review from a team as a code ownerOctober 14, 2021 08:50
@hogepodge

Copy link
Copy Markdown
Contributor

Thank you for catching these. I would like to request a change in how the links are handled. Instead of direct links, can we please use Sphinx reference links? This will help prevent breaks in the future.

For example, this file has a reference at the top of it:

We can write the link to that as:

:ref:`Auto-tuning a convolution network for x86 CPU <tune_relay_x86>`.

This will make the link more durable and less likely to break if the files are ever moved again. There is documentation for Sphinx that describes this feature more fully. This would be a great start on that. Thank you for sending up this patch, and catching links that I missed in the refactor.

@hogepodge

Copy link
Copy Markdown
Contributor

One more comment, if the target link doesn't have a reference tag as shown above, it should be added. Any name that doesn't collide with another tag should work. If you need me to build the docs and check once the patch is up, I'd be happy to help out with that.

@jroesch

Copy link
Copy Markdown
Member

Agree that it would be best to make the change @hogepodge suggested to avoid future breakage. Thanks for the fix!

@tqchentqchen added the status: need update need update based on feedbacks label Oct 14, 2021
@mkroening

Copy link
Copy Markdown
ContributorAuthor

I pushed three more commits, the last of which adopts sphinx references.

@hogepodge, it would be great if you could build and check if it works.

@mkroening

Copy link
Copy Markdown
ContributorAuthor

I also noticed one code block1 that looks like having the comments not be outside the block might not be intentional.

Footnotes

  1. https://tvm.apache.org/docs/tutorial/tensor_expr_get_started.html#targeting-vector-addition-for-gpus-optional

@mkroening

Copy link
Copy Markdown
ContributorAuthor

I added another commit, fixing a link in README.md.

@hogepodge

hogepodge commented Oct 19, 2021

Copy link
Copy Markdown
Contributor

@mkroening I did a pass through the code and fixed a bunch of other links. Rather than send competing patching, can you check the differences in this patch and update to catch the remainder of direct links?

https://github.com/hogepodge/tvm/tree/fix-links

@hogepodge

Copy link
Copy Markdown
Contributor

Probably easier to compare from this PR: #9314

@mkroening
mkroeningforce-pushed the tutorial-fix branch 2 times, most recently from 492268a to d26ed50CompareOctober 19, 2021 07:04
@mkroeningmkroening changed the title [Tutorial] Fix dead links, formatting[Tutorial] Fix formatting, grammar, dead linkOct 19, 2021
@mkroening

Copy link
Copy Markdown
ContributorAuthor

@hogepodge, I subtracted #9314 from this PR.

@mkroening

Copy link
Copy Markdown
ContributorAuthor

I think the CI failure should be unrelated to this PR.

@hogepodge

Copy link
Copy Markdown
Contributor

If you push a basic change it will re-kick the gate job. I’m sorry this is taking so long to merge.

@mkroening

Copy link
Copy Markdown
ContributorAuthor

Another spurious error, trying again.

@mkroening
mkroeningforce-pushed the tutorial-fix branch 2 times, most recently from 95bb1cb to 75b0a24CompareOctober 21, 2021 13:20
@mkroening

Copy link
Copy Markdown
ContributorAuthor

Okay, on the sixth try CI passes. 🎉

@masahi
masahi merged commit bb5e653 into apache:mainOct 23, 2021
@mkroening
mkroening deleted the tutorial-fix branch October 23, 2021 00:18
@hogepodge

Copy link
Copy Markdown
Contributor

🎉

ylc pushed a commit to ylc/tvm that referenced this pull request Jan 7, 2022
* tutorial: preprocess.py: Fix leading whitespace
This fixes the indentation of metadata in `preprocess.py` in the TVMC tutorial, removing the leading whitespaces in the HTML rendering[^1].
[^1] https://tvm.apache.org/docs/tutorial/tvmc_command_line_driver.html#preprocess-py
* tutorial: Add missing code block escapes
* tutorial: Grammar fixup
* README.md: Fix link to introduction
Co-authored-by: Martin Kröning <martin.kroening@neclab.eu>
ylc pushed a commit to ylc/tvm that referenced this pull request Jan 13, 2022
* tutorial: preprocess.py: Fix leading whitespace
This fixes the indentation of metadata in `preprocess.py` in the TVMC tutorial, removing the leading whitespaces in the HTML rendering[^1].
[^1] https://tvm.apache.org/docs/tutorial/tvmc_command_line_driver.html#preprocess-py
* tutorial: Add missing code block escapes
* tutorial: Grammar fixup
* README.md: Fix link to introduction
Co-authored-by: Martin Kröning <martin.kroening@neclab.eu>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: need updateneed update based on feedbacks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@mkroening@hogepodge@jroesch@tqchen@masahi