') + ')', '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); } })(); })(); [Hexagon] Add E2E test demonstrating how to apply blocked layout schedule to conv2d via metaschedule by csullivan · Pull Request #13180 · apache/tvm · GitHub
Skip to content

[Hexagon] Add E2E test demonstrating how to apply blocked layout schedule to conv2d via metaschedule - #13180

Merged
csullivan merged 8 commits into
apache:mainfrom
csullivan:hexagon/schedule_rule_layout_demo
Oct 31, 2022
Merged

[Hexagon] Add E2E test demonstrating how to apply blocked layout schedule to conv2d via metaschedule#13180
csullivan merged 8 commits into
apache:mainfrom
csullivan:hexagon/schedule_rule_layout_demo

Conversation

@csullivan

Copy link
Copy Markdown
Contributor

Demonstrates the use of a custom search space generation from a manual written schedule. In this there are no degrees of freedom so tuning will not improve the schedule currently, but the test demonstrates the schedule-time layout transformation of the conv2d primfunc to the 8x8x32 packed layout for convolution ops.

converting input and output activation
to Hexagon's blocked layout.
See TODO, this may also disable auto scheduling for non-convolution ops.
@tvm-bot

tvm-bot commented Oct 24, 2022

Copy link
Copy Markdown
Collaborator

Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.

Generated by tvm-bot

@masahi

Copy link
Copy Markdown
Member

@tvm-bot rerun

Comment threadtests/python/contrib/test_hexagon/metaschedule_e2e/test_resnet50_int8.py Outdated
strategy="replay-trace",
builder=get_hexagon_local_builder(),
runner=get_hexagon_rpc_runner(hexagon_launcher, number=20),
# TODO(csullivan): Configrm the below is accurate

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @zxybazh so by using ScheduleFn here, MS won't be looking at non conv2d blocks?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By using ScheduleFn here, the search space is solely generated by the schedule function over the whole workload. In this case, if you're using _schedule_packed_8x8x32_conv2d's schedule_fn to construct the ScheduleFn space generator, it will only look at conv2d blocks because the function doesn't transform any of the non-conv2d blocks right?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's my understanding.

@masahimasahiOct 24, 2022

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@csullivan so shall we remove the TODO comment (which also has a typo lol)?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:) Yes, but one more question, if one utilizes a ScheduleFn to define a search space, but also sets custom sch_rules to be applied per block as,

 space=ms.space_generator.ScheduleFn(
schedule_conv2d_for_tune,
sch_rules=[some set of rules] , # <<<<
postprocs=[],
mutator_probs={},
),

what will be the interaction between the scheduling function and the rules?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For ScheduleFn I don't think there will be any interaction between the scheduling function and the rules, they will only be used for PostOrderApply space generator.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@csullivan can you remove the TODO comment?

@masahimasahi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM modulo the confirmation on TODO

def schedule_fn(sch, conv2d_block: Optional[BlockRV] = None) -> bool:
if conv2d_block == None:
try:
conv2d_block = sch.get_block("conv2d_NCHWc_int8")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My PR #13206 has has_block(sch, block_name) utility, which can remove this hack. I'll update this code after it is merged.

@csullivan

Copy link
Copy Markdown
ContributorAuthor

Thanks for patience, let us hold off on merging this one for a bit as there are a few issues that arise at the end of a tuning run with this test:

  1. Lack of JSON serialization for tir::IndexMap in src/meta_schedule/database/database_utils.cc::JSONDumps
  2. Metascheduler search workers hang when the search space has only one sample.

@zxybazh

Copy link
Copy Markdown
Member

Hi Chris, regarding (2) does the worker hang when the search space that has only one sample, and will not terminate by itself even after 5 iterations?

@csullivan

Copy link
Copy Markdown
ContributorAuthor

Thanks @zxybazh for following the thread closely. Looks like (2) was a red herring and is not reproducible for me any longer. Furthermore, (1) is coming in a follow up PR and this test is skipped so no harm merging this now.

@csullivan
csullivan merged commit 76cd298 into apache:mainOct 31, 2022
xinetzone pushed a commit to daobook/tvm that referenced this pull request Nov 10, 2022
…dule to conv2d via metaschedule (apache#13180)
Demonstrates the use of a custom search space generation from a manual written schedule. In this there are no degrees of freedom so tuning will not improve the schedule currently, but the test demonstrates the schedule-time layout transformation of the conv2d primfunc to the 8x8x32 packed layout for convolution ops.
* Add test that demonstrates applying a custom TIR schedule to E2E model.
* Add example scheduling that demonstrates converting input and output activation to Hexagon's blocked layout.
* PR feedback: Remove latency measurement and profiling report.
* Update comment to reflect PR discussion summary, remove TODO.
* Use ScheduleFn space generator to disable any autotuning.
xinetzone pushed a commit to daobook/tvm that referenced this pull request Nov 25, 2022
…dule to conv2d via metaschedule (apache#13180)
Demonstrates the use of a custom search space generation from a manual written schedule. In this there are no degrees of freedom so tuning will not improve the schedule currently, but the test demonstrates the schedule-time layout transformation of the conv2d primfunc to the 8x8x32 packed layout for convolution ops.
* Add test that demonstrates applying a custom TIR schedule to E2E model.
* Add example scheduling that demonstrates converting input and output activation to Hexagon's blocked layout.
* PR feedback: Remove latency measurement and profiling report.
* Update comment to reflect PR discussion summary, remove TODO.
* Use ScheduleFn space generator to disable any autotuning.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@csullivan@tvm-bot@masahi@zxybazh