Skip to content
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

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

Merged
merged 8 commits into from
Oct 31, 2022
Merged

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

merged 8 commits into from
Oct 31, 2022

Conversation

csullivan
Copy link
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
Copy link
Collaborator

tvm-bot commented Oct 24, 2022

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
Member

masahi commented Oct 24, 2022

@tvm-bot rerun

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
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
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
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.

Copy link
Member

@masahi masahi Oct 24, 2022

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
Contributor Author

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
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
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?

Copy link
Member

@masahi masahi left a comment

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
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
Contributor Author

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
Member

zxybazh commented Oct 28, 2022

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
Contributor Author

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:main Oct 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 free to 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